2

I am trying to do Student T-test as provided here:

import Data.Vector as V
import Statistics.Test.StudentT
sampleA = V.fromList [1.0,2.0,3.0,4.0,1.0,2.0,3.0,4]
sampleB = V.fromList [2.0,4.0,5.0,5.0,3.0,4.0,5.0,6]
main = print $ StudentT sampleA sampleB SamplesDiffer

However, I am getting following error:

rnunttest.hs:8:16: error:
    Data constructor not in scope:
      StudentT :: Vector Double -> Vector Double -> PositionTest -> a0

Where is the problem and how can it be solved? Thanks for your help.

rnso
  • 23,686
  • 25
  • 112
  • 234

2 Answers2

3

I think you have to change the constructor to studentTTest

main = print $ studentTTest sampleA sampleB SamplesDiffer
developer_hatch
  • 15,898
  • 3
  • 42
  • 75
2

You made two mistakes here:

  1. the function is studenTTest, not StudentT, that is the name of the type constructor; and
  2. the constructor takes a PositionTest foollowed by two vectors.
import Data.Vector as V
import Statistics.Test.StudentT

sampleA = V.fromList [1.0,2.0,3.0,4.0,1.0,2.0,3.0,4]
sampleB = V.fromList [2.0,4.0,5.0,5.0,3.0,4.0,5.0,6]

main = print (studentTTest SamplesDiffer sampleA sampleB)

For the given sample data, this gives us:

Prelude V Statistics.Test.StudentT> main
Just (Test {testSignificance = mkPValue 1.351738152442984e-2, testStatistics = -2.8243130467507513, testDistribution = studentT 14.0})
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555