I want to define a loglikelihood function to perform a fit of some data points to a function, like the following, but using the native LogLikelihood[] function.
$ likelihood=\sum_{i}(Log{(\frac{1}{\sqrt{2*\pi*}*\sigma_i}\cdot e^{-\frac{(y_i-f(x_i))^2}{2\sigma_i^2}})}) $
where the function f depends also on the parameters I want to estimate by maximization.
If the $\sigma_i$ are constant I can create the loglikelihood in this way (e.g. using $\sigma=0.2$):
likelihood = LogLikelihood[NormalDistribution[0, 0.2], ydata - f[xdata]];
But if the $\sigma_i$ of the normal distribution are given by the experimental data, they can be different for each data point and I don't if it is possible to set a different distribution parameter for each data point
Obviously, creating the LogL "by hand" with the explicit PDF expression works perfectly, but I saw that if the LogL function is defined using the native function of Mathematica, the computation time is much lower, so I'd like to know if there is a way to solve this issue.
Thanks