tag=randn(1,100);%产生标准正态分布数据100个
>> tag=tag+5;
>> average=sum(tag)/100 %求的均值
average =
5.1231
>> variance=sum((tag-average).^2)/100 %求得方差
variance =
1.3377
当然利用函数var(tag)求到得是总体方差,而上面的是样本方差,因为
var(tag)=sum((tag-average).^2)/99
答案却是
1.3512
tag=randn(1,100);%产生标准正态分布数据100个
>> tag=tag+5;
>> average=sum(tag)/100 %求的均值
average =
5.1231
>> variance=sum((tag-average).^2)/100 %求得方差
variance =
1.3377
当然利用函数var(tag)求到得是总体方差,而上面的是样本方差,因为
var(tag)=sum((tag-average).^2)/99
答案却是
1.3512