Created
May 24, 2012 15:31
-
-
Save monodera/2782250 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import sys | |
import os | |
import random | |
import numpy | |
# making frames with Gaussian noise | |
def makeframes(mu,sigma): | |
frames = numpy.random.normal(mu,sigma,(100,2500)) | |
return(frames) | |
# making reference using median combination | |
def medianref(frames): | |
ref_med = numpy.median(frames, axis=0) | |
return(ref_med) | |
# subtracting median reference | |
def mediansub(frames,ref_med_input): | |
ref_med_mat = numpy.tile(ref_med_input, (100,1)) | |
results = frames - ref_med_mat | |
return(results) | |
# combining into one frame | |
def combine(result_input): | |
result = numpy.median(result_input, axis=0) | |
return(result) | |
# calculating mean and std | |
def calc(frame): | |
# print(frame) | |
mean = numpy.mean(frame) | |
sig = numpy.std(frame) | |
return(mean, sig) | |
if __name__ == '__main__': | |
mu = 100. | |
sigma = 10. | |
frames = makeframes(mu,sigma) | |
medref = medianref(frames) | |
result_med = mediansub(frames,medref) | |
ret = calc(result_med) | |
print('median combination') | |
print('mean=%f sigma=%f' % (ret[0],ret[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment