Struct SDE
pub struct SDE { /* private fields */ }Expand description
Stochastic Differential Equation solver for pharmacometric models.
This struct represents a stochastic differential equation system and provides methods to simulate particles and estimate likelihood for PKPD modeling.
SDE models introduce stochasticity into the system dynamics, allowing for more realistic modeling of biological variability and uncertainty.
Implementations§
§impl SDE
impl SDE
pub fn new(
drift: fn(&NalgebraVec<f64>, &NalgebraVec<f64>, f64, &mut NalgebraVec<f64>, &NalgebraVec<f64>, &Covariates),
diffusion: fn(&NalgebraVec<f64>, &mut NalgebraVec<f64>),
lag: fn(&NalgebraVec<f64>, f64, &Covariates) -> HashMap<usize, f64>,
fa: fn(&NalgebraVec<f64>, f64, &Covariates) -> HashMap<usize, f64>,
init: fn(&NalgebraVec<f64>, f64, &Covariates, &mut NalgebraVec<f64>),
out: fn(&NalgebraVec<f64>, &NalgebraVec<f64>, f64, &Covariates, &mut NalgebraVec<f64>),
nparticles: usize,
) -> SDE
pub fn new( drift: fn(&NalgebraVec<f64>, &NalgebraVec<f64>, f64, &mut NalgebraVec<f64>, &NalgebraVec<f64>, &Covariates), diffusion: fn(&NalgebraVec<f64>, &mut NalgebraVec<f64>), lag: fn(&NalgebraVec<f64>, f64, &Covariates) -> HashMap<usize, f64>, fa: fn(&NalgebraVec<f64>, f64, &Covariates) -> HashMap<usize, f64>, init: fn(&NalgebraVec<f64>, f64, &Covariates, &mut NalgebraVec<f64>), out: fn(&NalgebraVec<f64>, &NalgebraVec<f64>, f64, &Covariates, &mut NalgebraVec<f64>), nparticles: usize, ) -> SDE
Creates a new stochastic differential equation solver with default Neqs.
Use builder methods to configure dimensions:
SDE::new(drift, diffusion, lag, fa, init, out, nparticles)
.with_nstates(2)
.with_ndrugs(1)
.with_nout(1)pub fn with_nstates(self, nstates: usize) -> SDE
pub fn with_nstates(self, nstates: usize) -> SDE
Set the number of state variables.
pub fn with_ndrugs(self, ndrugs: usize) -> SDE
pub fn with_ndrugs(self, ndrugs: usize) -> SDE
Set the number of drug inputs (size of bolus[] and rateiv[]).
pub fn with_metadata(
self,
metadata: ModelMetadata,
) -> Result<SDE, SdeMetadataError>
pub fn with_metadata( self, metadata: ModelMetadata, ) -> Result<SDE, SdeMetadataError>
Attach validated handwritten-model metadata to this SDE model.
pub fn metadata(&self) -> Option<&ValidatedModelMetadata>
pub fn metadata(&self) -> Option<&ValidatedModelMetadata>
Access the validated metadata attached to this SDE model, if any.
pub fn parameter_index(&self, name: &str) -> Option<usize>
pub fn covariate_index(&self, name: &str) -> Option<usize>
pub fn state_index(&self, name: &str) -> Option<usize>
Trait Implementations§
§impl Cache for SDE
impl Cache for SDE
§fn with_cache_capacity(self, size: usize) -> SDE
fn with_cache_capacity(self, size: usize) -> SDE
§fn enable_cache(self) -> SDE
fn enable_cache(self) -> SDE
§fn clear_cache(&self)
fn clear_cache(&self)
§fn disable_cache(self) -> SDE
fn disable_cache(self) -> SDE
Source§impl DiffusionOptimize for SDE
impl DiffusionOptimize for SDE
Source§fn optimize_diffusion(
&self,
data: &Data,
theta: &mut Theta,
sigma_params: &[String],
error_models: &AssayErrorModels,
posterior: Option<&Posterior>,
config: DiffusionConfig,
) -> Result<DiffusionResult>
fn optimize_diffusion( &self, data: &Data, theta: &mut Theta, sigma_params: &[String], error_models: &AssayErrorModels, posterior: Option<&Posterior>, config: DiffusionConfig, ) -> Result<DiffusionResult>
§impl Equation for SDE
impl Equation for SDE
§fn estimate_likelihood(
&self,
subject: &Subject,
parameters: &Parameters,
error_models: &AssayErrorModels,
) -> Result<f64, PharmsolError>
👎Deprecated since 0.23.0: Use estimate_log_likelihood() instead for better numerical stability
fn estimate_likelihood( &self, subject: &Subject, parameters: &Parameters, error_models: &AssayErrorModels, ) -> Result<f64, PharmsolError>
Use estimate_log_likelihood() instead for better numerical stability
Estimates the likelihood of observed data given a model and parameters.
§Arguments
subject- Subject data containing observationsparameters- Parameter vector for the modelerror_model- Error model to use for likelihood calculations
§Returns
The log-likelihood of the observed data given the model and parameters.
§fn estimate_log_likelihood(
&self,
subject: &Subject,
parameters: &Parameters,
error_models: &AssayErrorModels,
) -> Result<f64, PharmsolError>
fn estimate_log_likelihood( &self, subject: &Subject, parameters: &Parameters, error_models: &AssayErrorModels, ) -> Result<f64, PharmsolError>
fn kind() -> EqnKind
§fn estimate_predictions(
&self,
subject: &Subject,
parameters: &Parameters,
) -> Result<Self::P, PharmsolError>
fn estimate_predictions( &self, subject: &Subject, parameters: &Parameters, ) -> Result<Self::P, PharmsolError>
§fn simulate_subject(
&self,
subject: &Subject,
parameters: &Parameters,
error_models: Option<&AssayErrorModels>,
) -> Result<(Self::P, Option<f64>), PharmsolError>
fn simulate_subject( &self, subject: &Subject, parameters: &Parameters, error_models: Option<&AssayErrorModels>, ) -> Result<(Self::P, Option<f64>), PharmsolError>
Source§impl EquationMetadataSource for SDE
impl EquationMetadataSource for SDE
fn equation_metadata(&self) -> Option<&ValidatedModelMetadata>
Auto Trait Implementations§
impl Freeze for SDE
impl !RefUnwindSafe for SDE
impl Send for SDE
impl Sync for SDE
impl Unpin for SDE
impl UnsafeUnpin for SDE
impl !UnwindSafe for SDE
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,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.