Mercurial > hg > numerics
changeset 189:637507918c17
untested implementation of choosing Gaussian parameters
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 21 Jul 2017 13:10:47 -0700 |
parents | 100697f7c195 |
children | 72ae8c768504 |
files | numerics/gaussian.py |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/numerics/gaussian.py Fri Jul 21 12:58:40 2017 -0700 +++ b/numerics/gaussian.py Fri Jul 21 13:10:47 2017 -0700 @@ -9,8 +9,23 @@ import argparse import os -import subprocess import sys +from .filters import mean + +def gaussian(data): + """ + find mean + variance; fit to a Gaussian distribution + """ + + # find mean + _mean = mean(data) + + # find variance + sigma_squared = sum([(x-_mean)**2 + for x in data])/float(len(data)) + + # return parameters + return (_mean, sigma_squared) def main(args=sys.argv[1:]):