Really slow when creating and indexing RVs

The model is quite simple. The n_subject equalls 200, which means the shape of alpha is 200.
It take seconds to create this variable, and seconds to run subject_alpha = alpha[idx]. But to run mcmc this operation has to run for every data item and every sample which makes the time too long. I’m not sure if this time consumption is normal.

I have updated pymc to the latest version and i’m running on a 32core 256G red hat computer.

Thanks for help

with pm.Model() as model:

    # top level proirs

    alpha_alpha = pm.HalfNormal(sigma=1, name='alpha_alpha')

    alpha_beta = pm.HalfNormal(sigma=1, name='alpha_beta')


    # subject level proirs

    alpha = pm.Beta(alpha=alpha_alpha, beta=alpha_beta,

                    shape=n_subjects, name='alpha')




    for subject_data in subject_data_list:


        subject_alpha = alpha[idx]

Hi,
Yeah I guess it’s because of the for loop. You should try to get rid of it by vectorizing subject_alpha, as you started to do.
Hope this helps :vulcan_salute: