bartz.testing.gen_params¶
- bartz.testing.gen_params(key, *, p, k, q, lambda_=None, sigma2_lin, sigma2_quad, sigma2_eps, offset=0.0, x_distr=Uniform(), beta_distr=DiscreteUniform(m=2), A_distr=DiscreteUniform(m=2), gamma_distr=DiscreteUniform(m=2), error_distr=Normal(), s_distr=Constant(), outcome_type='continuous', het_strength=None, het_shape=None, error_corr=None)[source]¶
Sample DGP coefficients and parameters (no dependence on
n).See
Paramsfor the meaning of every parameter and the generative model they parametrize.- Parameters:
key (
Key[Array, '']) – JAX random key.p (
int) – Number of predictors.k (
int|None) – Number of outcome components. IfNone, generate a univariate DGP and skip the separate code path:partition,beta_separate,A_separateandlambda_are all set toNoneon the returnedParams, and only the shared coefficients are drawn.lambda_ (
Float[Array, '']|float|None, default:None) – Coupling parameter; must beNoneiffk is None. SeeParams.sigma2_lin (
Float[Array, '']|float)sigma2_quad (
Float[Array, '']|float)sigma2_eps (
Float[Array, '']|float)offset (
Float[Array, '']|Float[Array, 'k']|float, default:0.0) – SeeParams.x_distr (
Distr, default:Uniform()) – Distribution family of the predictors (defaultUniform). Binary predictors (DiscreteUniformwithm=2, kurtosis 1) requireq >= 2because their squares are constant.beta_distr (
Distr, default:DiscreteUniform(m=2))A_distr (
Distr, default:DiscreteUniform(m=2)) – Families of the linear and quadratic coefficient draws. The default random signs (DiscreteUniformwithm=2) give every predictor exactly its share of the variance budgets, so with the defaultConstantscales all predictors are equally important.gamma_distr (
Distr, default:DiscreteUniform(m=2)) – Family of the noise projection draws; its kurtosis entersvar_v.error_distr (
Distr, default:Normal()) – Marginal family of the additive errors (defaultNormal), realized through theerror_corrGaussian copula. Any standardized family keeps the error variance atsigma2_eps; non-Normal families attenuate the realized error correlation relative toerror_corr. SeeParams.s_distr (
ScaleDistr, default:Constant()) – Scale family of the per-predictor importance scaless(e.g.GammaorSpikeSlab); more dispersed scales make the dependence on the predictors sparser.Constant(default) gives uniform importance. UseScaleDistr.from_peffto set the dispersion via an effective number of active predictors instead of the raw family parameter.outcome_type (
OutcomeType|str|tuple[OutcomeType|str,...], default:'continuous') –'continuous','binary', anOutcomeType, or a tuple of lengthkfor mixed outcomes. Tuples with all elements equal are collapsed to the scalar form. Tuples are not allowed whenk is None. SeeParamsfor the semantics.het_strength (
Float[Array, '']|float|None, default:None) – Heteroskedasticity knobrhoin[0, 1](0 homoskedastic, 1 maximally heterogeneous); must beNoneiffhet_shape is None. SeeParams.het_shape (
Literal['scalar','vector'] |None, default:None) – Heteroskedasticity mode:None(homoskedastic),'scalar'(oneerror_scaleper datapoint, scaling the whole outcome vector), or'vector'(per-component scales, multivariate only). SeeParams.error_corr (
Float[Array, 'k k']|None, default:None) – Across-component error correlation. A symmetric positive-definite matrix of shape(k, k), normalized to unit diagonal before use (only its correlation structure matters; the noise scale issigma2_eps).None(default) gives independent errors. Multivariate only. SeeParams.
- Returns:
Params– AParamswith the sampled coefficients and forwarded hyperparameters.- Raises:
ValueError – If
outcome_typeis a tuple whose length does not matchk, or if a tupleoutcome_typeis combined withk=None, or if(lambda_ is None) != (k is None), or if(het_strength is None) != (het_shape is None), or ifhet_shape='vector'is combined withk=None, or if a vectoroffsetis combined withk=Noneor has a length other thank, or iferror_corris combined withk=Noneor does not have shape(k, k).