clear all; close all; clc; randn('seed',0); %{ 一维情况 mu=0; N=100000; S=5; data=mvnrnd(mu,S,N); me=mean(data); S2=1/N*sum((data-me).^2); %} %%二维或多维情况 mu=[0 0]; S=[0.3 0;0 0.35]; N=10000; data=mvnrnd(mu,S,N); me=mean(data) S1=1/N*sum((data(:,1)-me(1)).^2) S2=1/N*sum((data(:,2)-me(2)).^2)