Author | Post | ||
Hessiann |
Do you guys know about numeric integration? specifically, monte carlo method. Whater you decide to integrate using this method, u use random values to feed the function. At the end, ur solution will be something like (IntMontCarl -3Sigma/sqrt(n) ; IntMontCarl + 3Sigma/sqrt(n) ) with probability of 99.7%. This probability is 99.7 because I used 3*Sigma. Do you know how to get x*Sigma given a different probability??? i.e: Re-calculate the integral of the function f using the monte carlo method, but using a probability of 97%. How to proceed in the inverse order? TIA hess |
||
14.04.2012 20:07:49 |
|
||
aceldama |
don't have time to look into it, but i'd start as always with wikipedia. there seems to be pseudocode on the page that might help you: link: http://en.wikipedia.org/wiki/Numerical_integration |
||
14.04.2012 20:35:08 |
|
||
Hessiann |
Already chequed that. Couldnt find the solution to my question |
||
14.04.2012 20:44:19 |
|
||
fourmi |
Have a look at http://planetmath.org/encyclopedia/MonteCarlo2.html, part on Bounds on error |
||
15.04.2012 12:21:38 |
|
||
Hessiann |
fourmi, i just had a look to what you show me, it looks good...but im not getting it very well, im not sure about how to read the script parts like $m$ and variance $v$ , then$$ \frac{1}{\sqrt{n}} \sum_{i=1}^n \frac{X_i - m}{\sqrt{v}}$$ Do you happen to know how to read that? Btw ty very much hess |
||
15.04.2012 17:35:09 |
|
||
harvestsnow |
It's LaTeX. Enable javascript... |
||
15.04.2012 18:47:23 |
|
||
fourmi |
appart from the problem of the display, here are some hints to answer your initial question : - sigma is simply the square root of variance so your Sigma/sqrt(n) is exactly the srqt(v/n) - the probability of being in between -alpha*Sigma/sqrt(n) and +alpha*Sigma/sqrt(n) is according to second formula : 2*Phi(alpha)-1 Phi is the Gaussian cumulative distribution function. See the part on Cumulative distribution function in http://en.wikipedia.org/wiki/Normal_distribution To make it short, 2*Phi(alpha)-1 = erf(alpha/sqrt(2)) where erf is the error function (well named isn't it ?) Then see http://en.wikipedia.org/wiki/Error_function for value. As an example, for alpha = 3, alpha/sqrt(2) = 2.12 and your probability is 99.7% as mentionned. For a probability of 99.99%, you need alpha/sqrt(2) around 2.75, that is alpha = 3.89 Cheers, fourmi |
||
16.04.2012 19:42:12 |
|
||
Hessiann |
Thx fourmi for the reply. Im not a 100% sure your method is the same as my teacher taught me today, but I will post mine for if anyone ever have the same problem. (Btw I was lucky to find my profesor today, because the exam is tomorrow ) Solution using MatLab If they ask you to find the integral of a given function, using Monte Carlo method, and using a probability as input, what you will have to do to calculate the number that affects the sigma, is to use the function norminv. The probability that you will have to use to feed that function, is the cumulative one, so if they gave u, for example, 97% as input, what you have to do is: P = 0.97 CDF= 1 - 0.97; % (CDF stands for cumulative distribution function, % stands for comments in matlab) %Given a curve that represents a normal distribution, 0.97 is the interval that u are interested in, and the two tails are the rest, that is 1-0.97=0.03 CDF= CDF/2; % You want the cumulative value, so you add 1 tail to the prob expected. CDF=P+CDF; % Add previous result to original prob norminv(CDF,0,1); %0 is mu and 1 is sigma, or you can just use norminv(CDF); et voila! it wont give exactly 3 for prob=0.997 but will be something like 2.97668 thats the value u are looking for. So if they ask you to re-do the excersice but using a different probability, just do the above and will work just fine Thanks for everyone who tried to give me a hand with this easy (?) problem See you around and I hope I can pass this exam |
||
17.04.2012 01:33:40 |
|