Goal
Modernize jax.random.PRNGKey(...) to jax.random.key(...) across the lecture series.
Background
random.PRNGKey is the legacy key constructor (returns a raw uint32[2] array). JAX now recommends random.key, which returns a typed key (dtype=key<...>). PRNGKey is not formally deprecated yet (no warning as of JAX 0.8.0), so this is forward-looking cleanup rather than a fix — but doing it now avoids churn when JAX eventually deprecates the legacy API.
Verified while rewriting bayes_nonconj.md (#913) that NumPyro accepts the typed key throughout (MCMC, SVI, sample_posterior), and the lecture runs end-to-end with it. bayes_nonconj.md already uses random.key.
Scope
Files still using PRNGKey (grep -rl "PRNGKey" lectures/*.md):
Notes
Goal
Modernize
jax.random.PRNGKey(...)tojax.random.key(...)across the lecture series.Background
random.PRNGKeyis the legacy key constructor (returns a rawuint32[2]array). JAX now recommendsrandom.key, which returns a typed key (dtype=key<...>).PRNGKeyis not formally deprecated yet (no warning as of JAX 0.8.0), so this is forward-looking cleanup rather than a fix — but doing it now avoids churn when JAX eventually deprecates the legacy API.Verified while rewriting
bayes_nonconj.md(#913) that NumPyro accepts the typed key throughout (MCMC, SVI,sample_posterior), and the lecture runs end-to-end with it.bayes_nonconj.mdalready usesrandom.key.Scope
Files still using
PRNGKey(grep -rl "PRNGKey" lectures/*.md):lectures/ar1_bayes.mdlectures/mix_model.mdlectures/aiyagari_egm.mdlectures/back_prop.mdlectures/ifp_advanced.mdlectures/ifp_egm.mdlectures/ifp_egm_transient_shocks.mdlectures/lake_model.mdlectures/mccall_model.mdlectures/mccall_model_with_sep_markov.mdlectures/mccall_fitted_vfi.mdlectures/mccall_persist_trans.mdlectures/mccall_persist_trans.mdlectures/os_egm_jax.mdlectures/newton_method.mdNotes
ar1_bayes,mix_model) and plain-JAX lectures (the rest);random.keyis the right call in both cases.random.PRNGKey(->random.key(), plus any prose references), but each lecture should be re-executed to confirm nothing downstream relies on the rawuint32[2]representation of a key.unemployment_bayes[unemployment_bayes] New lecture: Bayesian estimation of nonlinear unemployment dynamics #910,population_ssm[population_ssm] New lecture: Bayesian state-space models (linear filtering to nonlinear population dynamics) #911) will userandom.keyfrom the start.