【参考视频:https://www.bilibili.com/video/av14503445/?p=13】
常用函数:

mean:平均数;
median:中位数;
mode:众数

quartile:按顺序后的四等分位。
【用prctile()实现:prctile(A, 0.25) prctile(A, 0.75)】


range :最大值和最小值之间的距离。
interquartile range:两个quartile之间的距离


var = (std)^2

>> load stockreturns
>> x4 = stocks(:,4);
>> mean(x4)
ans =
-5.8728e-04
>> median(x4)
ans =
0.0617
>> mode(x4)
ans =
-5.8764
>> prctile(x4,.25)
ans =
-5.8764
>> prctile(x4,.75)
ans =
-5.7628
>> range(x4)
ans =
12.3455
>> std(x4)
ans =
2.3590
>> var(x4)
ans =
5.5649
>>
画图:

freqy 的意思:‘1’处有1个点。‘2’处0个,‘3’处1个,‘4’处0个,‘5’处4个,……
>> x = 1:14;
>> freqy = [1 0 1 0 4 0 1 0 3 1 0 0 1 1];
>> subplot(1,3,1); bar(x,freqy);
>> xlim([0 15]);
>> subplot(1,3,2); area(x,freqy); xlim([0 15]);
>> subplot(1,3,3);
>> stem(x,freqy); xlim([0,15]);
>>

Boxplot:

>> marks = [80 81 81 84 88 92 92 94 96 97];
>> boxplot(marks)
>> prctile(marks,[25,50,75])
ans =
81 90 94
>>

>> load stockreturns
>> boxplot(stocks)
>>

Skewness (偏度)
偏度定义中包括正态分布(偏度=0),右偏分布(也叫正偏分布,其偏度>0),左偏分布(也叫负偏分布,其偏度<0)。


>> X= randn([10 3])*3;
>> X(X(:,1)<0,1) = 0;
>> X(X(:,3)>0,3) = 0;
>> boxplot(X,{'Right-skewness','Symmetric','Left-skewness'});
>> y = skewness(X);
>> y
y =
1.0487 0.2193 -1.5381
>>

Kurtosis(峰度)
【看它尖不尖】
关于偏度和峰度:https://blog.csdn.net/xbmatrix/article/details/69360167
>> load stockreturns;
>> skewness(stocks)
ans =
1 至 4 列
-0.2318 0.2304 -0.1773 -0.1236
5 至 8 列
-0.1874 -0.1527 -0.3484 -0.2678
9 至 10 列
0.0963 0.0580
>> kurtosis(stocks)
ans =
1 至 3 列
3.4272 2.5871 2.4970
4 至 6 列
2.8580 2.7638 2.3758
7 至 9 列
3.4207 2.4909 3.3993
10 列
3.1807
>> x = 0:0.1:2*pi;
>> y = sin(x);
>> kurtosis(y)
ans =
1.5040
>> x = [1 1 1 1 1 1 1 1 1];
>> kurtosis(x)
ans =
NaN
峰度包括正态分布(峰度值=3),厚尾(峰度值>3),瘦尾(峰度值<3)
推论统计
步骤:


h:null hypothesis是否成立。0:yes 1:no
p:null hypothesis发生的几率。
>> load stockreturns;
>> x1 = stocks(:,3);x2 = stocks(:,10);
>> boxplot([x1 x2], {'3','10'});
>> [h p ] = ttest2(x1,x2)
h =
1
p =
0.0423
>>

我们一般使用双维测试:
(两端部分被认为超出范围)

也可以采用单维:

常用函数

本文介绍了Matlab中的统计分析,包括常用的统计量如平均数、中位数、众数和四分位数,并讲解了如何利用`prctile()`计算。此外,详细探讨了Boxplot、偏度(Skewness)和峰度(Kurtosis)的概念,以及它们在数据分布中的作用。同时提到了推论统计的基本步骤和相关函数。

249

被折叠的 条评论
为什么被折叠?



