1、基本统计
mean函数可得数据均值
>> A = [ 13 15 6 54 8 121 64 ];
>> mean(A)
ans =
40.1429
>> %各个分数
>> x = [ 67 68 45 89 95 65 84 95 45 78 ];
>> y = [ 1 2 5 4 2 3 1 2 3 7 ];
>> %y为各个分数的人数
>> %N为总人数
>> N = sum(y)
N =
30
>> %M为每个人分数的总和
>> M = sum(x.*y)
M =
2124
>> %平均分数为average
>> average = M / N
average =
70.8000
>> %P为各个分数的频率
>> P = y / N
P =
0.0333 0.0667 0.1667 0.1333 0.0667 0.1000 0.0333 0.0667 0.1000 0.2333
>> %average也为平均分数
>> %average1也为平均分数
>> average1 = sum(P.*x)
average1 =
70.8000