Leeds-MRG / Minos

SIPHER Microsimulation for estimating the effect on Income policy on mental health.
MIT License
4 stars 3 forks source link

continuous random noise. #208

Open RobertClay opened 1 year ago

RobertClay commented 1 year ago

adding continuous noise into MINOS for continuous variables. This can be done simply by adding noise from numpy.random functions using some variance (e.g. 10 for SF12).

However is seems a good idea to implement common random numbers here to seed values if necessary. vivarium has CRN seeded random number generation but its only for uniform distributed variables (as far as I know https://vivarium.readthedocs.io/en/latest/api_reference/framework/randomness/stream.html#vivarium.framework.randomness.stream.RandomnessStream.get_draw).

You can use two samples from uniform distributions to create two standard Normal N(0, 1) distributions using the Box-Muller transform https://rh8liuqy.github.io/Box_Muller_Algorithm.html. Its pretty straightforward with a couple things to think about.

RobertClay commented 1 year ago

well that was easy.

RobertClay commented 1 year ago

very easy to add Gaussian noise on top of continuous variables. Using scipy.special.ndti can convert uniform distribution draws to Gaussian variables. then scale by desired mean and sd. Couple of follow up questions: