Toilet Seat Up or Down
This simulation is purely intended for fun. The author in full transparency himself leaves the toilet seat down and continues to do so irrespective of what parameters or the simulation say, because, not all of life's nuances can be simulated :)
As an exercise, we would like to investigate setting up the problem to determine how much work is spent in moving the toilet seat up and down. We assume that the toilet is shared and is unisex. This simulation exposes a few different parameters:
(1) Policy: There are two policies that we simulate. "Always Down" and "Being Lazy". The always down will leave the toilet seat down after each use. Being lazy on the other hand, will only do the minimal work to put the toilet seat into the position before it needs to be used.
(2) Fraction of Women: Needless to say the amount of work spent depends on the ratio of women to men and this parameter controls for it.
(3) Fraction Business 1 Performed: Fraction of times one pees as opposed to poops. Maybe the entire office or home has a diarrhea, would that change the policy's effectiveness?
There are a few different metrics that we monitor as the simulation runs:
(1) Work / Iter_num: This is the average work performed per usage of the toilet. We count one unit of work to put the seat down and one to put the seat back up.
(2) Male_work / Iter_num: This is the average work performed by a male person for using the toilet.
(3) Female_work / Iter_num: This is the average work performed by a female person for using the toilet.
We also have one graph: Average Work performed overall per usage of the toilet as the simulation proceeds.
Sample an outcome from the outcomes array based on the corresponding probabilities in the probabilities array.
Returns the average of the values in the array. It can be handy to store the values of metrics from each simulation run and average it across all runs to obtain an estimate of the metric.
Returns the estimated error (1.96 x standard error) of the average of the values at 95% confidence. In simple terms, you can assume that the estimate average(values) has error bounds +/- error_average(values). It can be handy to store the values of metrics from each simulation run and estimate both the average and the error of the average across all runs.
Returns the standard deviation of the values in the passed in array.
Creates a radio button parameter with name and have each option in the options array selectable. Returns the selected option.
Create a textbox parameter with name and a required default value. Returns the value of the textbox.
scatter_graph(data, xlabel, ylabel)
Create a graph based on a data array and plot (data.xlabel, data.ylabel) on it. Can also pass xmin=null, xmax=null, ymin=null, ymax=null as added arguments.
Calling this function, stops the simulation.