class FootballModel( NonLinearModel ) | Source |
---|
More or less complex model for the outcome of football marches.
The input values are a (nteams,2) list of integers. They represent teams that play a match, the first at home the other away.
For each team the complexity lists parameters
name | complexity | limits | default | comment |
---|---|---|---|---|
Attack | 1 | 0<a | n/a | trials on the goal |
Defensive strength | 2 | 0<b<1 | 0 | fraction of trials stopped |
Midfield strength | 3 | 0<c<2 | 1 | relative strength of the team |
Home advantage | 4 | 0<d<2 | 1 | advantage of playing at home |
Strategy | 5 | 0<e<2 | 1 | defensive <-> offensive |
Note: Computational runtime errors/warnings occur when (some of) the parameters are at their limits.
The default values are chosen such that they dont have effect on the results. I.e. a model with complexity=5 and all parameters at the defaults except for "trials", has the same result as a model with complexity 1 with the same "trials" value.
For information what is calculated at each level of complexity, see info at the methods goals1(), goals2(), ... goals5(), below.
Note This is about the game that most of the world calls football.
Examples
fm = FootballModel( 18 )
print( fm.npars )
90
- Author : Do Kester
Attributes
- nteams : int
number of teams - complexity : int
degree of complexity, default = 5.
Attributes from Model
npchain, parameters, stdevs, xUnit, yUnit
Attributes from FixedModel
npmax, fixed, parlist, mlist
Attributes from BaseModel
npbase, ndim, priors, posIndex, nonZero, tiny, deltaP, parNames
FootballModel( nteams, complexity=5, copy=None, **kwargs ) |
---|
Calculate the score of football matches
The number of parameters is ( nteams * complexity )
Parameters
- nteams : int
number of teams - complexity : 1 <= int <= 5
of the model - copy : FootballModel
model to copy - fixed : None or dictionary of {int:float|Model}
int index of parameter to fix permanently.
float|Model values for the fixed parameters.
Attribute fixed can only be set in the constructor.
See: FixedModel
copy( ) |
---|
getPrior( k ) |
---|
Parameters
- k : int
parameter number.
goals1( xdata, par ) |
---|
S1 = a1
S2 = a2
Parameters
- xdata : array of int
list of matches team 1 vs team 2 - par : array_like
attack values
goals2( xdata, par ) |
---|
S1 = a1 * ( 1 - d2 )
S2 = a2 * ( 1 - d1 )
Parameters
- xdata : array of int
list of matches team 1 vs team 2 - par : array_like
team values
goals3( xdata, par ) |
---|
The ratio of the midfield strength modifies attack and defense
S1 = a1 * √(m1/m2) * ( 1 - d2 (m2/m1) )
S2 = a2 * √(m2/m1) * ( 1 - d1 (m1/m2) )
Parameters
- xdata : array of int
list of matches team 1 vs team 2 - par : array_like
team values
goals4( xdata, par ) |
---|
The strategy modifies the midfield strangth of the home team.
mh = m1 * h1
S1 = a1 * √(mh/m2) * ( 1 - d2 (m2/mh) )
S2 = a2 * √(m2/mh) * ( 1 - d1 (mh/m2) )
Parameters
- xdata : array of int
list of matches team 1 vs team 2 - par : array_like
team values
goals5( xdata, par ) |
---|
A offensive strategy (s>1) strenghtens the attach and weakens the defense.
A defensive strategy (s<1) strenghtens the defense and weakens the attack.
mh = m1 * h1
S1 = a1 * √(s1 * mh/m2) * ( 1 - d2 (s2 * m2/mh) )
S2 = a2 * √(s2 * m2/mh) * ( 1 - d1 (s1 * mh/m2) )
Parameters
- xdata : array of int
list of matches team 1 vs team 2 - par : array_like
team values
baseResult( xdata, params ) |
---|
The partials are the powers of x ( xdata ) from 0 to degree.
Parameters
- xdata : array_like [2:nteams]
list of team ids playing against each other. - params : array_like
parameters for the model
basePartial( xdata, params, parlist=None ) |
---|
The partials are the powers of x ( xdata ) from 0 to degree.
Parameters
- xdata : array_like
values at which to calculate the partials - params : array_like
parameters for the model (ignored for LinearModels). - parlist : array_like
list of indices of active parameters
part1( xdata, par ) |
---|
Parameters
- xdata : array_like [2:nteams]
list of team ids playing against each other. - par : array_like
parameters for the model
part2( xdata, par ) |
---|
Parameters
- xdata : array_like [2:nteams]
list of team ids playing against each other. - par : array_like
parameters for the model
part3( xdata, par ) |
---|
Parameters
- xdata : array_like [2:nteams]
list of team ids playing against each other. - par : array_like
parameters for the model
part4( xdata, par ) |
---|
Parameters
- xdata : array_like [2:nteams]
list of team ids playing against each other. - par : array_like
parameters for the model
part5( xdata, par ) |
---|
Parameters
- xdata : array_like [2:nteams]
list of team ids playing against each other. - par : array_like
parameters for the model
baseDerivative( xdata, params ) |
---|
Parameters
- xdata : array_like
values at which to calculate the partials - params : array_like
parameters for the model.
baseName( ) |
---|
baseParameterName( k ) |
---|
- k : int
parameter number.
baseParameterUnit( k ) |
---|
Parameters
- k : int
parameter number.
Methods inherited from NonLinearModel |
---|
Methods inherited from Model |
---|
- chainLength( )
- isNullModel( )
- isolateModel( k )
- addModel( model )
- subtractModel( model )
- multiplyModel( model )
- divideModel( model )
- pipeModel( model )
- appendModel( model, operation )
- correctParameters( params )
- result( xdata, param=None )
- operate( res, pars, next )
- derivative( xdata, param, useNum=False )
- selectPipe( ndim, ninter, ndout )
- pipe_0( dGd, dHdG )
- pipe_1( dGd, dHdG )
- pipe_2( dGd, dHdG )
- pipe_3( dGd, dHdG )
- pipe_4( dGdx, dHdG )
- pipe_5( dGdx, dHdG )
- pipe_6( dGdx, dHdG )
- pipe_7( dGdx, dHdG )
- pipe_8( dGdx, dHdG )
- pipe_9( dGdx, dHdG )
- shortName( )
- getNumberOfParameters( )
- numDerivative( xdata, param )
- numPartial( xdata, param )
- isDynamic( )
- hasPriors( isBound=True )
- setPrior( kpar, prior=None, **kwargs )
- getParameterName( kpar )
- getParameterUnit( kpar )
- getIntegralUnit( )
- setLimits( lowLimits=None, highLimits=None )
- getLimits( )
- hasLimits( fitindex=None )
- unit2Domain( uvalue, kpar=None )
- domain2Unit( dvalue, kpar=None )
- partialDomain2Unit( dvalue )
- nextPrior( )
- getLinearIndex( )
- testPartial( xdata, params, silent=True )
- strictNumericPartial( xdata, params, parlist=None )
- assignDF1( partial, i, dpi )
- assignDF2( partial, i, dpi )
- strictNumericDerivative( xdata, param )
Methods inherited from FixedModel |
---|
Methods inherited from BaseModel |
---|