Created
November 6, 2020 00:42
-
-
Save teebu/ecc51c3d469cddec00f0c9c4a577adf8 to your computer and use it in GitHub Desktop.
normalizing score
This file contains hidden or 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 numpy as np | |
import matplotlib.pyplot as plt | |
from math import exp, log | |
def getGaussDecayValue(value,origin,scale,decay,offset=0): | |
# does this work? | |
z = -1*(scale**2)/(2*log(decay)) | |
a = (-1* (max(0, abs(value - origin) - offset)**2)) | |
value = exp(a/2*z) | |
return value | |
def getExpDecayValue(value, origin, scale, decay, offset=0): | |
z = log(decay) / scale | |
value = exp(z * max(0, abs(value - origin) - offset)) | |
return value | |
def getDecayValue(type, value, origin, scale, decay, offset=0): | |
if type == 'exp': | |
return getExpDecayValue(value, origin, scale, decay, offset) | |
else: | |
return getGaussDecayValue(value, origin, scale, decay, offset) | |
def getApproachValue(type, value, bar, scale, decay, offset=0): | |
v = getDecayValue(type, value, 0, scale, decay, offset) | |
return (bar - (bar * v)) / bar | |
plt.axis([0, 500, 0, 1]) | |
x = [] | |
y = [] | |
for score in range(1, 200, 10): | |
# what does bar do? | |
val = getApproachValue('exp', score, 10, 70, 0.40, 0) | |
print(score, '\t', val) | |
x.append(score) | |
y.append(val) | |
plt.plot(x, y) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment