Fairly new at coding, Im using python to do a monte carlo simulation. Not really sure how I would go about this, the end result would be to graph out the results from the steadystate function.
import random
import numpy as np
def steadystate():
p=0.88
Cout=4700000000
LambdaAER=0.72
Vol=44.5
Depo=0.42
Uptime=0.1
Effic=0.38
Recirc=4.3
x = random.randint(86900000,2230000000000)
conc = ((p*Cout*LambdaAER)+(x/Vol))/(LambdaAER+Depo+(Uptime*Effic*Recirc))
return conc
x = 0
while x < 10000:
result = steadystate()
print(result)
x+=1
Right now I just want to save the results from the while loop as an array so I can graph it. Ive tried appending it but it wouldnt print anything.
>Solution :
The simplest way to achieve what you need would be to generate your random integers as an array to start with, e.g.:
size = 10000
# generate 10000 (size) random integers as a numpy array
x = np.random.randint(86900000, 2230000000000, size=size)
p = 0.88
Cout = 4700000000
LambdaAER = 0.72
Vol = 44.5
Depo = 0.42
Uptime = 0.1
Effic = 0.38
Recirc = 4.3
result = ((p*Cout*LambdaAER)+(x/Vol))/(LambdaAER+Depo+(Uptime*Effic*Recirc))
The result object will also be a numpy array of the same size as x.