I am trying to implement an event time sampling for different distributions using the MathNet library. I have them working for exponential, normal and weibull but the same process is not working for Gamma anyone know what I am doing wrong?
Testing Example to get mean.
using System;
using MathNet.Numerics.Distributions;
public class Program
{
public static void Main()
{
double sum = 0.0;
var dist = new Gamma(0.5,50);
int runs = 1000000;
for (int i=0; i<runs; i++)
{
sum += dist.Sample();
}
Console.WriteLine((sum/runs).ToString());
}
}
Returns: ~0.01
Using online calculator https://keisan.casio.com/exec/system/1180573218 I get 11.37 for the mean. (CD 0.5, shape 0.5 scale 50)
There are two things to keep in mind:
E[X] = shape/rate
, that is quite close to the result you get from your code