Created
February 16, 2016 06:27
-
-
Save Davidnet/91741f92c04e2bee9e1e to your computer and use it in GitHub Desktop.
Montecarlo Integral
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Distributions | |
e = 10.0^(-3); | |
p = 0.85; | |
variance = 4; | |
N = floor(Int, variance / ((1-p)*((e/2)^2))) + 1 | |
u = Uniform(0,2); | |
x = rand(N); | |
y = rand(N); | |
z = rand(u, N); | |
result = sum((x.^2 + y.^2 .<= 1) & (z .<= x.^4 + y.^2))*2.0 / N |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment