I am trying to port the attached equation into Matlab Mupad.
I have attempted the following Mupad language code:
xbar = stats::mean(x)
xSumTerm := x -> _plus(x - xbar $ i=1..(nops(x)-1));
sum((x-xbar)^2,x=0..m-1)
Error: The operand is invalid. [_plus]
I am trying to figure out what the proper Mupad code should be to interpret this equation. It is even more confusing with this selector at the end. The selector was described as
δ () is a selector, i.e. δ () 1 x = if x>0, else δ () 0 x = ;
In the sum, you should vary the index i
rather than the variable x
itself that depends on the index:
xbar := Symbol::accentOverBar(x):
`σ_+^2`(n) := sum((x[n-i]-xbar[n-i])^2 * `δ`(x[n-i]-xbar[n-i]), i=0..m-1):
hold(`σ_+^2`(n)) =`σ_+^2`(n)