sample_parameters_uniformly#
- pharmpy.modeling.sample_parameters_uniformly(model, parameter_estimates, fraction=0.1, force_posdef_samples=None, n=1, seed=None, scale='normal')[source]#
Sample parameter vectors using uniform sampling
Each parameter value will be randomly sampled from a uniform distribution with the bounds being estimate ± estimate * fraction.
- Parameters:
model (Model) – Pharmpy model
parameter_estimates (pd.Series) – Parameter estimates for parameters to use
fraction (float) – Fraction of estimate value to use for distribution bounds
force_posdef_samples (int) – Number of samples to reject before forcing variability parameters to give positive definite covariance matrices.
n (int) – Number of samples
seed (int or rng) – Random number generator or seed
scale (str) – Scale to perform sampling on. Valid options are ‘normal’ and ‘UCP’
- Returns:
pd.DataFrame – samples
Example
>>> from pharmpy.modeling import create_rng, sample_parameters_uniformly, load_example_model >>> from pharmpy.tools import load_example_modelfit_results >>> model = load_example_model("pheno") >>> results = load_example_modelfit_results("pheno") >>> rng = create_rng(23) >>> pe = results.parameter_estimates >>> sample_parameters_uniformly(model, pe, n=3, seed=rng) POP_CL POP_VC COVAPGR IIV_CL IIV_VC SIGMA 0 0.004878 0.908216 0.149441 0.029179 0.025472 0.012947 1 0.004828 1.014444 0.149958 0.028853 0.027653 0.013348 2 0.004347 1.053837 0.165804 0.028465 0.026798 0.013727
See also
sample_parameters_from_covariance_matrix
Sample parameter vectors using the uncertainty covariance matrix
sample_individual_estimates
Sample individual estiates given their covariance