使用MATLAB拟合累积分布函数 [英] Fitting the cumulative distribution function using MATLAB

查看:1083
本文介绍了使用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.

由于我没有关于数据性质的其他背景信息,因此正常和内核

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆