How do I differentiate and evaluate in Matlab?

294 views Asked by At

I need to differentiate exp((s^2*sigma^2)/2 + mu*s) and evaluate it to s=0.

Anyone can provide advice on the syntax or how I should go about performing this differentiation?

If it helps, the above function is the mgf of a standard normal.

I want to differentiate and evaluate s=0 so I can get the mean,variance,skew and kurtosis.

Thanks!

1

There are 1 answers

0
P0W On

Try this :

>> syms s sigma mu
>> f=diff(exp((s^2*sigma^2)/2 + mu*s),s)

f =

exp((s^2*sigma^2)/2 + mu*s)*(s*sigma^2 + mu)

>> subs(f, 's', 0)

ans =

mu

>> subs(f, 's', 1)

ans =

exp(sigma^2/2 + mu)*(sigma^2 + mu)

Ref - diff, subs