average_integrand

View page source

Compute The Average Integrand

Syntax

# avg =
def average_integrand(rate_fun, integrand_name, grid, abs_tol) :
   assert type(rate_fun) == dict
   assert type(integrand_name) == str
   assert type(grid) == dict
   assert type(abs_tol) == float
   assert type(avg) == float
   return avg

Purpose

The predict_command is a much faster way to calculate these values. This routine is easier to use and provides independent testing of the dismod_at integrators.

rate_fun

This is a dictionary and it’s possible keys are the rate names . If a key is a key in the dictionary,

value = rate_fun [ key ]( age , time )

returns a float equal to the value of the specified rate at the specified age and time (where age and time are floats). Note that age will always be zero when evaluating

value = rate_fun [ 'pini' ]( age , time )

If a rate name is not in the rate_fun, the corresponding rate is zero.

integrand_name

This string is one of the integrand names .

grid

This argument defines the grid for trapezoidal integration. (The dismod_at integrands are often non-smooth and so a low order integration method is called for.) The grid is a dictionary with the following keys:

age

grid [ 'age' ] is a list of floats containing the grid points for the average w.r.t. age. These points are monotone increasing, the first (last) point is the lower (upper) age limit for the average

time

grid [ 'time' ] is a list of floats containing the grid points for the average w.r.t. time. These points are monotone increasing, the first (last) point is the lower (upper) time limit for the average

abs_tol

This float is an absolute error bound, that the integrator will achieve.

avg

The return value avg is the corresponding average integrand .

Example

The file user_average_integrand.py contains an example and test of this routine.