public static string GetDerivHistogram(CylData cylData) { try { var derivs = new List <double>(); double max = double.MinValue; double min = double.MaxValue; for (int i = 0; i < cylData.Count - 1; i++) { var p1 = cylData[i + 1]; var p0 = cylData[i]; var d = Math.Abs((p1.R - p0.R) / (p1.ThetaRad - p0.ThetaRad)); if (d < min) { min = d; } if (d > max) { max = d; } derivs.Add(d); } //double deltaD = (max - min) / 20; var h = new MathNet.Numerics.Statistics.Histogram(derivs, 10, min, max); var bmax = 100 * h.GetBucketOf(max).Count / h.DataCount; var bmin = 100 * h.GetBucketOf(min).Count / h.DataCount; return(String.Concat("%min, %max Derivatives : ", bmin.ToString("f4"), " , ", bmax.ToString("f4"))); } catch (Exception) { throw; } }
public static List <HistogramBucket> GetDerivHistogram(List <double> data, int bucketCount) { try { var derivs = new List <double>(); double max = double.MinValue; double min = double.MaxValue; for (int i = 0; i < data.Count - 1; i++) { var p1 = data[i + 1]; var p0 = data[i]; var d = Math.Abs(p1 - p0); if (d < min) { min = d; } if (d > max) { max = d; } derivs.Add(d); } double deltaD = (max - min) / bucketCount; var h = new MathNet.Numerics.Statistics.Histogram(derivs, bucketCount, min, max); var bucketV = min + (deltaD / 2.0); var histogram = new List <HistogramBucket>(); while (bucketV <= max) { var b = h.GetBucketOf(bucketV); histogram.Add(new HistogramBucket(bucketV, b.Count)); bucketV += deltaD; } return(histogram); //return String.Concat("%min, %max Derivatives : ", bmin.ToString("f4"), " , ", bmax.ToString("f4")); } catch (Exception) { throw; } }