本文整理汇总了C#中FreeQuant.Series.TimeSeries.GetMean方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSeries.GetMean方法的具体用法?C# TimeSeries.GetMean怎么用?C# TimeSeries.GetMean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FreeQuant.Series.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.GetMean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCovariance
public override double GetCovariance(TimeSeries series, DateTime datetime1, DateTime datetime2)
{
if (!(series is DoubleSeries))
throw new ArgumentException("not a DoubleSeries");
double mean1 = this.GetMean();
double mean2 = series.GetMean();
double n = 0.0;
double sum = 0.0;
int index1 = series.GetIndex(datetime1, EIndexOption.Next);
int index2 = series.GetIndex(datetime2, EIndexOption.Prev);
for (int i = index1; i <= index2; ++i)
{
DateTime dt = this.GetDateTime(i);
if (series.Contains(dt))
{
sum += (this[i] - mean1) * ((double)series[dt] - mean2);
++n;
}
}
if (n <= 1.0)
return 0.0;
return sum / (n - 1.0);
}