The question about Turing likelihood

Hi, all. I am new to Julia, I am trying to fit an image model, I aim to minimize the model image and observed image:

minimize(sum(model_intensity - data_obs))

both model_intensity and data_obs are 2d-array.
I am not sure the following likelihood meets my requirement:

for i in eachindex(data_obs)
        data_obs[i] ~ Normal(model_intensity[i], sigma)
end

The problem with minimizing the sum is that it’s numerically the same as

minimize(sum(model_intensity) - sum(data_obs)) 

So you’re effectively collapsing each image down into a single scalar and then comparing those scalars, which is not very informative. You probably want to minimize the mean squared error (corresponds to a Normal likelihood) or mean absolute error (corresponds to a Laplace likelihood).

Thank you for your replay. Yes, I want to minimize the mean square error. Is the above formula correct?

Looks correct to me. MSE is the negative log-likelihood of a normal distribution with fixed variance. Your code says that each data_obs[i] is normally distributed with the expected value given by your model, which is correct.

(post deleted by author)