public void BalancedTest() { var distribution = BernoulliDistribution.Balanced(); Assert.AreEqual( expected: 0.5, actual: distribution.SuccessProbability, delta: DoubleMatrixTest.Accuracy); }
public void SuccessProbabilityTest() { // Valid successProbability { var distribution = BernoulliDistribution.Balanced(); var expected = 0.12; distribution.SuccessProbability = expected; Assert.AreEqual( expected: expected, actual: distribution.SuccessProbability, delta: DoubleMatrixTest.Accuracy); } // successProbability < 0 { string STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL = string.Format( ImplementationServices.GetResourceString( "STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL"), "0", "1"); ArgumentExceptionAssert.Throw( () => { BernoulliDistribution.Balanced().SuccessProbability = -2.0; }, expectedType: typeof(ArgumentOutOfRangeException), expectedPartialMessage: STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL, expectedParameterName: "value"); } // successProbability > 1 { string STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL = string.Format( ImplementationServices.GetResourceString( "STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL"), "0", "1"); ArgumentExceptionAssert.Throw( () => { BernoulliDistribution.Balanced().SuccessProbability = 2.0; }, expectedType: typeof(ArgumentOutOfRangeException), expectedPartialMessage: STR_EXCEPT_PAR_NOT_IN_CLOSED_INTERVAL, expectedParameterName: "value"); } }