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))); }
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)); }
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); }
ICollection <V> IDictionary <K, V> .get_Values() { return((ICollection <V>)System.Array.AsReadOnly <V>((V[])ArrayModule.OfSeq <V>((IEnumerable <M0>) this.values))); }
ICollection <K> IDictionary <K, V> .get_Keys() { return((ICollection <K>)System.Array.AsReadOnly <K>((K[])ArrayModule.OfSeq <K>((IEnumerable <M0>) this.keys))); }
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))); }
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)); }
public static Frame <int, int> FromArray2D <T>(T[,] array) { IIndexBuilder instance1 = FIndexBuilderimplementation.IndexBuilder.Instance; int length1 = array.GetLength(0); FSharpFunc <int, int> fsharpFunc1 = (FSharpFunc <int, int>) new FrameExtensions.rowIndex(); if (length1 < 0) { throw new ArgumentException(string.Format("{0}\n{1} = {2}", new object[3] { (object)LanguagePrimitives.ErrorStrings.get_InputMustBeNonNegativeString(), (object)"count", (object)length1 }), "count"); } int[] numArray1 = new int[length1]; IIndexBuilder indexBuilder1 = instance1; for (int index = 0; index < numArray1.Length; ++index) { numArray1[index] = fsharpFunc1.Invoke(index); } IIndex <int> rowIndex = indexBuilder1.Create <int>((IEnumerable <int>)numArray1, FSharpOption <bool> .Some(true)); IIndexBuilder instance2 = FIndexBuilderimplementation.IndexBuilder.Instance; int length2 = array.GetLength(1); FSharpFunc <int, int> fsharpFunc2 = (FSharpFunc <int, int>) new FrameExtensions.colIndex(); if (length2 < 0) { throw new ArgumentException(string.Format("{0}\n{1} = {2}", new object[3] { (object)LanguagePrimitives.ErrorStrings.get_InputMustBeNonNegativeString(), (object)"count", (object)length2 }), "count"); } int[] numArray2 = new int[length2]; IIndexBuilder indexBuilder2 = instance2; for (int index = 0; index < numArray2.Length; ++index) { numArray2[index] = fsharpFunc2.Invoke(index); } IIndex <int> columnIndex = indexBuilder2.Create <int>((IEnumerable <int>)numArray2, FSharpOption <bool> .Some(true)); IVector[] vectorArray = (IVector[])ArrayModule.ZeroCreate <IVector>(array.GetLength(1)); for (int c = 0; c < vectorArray.Length; ++c) { int length3 = array.GetLength(0); FSharpFunc <int, T> fsharpFunc3 = (FSharpFunc <int, T>) new FrameExtensions.col <T>(array, c); if (length3 < 0) { throw new ArgumentException(string.Format("{0}\n{1} = {2}", new object[3] { (object)LanguagePrimitives.ErrorStrings.get_InputMustBeNonNegativeString(), (object)"count", (object)length3 }), "count"); } T[] objArray1 = new T[length3]; for (int index = 0; index < objArray1.Length; ++index) { objArray1[index] = fsharpFunc3.Invoke(index); } T[] objArray2 = objArray1; vectorArray[c] = (IVector)FVectorBuilderimplementation.VectorBuilder.Instance.Create <T>(objArray2); } IVector <IVector> data = FVectorBuilderimplementation.VectorBuilder.Instance.Create <IVector>(vectorArray); return(new Frame <int, int>(rowIndex, columnIndex, data, FIndexBuilderimplementation.IndexBuilder.Instance, FVectorBuilderimplementation.VectorBuilder.Instance)); }