For no practical reasons whatsoever, I designed a simple Monte Carlo simulation in python.
import random
import numpy as np
class Part:
def __init__(self,exp_death=80):
self.age = 0
self.exp_death = exp_death
self.alive = True
def survive(self,days=1):
self.age += days
event = random.uniform(0,1)
surv = 1/(1 + np.exp(- (self.exp_death - self.age)))
if event >= surv:
self.alive = False
def test(self):
while self.alive:
self.survive()
data = []
for i in range(100):
p = Part()
p.test()
data.append(p.age)
And now I can take a look at the mean age of death and standard deviation:
print(np.average(data), np.std(data))
>>>
79.74 1.616292052817188
The variance is extremely tight around the expected death. I'm curious, simply for the sake of learning, how could I increase or decrease the variance in this MC simulation? In other words, how could create a variance knob to control in these simulations?
Again, this has no practical motivation; I'm just curious.