Question: A python function (m, cv) = program(fun, nSamples, nOutput, nInput, mn, sd) which implements a Monte Carlo simulation. The model of the simulation is contained

A python function (m, cv) = program(fun, nSamples, nOutput, nInput, mn, sd) which implements a Monte Carlo simulation. The model of the simulation is contained in fun and all input variables follow a normal distribution.

 

Inputs:

fun: A function with the call out = fun(in) where in is a 1D numpy array of length nInput and out is a 1D numpy array of length nOutput.

 

'nSamples': The number of samples to collect.

 

nOutput: The length of the output array of func.

 

nInput: The length of the input array of func.

 

mn: A 1D numpy array of length nInput listing the mean of each input variable

.

sd: A 1D numpy array of length nInput listing the standard deviation of each input variable.

 

Outputs:

m: A 1D numpy array of length nOutput with the mean of each output variable.

 

cv: A 2D numpy array of size nOutput by nOutput containing the covariance matrix of the output variables.

 

You can use numpy functions like:

empty or zeros, mean, cov, random.normal

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!