Ejemplo n.º 1
0
        public TTestResult TTestPaired(double hypothesizedMeanDifference, double probability, string firstInputSeriesName, string secondInputSeriesName)
        {
            TTestResult tTestResult = new TTestResult();
            string      str         = hypothesizedMeanDifference.ToString(CultureInfo.InvariantCulture);

            str = str + "," + probability.ToString(CultureInfo.InvariantCulture);
            formulaData.Common.DataManager.Series.Add(tempOutputSeriesName);
            string inputSeries = firstInputSeriesName.ToString(CultureInfo.InvariantCulture) + "," + secondInputSeriesName.ToString(CultureInfo.InvariantCulture);

            formulaData.Formula("TTestPaired", str, inputSeries, tempOutputSeriesName);
            DataPointCollection points = formulaData.Common.DataManager.Series[tempOutputSeriesName].Points;

            tTestResult.firstSeriesMean      = points[0].YValues[0];
            tTestResult.secondSeriesMean     = points[1].YValues[0];
            tTestResult.firstSeriesVariance  = points[2].YValues[0];
            tTestResult.secondSeriesVariance = points[3].YValues[0];
            tTestResult.tValue                = points[4].YValues[0];
            tTestResult.degreeOfFreedom       = points[5].YValues[0];
            tTestResult.probabilityTOneTail   = points[6].YValues[0];
            tTestResult.tCriticalValueOneTail = points[7].YValues[0];
            tTestResult.probabilityTTwoTail   = points[8].YValues[0];
            tTestResult.tCriticalValueTwoTail = points[9].YValues[0];
            formulaData.Common.DataManager.Series.Remove(formulaData.Common.DataManager.Series[tempOutputSeriesName]);
            return(tTestResult);
        }
Ejemplo n.º 2
0
        public ZTestResult ZTest(double hypothesizedMeanDifference, double varianceFirstGroup, double varianceSecondGroup, double probability, string firstInputSeriesName, string secondInputSeriesName)
        {
            ZTestResult zTestResult = new ZTestResult();
            string      str         = hypothesizedMeanDifference.ToString(CultureInfo.InvariantCulture);

            str = str + "," + varianceFirstGroup.ToString(CultureInfo.InvariantCulture);
            str = str + "," + varianceSecondGroup.ToString(CultureInfo.InvariantCulture);
            str = str + "," + probability.ToString(CultureInfo.InvariantCulture);
            formulaData.Common.DataManager.Series.Add(tempOutputSeriesName);
            string inputSeries = firstInputSeriesName.ToString(CultureInfo.InvariantCulture) + "," + secondInputSeriesName.ToString(CultureInfo.InvariantCulture);

            formulaData.Formula("ZTest", str, inputSeries, tempOutputSeriesName);
            DataPointCollection points = formulaData.Common.DataManager.Series[tempOutputSeriesName].Points;

            zTestResult.firstSeriesMean      = points[0].YValues[0];
            zTestResult.secondSeriesMean     = points[1].YValues[0];
            zTestResult.firstSeriesVariance  = points[2].YValues[0];
            zTestResult.secondSeriesVariance = points[3].YValues[0];
            zTestResult.zValue = points[4].YValues[0];
            zTestResult.probabilityZOneTail   = points[5].YValues[0];
            zTestResult.zCriticalValueOneTail = points[6].YValues[0];
            zTestResult.probabilityZTwoTail   = points[7].YValues[0];
            zTestResult.zCriticalValueTwoTail = points[8].YValues[0];
            formulaData.Common.DataManager.Series.Remove(formulaData.Common.DataManager.Series[tempOutputSeriesName]);
            return(zTestResult);
        }
Ejemplo n.º 3
0
        public AnovaResult Anova(double probability, string inputSeriesNames)
        {
            AnovaResult anovaResult = new AnovaResult();
            string      parameters  = probability.ToString(CultureInfo.InvariantCulture);

            formulaData.Common.DataManager.Series.Add(tempOutputSeriesName);
            formulaData.Formula("Anova", parameters, inputSeriesNames, tempOutputSeriesName);
            DataPointCollection points = formulaData.Common.DataManager.Series[tempOutputSeriesName].Points;

            anovaResult.sumOfSquaresBetweenGroups       = points[0].YValues[0];
            anovaResult.sumOfSquaresWithinGroups        = points[1].YValues[0];
            anovaResult.sumOfSquaresTotal               = points[2].YValues[0];
            anovaResult.degreeOfFreedomBetweenGroups    = points[3].YValues[0];
            anovaResult.degreeOfFreedomWithinGroups     = points[4].YValues[0];
            anovaResult.degreeOfFreedomTotal            = points[5].YValues[0];
            anovaResult.meanSquareVarianceBetweenGroups = points[6].YValues[0];
            anovaResult.meanSquareVarianceWithinGroups  = points[7].YValues[0];
            anovaResult.fRatio         = points[8].YValues[0];
            anovaResult.fCriticalValue = points[9].YValues[0];
            formulaData.Common.DataManager.Series.Remove(formulaData.Common.DataManager.Series[tempOutputSeriesName]);
            return(anovaResult);
        }
Ejemplo n.º 4
0
        public FTestResult FTest(double probability, string firstInputSeriesName, string secondInputSeriesName)
        {
            FTestResult fTestResult = new FTestResult();
            string      parameters  = probability.ToString(CultureInfo.InvariantCulture);
            string      inputSeries = firstInputSeriesName.ToString(CultureInfo.InvariantCulture) + "," + secondInputSeriesName.ToString(CultureInfo.InvariantCulture);

            formulaData.Common.DataManager.Series.Add(tempOutputSeriesName);
            RemoveEmptyPoints(firstInputSeriesName);
            RemoveEmptyPoints(secondInputSeriesName);
            formulaData.Formula("FTest", parameters, inputSeries, tempOutputSeriesName);
            DataPointCollection points = formulaData.Common.DataManager.Series[tempOutputSeriesName].Points;

            fTestResult.firstSeriesMean      = points[0].YValues[0];
            fTestResult.secondSeriesMean     = points[1].YValues[0];
            fTestResult.firstSeriesVariance  = points[2].YValues[0];
            fTestResult.secondSeriesVariance = points[3].YValues[0];
            fTestResult.fValue = points[4].YValues[0];
            fTestResult.probabilityFOneTail   = points[5].YValues[0];
            fTestResult.fCriticalValueOneTail = points[6].YValues[0];
            formulaData.Common.DataManager.Series.Remove(formulaData.Common.DataManager.Series[tempOutputSeriesName]);
            return(fTestResult);
        }
Ejemplo n.º 5
0
        internal void DataBindCrossTab(IEnumerable dataSource, string seriesGroupByField, string xField, string yFields, string otherFields, bool sort, PointsSortOrder sortingOrder)
        {
            ArrayList arrayList  = new ArrayList();
            ArrayList arrayList2 = new ArrayList();

            string[] array = null;
            if (yFields != null)
            {
                array = yFields.Replace(",,", "\n").Split(',');
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = array[i].Replace("\n", ",");
                }
            }
            string[] otherAttributeNames = null;
            string[] otherFieldNames     = null;
            string[] otherValueFormat    = null;
            DataPointCollection.ParsePointFieldsParameter(otherFields, ref otherAttributeNames, ref otherFieldNames, ref otherValueFormat);
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource", SR.ExceptionDataPointInsertionNoDataSource);
            }
            if (dataSource is string)
            {
                throw new ArgumentException(SR.ExceptionDataBindSeriesToString, "dataSource");
            }
            if (array == null || array.Length == 0)
            {
                throw new ArgumentOutOfRangeException("yFields", SR.ExceptionChartDataPointsInsertionFailedYValuesEmpty);
            }
            if (seriesGroupByField == null || seriesGroupByField.Length == 0)
            {
                throw new ArgumentException(SR.ExceptionDataBindSeriesGroupByParameterIsEmpty, "seriesGroupByField");
            }
            IEnumerator dataSourceEnumerator = DataPointCollection.GetDataSourceEnumerator(dataSource);

            if (dataSourceEnumerator.GetType() != typeof(DbEnumerator))
            {
                try
                {
                    dataSourceEnumerator.Reset();
                }
                catch
                {
                }
            }
            bool flag = true;

            object[] array2 = new object[array.Length];
            object   obj2   = null;
            bool     flag2  = true;

            do
            {
                if (flag)
                {
                    flag = dataSourceEnumerator.MoveNext();
                }
                if (!flag)
                {
                    continue;
                }
                object obj3   = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, seriesGroupByField);
                Series series = null;
                int    num    = arrayList2.IndexOf(obj3);
                if (num >= 0)
                {
                    series = (Series)arrayList[num];
                }
                else
                {
                    series = new Series();
                    series.YValuesPerPoint = array.GetLength(0);
                    if (arrayList.Count > 0)
                    {
                        series.XValueType     = ((Series)arrayList[0]).XValueType;
                        series.autoXValueType = ((Series)arrayList[0]).autoXValueType;
                        series.YValueType     = ((Series)arrayList[0]).YValueType;
                        series.autoYValueType = ((Series)arrayList[0]).autoYValueType;
                    }
                    if (obj3 is string)
                    {
                        series.Name = (string)obj3;
                    }
                    else
                    {
                        series.Name = seriesGroupByField + " - " + obj3.ToString();
                    }
                    arrayList2.Add(obj3);
                    arrayList.Add(series);
                }
                if (flag2)
                {
                    flag2 = false;
                    DataPointCollection.AutoDetectValuesType(series, dataSourceEnumerator, xField, dataSourceEnumerator, array[0]);
                }
                DataPoint dataPoint = new DataPoint(series);
                bool      flag3     = false;
                if (xField.Length > 0)
                {
                    obj2 = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, xField);
                    if (DataPointCollection.IsEmptyValue(obj2))
                    {
                        flag3 = true;
                        obj2  = 0.0;
                    }
                }
                if (array.Length == 0)
                {
                    array2[0] = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, null);
                    if (DataPointCollection.IsEmptyValue(array2[0]))
                    {
                        flag3     = true;
                        array2[0] = 0.0;
                    }
                }
                else
                {
                    for (int j = 0; j < array.Length; j++)
                    {
                        array2[j] = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, array[j]);
                        if (DataPointCollection.IsEmptyValue(array2[j]))
                        {
                            flag3     = true;
                            array2[j] = 0.0;
                        }
                    }
                }
                if (otherAttributeNames != null && otherAttributeNames.Length != 0)
                {
                    for (int k = 0; k < otherFieldNames.Length; k++)
                    {
                        object obj4 = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, otherFieldNames[k]);
                        if (!DataPointCollection.IsEmptyValue(obj4))
                        {
                            dataPoint.SetPointAttribute(obj4, otherAttributeNames[k], otherValueFormat[k]);
                        }
                    }
                }
                if (flag3)
                {
                    if (obj2 != null)
                    {
                        dataPoint.SetValueXY(obj2, array2);
                    }
                    else
                    {
                        dataPoint.SetValueXY(0, array2);
                    }
                    DataPointCollection.DataPointInit(series, ref dataPoint);
                    dataPoint.Empty = true;
                    series.Points.Add(dataPoint);
                }
                else
                {
                    if (obj2 != null)
                    {
                        dataPoint.SetValueXY(obj2, array2);
                    }
                    else
                    {
                        dataPoint.SetValueXY(0, array2);
                    }
                    DataPointCollection.DataPointInit(series, ref dataPoint);
                    series.Points.Add(dataPoint);
                }
            }while (flag);
            if (sort)
            {
                ArrayList arrayList3 = (ArrayList)arrayList2.Clone();
                arrayList2.Sort();
                if (sortingOrder == PointsSortOrder.Descending)
                {
                    arrayList2.Reverse();
                }
                ArrayList arrayList4 = new ArrayList();
                foreach (object item in arrayList2)
                {
                    arrayList4.Add(arrayList[arrayList3.IndexOf(item)]);
                }
                arrayList = arrayList4;
            }
            foreach (Series item2 in arrayList)
            {
                common.Chart.Series.Add(item2);
            }
        }
Ejemplo n.º 6
0
        internal void DataBind(IEnumerable dataSource, ArrayList seriesList)
        {
            if (dataSource == null || common == null)
            {
                return;
            }
            if (seriesList == null)
            {
                seriesList = new ArrayList();
                foreach (Series item in common.Chart.Series)
                {
                    if (common.Chart.IsDesignMode())
                    {
                        if (item.ValueMembersY.Length > 0)
                        {
                            seriesList.Add(item);
                        }
                    }
                    else
                    {
                        seriesList.Add(item);
                    }
                }
            }
            foreach (Series series4 in seriesList)
            {
                if (series4.ValueMemberX.Length > 0 || series4.ValueMembersY.Length > 0)
                {
                    series4.Points.Clear();
                }
            }
            IEnumerator enumerator2 = dataSource.GetEnumerator();

            if (enumerator2.GetType() != typeof(DbEnumerator))
            {
                try
                {
                    enumerator2.Reset();
                }
                catch
                {
                }
            }
            bool flag  = true;
            bool flag2 = true;

            do
            {
                flag = enumerator2.MoveNext();
                foreach (Series series5 in seriesList)
                {
                    if (series5.ValueMemberX.Length <= 0 && series5.ValueMembersY.Length <= 0)
                    {
                        continue;
                    }
                    string[] array = null;
                    if (series5.ValueMembersY.Length > 0)
                    {
                        array = series5.ValueMembersY.Replace(",,", "\n").Split(',');
                        for (int i = 0; i < array.Length; i++)
                        {
                            array[i] = array[i].Replace("\n", ",").Trim();
                        }
                    }
                    if (dataSource is string)
                    {
                        throw new ArgumentException(SR.ExceptionDataBindYValuesToString, "dataSource");
                    }
                    if (array == null || array.GetLength(0) > series5.YValuesPerPoint)
                    {
                        throw new ArgumentOutOfRangeException("yValue", SR.ExceptionDataPointYValuesCountMismatch(series5.YValuesPerPoint.ToString(CultureInfo.InvariantCulture)));
                    }
                    if (!flag)
                    {
                        continue;
                    }
                    if (flag2)
                    {
                        flag2 = false;
                        string text = array[0];
                        int    num  = 1;
                        while (text.Length == 0 && num < array.Length)
                        {
                            text = array[num++];
                        }
                        DataPointCollection.AutoDetectValuesType(series5, enumerator2, series5.ValueMemberX.Trim(), enumerator2, text);
                    }
                    DataPoint dataPoint = new DataPoint(series5);
                    bool      flag3     = false;
                    bool      flag4     = false;
                    object[]  array2    = new object[array.Length];
                    object    obj2      = null;
                    if (series5.ValueMemberX.Length > 0)
                    {
                        obj2 = DataPointCollection.ConvertEnumerationItem(enumerator2.Current, series5.ValueMemberX.Trim());
                        if (obj2 is DBNull || obj2 == null)
                        {
                            flag4 = true;
                            flag3 = true;
                            obj2  = 0.0;
                        }
                    }
                    if (array.Length == 0)
                    {
                        array2[0] = DataPointCollection.ConvertEnumerationItem(enumerator2.Current, null);
                        if (array2[0] is DBNull || array2[0] == null)
                        {
                            flag3     = true;
                            array2[0] = 0.0;
                        }
                    }
                    else
                    {
                        for (int j = 0; j < array.Length; j++)
                        {
                            if (array[j].Length > 0)
                            {
                                array2[j] = DataPointCollection.ConvertEnumerationItem(enumerator2.Current, array[j]);
                                if (array2[j] is DBNull || array2[j] == null)
                                {
                                    flag3     = true;
                                    array2[j] = 0.0;
                                }
                            }
                            else
                            {
                                array2[j] = (((Series)seriesList[0]).IsYValueDateTime() ? DateTime.Now.Date.ToOADate() : 0.0);
                            }
                        }
                    }
                    if (!flag4)
                    {
                        if (flag3)
                        {
                            if (obj2 != null)
                            {
                                dataPoint.SetValueXY(obj2, array2);
                            }
                            else
                            {
                                dataPoint.SetValueXY(0, array2);
                            }
                            series5.Points.DataPointInit(ref dataPoint);
                            dataPoint.Empty = true;
                            series5.Points.Add(dataPoint);
                        }
                        else
                        {
                            if (obj2 != null)
                            {
                                dataPoint.SetValueXY(obj2, array2);
                            }
                            else
                            {
                                dataPoint.SetValueXY(0, array2);
                            }
                            series5.Points.DataPointInit(ref dataPoint);
                            series5.Points.Add(dataPoint);
                        }
                    }
                    if (common.Chart.IsDesignMode())
                    {
                        series5["TempDesignData"] = "true";
                    }
                }
            }while (flag);
        }