其他分享
首页 > 其他分享> > 零基础Matlab Note14--基本统计

零基础Matlab Note14--基本统计

作者:互联网

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

标签:分数,--,average,45,Matlab,0.0667,sum,average1,Note14
来源: https://blog.csdn.net/m0_64837979/article/details/122724132