Changed Threshold to double
added a seed to rng to get reproducable results
added write to csv file