Questions tagged [montecarlo]
Monte Carlo methods are stochastic (probabilistic) systems that use many random samples to derive properties of a complex system.
1,156
questions
1
vote
0
answers
25
views
MonteCarlo Simulation for Diffusion in AES
I need to implement a MonteCarlo simulation to an AES to observe the effect of diffusion (if I change a single bit of the plaintext, then half of the bits in the ciphertext should change)... I think I ...
0
votes
0
answers
13
views
Pricing Barrier Option with Down and In
trying to price a Put Down In option, but i keep getting all my options values to 0.
I'm trying to implement this model from a working Put Up Out model.
I feel like the problem is in the logic at the ...
-8
votes
0
answers
58
views
Monte Carlo simulation call cente [closed]
Good day
I am working on a Monte Carlo simulation for a call center in R.
The part I am having difficulties with is determining the if statements and their content. The call availability is what ...
0
votes
0
answers
17
views
simR simulate within subjects data from between-subjects design
In my pilot study I applied a between-subjects design. For the follow-up study, a within-subjects manipulation seems more feasable. I want to conduct power analyses for the planned mixed-model ...
-1
votes
0
answers
14
views
problem in output of Monte Carlo simulation
My code is not giving me the desired result. It always shows 1. For your ease let me explain the base of code.
The failure occur when "C >= Cr". so I intend to calculate the probabilty of ...
-1
votes
0
answers
13
views
Problem in output of monte carlo in Matlab
In this code I am intending to get service life T(ser)
T(ser) = [ Pf(t) >= Pfmax ]
here , P is probability of an event.
Pfmax is generally between 7 to 10% and
Pf(t) = P[C >= Cr],
C = Cs[1-erf(...
0
votes
0
answers
14
views
Jackknife vs Bootstrap and CIs
I have computed jackknife the estimate as shown in the code, and want to compute the Bootstrap estimate with boot(data, statistic, R = ... ), but I can't seem to get it to work. Replace x.data with ...
0
votes
0
answers
22
views
Having a problem formatting a stock Monte Carlo model to create a histogram
Here's what I have, just watched a bunch of videos and created a monte carlo simulator using pandas. I was able to get the simulation to work and create the simulation outcomes, but trying to ...
0
votes
1
answer
86
views
SwiftUI: Get circle collision
Hi I am playing around with app that uses Monte Carlo Approximation Of Pi. So I wrote code that create square, circle inside and function that generate random dots. But I am stuck on getting ...
0
votes
0
answers
23
views
How to estimate the required sweeps to reach equilibrium in Ising model?
How to estimate the required sweeps to reach equilibrium in 2D Ising model, considering the Metropolis algorithm.
1
vote
0
answers
10
views
Metropolis-Hasting algorithm Trace plot
For MH proposal (Theta*=Theta(s)+u*) where u*~U(0,delta) and U denotes uniform distribution but for all the values of delta the algorithm is not satisfactory. How to do trace plot for such kind of MH ...
1
vote
1
answer
37
views
R: Unfair Coin Toss with Monte Carlo Method. Goal is Probability of N Exact Heads
I have a task to use the Monte Carlo method to evaluate an unfair coin flip and determine the probability of obtaining n heads out of n flips within n simulations. The guide my professor provided (at ...
1
vote
2
answers
55
views
How can i speed up the MC simulation of Ising model?
I am new here.
I programmed a Monte Carlo simultaion of 2D Ising model use Python, and find it is very slow. and i don't know how to speed it up.
I post the code below(only the test of trail_move ...
1
vote
1
answer
46
views
Using Python multiprocessing to generate points for Monte Carlo algorithm
I have a pool of 150 processes:
import multiprocessing as mp
pool = mp.Pool(processes=150)
For each process, I need to generate 10000 random 3D points inside the bounding box (min_X, max_X, etc.. ...
-1
votes
0
answers
62
views
MTGP32 generator for enormous Monte Carlo simulations
Problems:
I need to run an enormous number of Monte Carlo simulations.
__device__ curandState_t states[MONTE_SIMULATIONS_COUNT];
__global__
void monte_sims(unsigned long long* result)
{
...
...
1
vote
0
answers
30
views
Usage of "tfp.experimental.mcmc.particle_filter"
I tried to use the particle filter provided by Tensorflow due to its capability to incorporate with other Tensorflow functions. However, I couldn't quite find the example usage on Tensorflow ...
0
votes
0
answers
33
views
how do I pass a variables value into the pthread create parameters using a void function?
I'm doing a monte Carlo simulation to calculate pi using threads, I believe the mass of my logic is correct. I just need to pass the correct value into the pthread create function under the C library ...
0
votes
0
answers
39
views
How to run monte carlo similation in python within spacified upper and lower range of values?
I am trying to run Monte Carlo simulation for 520 weeks and 10000 trials. I am using the below code for the purpose.
my code:
import numpy as np
import pandas as pd
from pandas_datareader import data ...
0
votes
1
answer
28
views
python policy gradient reinforcement learning with continous action space is not working
i am trying to learn an agent to navigate to a target in my custom environment.
The agent is learning with a neural net (2 hidden Dense layer, one dropout and one output layer of dimension 4). As ...
1
vote
0
answers
48
views
How can I generate random time series data for a given probability distribution of wind speed and wind angles?
I have imported an excel data of ship operations into a Pandas data frame. The data frame has latitude and longitude and time stamps with an interval of 20 min. The data is for a voyage of one month. ...
0
votes
0
answers
34
views
Monte Carlo using pool in python
how do I change the Monte Carlo section of the code below into a multiprocessing pool with the arrays ARR1 and ARR2 as the outputs of the pool process?
import numpy as np
def HS():
arr1=np.zeros((...
0
votes
1
answer
28
views
JAGS bayesian MCMC but came into this: Error parsing model file: syntax error on line 5 near "="
when I run my jags model, I got this error message :
module glm loaded
Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, :
Error parsing model file:
syntax error ...
0
votes
0
answers
33
views
European Call Option Price Antithetic Variates Matlab
does anyone understand how to add/modify a monte carlo simulation for european option call pricing so it transforms to an antithetic variates method on matlab?
I already worked on the monte carlo ...
0
votes
0
answers
34
views
How to plot a "heatmap" of thousands of timeseries in python?
I am looking for a way to visualize, for the lack of a better word, the "density" or "heatmap" of some synthetic time series I have created.
I have a loop that creates a list, ...
0
votes
1
answer
25
views
AnyLogic: Invalid Histogram of total delay time of a discrete event simulation (MonteCarlo Experiment)?
I simulated a discrete event simulation and the model itself is stochastic (total delay time is different from model run to model run). So everything I want to do is a Monte Carlo Experiment in which ...
0
votes
0
answers
33
views
Use Matlab to do Brownian bridge to computes the quantile of the holding period log-returns
with parameters μ = 0.1; σ = 0.2;expiry of the call=3/12. Write a Monte Carlo code which computes the 1 day and 10 day 5% quantile of the holding period log-returns using the Brownian bridge by Matlab....
1
vote
3
answers
65
views
How to apply a function to a rows of a dataset and get the result for each row in R
I wrote a function that uses Monte Carlo Simulation to calculate the value of the call option in R. I want to apply the function to 63 rows of my dataset that contains the real data. In other words, I ...
0
votes
1
answer
20
views
How to fix a syntax error in a def function?
I have problems to get this code to work. Python says that there is a syntax error. It seems as though there might be something wrong with the indentation, however I cannot find the problem (see code ...
1
vote
1
answer
57
views
Monte Carlo Simulation of a date based on another date
I have a dataset like this. The date_e was accurate for status= "1". I want to simulate date_e based on age. Therefore, new_date_e will be changed for status="0", will be same for ...
-2
votes
1
answer
62
views
AnyLogic: Monte Carlo Simulation for total delay time in a Discrete Event Simulation
I plan to do a Monte Carlo Simulation, but the introduction on the AnyLogic page does not really help me. I want to vary one parameter via uniform(0,1) and run the model 1000 times and save the ...
0
votes
1
answer
30
views
How to compare int with list and receive index using np.where?
I am currently trying to get the index position of costShirts where the value in costShirts[0] is the largest number thats still smaller than the user input. I keep running into an error ">= ...
1
vote
1
answer
117
views
Monte Carlo Integration in R from normal distribution
Monte Carlo Question in R. I have the following equation.
h(x)=x/((3^x)-1)
I am trying to compute a estimator for the integral where random variables are generated from N(0,1).
The following code ...
1
vote
0
answers
136
views
Pythran with XSIMD - help vectorizing loop (Python)
NOTE: I'm trying to rewrite this Python function which is decorated to compile with Pythran into a Python module. It currently uses OpenMP fine but not SIMD. pythran -DUSE_XSIMD my-script.py
So the ...
0
votes
1
answer
53
views
Ising model metropolis algorithm
I am trying to use the metropolis algorithm to simulate the Ising model. The problem that I am having is that the code will not settle all the time. For high beta values, the energy preference should ...
0
votes
1
answer
30
views
AnyLogic: User Set Number Of Replications
In a MonteCarlo experiment, I wish to allow a user to enter the number of Replications via an input box. I have tried creating a variable linked to an input box and then referencing this in the "...
0
votes
0
answers
46
views
Autocorrelation function in Ising model Python
I am trying to use Python to plot the graph of autocorrelation function of metropolis algorithm by following the methodology of this lecture note. Autocorrelation function in this lecture note are ...
0
votes
0
answers
7
views
Grouping integers in Python
I have been workling on a monte carlo collision method for gases in a latice. For this, I need to group some integers in an array. To be precise, I want to return an array, which groups the index of ...
0
votes
0
answers
42
views
Making a Monte Carlo Fan Chart
I am looking on a better way of illustrating my Monte Carlo simulation.
My stock variables on inside of a pandas data reader
returnsdf = pf_data.pct_change()
meanReturns = returnsdf.mean()
...
0
votes
0
answers
55
views
Particle Filters (and Sequential Importance Resampling; SIR): any way to have them "learn" latent variances?
I'm working my way through learning about Sequential Importance Resampling (SIR) particle filters (starting with a relatively simple example), but am a bit stuck in my understanding.
I'm particularly ...
0
votes
1
answer
30
views
Adding variable list elements into a new list
Background: I'm trying to do a monte carlo simulation. The idea is if there is a process of n different random sub-processes and each has a cost distribution, what will be the histogram of probable ...
2
votes
1
answer
67
views
Calibrating the output(output factor) of a smaller source using Geant4/GATE MonteCarlo simulation
I am using GATE(which uses Geant4) to do MC studies on dosimetric output. I am using a cylindrical cobalt source at 80 cm SAD to measure the PDD in a water phantom and dose at depth of 10 cm.
I now ...
0
votes
0
answers
63
views
Why is If statement not working in Monte Carlo simulation?
I'm fairly new to python and am trying to run molecular dynamics simulation using Monte Carlo method wherein I construct a symmetrical system and slightly perturb a random particle and calculate the ...
4
votes
1
answer
41
views
R: Trying to recreate mean-median difference gerrymander tests
I'm trying to recreate the mean-median difference test described here: Archive of NYT article. I've downloaded House data from MIT's Election Lab, and pared it down to the 2012 Pennsylvania race. ...
3
votes
1
answer
69
views
Simulating a probability problem: 3 independent dice
I decided to simulate a probability question from a textbook:
Three fair dice are rolled independently, what is the probability that one dice shows 6 and the other two show two non-equal numbers (and ...
-1
votes
1
answer
77
views
Down and In Call Option using Monte Carlo in C++
I am trying to write a C++ program that runs a Monte Carlo simulation to approximate the theoretical price of a down-and-in call option with a barrier between the moment of pricing and the option ...
0
votes
1
answer
118
views
Simulating rate data (negative-binomial distribution)?
I am attempting to simulate data that approximates rate data - that is: count data that generally fit a negative binomial distribution but also an offset term for survey effort.
I think I can simulate ...
0
votes
0
answers
24
views
Fitting cumulative gaussan distribution
I try to reproduce the data analysis of this scientific paper but I struggle to understand the methodology as I'm novice with stats.
Here's what he says he does:
Cumulative Gaussian functions were ...
0
votes
0
answers
43
views
System of SDE in R
Let
dXt = -Yt dt +cos(Xt + Yt)/(sqrt(t+1))*dW1_t
dYt = Xt dt +sin(Xt + Yt)/(sqrt(t+1))*dW2_t
X0=1, Y0=1, T=1,
(W1_t, W2_t) is a Brownian Motion in dimension 2.
Could someone tell me how I could ...
1
vote
1
answer
169
views
Calculate the improper integral Monte Carlo method
For exaple, I'm trying to transform the integral:
I need to transform it to an integral that goes from 0 to 1 (or from a to b) in order to apply the algorithm of Monte Carlo I implemented. I already ...
1
vote
1
answer
61
views
Question About a Probability Model Using C++
I am trying to solve a probability question theoretically and then modeling it on C++ but my code outputs a different probability from the theoretical one.
Question:
A balanced coin is tossed three ...