# MATLAB函数var、std浅析

The Population:

Variance: σ 2 = ∑ ( x i − μ ) 2 N \sigma^2=\frac{\sum(x_i-\mu)^2}{N}
Stand Deviation: σ = σ 2 \sigma=\sqrt{\sigma^2}

A Sample

Variance: s 2 = ∑ ( x i − μ ) 2 N − 1 s^2=\frac{\sum(x_i-\mu)^2}{N-1}
Stand Deviation: s = s 2 s=\sqrt{s^2}

test=[4 5 6 3 5 7 2]; %随机给出一组数据
m=mean(test)
var1=sum((test(1,:)-m).^2)/length(test) %用总体数据公式定义的方法求方差
var2=sum((test(1,:)-m).^2)/(length(test)-1) %求样本数据的方差
var3=var(test) %用var函数计算

m =
4.571428571428571
var1 =
2.530612244897959
var2 =
2.952380952380953
var3 =
2.952380952380953



var4=var(test,1)

var4 =
2.530612244897959


std1=std(test,0)  %默认参数就是0来的
std2=sqrt(var(test,0))

std3=std(test,1)  %选择参数为1
std4=sqrt(var(test,1))

std1 =
1.718249385968449
std2 =
1.718249385968449
std3 =
1.590789817951435
std4 =
1.590789817951435


“MATLAB”，就可以获取丰富的资源啦（支持WIN,MAC,Linux三大系统）

• 3
点赞
• 1
评论
• 8
收藏
• 一键三连
• 扫一扫，分享海报

06-12

03-25 6894
02-28 5836
06-27 5万+
01-04 3万+
05-17 5554
01-08 2901
02-27 1922
07-26 3580
01-24 2971
05-17 4万+
12-08 1664
03-14 570
06-16 4781

¥2 ¥4 ¥6 ¥10 ¥20