Initial Implementation

This commit is contained in:
Manuel Raimann
2026-01-30 17:24:56 +01:00
parent 164aafc209
commit 4db6e56466
14 changed files with 4860 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
//! Parameter distribution types.
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Distribution for floating-point parameters.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct FloatDistribution {
/// Lower bound (inclusive).
pub low: f64,
/// Upper bound (inclusive).
pub high: f64,
/// Whether to sample in log space.
pub log_scale: bool,
/// Optional step size for discretization.
pub step: Option<f64>,
}
/// Distribution for integer parameters.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct IntDistribution {
/// Lower bound (inclusive).
pub low: i64,
/// Upper bound (inclusive).
pub high: i64,
/// Whether to sample in log space.
pub log_scale: bool,
/// Optional step size for discretization.
pub step: Option<i64>,
}
/// Distribution for categorical parameters.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct CategoricalDistribution {
/// Number of choices available.
pub n_choices: usize,
}
/// Enum wrapping all parameter distribution types.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum Distribution {
/// A floating-point distribution.
Float(FloatDistribution),
/// An integer distribution.
Int(IntDistribution),
/// A categorical distribution.
Categorical(CategoricalDistribution),
}