本文整理汇总了C#中Accord.Statistics.Kernels.Gaussian.Function方法的典型用法代码示例。如果您正苦于以下问题:C# Gaussian.Function方法的具体用法?C# Gaussian.Function怎么用?C# Gaussian.Function使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Accord.Statistics.Kernels.Gaussian
的用法示例。
在下文中一共展示了Gaussian.Function方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FunctionTest
public void FunctionTest()
{
Gaussian dense = new Gaussian(3.6);
SparseGaussian target = new SparseGaussian(3.6);
double[] sx = { 1, -0.555556, 2, +0.250000, 3, -0.864407, 4, -0.916667 };
double[] sy = { 1, -0.666667, 2, -0.166667, 3, -0.864407, 4, -0.916667 };
double[] sz = { 1, -0.944444, 3, -0.898305, 4, -0.916667 };
double[] dx = { -0.555556, +0.250000, -0.864407, -0.916667 };
double[] dy = { -0.666667, -0.166667, -0.864407, -0.916667 };
double[] dz = { -0.944444, +0.000000, -0.898305, -0.916667 };
double expected, actual;
expected = dense.Function(dx, dy);
actual = target.Function(sx, sy);
Assert.AreEqual(expected, actual);
expected = dense.Function(dx, dz);
actual = target.Function(sx, sz);
Assert.AreEqual(expected, actual);
expected = dense.Function(dy, dz);
actual = target.Function(sy, sz);
Assert.AreEqual(expected, actual);
}
示例2: GaussianFunctionTest
public void GaussianFunctionTest()
{
var x = new double[] { 0, 4, 2, 1 };
var y = new double[] { 3, 2, };
var dtw = new DynamicTimeWarping(1);
IKernel gaussian = new Gaussian<DynamicTimeWarping>(dtw, 1);
double actual = gaussian.Function(x, y);
Assert.AreEqual(0.3407192298459587, actual);
gaussian = new Gaussian<DynamicTimeWarping>(dtw, 11.5);
x = new double[] { 0.2, 5 };
y = new double[] { 3, 0.7 };
actual = gaussian.Function(x, y);
Assert.AreEqual(0.99065918303292089, actual);
}
示例3: GaussianFunctionTest
public void GaussianFunctionTest()
{
IKernel gaussian = new Gaussian(1);
double[] x = { 1, 1 };
double[] y = { 1, 1 };
double actual = gaussian.Function(x, y);
double expected = 1;
Assert.AreEqual(expected, actual);
gaussian = new Gaussian(11.5);
x = new double[] { 0.2, 5 };
y = new double[] { 3, 0.7 };
actual = gaussian.Function(x, y);
expected = 0.9052480234;
Assert.AreEqual(expected, actual, 1e-10);
}
示例4: FunctionTest_EqualInputs
public void FunctionTest_EqualInputs()
{
var x = new double[] { 1, 2, 5, 1 };
var y = new double[] { 1, 2, 5, 1 };
var target = new Gaussian<DynamicTimeWarping>(new DynamicTimeWarping(1), 4.2);
double expected = target.Function(x, y);
double actual = target.Function(x, x);
Assert.AreEqual(expected, actual, 0.000001);
}
示例5: FunctionTest2
public void FunctionTest2()
{
// Tested against R's kernlab
double[][] data =
{
new double[] { 5.1, 3.5, 1.4, 0.2 },
new double[] { 5.0, 3.6, 1.4, 0.2 },
new double[] { 4.9, 3.0, 1.4, 0.2 },
new double[] { 5.8, 4.0, 1.2, 0.2 },
new double[] { 4.7, 3.2, 1.3, 0.2 },
};
// rbf <- rbfdot(sigma = 1)
// R's sigma is framework's Gaussian's gamma:
Gaussian kernel = new Gaussian() { Gamma = 1 };
// Compute the kernel matrix
double[,] actual = new double[5, 5];
for (int i = 0; i < 5; i++)
for (int j = 0; j < 5; j++)
actual[i, j] = kernel.Function(data[i], data[j]);
double[,] expected =
{
{ 1.0000000, 0.9801987, 0.7482636, 0.4584060, 0.7710516 },
{ 0.9801987, 1.0000000, 0.6907343, 0.4317105, 0.7710516 },
{ 0.7482636, 0.6907343, 1.0000000, 0.1572372, 0.9139312 },
{ 0.4584060, 0.4317105, 0.1572372, 1.0000000, 0.1556726 },
{ 0.7710516, 0.7710516, 0.9139312, 0.1556726, 1.0000000 },
};
// Assert both are equal
for (int i = 0; i < 5; i++)
for (int j = 0; j < 5; j++)
Assert.AreEqual(expected[i, j], actual[i, j], 1e-6);
}
示例6: FunctionTest
public void FunctionTest()
{
double sigma = 0.1;
Gaussian target = new Gaussian(sigma);
double[] x = { 2.0, 3.1, 4.0 };
double[] y = { 2.0, 3.1, 4.0 };
double expected = 1;
double actual;
actual = target.Function(x, y);
Assert.AreEqual(expected, actual);
actual = target.Function(x, x);
Assert.AreEqual(expected, actual);
actual = target.Function(y, y);
Assert.AreEqual(expected, actual);
}
示例7: FunctionTest_EqualInputs
public void FunctionTest_EqualInputs()
{
var x = new double[] { 1, 2, 5, 1 };
var y = new double[] { 1, 2, 5, 1 };
var target = new Gaussian<Linear>(new Linear(1), 4.2);
double expected = target.Function(x, y);
double actual = target.Function(x, x);
Assert.AreEqual(expected, actual);
}
示例8: KernelFunctionCacheConstructorTest6
public void KernelFunctionCacheConstructorTest6()
{
IKernel kernel = new Gaussian(0.6);
int cacheSize = inputs.Length;
KernelFunctionCache target = new KernelFunctionCache(kernel, inputs, cacheSize);
Assert.AreEqual(10, target.Size);
Assert.AreEqual(0, target.Hits);
Assert.AreEqual(0, target.Misses);
for (int i = 0; i < inputs.Length; i++)
{
double expected = kernel.Function(inputs[i], inputs[i]);
double actual = target.GetOrCompute(i);
Assert.AreEqual(expected, actual);
}
Assert.AreEqual(0, target.Hits);
for (int i = 0; i < inputs.Length; i++)
{
for (int j = 0; j < inputs.Length; j++)
{
double expected = kernel.Function(inputs[i], inputs[j]);
double actual = target.GetOrCompute(i, j);
Assert.AreEqual(expected, actual);
}
}
for (int i = 0; i < inputs.Length; i++)
{
for (int j = 0; j < inputs.Length; j++)
{
double expected = kernel.Function(inputs[i], inputs[j]);
double actual = target.GetOrCompute(i, j);
Assert.AreEqual(expected, actual);
}
}
Assert.AreEqual(45, target.Misses);
Assert.AreEqual(135, target.Hits);
Assert.AreEqual(1.0, target.Usage);
}