How to change the diagonal value of matrix

Hi all. Could anyone tell me how to change the diagonal value to 1 for a deterministic matrix (pm.Deterministic)?

Basically I wish to implement formula like this:

The alpha matrix I constructed:

alpha_matrix = pm.Deterministic("alpha_matrix", C * pm.math.exp( (-1/2) * ((delta_t_matrix - mu_)/sigma_)**2 ) )

If I==j then I should set the value to 1. How to do that in pymc?

You need to use aesara.tensor.set_subtensor Basic Tensor Functionality — Aesara 2.8.6+6.gec82b9f7a.dirty documentation

1 Like