52matlab技术网站,matlab教程,matlab安装教程,matlab下载
标题:
几种常见分布统计量计算的matlab程序
[打印本页]
作者:
matlab的旋律
时间:
2017-12-8 16:06
标题:
几种常见分布统计量计算的matlab程序
本帖最后由 matlab的旋律 于 2017-12-8 16:07 编辑
下面几种分布生成的数据均满足均值为10
clear all
close all
clc
dataLen = 5000;
lambda = 10;
PoissonData = random('Poisson',lambda,[1,dataLen]);%mean = lambda
PoissonMean = mean(PoissonData)%均值
PoissonVar = var(PoissonData)%方差
PoissonKewness = skewness(PoissonData)%偏度
Poissonkurtosis = kurtosis(PoissonData)%峰度
figure
subplot(2,1,1)
plot(PoissonData)
title('泊松分布')
subplot(2,1,2)
[h,stats]=cdfplot(PoissonData)%经验分布图
title('经验分布图')
n = 30;
p = 1/3;
BinomialData = random('Binomial',n,p,[1,dataLen]);%mean = n*p
BinomialMean = mean(BinomialData)
BinomialVar = var(BinomialData)
BinomialKewness = skewness(BinomialData)
Binomialkurtosis = kurtosis(BinomialData)
figure
subplot(2,1,1)
plot(BinomialData)
title('二项分布')
subplot(2,1,2)
[h,stats]=cdfplot(BinomialData)%经验分布图
title('经验分布图')
p = 1/11;
GeometricData = random('Geometric',p,[1,dataLen]);%mean = (1 - p)/p
GeometricMean = mean(GeometricData)
GeometricVar = var(GeometricData)
GeometricKewness = skewness(GeometricData)
Geometrickurtosis = kurtosis(GeometricData)
figure
subplot(2,1,1)
plot(GeometricData)
title('几何分布')
subplot(2,1,2)
[h,stats]=cdfplot(GeometricData)%经验分布图
title('经验分布图')
r = 10;
p = 1/2;
NegativeBinomialData = random('NegativeBinomial',r,p,[1,dataLen]);%mean = r*p/(1-p)
NegativeBinomialMean = mean(NegativeBinomialData)
NegativeBinomialVar = var(NegativeBinomialData)
NegativeBinomialKewness = skewness(NegativeBinomialData)
NegativeBinomialkurtosis = kurtosis(NegativeBinomialData)
figure
subplot(2,1,1)
plot(NegativeBinomialData)
title('负二项分布')
subplot(2,1,2)
[h,stats]=cdfplot(NegativeBinomialData)%经验分布图
title('经验分布图')
M = 100;
K = 50;
n = 20;%M>K>n
HypergeometricData = random('Hypergeometric',M,K,n,[1,dataLen]);%mean = n*K/M
HypergeometricMean = mean(HypergeometricData)
HypergeometricVar = var(HypergeometricData)
HypergeometricKewness = skewness(HypergeometricData)
Hypergeometrickurtosis = kurtosis(HypergeometricData)
figure
subplot(2,1,1)
plot(HypergeometricData)
title('超几何分布')
subplot(2,1,2)
[h,stats]=cdfplot(HypergeometricData)%经验分布图
title('经验分布图')
欢迎光临 52matlab技术网站,matlab教程,matlab安装教程,matlab下载 (http://www.52matlab.com/)
Powered by Discuz! X3.2