I was wondering if the following is possible using anonymous functions. I am fairly new to them and this is not for a class - just FYI.
Let N >= 2 specify the number of mixture components I would like to build into my anonymous function. Let's say I want each component to be a Normal Distribution. I have three vectors for their weights (w), means (m), and standard deviations (s).
If N = 2 then the anonymous function would look like:
fun = @(x) w(1)/(s(1) *sqrt(2*pi))*exp(-(x-m(1))^2/(2*s(1)^2)) + w(2)/(s(2) *sqrt(2*pi))*exp(-(x-m(2))^2/(2*s(2)^2));
This becomes exceedingly arduous as N grows. It would be preferable to be able to define this function generically so it does not have to get written out.
Is this possible? From research the literature I am only finding examples where the author "hard coded" the function.
However, I could be searching for it incorrectly or missing a specific term.
Any insights would be greatly appreciated.