public static double Mean <K, V>(this Series <K, V> series)
        {
            Series <K, V> series1 = series;
            int           num1    = 1;

            OptionalValue <V>[] optionalValueArray = StatsInternal.valuesAllOpt <K, V>(series1);
            int num2 = num1;

            V[] vArray1 = ArrayModule.Choose <OptionalValue <V>, V>((FSharpFunc <M0, FSharpOption <M1> >) new SeriesStatsExtensions.Mean <V>(), (M0[])optionalValueArray);
            FSharpFunc <V, double> fsharpFunc = (FSharpFunc <V, double>) new SeriesStatsExtensions.Mean <V>();

            V[] vArray2 = vArray1;
            if ((object)vArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            double[] init   = new double[vArray2.Length];
            int      moment = num2;

            for (int index = 0; index < init.Length; ++index)
            {
                init[index] = fsharpFunc.Invoke(vArray2[index]);
            }
            StatsInternal.Sums sums = StatsInternal.initSumsDense(moment, init);
            return(sums.sum / sums.nobs);
        }
        public static double Median <K, V>(this Series <K, V> series)
        {
            V[] vArray1 = (V[])ArrayModule.OfSeq <V>((IEnumerable <M0>)series.Values);
            FSharpFunc <V, double> fsharpFunc = (FSharpFunc <V, double>) new SeriesStatsExtensions.Median <V>();

            V[] vArray2 = vArray1;
            if ((object)vArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            double[] numArray = new double[vArray2.Length];
            for (int index = 0; index < numArray.Length; ++index)
            {
                numArray[index] = fsharpFunc.Invoke(vArray2[index]);
            }
            double[] arr = numArray;
            int      n   = arr.Length / 2;

            if (arr.Length == 0)
            {
                return(Operators.get_NaN());
            }
            if (arr.Length % 2 == 1)
            {
                return(StatsInternal.quickSelectInplace(n, arr));
            }
            return((StatsInternal.quickSelectInplace(n, arr) + StatsInternal.quickSelectInplace(n - 1, arr)) / 2.0);
        }