BatchMeanBatchCorrelation

class BatchMeanBatchCorrelation(X, Y, metrics='L2', startBatchSize=2, threshold=0.3, upperThreshold=0.6, fixedBatchSize=False, sortSample=True)

Estimate the variance of the mean for correlated data using the Batch Mean method.

This method partitions the sample into batches and adjusts the batch size to minimize correlation between batches, enabling consistent variance estimation.

Parameters:
XSample

Sample of positions (e.g., time or spatial coordinates) of shape (n_samples, n_dims).

YSample

Measurement sample of shape (n_samples, 1). Must be 1-dimensional.

metrics{“L1”, “L2”}, optional

Distance metric for sorting the sample. Default is “L2”.

startBatchSizeint, optional

Initial batch size. Default is 2.

thresholdfloat, optional

Lower threshold for the ratio S1/S0 (correlated vs. uncorrelated variance). If S1/S0 < threshold, the batch size is reduced. Default is 0.3.

upperThresholdfloat, optional

Upper threshold for S1/S0. If S1/S0 > upperThreshold, the batch size is increased. Default is 0.6.

fixedBatchSizebool, optional

If True, the batch size is fixed to startBatchSize and not optimized. Default is False.

sortSamplebool, optional

If True, the sample is sorted by distance before batching. Default is True.

Attributes:
resultBMBCResult

Result object containing batch statistics (available after calling run()).

sampleXsortedSample

Sorted positions (if sortSample=True).

sampleYsortedSample

Sorted measurements (if sortSample=True).

Methods

computeDistance(i, j)

Compute distance between point i and j according to specified norm.

computeS0S1(M)

Compute S0 and S1 for a given batch size.

getResult()

Accessor to BMBC result.

run()

Compute the optimal batch size and estimate the mean variance.

Notes

The method is based on the batch means approach for correlated data. The optimal batch size M is determined iteratively to satisfy: threshold <= S1/S0 <= upperThreshold, where S0 is the uncorrelated variance and S1 is the correlated variance.

__init__(X, Y, metrics='L2', startBatchSize=2, threshold=0.3, upperThreshold=0.6, fixedBatchSize=False, sortSample=True)
computeDistance(i, j)

Compute distance between point i and j according to specified norm.

Parameters:
iint

Index of point i.

jint

Index of point j.

Returns:
dfloat

Distance between points i and j.

computeS0S1(M)

Compute S0 and S1 for a given batch size.

Parameters:
Mint

Size of batch.

Returns:
S0float

Independent (uncorrelated) variance of mean estimator.

S1float

Correlated variance of mean estimator.

getResult()

Accessor to BMBC result.

Returns:
resultBMBCResult

Result object containing batch statistics.

run()

Compute the optimal batch size and estimate the mean variance.

Steps:

  1. If sortSample=True, sort the sample by distance.

  2. Iteratively adjust the batch size M until S1/S0 falls within [threshold, upperThreshold].

  3. Store results in result (including S0, S1, and batch sizes).

Returns:
None

Results are stored in result.