/** * @brief Výpočet smerodajnej odchýlky * * @param list Zoznam double, z ktorého vypočítať smerodajnú odchýlku * @return Smerodajná odchýlka */ public static double GetStandartDeviation(List <double> list) { int N = list.Count; double tmp = MatLib.subtract(GetSumSqr(list), MatLib.multiply(N, MatLib.square(GetArithmeticMean(list)))); try { tmp = MatLib.divide(tmp, N - 1); } catch (DivideByZeroException e) { Console.WriteLine("{0}", e.Message); Console.WriteLine("Press any key to continue . . ."); Console.Read(); Environment.Exit(-1); } tmp = MatLib.sqrt(tmp); return(tmp); }
public void ShouldMultiply() { Assert.AreEqual(1, MatLib.multiply(1, 1)); Assert.AreEqual(0, MatLib.multiply(1, 0)); Assert.AreEqual(0, MatLib.multiply(100000, 0)); Assert.AreEqual(0, MatLib.multiply(0, 100000)); Assert.AreEqual(4, MatLib.multiply(2, 2)); Assert.AreEqual(-4, MatLib.multiply(2, -2)); Assert.AreEqual(6, MatLib.multiply(-2, -3)); Assert.AreEqual(625, MatLib.multiply(25, 25)); Assert.AreEqual(1.805375, MatLib.multiply(1.625, 1.111), Accuracy); Assert.AreEqual(-1.805375, MatLib.multiply(-1.625, 1.111), Accuracy); Assert.AreEqual(-1.805375, MatLib.multiply(1.625, -1.111), Accuracy); Assert.AreEqual(1.805375, MatLib.multiply(-1.625, -1.111), Accuracy); Assert.AreEqual(0.0009, MatLib.multiply(9, 0.0001), Accuracy); Assert.AreNotEqual(100, MatLib.multiply(10, -10)); Assert.AreNotEqual(0.13, MatLib.multiply(0.4, 0.3)); Assert.AreNotEqual(-10000, MatLib.multiply(-100, -100)); Assert.AreNotEqual(-0.002, MatLib.multiply(0.0002, -0.1), Accuracy); }