Derivatives seem ok but result is not as expected: pls help, can't complete the course for this! #4
-
Please, anyone has a hint about where to look for errors? I made dfdmu as: f(x, mu, sig) * (1/((sig**3) * (np.sqrt(2 * np.pi)))) * (x - mu) dfdsig as: f(x, mu, sig) * -(sig2 - x2 + 2mux - mu2)/(np.sqrt(2*np.pi) * sig4) J = np.array([ -2*(y - f(x,mu,sig)) @ dfdmu(x,mu,sig),
I checked for errors in derivatives (by online calculator, too) and can't find any but the results are wrong. Thanks in advance for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, zahra, if you still want to know why your original derivatives were wrong, here is a full explanation. It a mistake was made, it deserves to be investigated why it was a mistake. That's how progress is made. df / dμ I don't know what you got from the online derivative calculator, below is what I got by differentiate f with respect to μ by hands: Hence, the partial derivative with respect to μ can be simplified to: In Python, the partial derivative with respect to μ would look like:
Compare the above with your original code, which you stated in the post here, you would immediately know why your original answer was wrong. df / dϬ For the partial derivative with respect to б, the product rule is needed here: Differentiate A(Ϭ) with respect to Ϭ and treat B(Ϭ) as constant for the moment. Differentiate B(Ϭ) with respect to Ϭ and treat A(Ϭ) as constant now. The partial derivative with respect to Ϭ is (1) + (2):Compare the above with your original code, which you stated in the post here, you would immediately know why your original answer was wrong. df / dϬ For the partial derivative with respect to б, the product rule is needed here: Differentiate A(Ϭ) with respect to Ϭ and treat B(Ϭ) as constant for the moment. Differentiate B(Ϭ) with respect to Ϭ and treat A(Ϭ) as constant now. The partial derivative with respect to Ϭ is (1) + (2): In Python, the partial derivative with respect to Ϭ would look like:
Compare the above with your initial answer for df/dsig(x, mu, sig). |
Beta Was this translation helpful? Give feedback.
Hi, zahra, if you still want to know why your original derivatives were wrong, here is a full explanation. It a mistake was made, it deserves to be investigated why it was a mistake. That's how progress is made.
df / dμ
I don't know what you got from the online derivative calculator, below is what I got by differentiate f with respect to μ by hands:
Hence, the partial derivative with respect to μ can be simplified to:
In Python, the partial derivative with respect to μ would look like:
Compare the above with your original code, which you stated in the post here, you would immediately know why your original answer was wrong.
…