Monte Carlo Integration - Expected value of a function

2 visualizaciones (últimos 30 días)
Alexis Villacis
Alexis Villacis el 21 de Feb. de 2019
Hello community,
I estimated this corn production function using data on corn yields and fertilizer
Y = min ( a + b*x , c)
where Y is yield and x is the amount of fertilizer.
Now I want to estimate the expected value of this function using monte carlo integration.
The data I used for estimating this function have x in the range of [0 200].
So I coded this:
%%
%Define size of sample
n=1000000
%Generate uniformly distributed random numbers in the interval (0,1) and de
u = rand(n,1)
%Define random points in the interval of fertilizer applied [0 200]
f = 200*rand(n,1)
%% Evaluate the function at the different random points
Y = min( a + b*f , c );
%%Obtain the average of the evaluations
meanY = mean (Y)
When I do this I get a pretty reasonable result.
My question is:
Do I have the evaluation of the function at the different random points right?
I've been reading and it seems that I need to correct my evaluation, because my fertilizer data come from the range [0 200] such that the evaluation of the function should be:
Y = 200 * min( a + b*f , c );
but when I do this, the value of my expectation (average of the evaluations) does not make sense (it increases 200 times).
Any help will be appreciated.
Thank you!

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by