I have a large set of simple simulations that I need to run, and I wonder if they can be done at the same time. Let me describe the situation: I have 1000 cases of prevalence for 100 diseases, and 1000 nobody's corresponding disability weights for these diseases (how bad it is to have this disease on a scale of 0-1) for 20 age groups. The simulation I need to do is determine, given the many prevalences, how many people will have different combinations of diseases. Here's what the raw data for 10 diseases will look like:
from __future__ import division import numpy as np disease_number = np.array([1,2,3,4]*10) age = np.array([5, 10, 15, 20]*10) prevalence = np.random.uniform(0, 1, (40, 1000)) disability_weight = np.random.uniform(0,1,(40, 1000))
A simulation of one draw would look something like this: at the age of 5 draw 1.
prev_draw1 = prevalence[age==5, 1] disability_draw1 = disability_weight[age==5, 1] simulation = np.random.binomial(1, prev_draw1, (100000, prev_draw1.shape[0])
Then, to calculate the weight of the disability associated with each disease, given the concomitant pathology of multiple diseases, I do the following: Set the denominator as the sum of the current disability weights and use the disability weight of the disease as a numerator. For illness 1:
denom = np.sum(disability_draw1**simulaiton) denom[denom==1]=0 numerator = disability_draw1*simulation[:, 0] adjusted_dw = np.sum(numerator/denom)
I would need this adjusted dw calculation separately for each disease. Is there a way for me to do these 1000 simulations at the same time? Any help is appreciated, and I'm pretty new to python, so more descriptions are very helpful.