# solarforecastarbiter.metrics.deterministic.constant_cost¶

solarforecastarbiter.metrics.deterministic.constant_cost(obs, fx, cost_params, error_fnc=<function error>)[source]

Compute cost using a constant cost value. The attributes cost, net, and aggregation are used from cost_params to perform the following calculation depending on (net, aggregation):

$\begin{split}\text{cost} = C * \begin{cases} 1/n \sum_{i=1}^n S(\text{obs}_i, \text{fx}_i) & \text{True, mean} \\ \sum_{i=1}^n S(\text{obs}_i, \text{fx}_i) & \text{True, sum} \\ 1/n \sum_{i=1}^n |S(\text{obs}_i, \text{fx}_i)| & \text{False, mean} \\ \sum_{i=1}^n |S(\text{obs}_i, \text{fx}_i)| & \text{False, sum} \end{cases}\end{split}$

where $$S$$ is the error function defined by error_fnc and $$C$$ is the cost.

Parameters: obs ((n,) array-like) – Observed values. fx ((n,) array-like) – Forecasted values. cost_params (solarforecastarbiter.datamodel.ConstantCost) – Parameters that the define the cost value along with how to aggregate the costs. error_fnc (function) – A function that returns the error, default fx - obs. First argument is obs, second argument is fx. cost (float) – The cost of the forecast errors.