<< Sensitivity Analysis Sensitivity Analysis nisp_sobolsaAll >>

NISP >> NISP > Sensitivity Analysis > nisp_bruteforcesa

nisp_bruteforcesa

Compute sensitivity indices by brute force.

Calling Sequence

s=nisp_bruteforcesa(func,nx)
s=nisp_bruteforcesa(func,nx,randgen)
s=nisp_bruteforcesa(func,nx,randgen,n)
[s,nbevalf]=nisp_bruteforcesa(...)

Parameters

func :

a function or a list, the name of the function to be evaluated.

nx :

a 1-by-1 matrix of floating point integers, the number of inputs of the function.

randgen :

a function or a list, the random number generator. (default = uniform random variables)

n :

a 1-by-1 matrix of floating point integers (default n=10000), the number of Monte-Carlo experiments, for each sensitivity index

s :

a nx-by-1 matrix of doubles, the first order sensitivity indices

nbevalf :

a nx-by-1 matrix of doubles, the actual number of function evaluations.

Description

The algorithm uses the Sobol method to compute the first order sensitivity indices. This function assumes that the input variables are independent. By design, the algorithm produces sensitivity indices which are positive. If a computed indice is greater than 1, it is set to 1. It is not guaranteed that the sum of indices in s is 1: in fact this is rarely the case.

Any optional input argument equal to the empty matrix will be set to its default value.

The function should have header

y = func ( x )

where x is a m-by-nx matrix of doubles, where m is the number of experiments to perform, nx is the number of input random variables, and y is a m-by-1 matrix of doubles.

It might happen that the function requires additionnal arguments to be evaluated. In this case, we can use the following feature. The argument func can also be a list, with header

y = f ( x , a1 , a2 , ... ).

In this case the func variable should hold the list (f,a1,a2,...) and the input arguments a1, a2, will be automatically be appended at the end of the calling sequence of f.

The random number generator must have header

x = randgen ( n , i )

where

On output, x must contain random numbers sampled from the distribution function associated with the input variable #i.

It might happen that the random number generator requires additionnal arguments to be evaluated. In this case, we can use the following feature. The argument randgen can also be a list, with header

x = rg ( n , i , a1 , a2 , ... ).

In this case the randgen variable should hold the list (rg,a1,a2,...) and the input arguments a1, a2, will be automatically be appended at the end of the calling sequence of rg.

Examples

// Compute the first order sensitivity indices
// of the ishigami function.
// Three random variables uniform in [-pi,pi].
function y=ishigami(x)
a=7.
b=0.1
s1=sin(x(:,1))
s2=sin(x(:,2))
x34 = x(:,3).^4
y(:,1) = s1 + a.*s2.^2 + b.*x34.*s1
endfunction
function x=myrandgen(n, i)
x = distfun_unifrnd(-%pi,%pi,n,1)
endfunction
a=7.;
b=0.1;
exact = nisp_ishigamisa(a,b);
n = 500;
nx = 3;
[s,nbevalf]=nisp_bruteforcesa(ishigami,nx,myrandgen,n);
[s(1),exact.S1]
[s(2),exact.S2]
[s(3),exact.S3]

// See the number of significant digits
// when N increases
stacksize("max");
imax=11;
for i=2:11
n=2^i;
s=nisp_bruteforcesa(ishigami,nx,myrandgen,n);
d(i-1,1)=assert_computedigits(s(1),exact.S1);
d(i-1,2)=assert_computedigits(s(2),exact.S2);
end
scf();
plot(1:imax-1,d(:,1)',"r-");
plot(1:imax-1,d(:,2)',"b-");
legend(["S1","S2"]);
xtitle("","Log2(N)","Digits");

// Repeat the computation N times
// See the histogram
stacksize("max");
n=2^7;
nsamples=100;
smat=zeros(3,nsamples);
for i=1:nsamples
s(:,i)=nisp_bruteforcesa(ishigami,nx,myrandgen,n);
end
scf();
//
subplot(1,3,1);
histplot(20,s(1,:))
plot([exact.S1,exact.S1],[0,10],"r-");
xtitle("","S1","Frequency");
legend(["Data","Exact"]);
//
subplot(1,3,2);
histplot(20,s(2,:))
plot([exact.S2,exact.S2],[0,10],"r-");
xtitle("","S2","Frequency");
legend(["Data","Exact"]);
//
subplot(1,3,3);
histplot(20,s(3,:))
plot([exact.S3,exact.S3],[0,200],"r-");
xtitle("","S3","Frequency");
legend(["Data","Exact"]);

Authors


Report an issue
<< Sensitivity Analysis Sensitivity Analysis nisp_sobolsaAll >>