如何使用JAVA / Android估算/拟合指数修正高斯分布(exGaussian)的参数?
我需要像伪代码一样:
// some observed data points
double dataPoints[] = {200,300,400,278,366,466,325,335,322,332};
// ex-gaussian distribution
ExponentiallyModifiedGaussianDistribution exGaussian = new ExponentiallyModifiedGaussianDistribution();
// MLE
MaximumLikelihoodEstimation MLE = new MaximumLikelihoodEstimation(dataPoints, exGaussian);
MLE.setGuess(3.0, 1.0, 1.0);
MLE.compute();
// get estimated / fitted parameters
double[] parameterEstimates = MLE.getEstimates();
有一些示例演示了 Gamma Distribution 的参数估算。但是这个lib似乎不是开源的。
我在JAVA中找到ex-gaussian distribution implementation。但缺少参数估计。
我认为有很多方法可以估算参数,例如使用最大似然估计(MLE)等。
更新1:
我会避免使用less than 40 dataPoints。
更新2:
估算分布参数的一种简单方法是矩估计方法(described on wiki)
答案 0 :(得分:1)
也许你可以在stats.stackexchange.com上找到更好的答案。
但我认为您可以创建一个进行时刻匹配的优化算法。基本上你需要最小化样本数据和理论分布之间的第一个时刻(平均值),第二个时刻(方差),第三个时刻(偏度)等的差异。
您可以将目标函数视为时刻的总和或乘积。您还可以使用不同的权重(平均值可以获得更高的权重)。
您可以尝试获取目标函数的导数以使用梯度下降法(使用Mathematica或Sage数学),或甚至使用有限差分法以数值方式计算导数。这种方法被大量用于估计回归,逻辑回归和人工神经网络的参数。
你也可以使用元启发式算法(遗传,禁忌搜索等)。
答案 1 :(得分:1)
估算分布参数的一种简单方法是矩量法(described on wiki)。
实现:
// some observed data points
double dataPoints[] = {0.464,0.443,0.424,0.386,0.367,0.382,0.455,0.410,0.411,0.424,0.338,0.355,0.342,0.324,
0.354,0.322,0.364,0.375,1.085,0.575,0.597,0.464,0.414,0.408,1.156,0.819,1.156,1.024,1.152,1.103,
0.431,0.378,0.358,0.382,0.354,0.435,0.386,0.361,0.397,0.362,0.334,0.357,0.344,0.362,0.317,0.331,
0.199,0.351,0.284,0.343,0.354,0.336,0.280,0.312,0.778,0.723,0.755,0.774,0.759,0.762,0.490,0.400,
0.364,0.439,0.441,0.673};
DescriptiveStatistics maths = new DescriptiveStatistics(dataPoints);
double sampleMean = maths.getMean();
double sampleStdDev = maths.getStandardDeviation();
double sampleSkev = (Math.abs(sampleMean - maths.getPercentile(50)) / sampleStdDev);
// parameter estimation using method of moments ex-gaussian distribution
double mean = sampleMean - sampleStdDev * Math.pow(sampleSkev/2., 1./3) ;
double stdDev = Math.sqrt(sampleStdDev*(1 - Math.pow(sampleSkev/2., 2./3)));
double tau = sampleStdDev * (Math.pow(sampleSkev/2., 1./3));
double lambda = 1 / tau;
ExponentiallyModifiedGaussianDistribution exGaussian = new ExponentiallyModifiedGaussianDistribution(mean, stdDev, lambda);
System.out.println(sampleStdDev);
System.out.println(exGaussian.getStddev());
Gradle Dependencies:
编组:'de.lmu.ifi.dbs.elki',名称:'elki',版本:'0.7.1'
编译组:'org.apache.commons',名称:'commons-math3',版本: '3.6'
答案 2 :(得分:1)
ELKI包含用于分发的各种估算器(请注意,对于某些分布,我们有多种估算技术;对于某些我们还没有任何估算技术,请贡献):
<div id="myCarousel" class="carousel slide">
<!-- Carousel items -->
<div class="carousel-inner">
<?php
$my_query = new WP_Query('posts_per_page=3');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>
<!-- The 1st Loop... -->
<div class="active item well-blue">
<div class="offset1">
<h3><?php the_title(); ?></h3>
<p class="lead"><?php $excerpt = strip_tags(get_the_excerpt()); echo $excerpt; ?></p>
<a href="<?php the_permalink() ?>" class="btn" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read more...</a>
</div>
</div>
<?php endwhile; wp_reset_query(); ?> <?php
// The 2nd Loop limits the query to 2 more posts...
$limit_query = new WP_Query('posts_per_page=3');
while ($limit_query->have_posts()) :$limit_query->the_post();$do_not_duplicate = $post->ID;?>
<!-- The 2nd Loop same data as 1st loop -->
<div class="item well-blue">
<div class="offset1">
<h3><?php the_title(); ?></h3>
<p class="lead"><?php $excerpt = strip_tags(get_the_excerpt()); echo $excerpt; ?></p>
<a href="<?php the_permalink() ?>" class="btn" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read more...</a>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
将产生ExGaussian分布:
ExponentiallyModifiedGaussianDistribution dist =
EMGOlivierNorbergEstimator.STATIC.estimate(dataPoints, DoubleArrayAdapter.STATIC);
你也可以尝试最合适的估计。
> ExGaussianDistribution(mean=0.2675761092764285, stddev=0.07999178722695827,
lambda=4.4179732613344)
表示移位的Log-Normal可能更适合您的数据(但是,EMG在理论上可能更适合您的问题 - 移位的对数法线总是有点奇怪)。
Distribution dist = BestFitEstimator.STATIC.estimate(dataPoints, DoubleArrayAdapter.STATIC);