[ 
https://issues.apache.org/jira/browse/MATH-1536?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17352880#comment-17352880
 ] 

Alex Herbert commented on MATH-1536:
------------------------------------

I think GaussianRandomGenerator could be deleted from CM. It is used in 3 test 
classes and also the javadoc class description for 
CorrelatedRandomVectorGenerator. So not actually in any main code. However it 
may be useful as it implements NormalizedRandomGenerator (see below).

To get the test to pass you could switch it to use a chi-squared test against 
the expected quantiles for the 10000 samples. I expect with 10000 samples the 
tolerances are too tight for the existing test. But the chi-square test will 
set appropriate tolerances for the sample size. You also get to test that the 
distribution is actually the correct shape.

NormalizedRandomGenerator is used by several classes in the random package. It 
is relied on by the UncorrelatedRandomVectorGenerator and 
CorrelatedRandomVectorGenerator classes. It could be replaced by a functional 
interface from JDK 8. But that does not explicitly document the intention for 
implementing classes such as UniformRandomGenerator, GaussianRandomGenerator 
(to be deleted?) and StableRandomGenerator (which is not normalized).

Note that in my investigations for [RNG-137] on the StableRandomGenerator I 
have found a few bugs in that class. The test suite was very sparse and when 
improving it I found the samples did not fit with stable distribution CDFs 
produced by other software. In 3 of the 5 cases for sampling from variations of 
input alpha and beta it outputs the wrong samples. Here the notable issue is 
that it is not a NormalizedRandomGenerator as the mean and standard deviation 
are not 0 and 1 respectively. The location (or shift) is 0 and the scale is 1 
but these values are not the same as the mean and standard deviation. Only in 
the case of alpha=2 is it a Normal distribution but for this case the variance 
should be 2 (the current implementation has variance 1 which is incorrect). In 
the case of beta=0 the distribution is symmetric and the mean is 0. However the 
variance is infinite for all cases except alpha=2. When beta is not 0 then the 
shape of the distribution depends on the parametrisation of the distribution. 
The current sampler has a parametrisation that sets the mean to zero. But it 
can be defined at other locations depending on the parametrisation (there are a 
few in the literature). I'll add more to the RNG ticket when I have a working 
version.



> Sensitivity to RNG (unit tests)
> -------------------------------
>
>                 Key: MATH-1536
>                 URL: https://issues.apache.org/jira/browse/MATH-1536
>             Project: Commons Math
>          Issue Type: Task
>            Reporter: Gilles Sadowski
>            Priority: Major
>              Labels: rng, unit-test
>             Fix For: 4.0
>
>
> Several unit tests fail when upgrading to version 1.3 of "Commons RNG":
> {noformat}
> [ERROR] Failures: 
> [ERROR]   LogitTest.testDerivativesWithInverseFunction:195 maxOrder = 2 
> expected:<0.0> but was:<1.0658141036401503E-14>
> [ERROR]   EnumeratedIntegerDistributionTest.testMath1533:196
> [ERROR]   EnumeratedIntegerDistributionTest.testSample:174 expected:<7.84> 
> but was:<7.857073891264003>
> [ERROR]   MiniBatchKMeansClustererTest.testCompareToKMeans:86 Different score 
> ratio 46.645378%!, diff points ratio: 34.716981%
> [ERROR]   CalinskiHarabaszTest.test_compare_to_skLearn:102 
> expected:<597.7763150683217> but was:<559.2829020672648>
> [ERROR]   MultiStartMultivariateOptimizerTest.testCircleFitting:76 
> expected:<69.9597> but was:<69.96228624385736>
> [ERROR]   MultiStartMultivariateOptimizerTest.testRosenbrock:114 numEval=873
> [ERROR]   GaussianRandomGeneratorTest.testMeanAndStandardDeviation:37 
> expected:<1.0> but was:<0.9715310171501561>
> [ERROR]   NaturalRankingTest.testNaNsFixedTiesRandom:227 Array comparison 
> failure
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to