本文整理汇总了C#中IROVector.Sum方法的典型用法代码示例。如果您正苦于以下问题:C# IROVector.Sum方法的具体用法?C# IROVector.Sum怎么用?C# IROVector.Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IROVector
的用法示例。
在下文中一共展示了IROVector.Sum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProbabilityDensity
/// <summary>
///
/// </summary>
/// <param name="x"></param>
/// <param name="bw"></param>
/// <param name="bwSel"></param>
/// <param name="adjust"></param>
/// <param name="kernel"></param>
/// <param name="weights"></param>
/// <param name="width"></param>
/// <param name="widthSel"></param>
/// <param name="n"></param>
/// <param name="from"></param>
/// <param name="to"></param>
/// <param name="cut"></param>
/// <remarks>Adapted from the R-project (www.r-project.org), Version 2.72, file density.R</remarks>
public static ProbabilityDensityResult ProbabilityDensity(
this IROVector x,
double bw,
string bwSel,
double adjust,
ConvolutionKernel kernel,
IROVector weights,
double width,
string widthSel,
int n,
double from,
double to,
double cut // default: 3
)
{
double wsum;
if (null == weights)
{
weights = VectorMath.GetConstantVector(1.0 / x.Length, x.Length);
wsum = 1;
}
else
{
wsum = weights.Sum();
}
double totMass = 1;
int n_user = n;
n = Math.Max(n, 512);
if (n > 512)
n = BinaryMath.NextPowerOfTwoGreaterOrEqualThan(n);
if (bw.IsNaN() && !(width.IsNaN() && null == widthSel))
{
if (!width.IsNaN())
{
// S has width equal to the length of the support of the kernel
// except for the gaussian where it is 4 * sd.
// R has bw a multiple of the sd.
double fac = 1;
switch (kernel)
{
case ConvolutionKernel.Gaussian:
fac = 4;
break;
case ConvolutionKernel.Rectangular:
fac = 2 * Math.Sqrt(3);
break;
case ConvolutionKernel.Triangular:
fac = 2 * Math.Sqrt(6);
break;
case ConvolutionKernel.Epanechnikov:
fac = 2 * Math.Sqrt(5);
break;
case ConvolutionKernel.Biweight:
fac = 2 * Math.Sqrt(7);
break;
case ConvolutionKernel.Cosine:
fac = 2 / Math.Sqrt(1 / 3 - 2 / (Math.PI * Math.PI));
break;
case ConvolutionKernel.Optcosine:
fac = 2 / Math.Sqrt(1 - 8 / (Math.PI * Math.PI));
break;
default:
throw new ArgumentException("Unknown convolution kernel");
}
bw = width / fac;
}
else
{
bwSel = widthSel;
}
}
if (null != bwSel)
{
//.........这里部分代码省略.........