Skip to content

functions

Functions:

Name Description
ce_func

Calculate CRRA function

mean_func

Calculate a mean

dscim.utils.functions.ce_func

ce_func(consumption, dims, eta)

Calculate CRRA function

Source code in src/dscim/utils/functions.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
def ce_func(consumption, dims, eta):
    """Calculate CRRA function"""
    # use log utility when eta is 1
    if eta == 1:
        return np.exp(np.log(consumption).mean(dims))
    # CRRA utility otherwise
    else:
        return power(
            (power(consumption, (1 - eta)) / (1 - eta)).mean(dims) * (1 - eta),
            (1 / (1 - eta)),
        )

dscim.utils.functions.mean_func

mean_func(consumption, dims)

Calculate a mean

Source code in src/dscim/utils/functions.py
18
19
20
def mean_func(consumption, dims):
    """Calculate a mean"""
    return consumption.mean(dims)