Questions tagged [montecarlo]

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

Filter by
Sorted by
Tagged with
-1 votes
1 answer
90 views

Monte Carlo with OpenMP

I am studying OpenMP and need to implement it into the monte carlo simulation for estimating probability of consecutive kings in a Shuffled Deck. However, after I implemented it, the time taken still ...
Alexander's user avatar
0 votes
0 answers
14 views

How incorporate autocorrelation adjustment into brownian motion monte carlo simulation using Python?

First of all, I am new to both Python and the forum so please be kind if I misunderstand something. :) I would like to incorporate first-order autocorrelation in a brownian motion monte carlo ...
user22465897's user avatar
0 votes
0 answers
14 views

Multiple simulations of portfolio with varying parameters and sample sizes

I have a portfolio that I would like to use the Monte Carlo method to do 100,000 simulations to understand the expected payout by first getting the expected number of payout. The trickier part is that ...
A. Belrose's user avatar
1 vote
1 answer
77 views

Parameterizing a log normal distribution in Sheets

I'm trying to run some monte carlo simulations in Sheets, and want the option of specifying a lognormal distribution. I want to parameterize this based on the mean and 25th percentile i.e. when I run ...
Adotdems's user avatar
0 votes
0 answers
23 views

using cdf to calculate number of occurrence from Monte Carlo simulation

I've run a small Monte Carlo simulation of 800 runs using python. One of the output from the simulation is a max_usage excel file. The file provides me with the "requirement," number of ...
brewig615's user avatar
3 votes
0 answers
83 views

Antithetic Sampling for variance reduction in graph convolutional network (GCN)

I am trying to implement Antithetic Sampling to sample vertices of the graph and train the downstream graph convolutional network (GCN) model on the sampled graph. Antithetic Sampling is a variance ...
Asif's user avatar
  • 763
0 votes
1 answer
60 views

My Monte Carlo simulation keeps giving me the incorrect value for Theta. The other estimated option greeks are correct, but not Theta

I am trying to run a Monte Carlo simulation to help me price option greeks in python. Most of the values I am getting are correct, but I am not sure why I never get the right result for Theta. Plus, ...
googoo's user avatar
  • 11
1 vote
1 answer
69 views

How to adjust for non-uniform sampling (log-scale/polar) in Monte Carlo integration?

I am trying to perform Monte Carlo integration of a function, but sample non-uniformly. I need this method to work for both logarithmic scale and for integration in polar coordinates since I will then ...
Marek Matas's user avatar
1 vote
0 answers
48 views

How to accumulate data over simulations in python

I have a function simulate: import torch MAX_VALUE = 12 LENGTH, WIDTH = (120, 5) MC_N = 100000 batch_size = 50 def simulate() -> tuple[npt.NDArray[np.int6], npt.NDArray[np.int16]]: x = torch....
Q2WKA's user avatar
  • 11
1 vote
2 answers
126 views

How to fix random seed in pytorch, while keeping the dropout randomness?

I am trying to approximate a Bayesian model by keeping the dropout probability during both training and inference (Monte Carlo dropout), in order to obtain the epistemic uncertainty of the model. Is ...
Traveling Salesman's user avatar
0 votes
0 answers
43 views

How can I optimise a Node.js simulation that writes results to a MySQL database?

I have a monte carlo simulation (essentially a simulation of game involving random numbers that I run millions of times) that I've coded in Node.js. The simulation runs a batch of 100,000 games and ...
Gabriel Rubinstein's user avatar
0 votes
0 answers
15 views

Reddening correction to errors

When dealing with astronomical data, Should we incorporate the reddening correction to the errors of the observational parameters too? I have applied reddening correction based on Cardelli et al to ...
Walker's user avatar
  • 1
1 vote
2 answers
137 views

Calculate the area of ​intersection of curves using the Monte Carlo Method in Python

I'm making a list of exercises in which I have the following exercise: "Use the Monte Carlo method to calculate the area of ​​intersection between the curves given below. For random number ...
Vitor Fernandes Reis's user avatar
0 votes
1 answer
38 views

How to construct correlation matrix from pymc.LKJCorr?

I want to construct a correlation matrix explicitly from using the pymc.LKJCorr distribution class, but I don't trust my understanding of the pymc.expand_packed_triangular. Here is a minimal working ...
Galen's user avatar
  • 1,148
0 votes
0 answers
27 views

How branching factor affects complexity of Monte Carlo Tree Search?

I was reading: What's the time complexity of Monte Carlo Tree Search? Where it says: The runtime of the algorithm can be simply be computed as O(mkI/C) where m and k are the same as before, and I ...
Algo's user avatar
  • 11
0 votes
1 answer
40 views

Python class object has no attribute in a for loop

I have a Monte Carlo simulation where I am trying to randomize my Dryden wind model class with each iteration. Initializing the class works as expected for the first iteration; however, future ...
megalomaniac's user avatar
0 votes
1 answer
18 views

Best way to parallelize montecarlo simulations of Misanthrope process Matlab

I am studying the diffusion of the misanthrope process with periodic boundary conditions. In this process, I consider a 1-D discrete lattice with M sites and N repulsive-interacting particles; each ...
Jared Lo's user avatar
  • 229
0 votes
0 answers
54 views

Applying XGBoost on a Monte Carlo simulation

I am currently looking into a special kind of regression analysis. Instead of a "natural phenomenon" I observe the outcome of a Monte Carlo simulation. Does anyone have some experience with ...
CodeMonkeyAtWork's user avatar
0 votes
0 answers
39 views

Potentially Normal Iterator Behaviour which seems like "Weird behaviour in Python Itertools Monte Carlo using itertools.takewhile"

Edit after slothrop's comment: It seems that takewhile eats up the last checked object in iterators (see comment) which means there is no telling if the next element will also satisfy the condition, ...
WonderfulWonder's user avatar
0 votes
0 answers
28 views

Python for looping to update one graph in python

I am familiarizing my self with Monte Carlo simulations and have played around with the following code. It is a gambling dice rolling game with an increased payout for doubles. It uses RNG and pyplot. ...
kca062's user avatar
  • 53
0 votes
1 answer
20 views

Issue outputting data generated from a user-defined function that uses sapply()

I am attempting to summarize the data generated from looping through data using sapply() and am not sure why I can't access the dataframe that's generated. I'm setting up a monte-carlo simulation, ...
John Heller's user avatar
0 votes
0 answers
54 views

Log-uniform distribution for priors using emcee

I want to use emcee to minimise a function, and want to vary 3 priors a,b,c over a log-uniform distribution of many orders of magnitude, and 2 more priors d, e over a uniform distribution. What would ...
user11339690's user avatar
0 votes
0 answers
26 views

Using numpy functions to optimise code instead of for loops for particle scattering

I was making code that would simulate 10000 particles interacting with some form of shielding made of a material. Although it works and finds the absorption, scattering and transmission rates, it ...
nion_marek's user avatar
0 votes
1 answer
34 views

How to fix Input arguments to function include colon operator error

clc; clear w = load('dimensionless_concentration_data.txt'); time = w(:,1); C_mea = w(:,2); figure(1) plot(time,C_mea,'*','LineWidth',1.5,'Color','r') xlabel('Time (seconds)','FontName','Arial','...
Utku Yalçın's user avatar
0 votes
0 answers
35 views

Correct bootstrap estimates from mixed-models estimated using GLMMadaptive package in R?

I have estimated a model using the mixed_model() function in the GLMMadaptive package. I then run marginal_coefs() to get estimates of the model coefficients. However, I am interested in individual ...
Oskar Flygare's user avatar
0 votes
0 answers
102 views

Path-integral Monte Carlo to simulate motion of an atom in one-dimensional harmonic potential

I am trying to simulate the motion of an atom in a one-dimensional harmonic potential. I want to calculate the position of an atom in the harmonic potential and then plot the position with respect to ...
Programmer's user avatar
0 votes
1 answer
179 views

Why can't you do a Monte Carlo of a Monte Carlo in Excel

I teach a class in Excel and I want to take multiple averages from different sets of Monte Carlo simulations as a way to illustrate the central limit theorem. In Excel you can do a Monte Carlo using ...
Joseph Stover's user avatar
0 votes
0 answers
114 views

Monte Carlo simulation in Power BI using Azure DevOps/Jira data

I previously had a monte carlo simulation built into my free flow metrics template for agile teams who use Azure DevOps/Jira to use in Power BI (attached) Recently the visual (using the D3 visual) ...
Nicolas Brown's user avatar
0 votes
0 answers
38 views

Having an issue with a Monte Carlo Simulations

I'm developing a Monte Carlo simulation for Magic: the Gathering. Currently the goal is simply to determine the probability of making land drops on curve. This can be calculated through Hypergeometric ...
user21677832's user avatar
1 vote
0 answers
26 views

MonteCarlo Power Analysis: 3 -Level MSEM in MPLUS

I am running a MonteCarlo simulation for a 3-level 1-1-2 MSEM in MPLUS and I keep getting the following error code: *** ERROR in MONTECARLO command The total number of observations in the CSIZES ...
dwitzz's user avatar
  • 11
0 votes
1 answer
67 views

Problem with migrating Metropolis-Hastings algorithm from R to Python

New to Python. I am trying to port the R code for the Metropolis Hastings Algorithm found here over to Python. I have successfully duplicated the results in R, but am struggling with the Python ...
user1884367's user avatar
0 votes
1 answer
83 views

Using BigQuery to run a Monte Carlo simulation that is too big for excel

I have been experimenting with linear regression to predict future test scores for students. I have also found a couple of distributions that would potentially fit my data and that I would like to use ...
CRJH's user avatar
  • 1
-3 votes
1 answer
61 views

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 ...
user21637077's user avatar
0 votes
0 answers
21 views

estimating the value of pi using the monte carlo method, I am using radius as 1,I dont get the value of pi, increasing the iterations doesnt change it

#include <stdio.h> #include <stdlib.h> #include <time.h> double getRandomNumber(double lower_limit, double upper_limit){ double random = ((double)rand())/RAND_MAX; double ...
ello's user avatar
  • 1
1 vote
1 answer
93 views

using isnan in julia doesn't catch all the NaNs

NaNs keep getting introduced into my results for some reason, despite using isnan to filter them. This code generates NaNs in the X variable sometimes but not always, and I'm confused as to how it's ...
Ethan Leonard's user avatar
2 votes
2 answers
70 views

How to create a Monte Carlo function that simulates the consistency of the beta estimator?

I'm having some problems with my custom function. The main idea is that I want to show that the beta estimator gets closer to 1 as I increase the number of observations. So I wrote this custom ...
Tomas R's user avatar
  • 450
-1 votes
1 answer
43 views

Plotting a graph using a function applied to elements in an array

I'm trying to plot a graph where the x-values are denoted by the array below: player_number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] And the y values correspond to the value of the ...
cookiecainsy's user avatar
1 vote
0 answers
42 views

Synchronization algorithm for Monte Carlo (software model) [closed]

I'm working on a system that proceeds Monte Carlo Run where different parts need to run at different frequencies, but they also need to communicate and share data. How can I synchronize these parts to ...
Melih's user avatar
  • 27
1 vote
3 answers
101 views

Why does this Pi approximation become less accurate?

The code included below calculates a pi approximation in Java using a Monte Carlo method. As expected, the answer (very) gradually improves, but when the main loop terminates the answer is always ...
Andrew Davison's user avatar
0 votes
0 answers
51 views

Python: Why is my vectorization with numpy slower than a for cycle?

I implemented a simple estimation of Pi with MonteCarlo as exercise and it seems that using a for cycle is faster than using only the numpy vectorization... There must be something that I haven't ...
TommyGiak's user avatar
0 votes
0 answers
43 views

Monte Carlo simulations and sum of normal distributions

I am trying to predict the revenues of a portfolio of items. I want to simulate the revenues in a particular market situation in which they might increase. Each item's revenues is made up of 3 ...
floyd123's user avatar
-1 votes
2 answers
88 views

Cython optimisation for ising model

This is my first post, I am trying to make an ising model simulation using a monte carlo algorithm. I order to optimise the code I am currently trying to use Cython. However for now the execution time ...
Martin Baptiste's user avatar
0 votes
0 answers
189 views

Running a jit compiled tensorflow function inside a for loop

I am trying to use @tf.function(jit_compile=True) to run a markov chain monte carlo inside a for loop as per the eight schools example using a different prior each time. I am trying to run the ...
Stewie's user avatar
  • 1
0 votes
1 answer
52 views

Why my code generates values equal to "-nan"?

I need to calculate the mean of the coverages of two types of particles that could be trapped on a square surface. They are particle #1 and particle #2. Such averages are taken after certain number of ...
Auyk's user avatar
  • 109
0 votes
1 answer
29 views

Monte Carlo Simulation in R for Simple Game with Assigned Distribution

I am trying to figure out how to create a Monte Carlo Simulation for a game in R. In the game you have two players, P1 and P2. During each round, one player gets to take an action. P1 takes the action ...
kcgb20's user avatar
  • 1
0 votes
1 answer
83 views

Generate a Uniform Spherical Distribution using rejection methods in Python

I've been trying to generate a uniform spherical distribution in Python using uniform random sampling. For some reason my presumed spherical distribution looks more like an ovoid than like a sphere. I ...
Luis Miguel's user avatar
0 votes
1 answer
20 views

Distinguishing between structural & nonstructural regressor candidates in N Lassos run sequentially on N synthetic data sets

In this collaborative research project working towards a second draft of a 2008 Working Paper which proposed a promising straight-forward, yet novel Optimal Variable Selection Algorithm in Supervised ...
Marlen's user avatar
  • 171
2 votes
0 answers
75 views

How to choose randomly between two particles to be trapped in a square lattice, given some conditions?

I'm simulating a square surface that is able to trap two kinds of particles, say particle #1 and particle #2. I also need to calculate the averages of the coverages of the two trapped particles in ...
Auyk's user avatar
  • 109
1 vote
1 answer
68 views

How to calculate the average of a set of random numbers including additional conditions in C?

I'm trying to calculate the average of a set of random numbers (all of them between 0 and 1), considering if other conditions are fulfilled. That is, calculate the average of a list of random numbers ...
Auyk's user avatar
  • 109
0 votes
1 answer
335 views

Multiprocessing not using whole CPU

I'm testing python's module "multiprocessing". I'm trying to compute pi using a montecarlo technique using my 12 threads ryzen 5 5600. The problem is that my cpu is not fully used, instead ...
Prometeus's user avatar

1
2 3 4 5
26