cubie.outputhandling.summarymetrics.mean
Mean value summary metric for CUDA-accelerated batch integration.
This module implements a summary metric that calculates the arithmetic mean of values encountered during integration for each variable.
Classes
|
Summary metric to calculate the arithmetic mean of a variable. |
- class cubie.outputhandling.summarymetrics.mean.Mean[source]
Bases:
SummaryMetric
Summary metric to calculate the arithmetic mean of a variable.
This metric computes the mean value over a summary period by maintaining a running sum in the buffer and dividing by the number of samples when saving the final result.
Notes
The metric uses a single buffer slot per variable to accumulate the sum of values. The mean is calculated by dividing this sum by the number of integration steps in the summary period.
- CUDA_factory()[source]
Generate CUDA device functions for mean value calculation.
Creates optimized CUDA device functions with fixed signatures for updating running sums and calculating final mean values.
- Returns:
Tuple containing (update_function, save_function) for CUDA execution.
- Return type:
tuple[callable, callable]
Notes
The generated functions have the following signatures:
- update(value, buffer, current_index, customisable_variable):
Adds the new value to the running sum.
- save(buffer, output_array, summarise_every, customisable_variable):
Calculates mean by dividing sum by number of steps and resets buffer.
- __init__()[source]
Initialize the Mean summary metric.
Creates CUDA device functions for updating running sums and calculating mean values, and configures the metric with appropriate buffer and output sizes.
- save_device_func: Callable
- update_device_func: Callable