I have a large set of simple simulations that I need to run, and I'm wondering if they can be done simultaneously. Let me describe the situation: I have 1000 draws of prevalence for ~100 diseases, and 1000 draws of corresponding disability weights for those diseases (how bad it is to have that disease on a 0-1 scale)for 20 age-groups. The simulation that I need to do is to determine, given a set of prevalences, how many people would have different combinations of diseases. Here is what the input data would look like for 10 diseases:
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 a single draw would look something like this, for age 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 disability weight attributable to each disease given the comorbidity of multiple diseases, I do the following: Set the denominator as the sum of present disability weights, and use the disability weight of a given disease as the numerator. For disease 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 to this adjusted dw calculation seperately for each disease. Is there any way for me to do these 1000 simulations simultaneously? Any help is appreciated, and I'm fairly new to python, so more descriptions are very helpful.