1 clear all; 2 close all; 3 clc; 4 5 randn('seed',0); 6 %{ 7 一维情况 8 mu=0; 9 N=100000; 10 S=5; 11 data=mvnrnd(mu,S,N); 12 me=mean(data); 13 S2=1/N*sum((data-me).^2); 14 %} 15 16 %%二维或多维情况 17 mu=[0 0]; 18 S=[0.3 0;0 0.35]; 19 N=10000; 20 data=mvnrnd(mu,S,N); 21 22 me=mean(data) 23 S1=1/N*sum((data(:,1)-me(1)).^2) 24 S2=1/N*sum((data(:,2)-me(2)).^2)