[英]c# MathNet Gamma distribution sampling not matching
I am trying to implement an event time sampling for different distributions using the MathNet library.我正在尝试使用 MathNet 库为不同的分布实现事件时间采样。 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?我让他们为指数、正常和威布尔工作,但同样的过程对 Gamma 不起作用有人知道我做错了什么吗?
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回报:~0.01
Using online calculator https://keisan.casio.com/exec/system/1180573218 I get 11.37 for the mean.使用在线计算器https://keisan.casio.com/exec/system/1180573218我得到 11.37 的平均值。 (CD 0.5, shape 0.5 scale 50) (CD 0.5,形状 0.5 刻度 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下(或上)CDF 不等于分布的期望值:如果你用 积分来计算期望值,你会得到E[X] = shape/rate
,这与你从你得到的结果非常接近代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.