Private
Public Access
1
0

changed to exponential function

This commit is contained in:
Sander Roosendaal
2017-12-14 15:41:01 +01:00
parent 6b7207321c
commit 03eec117a6
3 changed files with 39 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ from utils import lbstoN
import numpy as np
from models import C2WorldClassAgePerformance
import pandas as pd
from scipy import optimize
rowingmetrics = (
('time',{
@@ -347,9 +348,20 @@ def getagegrouprecord(age,sex='male',weightcategory='hwt',
ages = df['age']
powers = df['power']
poly_coefficients = np.polyfit(ages,powers,6)
#poly_coefficients = np.polyfit(ages,powers,6)
fitfunc = lambda pars, x: np.abs(pars[0])*(1-x/max(120,pars[1]))-np.abs(pars[2])*np.exp(-x/np.abs(pars[3]))+np.abs(pars[4])*(np.sin(np.pi*x/max(50,pars[5])))
errfunc = lambda pars, x,y: fitfunc(pars,x)-y
power = np.polyval(poly_coefficients,age)
p0 = [700,120,700,10,100,100]
p1, success = optimize.leastsq(errfunc,p0[:],
args = (ages,powers))
power = fitfunc(p1, float(age))
#power = np.polyval(poly_coefficients,age)
power = 0.5*(np.abs(power)+power)
else:
power = 0