Skip to contents

Generate per-year multiplicative noise factors for stage capacity (K) values, from the cv columns of a habitat capacity file.

Usage

build_stage_k_noise(stage_k_cv = NULL, spawner_k_cv = 0, Nyears = 100)

Arguments

stage_k_cv

Numeric vector of cv values aligned with stage_k_override: position 1 is the fry flow cap (K0), positions 2 onward are stage 1..Nstage. Use the ret_stage_k_cv element returned by build_k_for_proj_dd(). NULL/NA entries are treated as 0.

spawner_k_cv

Numeric. cv for the total spawner capacity (k_stage_B_cv column); default 0.

Nyears

Numeric. Number of projection years (rows of the matrix).

Value

A matrix with Nyears rows and length(stage_k_cv) + 1 columns (K0, stage 1..Nstage, total spawner capacity), or NULL when all cv values are 0.

Details

Each capacity constraint with a cv > 0 gets an independent draw for every projection year from a normal distribution with mean 1 and standard deviation cv, clamped at zero (draws can never produce a negative capacity). Capacities with cv 0/NA keep a constant factor of 1 and consume no random numbers. Returns NULL when every cv is 0/NA, so runs without capacity uncertainty are bit-identical to runs before this feature existed.

PopulationModel_Run() calls this once per batch replicate and passes the same matrix to the CE and baseline projections of that replicate, so the pair sees identical capacity trajectories (common random numbers). Direct users of Projection_DD() can call it themselves and supply the result via the stage_k_noise argument.