pm.HalfStudentT.dist() failing to give correct shape

Runing on PyMC v4.4.0

df_penguins=pd.read_csv(r'https://raw.githubusercontent.com/BayesianModelingandComputationInPython/BookCode_Edition1/main/data/penguins.csv')
df=df_penguins.dropna(how = 'any').reset_index(drop=True) #drop if any of the values in a row is missing

data=df_adelie.loc[:,'body_mass_g'].values

with pm.Model() as model_adelie_penguin_mass:
   
    μ = pm.Normal("μ", 4000, 3000)
    σ = pm.HalfStudentT("σ", nu=30, sigma=2000)
    #σ=pm.Exponential('σ', 1/30)+1
    y = pm.Normal("y", mu=μ, sigma=σ, observed=data) 
    idata = pm.sample(2000,chains=2) 
    idata.extend(pm.sample_prior_predictive())
    idata.extend(pm.sample_posterior_predictive(idata))
az.plot_posterior(idata.prior, var_names=["σ"]) # This plot gives a symmetric approx normal shape around "σ"=2000 for the prior.   The shape of the prior from idata.prior["σ"] should be approx. pymc.HalfStudentT shape, instead its approximately symmetric normal centred on 2000. Has the parameterization of the pymc.HalfStudentT in the latest version of PYMC changed in some way. 

I tried the following: rv = pm.HalfStudentT.dist(nu=10,sigma=20)

rv = pm.HalfStudentT.dist(nu=30,sigma=3000)
x = np.linspace(-1000, 7000, 50)
pdf = pm.logp(rv,x).exp().eval()

fig,ax=plt.subplots(1,1,figsize=(4 ,3),sharex=True)
plt.plot(x, pdf, label='Half-Student-t', lw=2)

which showed a graph of the correct shape but

rv = pm.HalfStudentT.dist(nu=10,sigma=5)
sns.histplot(pm.draw(rv,10000)) 

again did not give the pymc.HalfStudentT shape. It would be very helpful if anybody can spot the flaw in the parameterisation or in the way I am attempting to parameterize the HalfStudentT prior. the example is taken from ‘Bayesian Moddelling and Computation’ in python by Osvaldo Martin page69 but he is using pymc3. I also tried instead setting prior to : σ=pm.Exponential('σ', 1/30)+1 which worked perfectly but would very much like to know why σ = pm.HalfStudentT("σ", nu=30, sigma=2000) fails to give correct shape when plotted with az.plot_posterior(idata.prior, var_names=["σ"]). Thanking you in advance. Declan.

continued… σ=pm.HalfNormal(“σ”,2000,dims=‘species’) also works.

@Nn_Nnn Thanks for reporting, it seems there is a bug in how we generate random draws for the HalfStudentT distribution!

sigma should be passed by keyword as scale, otherwise it’s used for loc

Opened an issue here: Bug in `rng_fn` of `HalfStudentT` · Issue #6657 · pymc-devs/pymc · GitHub

Thank you Ricardo for taking the time to look at the puzzling code.
Runing on PyMC v4.4.0 Just to follow up: if I run the code for σ = pm.HalfStudentT(“σ”, nu=30,scale=2000) using 'scale as mentioned does not seem to work, it gives:-
error:TypeError: make_node() got an unexpected keyword argument ‘scale’ .
Also σ = pm.HalfNormal(“σ”,sigma=2000) seems to work.
I think I might be wise to avoid σ = pm.HalfStudentT(“σ”, nu=30,scale=2000) and just use pm.HalfNormal(“σ”,sigma=2000). I Am assuming its ok to parameterizing normal distribution with mu and sigma and half-normal with sigma. thanks again for helping with these challenging puzzles. declan

Yes, unfortunately you can’t pass scale to the PyMC distribution yourself, we need to fix it in the codebase.

Thanks delan