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:
- X
Sample Sample of positions (e.g., time or spatial coordinates) of shape (n_samples, n_dims).
- Y
Sample 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). IfS1/S0 < threshold, the batch size is reduced. Default is 0.3.- upperThresholdfloat, optional
Upper threshold for
S1/S0. IfS1/S0 > upperThreshold, the batch size is increased. Default is 0.6.- fixedBatchSizebool, optional
If True, the batch size is fixed to
startBatchSizeand not optimized. Default is False.- sortSamplebool, optional
If True, the sample is sorted by distance before batching. Default is True.
- X
- Attributes:
- result
BMBCResult Result object containing batch statistics (available after calling
run()).- sampleXsorted
Sample Sorted positions (if
sortSample=True).- sampleYsorted
Sample Sorted measurements (if
sortSample=True).
- result
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.
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
Mis determined iteratively to satisfy:threshold <= S1/S0 <= upperThreshold, whereS0is the uncorrelated variance andS1is 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:
- result
BMBCResult Result object containing batch statistics.
- result
- run()¶
Compute the optimal batch size and estimate the mean variance.
Steps:
If
sortSample=True, sort the sample by distance.Iteratively adjust the batch size
MuntilS1/S0falls within [threshold,upperThreshold].Store results in
result(includingS0,S1, and batch sizes).
- Returns:
- None
Results are stored in
result.
otExperimentalMeasurement