当前位置: 首页>>代码示例>>C#>>正文


C# DenseVector.Mean方法代码示例

本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Double.DenseVector.Mean方法的典型用法代码示例。如果您正苦于以下问题:C# DenseVector.Mean方法的具体用法?C# DenseVector.Mean怎么用?C# DenseVector.Mean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MathNet.Numerics.LinearAlgebra.Double.DenseVector的用法示例。


在下文中一共展示了DenseVector.Mean方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NormalizeZScore

 public static double[] NormalizeZScore(this double[] data)
 {
     var d = new DenseVector(data);
     var result = new DenseVector(d.Count);
     d.CopyTo(result);
     result = (DenseVector) ((result - d.Mean())/(d.StandardDeviation()));
     return result.ToArray();
 }
开发者ID:ifzz,项目名称:QuantSys,代码行数:8,代码来源:StatisticsExtension.cs

示例2: VarianceRatioTest

        public void VarianceRatioTest(double[] data, int lag = 1, TimeSeriesType cor = TimeSeriesType.HOM)
        {
            DenseVector x = new DenseVector(data);

            //Mean
            double mu = x.Mean();

            //Variance for 1st Order Difference
            double s1 = (x.SubVector(lag, x.Count - lag) - x.SubVector(0, x.Count - 2)).Variance();


            double dLag = lag;
            double varvrt = double.NaN;
            switch (cor)
            {
                case TimeSeriesType.HOM:
                {
                    varvrt = 2*(2*dLag - 1)*(dLag - 1)/(3*dLag*x.Count);
                    break;
                }
                case TimeSeriesType.HET:
                {
                    varvrt = 0;
                    double sum2 = 0;
                    for (int j = 0; j < lag; j++)
                    {
                        double sum1a = 0; //(x(j+2:n)-x(j+1:n-1)-mu).^2
                        double sum1b = 0; //(x(2:n-j)-x(1:n-j-1)-mu).^2;
                        double sum1 = sum1a*sum1b;
                        double delta = sum1/(Math.Pow(sum2, 2));
                        varvrt += 0;  //(2*(q(i)-j)/q(i))^2)*delta;
                    }
                    break;
                }
            }

            ZScore = (VRatio - 1)/Math.Sqrt(varvrt);
            PValue = NormCDF(ZScore);

        }
开发者ID:ifzz,项目名称:QuantSys,代码行数:40,代码来源:VarianceRatio.cs

示例3: Covariance

        public static double Covariance(DenseVector x, DenseVector y)
        {
            var cov = new DenseVector(x.Count);
            double xMean = x.Mean();
            double yMean = y.Mean();

            if (xMean.Equals(double.NaN) || yMean.Equals(double.NaN))
                return double.NaN;

            for (int i = 0; i < x.Count; i++)
            {
                cov[i] = (x[i] - xMean)*(y[i] - yMean);
            }

            return ((double) 1/(x.Count - 1))*cov.Sum();
        }
开发者ID:ifzz,项目名称:QuantSys,代码行数:16,代码来源:StatisticsExtension.cs

示例4: Kurtosis

        public static double Kurtosis(this double[] data)
        {
            var d = new DenseVector(data);
            var num = new DenseVector(d.Count);
            var denom = new DenseVector(d.Count);
            d.CopyTo(num);
            d.CopyTo(denom);

            for (int i = 0; i < num.Count; i++)
            {
                num[i] = Math.Pow(d[i] - d.Mean(), 4);
                denom[i] = Math.Pow(d[i] - d.Mean(), 2);
            }

            return (num.Sum()*num.Count)/(Math.Pow(denom.Sum(), 2));
        }
开发者ID:ifzz,项目名称:QuantSys,代码行数:16,代码来源:StatisticsExtension.cs

示例5: AverageRawReturn

 public static double AverageRawReturn(this DenseVector d)
 {
     double[] result = RawRateOfReturn(d.ToArray());
     var e = new DenseVector(result);
     return e.Mean();
 }
开发者ID:ifzz,项目名称:QuantSys,代码行数:6,代码来源:StatisticsExtension.cs


注:本文中的MathNet.Numerics.LinearAlgebra.Double.DenseVector.Mean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。