北大心理学系数据分析使用

上传人:第*** 文档编号:61706542 上传时间:2018-12-10 格式:PPT 页数:93 大小:1.84MB
返回 下载 相关 举报
北大心理学系数据分析使用_第1页
第1页 / 共93页
北大心理学系数据分析使用_第2页
第2页 / 共93页
北大心理学系数据分析使用_第3页
第3页 / 共93页
北大心理学系数据分析使用_第4页
第4页 / 共93页
北大心理学系数据分析使用_第5页
第5页 / 共93页
点击查看更多>>
资源描述

《北大心理学系数据分析使用》由会员分享,可在线阅读,更多相关《北大心理学系数据分析使用(93页珍藏版)》请在金锄头文库上搜索。

1、数据分析-使用matlab 2015-4-14,Matlab statistic toolbox (white book),Introduction Probability distributions Descriptive statistics Linear models Nonlinear regression models Hypothesis tests Multivariate statistics Statistical plots Statistical process control Design of experiments Hidden Markov models,内容,导

2、入数据(excel, txt) 数据的预处理(平滑处理、标准化、数据修剪) 描述统计 分类统计 grpstats 数理统计(参数估计与假设检验) 曲线拟合,数据导入,Excel数据导入,M1 = xlsread(Matrix1.xls) %Importing data for Matrix I M2 = xlsread(Matrix2.xls) %Importing data for Matrix II,调用格式: num = xlsread(filename) num = xlsread(filename, -1) num = xlsread(filename, sheet) num = x

3、lsread(filename, range) num = xlsread(filename, sheet, range) num = xlsread(filename, sheet, range, basic) num = xlsread(filename, , functionhandle) num, txt= xlsread(filename, ) num, txt, raw = xlsread(filename, ) num, txt, raw, X = xlsread(filename, , functionhandle) xlsread filename sheet range b

4、asic,读入文本文件的数据, load examp02_01.txt load -ascii examp02_01.txt x1 = load(examp02_02.txt) x1 = load(examp02_02.txt, -ascii); load examp02_03.txt load examp02_04.txt , x = dlmread(examp02_03.txt) x = dlmread(examp02_03.txt, , 2, 3) x = dlmread(examp02_03.txt, , 1, 2, 2, 5) x = dlmread(examp02_05.txt)

5、x = dlmread(examp02_06.txt) x = dlmread(examp02_09.txt) ,A,B,C, = textread(filename,format) A,B,C, = textread(filename,format,N) = textread(,param,value,),2018/12/10,数据的标准化变换,2018/12/10,一、 标准化变换公式,2018/12/10,二、标准化变换的MATLAB实现,调用格式: Z = zscore(X) Z,mu,sigma = zscore(X) = zscore(X,1) = zscore(X,flag,di

6、m),1. zscore函数,2018/12/10,% 调用rand函数产生一个10行,4列的随机矩阵,每列服从不同的均匀分布 x = rand(10,1), 5*rand(10,1), 10*rand(10,1), 500*rand(10,1) % 调用zscore函数对x进行标准化变换(按列标准化), % 返回变换后矩阵xz,以及矩阵x各列的均值构成的向量mu,各列的标准差构成的向量sigma xz,mu,sigma = zscore(x) std(xz) % 求标准化后矩阵xz的各列的标准差,【例13-1】调用rand函数产生一个随机矩阵,然后调用zscore函数将其按列标准化,平滑处理

7、,2018/12/10,smooth函数,调用格式: yy = smooth(y) yy = smooth(y,span) yy = smooth(y,method) yy = smooth(y,span,method) yy = smooth(y,sgolay,degree) yy = smooth(y,span,sgolay,degree) yy = smooth(x,y,),2018/12/10,% 产生一个从0到2*pi的向量,长度为500 t = linspace(0,2*pi,500); y = 100*sin(t); % 产生正弦波信号 % 产生500行1列的服从N(0,152)

8、分布的随机数,作为噪声信号 noise = normrnd(0,15,500,1); y = y + noise; % 将正弦波信号加入噪声信号 figure; % 新建一个图形窗口 plot(t,y); % 绘制加噪波形图 xlabel(t); % 为X轴加标签 ylabel(y = sin(t) + 噪声); % 为Y轴加标签,【例13-2】产生一列正弦波信号,加入噪声信号,然后调用smooth函数对加入噪声的正弦波进行滤波(平滑处理),2018/12/10,移动平均法: yy1 = smooth(y,30); % 利用移动平均法对y进行平滑处理 figure; % 新建一个图形窗口 pl

9、ot(t,y,k:); % 绘制加噪波形图 hold on; plot(t,yy1,k,linewidth,3); % 绘制平滑后波形图 xlabel(t); % 为X轴加标签 ylabel(moving); % 为Y轴加标签 legend(加噪波形,平滑后波形);,2018/12/10,lowess方法: % 利用lowess方法对y进行平滑处理 yy2 = smooth(y,30,lowess); figure; % 新建一个图形窗口 plot(t,y,k:); % 绘制加噪波形图 hold on; plot(t,yy2,k,linewidth,3); % 绘制平滑后波形图 xlabel(

10、t); % 为X轴加标签 ylabel(lowess); % 为Y轴加标签 legend(加噪波形,平滑后波形);,2018/12/10,rlowess方法: % 利用rlowess方法对y进行平滑处理 yy3 = smooth(y,30,rlowess); figure; % 新建一个图形窗口 plot(t,y,k:); % 绘制加噪波形图 hold on; plot(t,yy3,k,linewidth,3); % 绘制平滑后波形图 xlabel(t); % 为X轴加标签 ylabel(rlowess); % 为Y轴加标签 legend(加噪波形,平滑后波形);,2018/12/10,loe

11、ss方法: % 利用loess方法对y进行平滑处理 yy4 = smooth(y,30,loess); figure; % 新建一个图形窗口 plot(t,y,k:); % 绘制加噪波形图 hold on; plot(t,yy4,k,linewidth,3); % 绘制平滑后波形图 xlabel(t); % 为X轴加标签 ylabel(loess); % 为Y轴加标签 legend(加噪波形,平滑后波形);,2018/12/10,sgolay方法: % 利用sgolay方法对y进行平滑处理 yy5 = smooth(y,30,sgolay,3); figure; % 新建一个图形窗口 plot

12、(t,y,k:); % 绘制加噪波形图 hold on; plot(t,yy5,k,linewidth,3); % 绘制平滑后波形图 xlabel(t); % 为X轴加标签 ylabel(sgolay); % 为Y轴加标签 legend(加噪波形,平滑后波形);,2018/12/10,数据修剪,初步整理,delete, transpose(转置) find diff repmat flipud, fliplr, rot90 sort sortrows reshape,Movies = ; %New Movies variable. Initializing it as empty. M1 =

13、xlsread(Matrix1.xls) %Importing data for Matrix I M2 = xlsread(Matrix2.xls) %Importing data for Matrix II temp = M1 M2; %Create a joint temporary Matrix, consisting of two long vectors k = 1; %Initializing index k as 1 for i = 1:length(temp) %Could have said 1603, this is flexible. Start i loop if i

14、snan(temp(i,1) = 0 %Update k index only in this case end %End if clause end %End for loop,索引,A=1 2 3 4; 5 6 7 8; 10 20 30 40; 50 60 70 80; A(1,:)=23 A(:,1)=23 find(A(2,:)=7) A(2,find(A(2,:)=7)=57 i=find(A(:,4)=40)&(A(:,4)60) A(i,4) = 7 A(3,2)=15 r,c=find(A=15),= (equal to) = (not equal to) (greater

15、than) = (greater than or equal to) & (AND) | (OR) (NOT) xor (EXCLUSIVE OR) any (true if any element is nonzero) all (true if all elements are nonzero.), x=1 4 9 16 25; d1=diff(x),d2=diff(d1),d3=diff(d2) d1 = 3 5 7 9 d2 = 2 2 2 d3 = 0 0,描述统计,集中趋势,mean mode median harmmean geomean: 几何平均数 trimmean(v, percent),离散度,range- max(v)-min(v) var std Std error: std(v)/sqrt(length(v),双变量与多变量描述统计,相关系数 R,P, RLO, RUP= corrcoef(X) span = 2 4 4 4 5 5 3 3 2 1 2 6 6 6 5 4 4 4 3 3; errors = 4 2 2 4 3 4 3 2 2 6 5 1 2 1 1 2 2 1 2 3; R,P,RLO,RUP = corrcoef(span, errors)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号