Quantcast
Channel: Math.NET Numerics
Viewing all articles
Browse latest Browse all 971

New Post: Negative Samples from Geometric Distribution

$
0
0
I downloaded the source (3.0 alpha?), and I'm getting negative samples in my unit tests for the Geometric Distribution. Is that intentional for some reason that I don't understand?

The code for the SampleUnchecked() method is shown below (notice the -Math.Log(...)).
        static int SampleUnchecked(System.Random rnd, double p)
        {
            return p == 1.0 ? 1 : (int) Math.Ceiling(-Math.Log(1.0 - rnd.NextDouble(), 1.0 - p));
        }
If I'm not mistaken, the NegativeBinomial distribution should return the same results as the Geometric distribution when r = 1 (for the same value of p).

If you test these two distributions side-by-side with random generators seeded exactly the same, you will see that the results are not correct.

Ben

Viewing all articles
Browse latest Browse all 971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>