pub struct Calibration {Show 20 fields
pub sigma_rate: Matrix9,
pub block_length: usize,
pub sigma_t: f64,
pub l_r: Matrix9,
pub prior_cov_marginal: Matrix9,
pub theta_ns: f64,
pub calibration_samples: usize,
pub discrete_mode: bool,
pub mde_ns: f64,
pub calibration_snapshot: CalibrationSnapshot,
pub timer_resolution_ns: f64,
pub samples_per_second: f64,
pub c_floor: f64,
pub projection_mismatch_thresh: f64,
pub theta_tick: f64,
pub theta_eff: f64,
pub theta_floor_initial: f64,
pub rng_seed: u64,
pub batch_k: u32,
pub preflight_result: PreflightResult,
}Expand description
Calibration results from the initial measurement phase (no_std compatible).
This struct contains the essential statistical data needed for the adaptive sampling loop. It is designed for use in no_std environments like SGX enclaves.
For full calibration with preflight checks, see tacet::Calibration.
§Student’s t Prior (v5.4+)
The prior is a Student’s t distribution with ν=4 degrees of freedom: δ ~ t_ν(0, σ_t²R)
This is implemented via scale mixture: λ ~ Gamma(ν/2, ν/2), δ|λ ~ N(0, (σ_t²/λ)R). The marginal variance is (ν/(ν-2)) σ_t² R = 2σ_t² R for ν=4.
Fields§
§sigma_rate: Matrix9Covariance “rate” - multiply by 1/n to get Sigma_n for n samples. Computed as Sigma_cal * n_cal where Sigma_cal is calibration covariance. This allows O(1) covariance scaling as samples accumulate.
block_length: usizeBlock length from Politis-White algorithm. Used for block bootstrap to preserve autocorrelation structure.
sigma_t: f64Calibrated Student’s t prior scale (v5.4). This is the σ in δ|λ ~ N(0, (σ²/λ)R).
l_r: Matrix9Cholesky factor L_R of correlation matrix R. Used for Gibbs sampling: δ = (σ/√λ) L_R z.
prior_cov_marginal: Matrix9Marginal prior covariance: 2σ²R (for ν=4). This is the unconditional prior variance of δ under the t-prior.
theta_ns: f64The theta threshold being used (in nanoseconds).
calibration_samples: usizeNumber of calibration samples collected per class.
discrete_mode: boolWhether discrete mode is active (< 10% unique values). When true, use mid-quantile estimators and m-out-of-n bootstrap.
mde_ns: f64Minimum detectable effect in nanoseconds.
calibration_snapshot: CalibrationSnapshotStatistics snapshot from calibration phase for drift detection.
timer_resolution_ns: f64Timer resolution in nanoseconds.
samples_per_second: f64Measured throughput for time estimation (samples per second). The caller is responsible for measuring this during calibration.
c_floor: f64Floor-rate constant. Computed once at calibration: 95th percentile of max_k|Z_k| where Z ~ N(0, Σ_rate). Used for analytical theta_floor computation: theta_floor_stat(n) = c_floor / sqrt(n).
projection_mismatch_thresh: f64Projection mismatch threshold. 99th percentile of bootstrap Q_proj distribution.
theta_tick: f64Timer resolution floor component. theta_tick = (1 tick in ns) / K where K is the batch size.
theta_eff: f64Effective threshold for this run. theta_eff = max(theta_user, theta_floor) or just theta_floor in research mode.
theta_floor_initial: f64Initial measurement floor at calibration time.
rng_seed: u64Deterministic RNG seed used for this run.
batch_k: u32Batch size K for adaptive batching. When K > 1, samples contain K iterations worth of timing. Effect estimates must be divided by K to report per-call differences.
preflight_result: PreflightResultResults of core preflight checks run during calibration (no_std compatible).
Platform-specific checks (like system configuration) are handled by the
tacet crate’s wrapper.
Implementations§
Source§impl Calibration
impl Calibration
Sourcepub fn new(
sigma_rate: Matrix9,
block_length: usize,
sigma_t: f64,
l_r: Matrix9,
theta_ns: f64,
calibration_samples: usize,
discrete_mode: bool,
mde_ns: f64,
calibration_snapshot: CalibrationSnapshot,
timer_resolution_ns: f64,
samples_per_second: f64,
c_floor: f64,
projection_mismatch_thresh: f64,
theta_tick: f64,
theta_eff: f64,
theta_floor_initial: f64,
rng_seed: u64,
batch_k: u32,
) -> Self
pub fn new( sigma_rate: Matrix9, block_length: usize, sigma_t: f64, l_r: Matrix9, theta_ns: f64, calibration_samples: usize, discrete_mode: bool, mde_ns: f64, calibration_snapshot: CalibrationSnapshot, timer_resolution_ns: f64, samples_per_second: f64, c_floor: f64, projection_mismatch_thresh: f64, theta_tick: f64, theta_eff: f64, theta_floor_initial: f64, rng_seed: u64, batch_k: u32, ) -> Self
Create a new Calibration with v5.4+ Student’s t prior.
Sourcepub fn with_preflight(
sigma_rate: Matrix9,
block_length: usize,
sigma_t: f64,
l_r: Matrix9,
theta_ns: f64,
calibration_samples: usize,
discrete_mode: bool,
mde_ns: f64,
calibration_snapshot: CalibrationSnapshot,
timer_resolution_ns: f64,
samples_per_second: f64,
c_floor: f64,
projection_mismatch_thresh: f64,
theta_tick: f64,
theta_eff: f64,
theta_floor_initial: f64,
rng_seed: u64,
batch_k: u32,
preflight_result: PreflightResult,
) -> Self
pub fn with_preflight( sigma_rate: Matrix9, block_length: usize, sigma_t: f64, l_r: Matrix9, theta_ns: f64, calibration_samples: usize, discrete_mode: bool, mde_ns: f64, calibration_snapshot: CalibrationSnapshot, timer_resolution_ns: f64, samples_per_second: f64, c_floor: f64, projection_mismatch_thresh: f64, theta_tick: f64, theta_eff: f64, theta_floor_initial: f64, rng_seed: u64, batch_k: u32, preflight_result: PreflightResult, ) -> Self
Create a new Calibration with all fields including preflight results.
Sourcepub fn n_eff(&self, n: usize) -> usize
pub fn n_eff(&self, n: usize) -> usize
Compute effective sample size accounting for dependence (spec §3.3.2 v5.6).
Under strong temporal dependence, n samples do not provide n independent observations. The effective sample size approximates the number of effectively independent blocks.
n_eff = max(1, floor(n / block_length))
where block_length is the estimated dependence length from Politis-White selector.
Sourcepub fn covariance_for_n(&self, n: usize) -> Matrix9
pub fn covariance_for_n(&self, n: usize) -> Matrix9
Scale sigma_rate to get covariance for n samples using effective sample size (v5.6).
Σ_n = Σ_rate / n_eff
where n_eff = max(1, floor(n / block_length)) to correctly account for reduced information under temporal dependence.
Sourcepub fn covariance_for_n_raw(&self, n: usize) -> Matrix9
pub fn covariance_for_n_raw(&self, n: usize) -> Matrix9
Scale sigma_rate to get covariance using raw n samples (ignoring dependence).
Σ_n = Σ_rate / n
Use this only when you need the raw scaling without n_eff correction.
Sourcepub fn estimate_collection_time_secs(&self, n: usize) -> f64
pub fn estimate_collection_time_secs(&self, n: usize) -> f64
Estimate time to collect n additional samples based on calibration throughput.
Returns estimated seconds. Caller should add any overhead.
Sourcepub fn to_summary(&self) -> CalibrationSummary
pub fn to_summary(&self) -> CalibrationSummary
Convert to an FFI-friendly summary containing only scalar fields.
Trait Implementations§
Source§impl Clone for Calibration
impl Clone for Calibration
Source§fn clone(&self) -> Calibration
fn clone(&self) -> Calibration
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Calibration
impl RefUnwindSafe for Calibration
impl Send for Calibration
impl Sync for Calibration
impl Unpin for Calibration
impl UnwindSafe for Calibration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.