matlab练习程序(最大似然估计)

时间:2022-10-27 19:02:38
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)