I know this can be transformed into ChiSquared dist analytically.
But we still will encounter more complicated and non-linear function (maybe deep nerual network!!) involving many different random variables. The complication make it impossible to design a custom DensityDist.
Is there any way to model a likelihood automatically?
If your complicated likelihood function is still relatively simple (mostly chained invertible functions), PyMC can figure it for you automatically. Otherwise you’ll have to step in.
But to take a step back, many times you don’t really need it. You can define an arbitrarily complex function for the mean / standard deviation and then assume a normal likelihood (or some other simple form) around this. Whether this is appropriate depends on your problem obviously.