本文整理汇总了C#中Sample.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Sample.Remove方法的具体用法?C# Sample.Remove怎么用?C# Sample.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sample
的用法示例。
在下文中一共展示了Sample.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SampleManipulations
public void SampleManipulations()
{
// create a sample
double[] data = new double[] { -1.1, 2.2, -3.3, 4.4 };
Sample sample = new Sample(data);
// check the length
Assert.IsTrue(sample.Count == data.Length);
// add a datum and check the length
sample.Add(5.5);
Assert.IsTrue(sample.Count == data.Length + 1);
// check wether an elements exists, remove it, check the length, check that it doesn't exist
Assert.IsTrue(sample.Contains(2.2));
Assert.IsTrue(sample.Remove(2.2));
Assert.IsTrue(sample.Count == data.Length);
Assert.IsFalse(sample.Contains(2.2));
Assert.IsFalse(sample.Remove(2.2));
// clear the sample and check the length
sample.Clear();
Assert.IsTrue(sample.Count == 0);
}
示例2: LowSampleMoments
public void LowSampleMoments()
{
// this is designed to test that means and standard deviations change properly when values
// are added and removed
Sample s = new Sample();
s.Add(2.0);
s.Add(4.0);
s.Add(6.0);
// set is 2, 4, 6: M = 4, V = (2^2 + 2^2) / 3
Assert.IsTrue(s.Count == 3);
Assert.IsTrue(TestUtilities.IsNearlyEqual(s.Mean, 4.0));
Assert.IsTrue(TestUtilities.IsNearlyEqual(s.Variance, 8.0 / 3.0));
// set is 4, 6: M = 5, V = (1^2 + 1^2) / 2
s.Remove(2.0);
Assert.IsTrue(s.Count == 2);
Assert.IsTrue(TestUtilities.IsNearlyEqual(s.Mean, 5.0));
Assert.IsTrue(TestUtilities.IsNearlyEqual(s.Variance, 1.0));
}