avhz / RustQuant

Rust library for quantitative finance.
https://avhz.github.io
Apache License 2.0
1.07k stars 124 forks source link

Fix Gaussian statistics. Convention used here is self.variance = sigma^2 #192

Closed aatmunbaxi closed 7 months ago

aatmunbaxi commented 7 months ago

The convention of what self.variance means in this struct is inconsistent. The struct definition defines it as "squared scale", as with the Wikipedia page. The pdf with this convention is then defined $$f(x) = \frac{\exp( -\frac{(x-\mu)^2}{2\sigma^2})}{\sigma \sqrt{2\pi}}.$$ In particular, self.variance should not be squared in exponential. Similarly an inconsistency was found in the implementation of Distribution::cf().

Note the old formulas passed tests because tests were run for $\sigma^2 = 1$, which is obviously constant upon taking powers.

avhz commented 7 months ago

Nice spot, thank you !