[Haskell-cafe] Testing for statistical properties

Lee Pike leepike at gmail.com
Fri Jan 8 00:36:43 EST 2010


> Hey everyone!  I have some computations that satisfy statistical  
> properties which I would like to test --- that is, the result of the  
> computation is non-deterministic, but I want to check that it is  
> sampling the distribution that it should be sampling.  Is anyone  
> aware of a Haskell library out there that does anything like this?

I don't know of a library, but here are a couple of ideas/pointers:

I wanted to do something vaguely similar in the realm of real-time  
hardware testing.  I used QuickCheck (QC) <http://hackage.haskell.org/package/QuickCheck 
 > to do some stochastic testing (in my case, generate test cases from  
the reals satisfying somewhat complex constraints), and I have a small  
patch to the QC library to make this possible.  I have a short '09  
Haskell Symposium paper about it (probably Sec. 5 is the most  
interesting).  The paper and patch are here: <http://www.cs.indiana.edu/~lepike/pub_pages/qc-biphase.html 

One caveat though is that I didn't check that the tests generated by  
QC satisfied any particular distribution---I was assuming it is  
roughly uniformly distributed.  Also, I didn't investigate how to  
generate other distributions, but I don't think that'd be too hard.

FYI, Bryan O'Sullivan has a statistics library <http://hackage.haskell.org/package/statistics 
 >, which I plan to use myself soon!

I'm personally interested in how things turn out for you---please keep  
me posted.


More information about the Haskell-Cafe mailing list