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
2 answers

How do I vectorize the following loop in Numpy?

"""Some simulations to predict the future portfolio value based on past distribution. x is a numpy array that contains past returns.The interpolated_returns are the returns generated from the cdf of the past returns to simulate future…
Akshay Sakariya
  • 107
  • 1
  • 9
0
votes
1 answer

Importance sampling in monte carlo method (in C)

Hiya, Ive written a code which successfully approximation one, two and three dimensional integrals using a 'crude' Monte-Carlo sampling technique. I would now like to improve this by using 'importance sampling', as apparently this can reduce…
JMzance
  • 1,704
  • 4
  • 30
  • 49
0
votes
1 answer

Number of dots in an image

I have an image which has plain dots scattered across. The dots are of the same size and they are solid (I can read the color to decide whether a point is inside or not). What is the most efficient algorithm to find the exact number of the dots? I…
D.Badawi
  • 175
  • 1
  • 13
0
votes
1 answer

Assignment Problem when jobs are available more than once

I have a normal assignment problem, where I want to match workers to jobs. But there are several kinds of jobs, each with a set amount of positions. So for example I would need 10,000 builders, 5,000 welders etc. Each worker has of course the same…
0
votes
2 answers

Matlab Single Row Vector, while loop that replaces value

numtrials = 10000; empty = 0; for i = 1:numtrials seat = zeros(1,100); seat(randi(100)) = 1; for p = 2:99 % second person in line will look for seat 2, only up to 99 because I want to see if 99 is zero if seat(p) == 0 …
0
votes
1 answer

How can I create a tree structure in Python?

I'm trying to make an AI that plays a game that looks a lot like checkers, the logic is pretty much the same. Anyway I'm looking to use Monte Carlo Tree Search method but I have no idea of how to implement the tree structure. If I'm not wrong the…
0
votes
2 answers

Minimize the number of cuRAND states stored during a MC simulation

I am currently writing a Monte-Carlo simulation in CUDA. As such, I need to generate lots of random numbers on the fly using the cuRAND library. Each thread processes one element in a huge float array (omitted in the example) and generates 1 or 2…
Element_126
  • 3
  • 1
  • 2
0
votes
3 answers

Why is my python 3 implementation much faster than the one I wrote in C++?

I know that C++ should be much faster than Python 3 because it is a compiled language as opposed to an interpreted language. I wrote 2 two programs that use the Monte Carlo Simulation to calculate Pi, one in Python 3 and the other in C++. Python…
0
votes
1 answer

The probability of an event occurring three times in a row, Matlab, Monte Carlo Method

numtrials = 1000000 turkeychance= 0 for i = numtrials for b = 1:10 r = rand(10,1); if r(b)<=.3143 I'm trying to use the monte Carlo simulation method to find the probability of an event occurring within a list of 10 three times in a…
0
votes
1 answer

Using postfile and post commands

When using the post command, I get the following error: post command requires expressions be bound in parenthesis My program generates a matrix which stores regression coefficients for each simulation, and then uses the post command to declare as…
k1000x
  • 65
  • 10
0
votes
5 answers

Is there a way of using linked lists to simplify my Monte-Carlo code

Hiya, my code currently has three functions each producing a massive array of random numbers. Im wondering if there is a way of just having one function returning a linked list or multidimensional array to make it a bit neater: (copied from…
JMzance
  • 1,704
  • 4
  • 30
  • 49
0
votes
3 answers

Random Number Generation : same C++ code, two different behaviors

My colleague and I are working on a Monte Carlo project together, in C++. She uses Visual Studio, I use Xcode, we shared the code through git. We are computing American option prices thanks to a given method requiring random number generation. We…
0
votes
0 answers

Stock Monte Carlo Simulation using GBM in R (more efficient code)

I am running a MC simulation on around 500 stocks in order to generate 252 days of stock prices. I am using the function GBM from the sde package. For this I have a data.frame of 500 stocks that give me the average volume, average return, daily…
RiskTech
  • 1,135
  • 3
  • 13
  • 19
0
votes
0 answers

I want to simulate my design but it is not working well

set.seed(123456) reps<-20 n.iter<-188 n<-90 t.Z1_30=matrix(NA,nrow=600,ncol=1) t.Z2_30=matrix(NA,nrow=600,ncol=1) t.Z3_30=matrix(NA,nrow=600,ncol=1) for(i in 1:n){ for(j in 1:reps){ `n<-90` `nc<-3` X<-rep(1:nc,…
yuri jung
  • 1
  • 1
0
votes
1 answer

Incrementing the values for monte carlo in matlab

I want to implement the monte carlo algorithm in matlab in a slightly different way than I've seen anywhere else. I have a working example where I generate a vector of 1000 points and calculate pi from that. Now I want a model where I can add extra…
wietjes
  • 65
  • 6