private static double findMathsInfo(HubBlockingCollection <int> list, string infoToFind) { if (infoToFind == "count") { return(list.Count); } if (list.Count <= 0) { return(-1); } //stops list with 0 members being submitted double averageMean = 0, highest = 0, lowest = list.FirstOrDefault(), standardDeviation = 0; int cumulativeTotal = 0; foreach (int item in list) { cumulativeTotal += item; if (item > highest) { highest = item; } if (item < lowest) { lowest = item; } } averageMean = cumulativeTotal / list.Count; if (infoToFind == "averageMean") { return(averageMean); } else if (infoToFind == "highest") { return(highest); } else if (infoToFind == "lowest") { return(lowest); } else if (infoToFind == "sd") { double cumulativeVariance = 0; foreach (int item in list) { double variance = Math.Pow((item - averageMean), 2); cumulativeVariance += variance; } standardDeviation = Math.Pow((cumulativeVariance / list.Count), 0.5); return(standardDeviation); } else { return(-1); } }
/* * Constructor */ public UserConnection(int indexNumber) { this.CurrentClicks = 0; //this.HasClicksChangedFlag = false; this.ClickChangeState = ClickChangeStatus.None; this.StopWatch = new Stopwatch(); this.roundtripTimesMsList = new HubBlockingCollection <int>(); this.BlockData = false; }