18 Mar 2013 21:21
Improving my implementation of "The Lady Tasting Tea"
Mark Fredrickson <mark.m.fredrickson <at> gmail.com>
2013-03-18 20:21:20 GMT
2013-03-18 20:21:20 GMT
Hello,For my first project in Haskell, I thought I would re-implement a statistical problem that I have previously done in R. In his 1925 book, Fisher tells of an experiment in which a lady claims she can tell the difference in cups of tea that have the milk or the tea/water added first (I'm a coffee drinker, so I'm unclear on the actual physical interpretation). To test this claim, Fisher proposes an experiment in which 8 cups are created, with 4 having milk first and 4 having tea first. If the lady can properly label 3 of the 4 milk first cups correctly, should we be suprised? What is the probability that she would get 3 or 4 of the milk first cups correct just due to chance (that is, independently of the actual allocation of milk and tea first)?
The current problem calls for binary treatment with no extra data. In the future, my N units may be partitioned into K groups (here K=2), and the score function will require additional data (e.g. each unit will have an outcome measure on a continuous or ordinal scale). In a sense, I'd like to use tuples to hold index values from 1 to N, but I wouldn't necessarily know the tuple size at compile time. The index values would point to an array or similar structure holding the additional data.
Some other properties of allocations:
- They are always the same size
- Order is not important
- All values are unique
Any standard types fit this description?
2. A better algorithm and perhaps data type for the combinations.
The current implementation uses a tree recursion to get the set of all possible combinations. In the future, this set will be too large to enumerate entirely, so I'll need to sample from it. It would be desirable to be able to write `take samples (permute $ combinations total treated)` where the `permute` function (perhaps with a random seed) properly re-orders the combinations. If these goals are supported by a data structure better than a list, I'm very open to using other types to hold the combinations.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe