MATLAB简单的全局敏感性分析法(附图)

clear all 
clc
hold off
%sample of size N
N=100;

%sample generation
x1=rand(N,1)-0.5;
x2=rand(N,1)-0.5;
x3=rand(N,1)-0.5;

plot(x1,x2,'o')
hold on
plot(x1,x3,'o')


%model evaluations
y=4*x1.^2+3*x2+x3;


%set n. of stripes
r=10;


for i=1:r
t=(i-1)/r-0.5;
ind=find(x1t);
condmean1(i)=mean(y(ind));
ind=find(x2t);
condmean2(i)=mean(y(ind));
ind=find(x3t);
condmean3(i)=mean(y(ind));
end


S1=var(condmean1)
S2=var(condmean2)
S3=var(condmean3)
plot(x1,y,'o')
hold on; grid
plot([-.5+1/(2*r):1/r:.5-1/(2*r)],condmean1,'ro')


figure
plot(x2,y,'o')
hold on; grid
plot([-.5+1/(2*r):1/r:.5-1/(2*r)],condmean2,'yo')
figure
p

你可能感兴趣的:(MATLAB软件)