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

Creating a N sets of combinations of variables from the given range of each variable

This may be a very vague question -- I apologize in advance. y is a function of a,b,c,d,e. a can go from 1 to 130; b from 0.5 to 1; c from 3 to 10; d from 0 to 1; and e is 1-d. Is there a way in python I can create N (say, 10,000) sets of…
DPdl
  • 723
  • 7
  • 23
-2
votes
1 answer

Parallelize Monte Carlo Integration

I would like to generate 1 billion random points from a probability distribution and evaluate functions using these points to calculate a Monte Carlo integral. The problem is I am using MATLAB and have little knowledge of other programming…
rickri
  • 43
  • 2
  • 9
-2
votes
1 answer

Monte Carlo using Fortran

I am attempting to do a Monte Carlo simulation using RANDOM_NUMBER. I am using gFortran. I want to perform the following: Calculate monteNum (fixed number) and generate a random number, monteTest. If monteNum >= monteTest, then generate another…
user27430
  • 11
  • 4
-2
votes
1 answer

Drawing from different distributions without looping in R

I want to vectorize the way I draw. Suppose I have a vector of parameter values for poisson, and for each parameter, I want to draw 1 sample. Is there a way to do this without looping?
wolfsatthedoor
  • 7,163
  • 18
  • 46
  • 90
-2
votes
1 answer

Gibbs Sampling Code

Does any one here have implemented Gibbs sampling using some test. I have to implement Gibbs sampling but i have problems in it in nailing it down to implementation level. ----How and from where to choose test data? ----How to create Bayesian…
Madu
  • 4,849
  • 9
  • 44
  • 78
-3
votes
1 answer

Python, roll 2 dice and sum up the outcomes 10000 times, present in histogram

Question is to use Monte carlo sample for throw of 10000 dice pairs of 10-faced dice, sum each pair, count the occurrence of each outcome and plot in histogram. This is my code: import random import matplotlib.pyplot as…
-3
votes
1 answer

Jupyter Notebook Python error: return_type

I am getting an error regarding return_type so any help would be much appreciated :) Code: def daily_returns(data, days, iterations): ft = drift_calc(data, return_type='n') try: stv = log_returns(data).std().values except: …
-3
votes
1 answer

object of type 'filter' has no len()

i'm trying to use the simulation of monte carlo in order to calculate the area under the curve (python 3.8) in order to get this plot eventually i tried this code import random, math NUM_POINTS = 10000 # Function for which we want to find area…
Hello_world
  • 65
  • 1
  • 3
  • 17
-3
votes
2 answers

Calculating pow(double,2) gives a huge number (C)

I'm trying to code a simulation of Pi calculating using multiple processes. I have a function that generates random double x, y numbers from 1 to -1, and when im trying to calculate whether x^2 + y^2 <= 1, but the result is a huge number, and its…
Django Freeman
  • 81
  • 1
  • 2
  • 9
-3
votes
1 answer

How to use MATLAB Code for Monte Carlo Simulation?

`n = 10000; Min= Minimum Value; Max= Maximum Value; Mode= Most Likely Value; X = [Min=5,Mode=7,Max=10]; Y = [Min=3,Mode=5,Max= 10]; Z = [Min=5,Mode=7,Max=12]; P= X*Y*Z;` I have three parameters such as, X =( Min=5,Mode=7,Max=10);…
Bisu
  • 13
  • 3
-4
votes
1 answer

Issue on accessing inherited members from a template class

I have a few issues with my the following classes . When I create an object of type "MonteCarloSingleAsset" and I apply to it the method "GetPrice()", I get this: copy\pricinglib\montecarlosingleasset.h(81): error C2597: illegal reference to…
Student
  • 117
  • 4
-5
votes
3 answers

can anyone help explain why removing the square brackets make the function work properly?

def roll(M=100,T=100,N=6): trails=[] N_plus_1=N+1 for m in range(M): collection=[random.randrange(1,N_plus_1)] while [sum(collection)
mezo
  • 1
-5
votes
1 answer

Difference between x>0 and x (as a condition) in python?

What is the difference between the following code snippets? (I'm aware that a negative value of bal will be truthy but why would bal ever be negative?) while spin and bal>0: bal = bal - 1 bal = bal + funciton() #adds either 0 or a positive…
user10210386
-6
votes
1 answer

Heston Simulation Monte Carlo: Slow R code

I need to simulate the stock price, that follows stochastic volatility process (Heston Model). I already asked, how to speed up my loops, but for this case I´m not able to use some tips due to the V[i-1] dependence. Basically the code is: V is the…
PereMkB
  • 29
  • 2
  • 5
1 2 3
83
84