public void OutputSamples(string user, string application, int MinSample = 10, int SampleAgg = 0, int[] SampleAggs = null, string path = null) { if (path == null) { path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\"; } if (SampleAgg == 0 && SampleAggs == null) { throw new System.Exception("SampleAgg or SampleAggs required"); } if (SampleAgg != 0 && SampleAggs != null) { throw new System.Exception("Only one of SampleAgg or SampleAggs required"); } //Calculate minimum samples needed to satisfy MinSample number int MinimumSamplesRequired = MinSample * (SampleAgg == 0 ? SampleAggs.Min() : SampleAgg); this.Sessions.Last().Close(); foreach (int Session in SampleCollections.Keys) { /// Build the statstable header String StatsTable = "FeatureName, FeatureCount, "; if (SampleAggs != null) { foreach (int SampleSize in SampleAggs) { StatsTable += (SampleSize * MinSample).ToString() + ": Midpoint,"; StatsTable += (SampleSize * MinSample).ToString() + ": Variance,"; } StatsTable.TrimEnd(','); StatsTable += Environment.NewLine; } foreach (SampleCollection SC in SampleCollections[Session].Values) { SC.Close(); if (!SampleCollection.IsTooSmall(SC, MinimumSamplesRequired)) //ignore small samplescollections { System.IO.StreamWriter SW = new System.IO.StreamWriter(path + $"{user}_{application}_Samples_{SC.FeatureName}.csv"); switch (SampleAgg) { case 0: //not define, send the int range //+ make a stats table! StatsTable += SC.PrintStats(SampleAggs); SW.Write(SC.Print("CSV", SampleAggs)); break; case 1: //no agg needed SW.Write(SC.Print("CSV")); break; default: //agg away SW.Write(SC.Print("CSV", SampleAgg)); break; } SW.Flush(); SW.Close(); } } if (SampleAggs != null) { System.IO.StreamWriter ST = new System.IO.StreamWriter(path + $"{user}_{application}_StatsTable.csv"); ST.Write(StatsTable); ST.Flush(); ST.Close(); } } }