commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zev Hochberg (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-888) GammaDistribution returns infinite density when cdf = 1
Date Wed, 14 Nov 2012 19:44:11 GMT

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

Zev Hochberg commented on MATH-888:
-----------------------------------

Here's a unit test error log, when I copy trunk to c:\ACM\commons-math3, rather than to c:\commons-math3
There was also a unit test error when trunk was much "deeper" in the drive; in that case failed
to open a file, which was in fact present.
I'll try and find my notes so I reproduce that one.

-------------------------------------------------------------------------------
Test set: org.apache.commons.math3.genetics.FixedElapsedTimeTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 3.488 sec <<< FAILURE!
testIsSatisfied(org.apache.commons.math3.genetics.FixedElapsedTimeTest)  Time elapsed: 3.487
sec  <<< FAILURE!
java.lang.AssertionError
	at org.junit.Assert.fail(Assert.java:92)
	at org.junit.Assert.assertTrue(Assert.java:43)
	at org.junit.Assert.assertTrue(Assert.java:54)
	at org.apache.commons.math3.genetics.FixedElapsedTimeTest.testIsSatisfied(FixedElapsedTimeTest.java:72)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)

                
> GammaDistribution returns infinite density when cdf = 1
> -------------------------------------------------------
>
>                 Key: MATH-888
>                 URL: https://issues.apache.org/jira/browse/MATH-888
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Windows 7
>            Reporter: Zev Hochberg
>
> When GammaDistribution.cumulativeProbability = 1, then GammaDistribution.density may
return Infinite - but it should return 0.
> Here is sample java code which demonstrates this issue, with results. Note that when
pass the point at which cumulativeProbability = 1, the density stays > 0, though very small
(pdf should be 0 when cdf = 1) - but as continue, then cdf stays 1, but pdf becomes infinite.
This is seen most clearly in the second set of data below.
> package ApacheTester;
> import org.apache.commons.math3.distribution.GammaDistribution;
> public class GammaDistributionTester
> {
>     public static void main(String[] args)
>     {
>         double mean = 10.118627813856065;
>         double std  = 0.8934747186204953;
>         double alpha = (mean*mean)/(std*std);
>         double beta = (std*std)/mean;
>         System.out.println("alpha: " + alpha);
>         System.out.println("beta: " + beta);
>         
>         GammaDistribution gd = new GammaDistribution(alpha, beta);
>         
>         for (int i=0; i<25; i++)
>         {
>             double pdf = gd.density(i);
>             double cdf = gd.cumulativeProbability(i);
>             System.out.println("i=" + i + "; pdf=" + pdf + "; cdf=" + cdf);         
  
>         }
>         System.out.println();
>         
>         for (int i=0; i<20; i++)
>         {
>             double x = 19.0 + (.1 * i);
>             double pdf = gd.density(x);
>             double cdf = gd.cumulativeProbability(x);
>             System.out.println("x=" + x + "; pdf=" + pdf + "; cdf=" + cdf);         
  
>         }
>     }
> }
> Here's results of running above test:
> alpha: 128.25629996917283
> beta: 0.07889380729280462
> i=0; pdf=0.0; cdf=0.0
> i=1; pdf=8.663477060371509E-79; cdf=7.488555717749243E-81
> i=2; pdf=5.5062704634862175E-46; cdf=1.0676382015037016E-47
> i=3; pdf=4.413483488439264E-29; cdf=1.4607150065658644E-30
> i=4; pdf=1.0945225959157887E-18; cdf=5.599255664602861E-20
> i=5; pdf=7.35929647596093E-12; cdf=5.590805261026197E-13
> i=6; pdf=2.7437881760964153E-7; cdf=3.0732983691238435E-8
> i=7; pdf=2.8376132639470645E-4; cdf=4.7826733420766874E-5
> i=8; pdf=0.021281179160656388; cdf=0.005695853765034336
> i=9; pdf=0.2151187723352627; cdf=0.10175065472250033
> i=10; pdf=0.44751658755472723; cdf=0.4586536845007119
> i=11; pdf=0.259114059558244; cdf=0.8385256983930766
> i=12; pdf=0.05218255030958943; cdf=0.9781383380332821
> i=13; pdf=0.004329365023697574; cdf=0.9986058018679428
> i=14; pdf=1.6878342979402664E-4; cdf=0.9999549514385939
> i=15; pdf=3.431947471368873E-6; cdf=0.9999992047520807
> i=16; pdf=3.9588967227014906E-8; cdf=0.9999999917873332
> i=17; pdf=2.7752325350928474E-10; cdf=0.9999999999473412
> i=18; pdf=1.2515801802459923E-12; cdf=0.9999999999997794
> i=19; pdf=3.808710263354571E-15; cdf=0.9999999999999993
> i=20; pdf=8.143130333262255E-18; cdf=1.0
> i=21; pdf=Infinity; cdf=1.0
> i=22; pdf=Infinity; cdf=1.0
> i=23; pdf=Infinity; cdf=1.0
> i=24; pdf=Infinity; cdf=1.0
> x=19.0; pdf=3.808710263354571E-15; cdf=0.9999999999999993
> x=19.1; pdf=2.0912827149653448E-15; cdf=0.9999999999999997
> x=19.2; pdf=1.144280754920214E-15; cdf=0.9999999999999998
> x=19.3; pdf=6.239549206021272E-16; cdf=0.9999999999999999
> x=19.4; pdf=3.3907057624200243E-16; cdf=1.0
> x=19.5; pdf=1.8363629496980252E-16; cdf=1.0
> x=19.6; pdf=9.912278358035803E-17; cdf=1.0
> x=19.7; pdf=5.332732516340122E-17; cdf=1.0
> x=19.8; pdf=2.8595785047900534E-17; cdf=1.0
> x=19.9; pdf=1.5284263208928833E-17; cdf=1.0
> x=20.0; pdf=8.143130333262255E-18; cdf=1.0
> x=20.1; pdf=4.324705899342647E-18; cdf=1.0
> x=20.2; pdf=2.2895693394216285E-18; cdf=1.0
> x=20.3; pdf=1.2083606178165914E-18; cdf=1.0
> x=20.4; pdf=6.357672846520565E-19; cdf=1.0
> x=20.5; pdf=Infinity; cdf=1.0
> x=20.6; pdf=Infinity; cdf=1.0
> x=20.7; pdf=Infinity; cdf=1.0
> x=20.8; pdf=Infinity; cdf=1.0
> x=20.9; pdf=Infinity; cdf=1.0

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message