Questions tagged [montecarlo]

Monte Carlo methods are stochastic (probabilistic) systems that use many random samples to derive properties of a complex system.

Monte Carlo methods are stochastic methods that use large sample sizes to gather information about a complex system. The outcomes of these trials can then be used to draw generalizations about the system as a whole, without first needing a proper solution.

Monte Carlo methods are especially useful when a numeric solution is available, but which is too complex to solve for directly. They are general enough that their use is widespread; Wikipedia provides a list too exhaustive to reproduce here.

1260 questions
11
votes
2 answers

Geometric Brownian Motion simulation in Python

I am trying to simulate Geometric Brownian Motion in Python, to price a European Call Option through Monte-Carlo simulation. I am relatively new to Python, and I am receiving an answer that I believe to be wrong, as it is nowhere near to converging…
tgood
  • 129
  • 1
  • 2
  • 7
11
votes
2 answers

Speed up sampling of kernel estimate

Here's a MWE of a much larger code I'm using. Basically, it performs a Monte Carlo integration over a KDE (kernel density estimate) for all values located below a certain threshold (the integration method was suggested over at this question BTW:…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
11
votes
5 answers

Uniform random (Monte-Carlo) distribution on unit sphere

I need a clarification with algorithm generating random values for my pet ray-tracer. I emit rays from one point. And I have the problem with distribution of these rays: I need the distribution to be uniform, but it isn't... The problem I face now…
avp
  • 4,895
  • 4
  • 28
  • 40
10
votes
1 answer

How is Monte Carlo Tree Search implemented in practice

I understand, to a certain degree, how the algorithm works. What I don't fully understand is how the algorithm is actually implemented in practice. I'm interested in understanding what optimal approaches would be for a fairly complex game (maybe…
10
votes
3 answers

How can I do a Monte Carlo analysis on an equation?

Given a function that depends on multiple variables, each with a certain probability distribution, how can I do a Monte Carlo analysis to obtain a probability distribution of the function. I'd ideally like the solution to be high performing as the…
bluprince13
  • 4,607
  • 12
  • 44
  • 91
10
votes
4 answers

Can Random Number Generator of Fortran 90 be trusted for Monte Carlo Integration?

I have written a short monte carlo integration algorithm to calculate an integral in Fortran 90. I once compared the result obtained by solving the integral with respect to some parameter using the intrinsic random number generator with the random…
DomiD
  • 103
  • 1
  • 8
10
votes
6 answers

Monte Carlo calculation of Pi in Scala

Suppose I would like to calculate Pi with Monte Carlo simulation as an exercise. I am writing a function, which picks a point in a square (0, 1), (1, 0) at random and tests if the point is inside the circle. import scala.math._ import…
Michael
  • 41,026
  • 70
  • 193
  • 341
10
votes
1 answer

Monte Carlo Simulation with Python: building a histogram on the fly

I have a conceptual question on building a histogram on the fly with Python. I am trying to figure out if there is a good algorithm or maybe an existing package. I wrote a function, which runs a Monte Carlo simulation, gets called 1,000,000,000…
marillion
  • 10,618
  • 19
  • 48
  • 63
10
votes
2 answers

Fast generation of random set, Monte Carlo Simulation

I have a set of numbers ~100, I wish to perform MC simulation on this set, the basic idea is I fully randomize the set, do some comparison/checks on the first ~20 values, store the result and repeat. Now the actual comparison/check algorithm is…
DeusAduro
  • 5,971
  • 5
  • 29
  • 36
9
votes
4 answers

What (else) is wrong with using time as a seed for random number generation?

I understand that time is an insecure seed for random number generation because it effectively reduces the size of the seed space. But say I don't care about security. For example, say I'm doing a Monte Carlo simulation for a card game. I DO…
pepsi
  • 6,785
  • 6
  • 42
  • 74
9
votes
1 answer

What's the difference between numpy.random vs numpy.random.Generate

I've been trying to simulate some Monte Carlos simulations lately and came across numpy.random. Checking the documentation of the exponential generator I've noticed that that's a warning in the page, which tells that Generator.exponential should be…
olenscki
  • 487
  • 7
  • 22
9
votes
1 answer

How to vectorize a random walk simulation in MATLAB

I am rewriting a Monte Carlo simulation model in MATLAB with an emphasis on readability. The model involves many particles, represented as (x,y,z), following a random walk over a small set of states with certain termination probabilities. The…
9
votes
1 answer

Estimating the probability density of sum of uniform random variables in python

I have two random variables X and Y which are uniformly distributed on the simplex: I want to evaluate the density of their sum: After evaluating the above integral, my final goal is to compute the following integral: To compute the first…
pikachuchameleon
  • 665
  • 3
  • 10
  • 27
9
votes
1 answer

How to efficiently generate a straight line with random slope and intercept in Python?

Consider a very basic Monte Carlo simulation of a straight line y = m * x + b, e.g. To visualize the effect of uncertainty in the parameters m and b. m and b are both sampled from a normal distribution. Coming from a MATLAB-background, I would write…
Fred S
  • 1,421
  • 6
  • 21
  • 37
9
votes
2 answers

Calculate overlap area of two functions

I need to calculate the area where two functions overlap. I use normal distributions in this particular simplified example, but I need a more general procedure that adapts to other functions too. See image below to get an idea of what I mean, where…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
1
2
3
83 84