public static Deedle.Series <a, b> ofObservations <a, b>(IEnumerable <Tuple <a, b> > observations)
            {
                Tuple <a, b>[] tupleArray1 = (Tuple <a, b>[])ArrayModule.OfSeq <Tuple <a, b> >((IEnumerable <M0>)observations);
                FSharpFunc <Tuple <a, b>, a> fsharpFunc1 = (FSharpFunc <Tuple <a, b>, a>) new FSeriesextensions.ofObservations <a, b>();

                Tuple <a, b>[] tupleArray2 = tupleArray1;
                if ((object)tupleArray2 == null)
                {
                    throw new ArgumentNullException("array");
                }
                a[] aArray1 = new a[tupleArray2.Length];
                for (int index = 0; index < aArray1.Length; ++index)
                {
                    aArray1[index] = fsharpFunc1.Invoke(tupleArray2[index]);
                }
                a[] aArray2 = aArray1;
                FSharpFunc <Tuple <a, b>, b> fsharpFunc2 = (FSharpFunc <Tuple <a, b>, b>) new FSeriesextensions.ofObservations <a, b>();

                Tuple <a, b>[] tupleArray3 = tupleArray1;
                if ((object)tupleArray3 == null)
                {
                    throw new ArgumentNullException("array");
                }
                b[] values = new b[tupleArray3.Length];
                a[] keys   = aArray2;
                for (int index = 0; index < values.Length; ++index)
                {
                    values[index] = fsharpFunc2.Invoke(tupleArray3[index]);
                }
                return(new Deedle.Series <a, b>(keys, values));
            }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 ICollection <V> IDictionary <K, V> .get_Values()
 {
     return((ICollection <V>)System.Array.AsReadOnly <V>((V[])ArrayModule.OfSeq <V>((IEnumerable <M0>) this.values)));
 }
Esempio n. 4
0
 ICollection <K> IDictionary <K, V> .get_Keys()
 {
     return((ICollection <K>)System.Array.AsReadOnly <K>((K[])ArrayModule.OfSeq <K>((IEnumerable <M0>) this.keys)));
 }
Esempio n. 5
0
        public static Frame <long, K> FrameofRowsOrdinalStatic <e, K, V>(IEnumerable <e> rows) where e : Series <K, V>
        {
            IVector <e> vector = FVectorBuilderimplementation.VectorBuilder.Instance.Create <e>(ArrayModule.OfSeq <e>(rows));

            return(FrameUtils.fromRows <long, K, e>(FIndexBuilderimplementation.IndexBuilder.Instance, FVectorBuilderimplementation.VectorBuilder.Instance, new Series <long, e>(FIndexBuilderimplementation.IndexBuilder.Instance.Create <long>((IEnumerable <long>)Operators.CreateSequence <long>((IEnumerable <M0>)Operators.OperatorIntrinsics.RangeInt64(0L, 1L, vector.Length - 1L)), FSharpOption <bool> .Some(true)), vector, FVectorBuilderimplementation.VectorBuilder.Instance, FIndexBuilderimplementation.IndexBuilder.Instance)));
        }
Esempio n. 6
0
        public static Frame <c, a> frame <a, b, c>(IEnumerable <Tuple <TLeft, TRight> > columns) where b : ISeries <c>
        {
            Tuple <a[], b[]> tuple1 = ArrayModule.Unzip <TLeft, TRight>((Tuple <M0, M1>[])ArrayModule.OfSeq <Tuple <TLeft, TRight> >((IEnumerable <M0>)columns));

            b[] values = tuple1.Item2;
            a[] keys   = tuple1.Item1;
            Tuple <FSharpList <IVectorBuilder>, FSharpList <IIndexBuilder> > tuple2 = new Tuple <FSharpList <IVectorBuilder>, FSharpList <IIndexBuilder> >((FSharpList <IVectorBuilder>)ListModule.OfSeq <IVectorBuilder>(SeqModule.Distinct <IVectorBuilder>((IEnumerable <M0>)SeqModule.ToList <IVectorBuilder>((IEnumerable <M0>) new FFrameextensions.vbs <b, c>(values, default(b), (IEnumerator <b>)null, 0, (IVectorBuilder)null)))), (FSharpList <IIndexBuilder>)ListModule.OfSeq <IIndexBuilder>(SeqModule.Distinct <IIndexBuilder>((IEnumerable <M0>)SeqModule.ToList <IIndexBuilder>((IEnumerable <M0>) new FFrameextensions.ibs <b, c>(values, default(b), (IEnumerator <b>)null, 0, (IIndexBuilder)null)))));
            Tuple <IVectorBuilder, IIndexBuilder> tuple3;

            if (tuple2.Item1.get_TailOrNull() != null)
            {
                FSharpList <IVectorBuilder> fsharpList1 = tuple2.Item1;
                if (fsharpList1.get_TailOrNull().get_TailOrNull() == null && tuple2.Item2.get_TailOrNull() != null)
                {
                    FSharpList <IIndexBuilder> fsharpList2 = tuple2.Item2;
                    if (fsharpList2.get_TailOrNull().get_TailOrNull() == null)
                    {
                        tuple3 = new Tuple <IVectorBuilder, IIndexBuilder>(fsharpList1.get_HeadOrDefault(), fsharpList2.get_HeadOrDefault());
                        goto label_5;
                    }
                }
            }
            tuple3 = new Tuple <IVectorBuilder, IIndexBuilder>(FVectorBuilderimplementation.VectorBuilder.Instance, FIndexBuilderimplementation.IndexBuilder.Instance);
label_5:
            Tuple <IVectorBuilder, IIndexBuilder> tuple4 = tuple3;
            IVectorBuilder vectorBuilder = tuple4.Item1;

            return(FrameUtils.fromColumns <c, a, b>(tuple4.Item2, vectorBuilder, new Series <TLeft, TRight>(keys, values)));
        }
Esempio n. 7
0
 public static Frame <R, C> CreateEmpty <R, C>()
 {
     return(new Frame <R, C>(FIndexextensions.Index.ofKeys <R>(FSharpList <R> .get_Empty()), FIndexextensions.Index.ofKeys <C>(FSharpList <C> .get_Empty()), FVectorBuilderimplementation.VectorBuilder.Instance.Create <IVector>((IVector[])ArrayModule.OfSeq <IVector>((IEnumerable <M0>)FSharpList <IVector> .get_Empty())), FIndexBuilderimplementation.IndexBuilder.Instance, FVectorBuilderimplementation.VectorBuilder.Instance));
 }