ToRadians() public static method

Transforms circular data into angles (normalizes the data to be between -PI and PI).
public static ToRadians ( this sample, double length ) : double
sample this The sample to be transformed.
length double The maximum possible sample value (such as 24 for hour data).
return double
Ejemplo n.º 1
0
        /// <summary>
        ///   Computes the circular quartiles of the given circular samples.
        ///   The minimum possible value for a sample must be zero and the maximum must
        ///   be indicated in the parameter <paramref name="length"/>.
        /// </summary>
        ///
        /// <param name="samples">A double array containing the circular samples.</param>
        /// <param name="length">The maximum possible value of the samples.</param>
        /// <param name="range">The sample quartiles, as an out parameter.</param>
        /// <param name="median">The median value of the <paramref name="samples"/>, if already known.</param>
        /// <param name="wrap">
        ///   Whether range values should be wrapped to be contained in the circle. If
        ///   set to false, range values could be returned outside the [+pi;-pi] range.
        /// </param>
        /// <param name="type">The quartile definition that should be used. See <see cref="QuantileMethod"/> for datails.</param>
        ///
        /// <returns>The median of the given samples.</returns>
        ///
        public static double Quartiles(double[] samples, double length, out DoubleRange range, double median, bool wrap = true, QuantileMethod type = QuantileMethod.Default)
        {
            double angleMedian = Circular.ToRadians(median, length);
            double q2          = Quartiles(ToRadians(samples, length), out range, angleMedian, wrap, type: type);

            range.Min = ToCircular(range.Min, length, wrap);
            range.Max = ToCircular(range.Max, length, wrap);
            return(ToCircular(q2, length));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Computes the circular quartiles of the given circular samples.
        ///   The minimum possible value for a sample must be zero and the maximum must
        ///   be indicated in the parameter <paramref name="length"/>.
        /// </summary>
        ///
        /// <param name="samples">A double array containing the circular samples.</param>
        /// <param name="length">The maximum possible value of the samples.</param>
        /// <param name="q1">The first quartile, as an out parameter.</param>
        /// <param name="q3">The third quartile, as an out parameter.</param>
        /// <param name="median">The median value of the <paramref name="samples"/>, if already known.</param>
        /// <param name="wrap">
        ///   Whether range values should be wrapped to be contained in the circle. If
        ///   set to false, range values could be returned outside the [+pi;-pi] range.
        /// </param>
        /// <param name="type">The quartile definition that should be used. See <see cref="QuantileMethod"/> for datails.</param>
        ///
        /// <returns>The median of the given samples.</returns>
        ///
        public static double Quartiles(double[] samples, double length, out double q1, out double q3, double median, bool wrap = true, QuantileMethod type = QuantileMethod.Default)
        {
            double angleMedian = Circular.ToRadians(median, length);
            double q2          = Quartiles(ToRadians(samples, length), out q1, out q3, angleMedian, wrap, type: type);

            q1 = ToCircular(q1, length, wrap);
            q3 = ToCircular(q3, length, wrap);
            return(ToCircular(q2, length));
        }