I'm unsure whether I "translated" the math correctly into the code. I can't seem to make sense of the summation sign here. I know the values of x, but does the math say "sum of x from index 1 to whatever t I'm at?
sum(x(1:t))
Here's what I've come up with instead. Obviously the summation is missing.
posterior = [posterior; exp((2/sigma^2) .* x(t))]; % This part
end
plot(posterior);
Could someone please have a look and direct me to some existing forum, but please not to https://se.mathworks.com/help/matlab/ref/sum.html because this doesn't help me translating the math to code.
First of all, you have to pay attention to the fact that there is no equality in the relation you presented, but rather a proportionality. Meaning that the posterior is given by this relation up to a nonzero constant. Now, imagine that you have a random variable , the posterior at t is given by summing the values from to , where , multiplying the result by a constant then taking e to the power of the result. Obviously, some constraints should be imposed on the definition of X such that p becomes a proper probability function.
Assuming that you have defined X, T, and sigma properly in your code, you can use this to compute the posterior
p = arrayfun(@(t) exp(sum(X(t:T))*2./sigma^2), t);
Thanks for a proper answer. The key thing I didn't understand, which I do now given your explanation, was that the posterior is given by the summing of vector x from x1 to xT. So my code simply needed this change:
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Translated by
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.