cubie.outputhandling.summarymetrics.rms

Root Mean Square (RMS) summary metric for CUDA-accelerated batch integration.

This module implements a summary metric that calculates the root mean square of values encountered during integration for each variable.

Classes

RMS()

Summary metric to calculate the root mean square (RMS) of a variable.

class cubie.outputhandling.summarymetrics.rms.RMS[source]

Bases: SummaryMetric

Summary metric to calculate the root mean square (RMS) of a variable.

This metric computes the RMS value over a summary period by maintaining a running sum of squares in the buffer and calculating the square root of the mean when saving the final result.

Notes

The metric uses a single buffer slot per variable to accumulate the sum of squared values. The RMS is calculated as sqrt(sum_of_squares / n_samples).

CUDA_factory()[source]

Generate CUDA device functions for RMS value calculation.

Creates optimized CUDA device functions with fixed signatures for updating running sums of squares and calculating final RMS 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 square of the new value to the running sum.

save(buffer, output_array, summarise_every, customisable_variable):

Calculates RMS by taking square root of mean of squares and resets buffer.

__init__()[source]

Initialize the RMS summary metric.

Creates CUDA device functions for updating running sums of squares and calculating RMS values, and configures the metric with appropriate buffer and output sizes.

buffer_size: int | Callable
input_variable: dict[str, int] | None
name: str
output_size: int | Callable
save_device_func: Callable
update_device_func: Callable