changed to exponential function
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user