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-06 09:17:35
|
Indeed, that's a bug. Thank you for pointing it out! I'll release a new snapshot in a couple of days with that bug fixed. .. and you're right about the test coverage for that package - it could be better. If you're interested/willing you could help out here. The class SampleSet may be useful when creating test cases. /Anders On 6 jun 2012, at 00:35, Chris Lucas 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 > > ------------------------------------------------------------------------------ > 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 > > |