markov-models/maths.py
2020-12-11 21:33:20 +00:00

15 lines
410 B
Python

from math import sqrt, pi
import numpy as np
from numpy import exp
root_2_pi = sqrt(2. * pi) # square root is expensive, define as constant here
def gaussian(x: float, mu: float, sd: float):
mu_pert = x - mu # mean pertubation
coefficient = 1. / (sd * root_2_pi)
return coefficient * exp( - (mu_pert**2)
/
(2.*sd**2))