Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 13148

Ignore:
Timestamp:
11/13/15 20:54:47 (9 years ago)
Message:

#2488: merged r13025:13026 and r13064 from trunk to stable branch

Location:
stable
Files:
6 edited
2 copied

Unmodified
Removed
• ## stable

• Property svn:mergeinfo changed /trunk/sources merged: 13025-13026,​13064
• ## stable/HeuristicLab.Algorithms.DataAnalysis

• Property svn:mergeinfo changed /trunk/sources/HeuristicLab.Algorithms.DataAnalysis merged: 13026
• ## stable/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

 r13146
• ## stable/HeuristicLab.Common/3.3/EnumerableStatisticExtensions.cs

 r12009 using System; using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Linq; } else { return (valuesArr[(n / 2) - 1] + valuesArr[n / 2]) / 2.0; } } /// /// Calculates the alpha-quantile element of the enumeration. /// /// /// public static double Quantile(this IEnumerable values, double alpha) { Contract.Assert(alpha > 0 && alpha < 1); // iterate only once double[] valuesArr = values.ToArray(); int n = valuesArr.Length; if (n == 0) throw new InvalidOperationException("Enumeration contains no elements."); Array.Sort(valuesArr); //  starts at 0 // return the element at Math.Ceiling (if n*alpha is fractional) or the average of two elements if n*alpha is integer. var pos = n * alpha; Contract.Assert(pos >= 0); Contract.Assert(pos < n); bool isInteger = Math.Round(pos).IsAlmost(pos); if (isInteger) { return 0.5 * (valuesArr[(int)pos - 1] + valuesArr[(int)pos]); } else { return valuesArr[(int)Math.Ceiling(pos) - 1]; } }
• ## stable/HeuristicLab.Tests

• Property svn:mergeinfo changed /trunk/sources/HeuristicLab.Tests merged: 13025,​13064