montecarlo

Error:'no variables defined' in stata when using monte carlo simulation

杀马特。学长 韩版系。学妹 提交于 2020-02-08 07:22:24
问题 I have written the program below and keep getting the error message that my variables are not defined. Can somebody plese see where the error is and how I should adapt the code? Really nothing seems to work. program define myreg, rclass drop all set obs 200 gen x= 2*uniform() gen z = rnormal(0,1) gen e = (invnorm(uniform()))^2 e=e-r(mean) replace e=e-r(mean) more gen y = 1 + 1*x +1*z + 1*e reg y x z e=e-r(mean) replace e=e-r(mean) more gen y = 1 + 1*x +1*z + 1*e reg y x z more return scalar

How does Monte Carlo Search Tree work?

两盒软妹~` 提交于 2020-01-13 13:50:41
问题 Trying to learn MCST using YouTube videos and papers like this one. http://www0.cs.ucl.ac.uk/staff/D.Silver/web/Applications_files/grand-challenge.pdf However I am not having much of a luck understanding the details beyond the high level theoretical explanations. Here are some quotes from the paper above and questions I have. Selection Phase: MCTS iteratively selects the highest scoring child node of the current state. If the current state is the root node, where did these children come from

Error in rep: invalide 'times' argument

て烟熏妆下的殇ゞ 提交于 2020-01-12 18:56:45
问题 When I try to run the following code for 10000 iterations I get the following error.Error in rep(G1[, 2], G1[, 3]) : invalid 'times' argument. So don't know how to change the code to fix that error. Basically just want to create time series for the generator performance using the equation for Time to fail and time to repair for 8736 hours in the year so that I have the time series in hours when the generator is operating in when is not. The starting conditions is that the generator is

Simple Dynamical Model in PyMC3

試著忘記壹切 提交于 2020-01-12 10:20:13
问题 I'm trying to put together a model of a dynamical system in PyMC3, to infer two parameters. The model is the basic SIR, commonly used in epidemiology : dS/dt = - r0 * g * S * I dI/dt = g * I ( r * S - 1 ) where r0 and g are parameters to be inferred. So far, I'm unable to get very far at all. The only examples I've seen of putting together a Markov chain like this yields errors about recursion being too deep. Here's my example code. # Time t = np.linspace(0, 8, 200) # Simulated observation

Branch divergence, CUDA and Kinetic Monte Carlo

笑着哭i 提交于 2020-01-12 09:57:12
问题 So, I have a code that uses Kinetic Monte Carlo on a lattice in order to simulate something. I am using CUDA to run this code on my GPU (although I believe the same question applies to OpenCl as well). This means that I divide my lattice into little sub-lattices and each thread operates on one of them. Since I am doing KMC, each thread has this code : While(condition == true){ *Grab a sample u from U[0,1]* for(i = 0; i < 100;i++){ *Do some stuff here to generate A* if(A > u){ *Do more stuff

Best seed for parallel process

偶尔善良 提交于 2020-01-03 16:45:34
问题 I need to run a MonteCarlo simulations in parallel on different machines. The code is in c++, but the program is set up and launched with a python script that set a lot of things, in particular the random seed. The function setseed thake a 4 bytes unsigned integer Using a simple import time setseed(int(time.time())) is not very good because I submit the jobs to a queue on a cluster, they remain pending for some minutes then they starts, but the start time is impredicible, it can be that two

Python Numerical Integration for Volume of Region

微笑、不失礼 提交于 2020-01-02 03:06:25
问题 For a program, I need an algorithm to very quickly compute the volume of a solid. This shape is specified by a function that, given a point P(x,y,z), returns 1 if P is a point of the solid and 0 if P is not a point of the solid. I have tried using numpy using the following test: import numpy from scipy.integrate import * def integrand(x,y,z): if x**2. + y**2. + z**2. <=1.: return 1. else: return 0. g=lambda x: -2. f=lambda x: 2. q=lambda x,y: -2. r=lambda x,y: 2. I=tplquad(integrand,-2.,2.,g

Parallelization for Monte Carlo pi approximation

≯℡__Kan透↙ 提交于 2019-12-31 04:50:47
问题 I am writing a c script to parallelize pi approximation with OpenMp. I think my code works fine with a convincing output. I am running it with 4 threads now. What I am not sure is that if this code is vulnerable to race condition? and if it is, how do I coordinate the thread action in this code ? the code looks as follows: #include <stdlib.h> #include <stdio.h> #include <time.h> #include <math.h> #include <omp.h> double sample_interval(double a, double b) { double x = ((double) rand())/(

How to structure an easily extensible Monte Carlo model in R

*爱你&永不变心* 提交于 2019-12-25 02:18:36
问题 I have a simple model for a company with two farms, growing two crops (apples and pears) on each farm. The first step is just to multiply the number of trees by the amount of fruit on each tree. The amount of fruit on each tree is simulated (across farms and crops). I face at least three decisions when modeling this in R: How to structure the variables How to simulate How to multiply a simulated variable with a non-simulated variable I want it to work even if I add another crop and/or farm -

Random number generator of L'Ecuyer with Bays-Durham

江枫思渺然 提交于 2019-12-24 19:26:52
问题 I am working with Monte Carlo simulations to find the decimal places of PI. So far so good but OpenMP came in and I realize that ran2, arguably the best RGN, is not threadsafe! The implementation is here. Since I have not worked with OpenMP and neither a lot on multi-threading I am stuck at making this thread safe using OpenMP. So far what I know is that a function is already thread-safe if it doesn't modify non-local memory and it doesn't call any function that does. In this case, there are