本文整理汇总了C#中YAMP.MatrixValue.Min方法的典型用法代码示例。如果您正苦于以下问题:C# MatrixValue.Min方法的具体用法?C# MatrixValue.Min怎么用?C# MatrixValue.Min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YAMP.MatrixValue
的用法示例。
在下文中一共展示了MatrixValue.Min方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Function
public FunctionValue Function(MatrixValue Y, ScalarValue nbins, ScalarValue nParameters)
{
var nn = nbins.GetIntegerOrThrowException("nbins", Name);
var nP = nParameters.GetIntegerOrThrowException("nParameters", Name);
var N = Y.Length;
var min_idx = Y.Min();
var min = Y[min_idx.Row, min_idx.Column];
var max_idx = Y.Max();
var max = Y[max_idx.Row, max_idx.Column];
var median = YMath.Median(Y);
var variance = ScalarValue.Zero;
var mean = Y.Sum() / Y.Length;
for (var i = 1; i <= Y.Length; i++)
{
variance += (Y[i] - mean).Square();
}
variance /= Y.Length;
var delta = (max - min) / nn;
var x = new MatrixValue(nn, 1);
for (var i = 0; i < nn; i++)
{
x[i + 1] = min + delta * i;
}
var histogram = new HistogramFunction();
var fx = histogram.Function(Y, x);
var linearfit = new LinfitFunction(Context);
var dist = linearfit.Function(x, fx, new FunctionValue((context, argument) =>
{
var _x = (argument as ScalarValue - median / 2) / (variance / 4);
var _exp_x_2 = (-_x * _x).Exp();
var result = new MatrixValue(1, nP - 1);
for (var i = 0; i < nP - 1; i++)
{
result[i + 1] = _exp_x_2 * _x.Pow(new ScalarValue(i));
}
return result;
}, true));
var norm = Y.Length * (max - min) / nbins;
var normed_dist = new FunctionValue((context, argument) =>
{
var temp = dist.Perform(context, argument);
if (temp is ScalarValue)
{
return ((ScalarValue)temp) / norm;
}
else if (temp is MatrixValue)
{
return ((MatrixValue)temp) / norm;
}
throw new YAMPOperationInvalidException();
}, true);
return normed_dist;
}