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(...)).
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
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