public void test_BetaEstimate_returns_correct_result() { /*B1-coefficient for linear model where testList is the response variable and testList2 * is the explanatory variable lm(testList ~ testList2) is -0.2259 (Calculated with R). * That means that for every unit testList2 value is elevated, testList value declines by * -0,2259. Result rounded to 4 decimals in the test*/ Assert.AreEqual(-0.2259, Math.Round(Regression.BetaEstimate(testList, testList2), 4)); }
public void test_BetaEstimate_null_list_throws_MathError() { /*If either of parameter lists are null, MathError should be thrown * with error "Parameter list cannot be a null item"*/ MathError err = Assert.Throws <MathError>(() => Regression.BetaEstimate(testList, null)); Assert.AreEqual("Parameter list cannot be a null item", err.error); }
public void test_BetaEstimate_different_Counts() { /*MathError with error message "Variable lists not the same length" should be thrown. * Since only one list is of length 0 this should produce different lengths error */ List <double> list1 = new List <double>(); MathError err = Assert.Throws <MathError>(() => Regression.BetaEstimate(testList, list1)); Assert.AreEqual("Variable lists not the same length", err.error); }
public void test_BetaEstimate_0_Count_throws_MathError() { /*If both list are of 0 length, MathError should be thrown with error "Parameter lists have 0 items"*/ List <double> list1 = new List <double>(); List <double> list2 = new List <double>(); MathError err = Assert.Throws <MathError>(() => Regression.BetaEstimate(list1, list2)); Assert.AreEqual("Parameter lists have 0 items", err.error); list1 = null; list2 = null; }