Skip to content

maths/gaussian.py is wrong #2212

@stkain

Description

@stkain

Hi,

the formula is wrong.

return 1 / sqrt(2 * pi * sigma ** 2) * exp(-((x - mu) ** 2) / 2 * sigma ** 2)
                                                              ^^^^^^^^^^^^^^^
                                                              this actually multiplies with sigma**2 instead of dividing by sigma**2

Instead, for example:

1 / (sqrt(2 * pi) * sigma) * exp(- 0.5 * ( (x - mu) / sigma     )**2 )

avoids squaring sigma and taking the sqrt again in the factor before the exponential

and first calculating (x-mu) / sigma and then squaring saves you squaring numerator and denominator separately
in the exponential.

Bye,
Stefan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions