dbwebb-se / matmod

Coursematerial for Matematisk modellering
Other
0 stars 4 forks source link

[python] Test cases should round instead of truncate #39

Open SpaceLenore opened 5 years ago

SpaceLenore commented 5 years ago

The function for binomial distribution is supposed to return 0.01 when called with bin(40, 100, 0.5) and rounded to 3 decimals according to the tests, however that should not be the case when rounding to 3 decimals. The full value is 0.010843866711637987 this would round to 0.011 when rounded to 3 decimals. Only way to round it to 0.01 is to round by 2 decimals. However, that breaks the next test case which expects 3 decimals. Only current way to solve this is to write a function for truncating the value at the third decimal.

SpaceLenore commented 5 years ago

Also, if one truncates instead of correctly rounding it the follow up tests with cumulative_bin does not work.

henrikfredriksson commented 5 years ago

The test files are updated

Thanks for pointing this out