Re: [ojAlgo-user] apparent bug in Gamma distribution
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Anders P. <an...@op...> - 2012-06-20 11:51:35
|
Thanks for the contribution! I've included your additions to RandomNumberTest. And then... 1) There is now a RandomUtils.gamma(x) function - with junit tests 2) Weibull mean and variance are now calculated analytically, and tested that it matches Exponential if shape=1.0 3) Your testWeibull method still fails. The resulting values are very large. I believe that's part of the problem Could you have a look at that to see what needs to be fixed; the Weibull class or the test case? /Anders On 19 jun 2012, at 20:05, Chris Lucas wrote: > Thanks for the new snapshot. The gamma distribution looks good. > > I've extended RandomNumberTest a bit: > > * Added a template for checking the mean and variance of a sample > against the analytic values for two-parameter distributions, using a > tiny inner-class wrapper. > * Applied said template to Gamma, Normal, and Weibull dists. > * Added couple of miscellaneous tests. I noticed that the Weibull mean > and variance are not computed analytically, which could be an issue > for users of that distribution. > > The attached file contains those changes. Note that the package name > is what I used in my own testing, and will need to be changed if you > replace the current RandomNumberTest.java with it. > > Chris > > On Tue, Jun 5, 2012 at 6:35 PM, Chris Lucas <cg...@gm...> wrote: >> Hi -- >> >> I've noticed what appears to be a bug in org.ojalgo.random.Gamma. I >> noticed that a Gamma(1,2) getDoubleValue() was returning negative >> values. After looking at the documentation (thinking it was just a >> non-standard parameterization at work) and confirming that the >> empirical means don't align with the value of getExpected(), I looked >> at the source (via >> http://ojalgo.cvs.sourceforge.net/viewvc/ojalgo/DevProj/src/org/ojalgo/random/Gamma.java?revision=1.14&view=markup) >> and found the following definition for generate() [which is called by >> getDoubleValue() in RandomNumber()]: >> >> 60 @Override >> 61 protected double generate() { >> 62 >> 63 double tmpVal = ZERO; >> 64 >> 65 for (int i = 0; i < myCount; i++) { >> 66 tmpVal += this.random().nextDouble(); >> 67 } >> 68 >> 69 return -tmpVal / myLambda; >> 70 } >> >> The function this.random() is inherited from RandomNumber, and appears >> to be a uniform distribution. Am I missing something? If not, this >> appears to be a fairly serious bug for anyone who wants to use the >> random number libraries. >> >> More generally, it appears that the test coverage in the random number >> unit tests (at >> http://ojalgo.cvs.sourceforge.net/viewvc/ojalgo/TestProj/src/org/ojalgo/random/RandomNumberTest.java?revision=1.11&view=markup) >> is fairly limited. Perhaps some tests could be added to establish that >> large-sample means are within certain easy-to-satisfy tolerances of >> the intended expected values? >> >> Chris > <RandomNumberTest.java>------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |