使用MATLAB拟合累积分布函数 [英] Fitting the cumulative distribution function using MATLAB
问题描述
当我使用 Cumulative_distribution_function 进行绘图时,如何使以下数据更合适?
How is it possible to make the following data more fitted when i will plot using Cumulative_distribution_function?
这是我的代码,使用cdfplot绘制
here is my code, plotted using the cdfplot
clear all;
close all;
y = [23 23 23 -7.59 23 22.82 22.40 13.54 -3.97 -4.00 8.72 23 23 10.56 12.19 23 9.47 5.01 23 23 23 23 22.85 23 13.61 -0.77 -14.15 23 12.91 23 20.88 -9.42 23 -1.37 1.83 14.35 -8.30 23 15.17 23 5.01 22.28 23 21.91 21.68 -4.76 -13.50 14.35 23]
cdfplot(y)
推荐答案
您的问题没有确定的答案,范围太广,主要属于统计信息.在进行任何计算之前,您应该回答一些问题:
There is no definite answer to your question, it is too broad and mainly belongs to statistics. Before doing any computation you should answer some questions:
- 数据是否遵循特定的分布类型?
- 选择分布类型并丢弃其他分布类型是否有理论依据?
- 我需要参数分布还是非参数分布?
- 如果没有其他特定的分布类型可供选择,那我应该调查哪一组分布?
- 如何比较分布,拟合优度度量?
- 我应该使用哪种拟合方法,例如最大可能性,贝叶斯等?
- 如何处理不确定性?
- 如何以及为什么要使用结果?
- 等
- is there a specific distribution type which the data follow?
- is there any theoretical justification to select a distribution type and discard others?
- do I need parametric or non-parametric distribution?
- if no specific distribution type can be selected than what set of distributions should I investigate?
- how to compare the distributions, goodness-of-fit measures?
- what fitting method should I use, e.g. max-likelihood, method of moments, Bayesian, etc.?
- how to treat uncertainties?
- how and for what want I use the results?
- etc.
如果不回答这些问题,那么谈论将数据分配给数据是没有意义的. 我为您提供了一个示例,该方法如何使用最大似然法在Matlab中进行拟合,仅用于说明目的,但是我强烈建议您不要考虑上述几点而劝阻您使用它.
Without answering these question it is meaningless to talk about fitting distribution to data. I give you an example how to do the fit in Matlab using maximum-likelihood method, just for illustration, but I would strongly discourage you to use it without considering the above points.
由于我没有关于数据性质的其他背景信息,因此正常和内核通过对分布进行拟合,可以说明1个参数分布和1个非参数分布.
Since I have no additional background information in respect of the nature of the data, normal and kernel distributions are fitted to illustrate 1 parametric and 1 non-parametric distribution.
cdfplot(y)
hold on
xx = -20:40;
%normal distribution
pd_norm = fitdist(y', 'normal');
F_norm = normcdf(xx, pd_norm.mu, pd_norm.sigma);
plot(xx, F_norm, 'r')
%kernel distribution
pd_kernel1 = fitdist(y', 'kernel', 'Kernel', 'normal', 'Width', 6);
F_kernel1 = cdf(pd_kernel1, xx);
plot(xx, F_kernel1, 'g')
%kernel distribution
pd_kernel2 = fitdist(y', 'kernel', 'Kernel', 'normal', 'Width', 2);
F_kernel2 = cdf(pd_kernel2, xx);
plot(xx, F_kernel2, 'black')
legend('ecdf', 'normal', 'kernel1', 'kernel2', 'Location', 'NorthWest')
这篇关于使用MATLAB拟合累积分布函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!