Make sure smooth returns values only between 0 and 1

This commit is contained in:
Grant Sanderson
2019-01-09 12:51:41 -08:00
parent 2f6fc82ecb
commit 67ae6bf3a8

View File

@ -10,7 +10,10 @@ def linear(t):
def smooth(t, inflection=10.0):
error = sigmoid(-inflection / 2)
return (sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error)
return np.clip(
(sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error),
0, 1,
)
def rush_into(t):