day 7
statistics
descriptive statistics
summary measures
central tendency
mean
median
mode 众数
quartile
prctile(,[25 50 75])
variation
range
max()
min()
variance
var()
standard deviation
std()
boxplot
marks=[3 5 85 37 463];
boxplot(mark,{‘str’})
skewness
kurtosis
inferential statistics
t-test
x1=stocks(:,3); x2=stocks(:,10);
boxplot([x1 x2],{‘3’,‘10’});
[h,p]=ttest2(x1,x2) %h=0原假设成立
regression
polyfit()
x=[1 2 3 4 5];
y=[3 4 6 7 9];
fit=polyfit(x,y,1) % 1为order
xfit=[x(1):0.1:x(end)];
yfit=fit(1)*xfit+fit(2);
plot(x,y,‘ro’,xfit,yfit);
scatter(x,y);box on;axis square;
corrcoef(x,y)
regress() % 双变量
y=a+bx1+cx2
load carsmall;
y=MPG;
x1=Weight;x2=Horsepower;
X=[ones(length(x1),1) x1 x2]; % 第一个参数为常数项a
b=regress(y,X);
x1fit=min(x1)💯max(x1);
x2fit=min(x2):10:max(x2);
[X1FIT,X2FIT]=meshgrid(x1fit,x2fit);
YFIT=b(1)+b(2)*X1FIT+b(3)*X2FIT;
scatter3(x1,x2,y,‘filled’)
cftool
interpolation
interp1()
spline()
interp2()