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
0
votes
1 answer

Monte Carlo policy evaluation confusion

I'm having trouble understanding Monte Carlo policy evaluation algorithm. What I am reading is that G is the average return after visiting a particular state, lets say s1, for the first time. Does this mean averaging all rewards following that state…
Marcus Ruddick
  • 9,795
  • 7
  • 28
  • 43
0
votes
3 answers

Scientific python array syntax

So i have this code writen in python. I'm not going to explain it as it is a simple syntax fix that i can't seem to see so it is useless to explain what's for. The problem that i have is that for a given d, for example 15 i get the value of…
0
votes
1 answer

Calculating integral sinx dx using Monte Carlo method?

I'm trying to calculate integral -1 to 6 sinx dx, but the following gives result near -1,14 and the correct solution is -0.41987. Where is the mistake? How to make my code look better and more clear? float MonteCarlo ( float a , float b, long…
Nowak Grzegorz
  • 207
  • 1
  • 12
0
votes
2 answers

Simulating geometric Brownian motion

Background Information: Consider the Psedocode: Question: I am trying to implement the above in C++ but I don't really understand how to implement it correctly. Note, the ZZ is the Z_ij in the Pseudocode. We have S[0] = 50. Here is my code: for(int…
user7465838
0
votes
1 answer

Uniform sampling around hemisphere

suppose that rand() can generate random value in [0, 1] uniformly. Is the direction of the ray generated by the following method uniformly distributed? (I am doing monte carlo integration.) X = rand() * 2 - 1 Y = rand() * 2 - 1 Z = rand() vec3 dir…
Tim Hsu
  • 402
  • 5
  • 19
0
votes
0 answers

Success probability of naive monte carlo algorithm for primality testing

Consider the following naive monte Carlo algorithn for primality testing of a number n. isPrimeMonteCarlo(n,t){ /* * Take an integer n as input and check wheather it is prime or not * using the naive monte carlo method. * If the number is prime…
Milan
  • 403
  • 2
  • 8
0
votes
2 answers

generate sum of results in python

We have a game, the game consists of 500 rounds. In each round, two coins are being rolled at the same time, if both coins have 'heads' then we win £1, if both have 'tails' then we lose £1 and if we have a situation where one coin shows 'heads' and…
0
votes
3 answers

'if' statement for when two random numbers are equal

I am trying to have a situation in which when we toss two coins at the same, if we get heads on both coins we win and if we get tails on both coins we lose. I have been able to generate the results of tossing one of the coins separately using: def…
0
votes
0 answers

Unable to reproduce exact results for the "100-sided die puzzle" via simulation in R

I am trying to replicate the results mentioned here using R. While I am able to get quite close to the theoretical number, it's still not quite there and I am not sure where I am going wrong. The strategy that I am using is, roll till an "a" or a…
Chaos
  • 466
  • 1
  • 5
  • 12
0
votes
1 answer

Integrating a function in R

I was hoping to get some help integrating a function that is based on a random variable. The function is to get an expected value of a continuous distribution. Here is the code that I have so far. montecarlo <- function(r,v,t,x,k) { y <- rnorm(1) …
0
votes
0 answers

Calculating particle equilibrium using Monte Carlo

I am trying to write a function that calculates the number of iterations it takes for two chambers to have equally as many particles.The evolution of the system is considered as a series of time-steps, beginning at t = 1. At each time-step…
Briyan
  • 23
  • 4
0
votes
0 answers

Monte Carlo Simulation with chaning distribution

I am experimenting with Monte Carlo Simulations and I have come up with this interesting problem. Suppose we are generating random values using a Normal distribution with St.Dev = 2 and mean = the last value generated (Markov process), we start at…
0
votes
0 answers

VaR montecarlo simulation matlab

i'm working on matlab for the thesis and i need some help. i need to calculate Value at Risk using montecarlo simulation method. the imputs is: a equity portfolio with daily observation : nx5 array with n daily prices observation and 5 different…
0
votes
1 answer

Monte Carlo Multiple Distributions

I have been struggling with an issue relating to the summation of multiple Risks' triangular distributions using Monte Carlo. I can get the correct shape of generation but the percentage probability is far off. This is what I am generating for 2…
J Dubbs
  • 201
  • 2
  • 11
0
votes
0 answers

Electron scattering Monte-carlo: prevent ghost-energy gain

I am working on a physics simulation, in which electrons scattter on protons, or get absorbed by them. However this situatuation occurs quite often: What I want to do is somehow prevent these situations. What can I do to prevent this apart from…
Adam Hunyadi
  • 1,890
  • 16
  • 32