52matlab技术网站,matlab教程,matlab安装教程,matlab下载

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 4092|回复: 0
打印 上一主题 下一主题

几种常见分布统计量计算的matlab程序

[复制链接]

125

主题

209

帖子

3070

积分

版主

Rank: 7Rank: 7Rank: 7

积分
3070
跳转到指定楼层
楼主
发表于 2017-12-8 16:06:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 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('经验分布图')



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|52matlab技术网站 ( 粤ICP备14005920号-5 )

GMT+8, 2024-11-22 12:24 , Processed in 0.081500 second(s), 19 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表