Skip to main content

estimate_effect_2

Function estimate_effect_2 

pub fn estimate_effect_2(u: f64, v: f64, alpha: f64, h1: f64, h2: f64) -> f64
Expand description

Computes the effect metric for a dual-site pharmacodynamic model.

The canonical equation solved by this function is

r(M) = 1 - u/M^h1 - v/M^h2
       - (alpha*u*v)/M^((h1+h2)/2)

The returned value is M / (1 + M). The interaction coefficient is calculated internally as w = alpha * u * v, matching the Drusano and mod120 model definitions. A finite negative alpha is valid and represents antagonism.

The first Nelder-Mead result is accepted only when its squared residual is at most 1e-10, matching the Fortran VALMIN threshold. Otherwise the historical FINDM0-style estimate seeds a second solve, and the candidate with the lower squared residual is selected. If no exact positive root exists, the historical behavior is retained: the best finite least-squares candidate is returned. Any optimizer failure is handled as a scalar fallback rather than a panic.

§Arguments

  • u - Coefficient for the first binding site.
  • v - Coefficient for the second binding site.
  • alpha - Finite interaction coefficient, including negative antagonistic values.
  • h1 - Positive finite exponent H1, the reciprocal of the first conventional Hill coefficient.
  • h2 - Positive finite exponent H2, the reciprocal of the second conventional Hill coefficient.

§Returns

The effect M / (1 + M). Two coefficients below 1e-5 return zero, as in the historical boundary condition, and exact zero coefficients use their closed-form single-site solution. Malformed inputs and cases without a meaningful finite scalar return NaN.

§Example

use pharmsol::estimate_effect_2;

// Single-site model: M = u^(1/h1) = 1.
let e2 = estimate_effect_2(1.0, 0.0, 0.5, 1.0, 2.0);
assert!((e2 - 0.5).abs() < 1e-10);

// Equal exponents have a closed-form combined coefficient.
let e2 = estimate_effect_2(1.0, 1.0, -0.5, 1.0, 1.0);
assert!((e2 - 0.6).abs() < 1e-6);