Derivative of function with 2 summations and powers












0














I'm trying to compute the gradient of a complex loss function but I'm stuck on calculating the derivative of part of the expression,namely:



with respect to $w_i$



$$sum_{n=1}^N(y^n -w_0 - sum_{j=1}^p A_{nj}w_j)^2$$



A - design matrix;
w - vector; y - vector; $w_0$ - first element of w



Edit
Where it said k it should have been n - now fixed










share|cite|improve this question
























  • How can $y$ be a vector? Should it be $y_n$ rather than $y^n$?
    – smcc
    Nov 25 '18 at 11:14
















0














I'm trying to compute the gradient of a complex loss function but I'm stuck on calculating the derivative of part of the expression,namely:



with respect to $w_i$



$$sum_{n=1}^N(y^n -w_0 - sum_{j=1}^p A_{nj}w_j)^2$$



A - design matrix;
w - vector; y - vector; $w_0$ - first element of w



Edit
Where it said k it should have been n - now fixed










share|cite|improve this question
























  • How can $y$ be a vector? Should it be $y_n$ rather than $y^n$?
    – smcc
    Nov 25 '18 at 11:14














0












0








0







I'm trying to compute the gradient of a complex loss function but I'm stuck on calculating the derivative of part of the expression,namely:



with respect to $w_i$



$$sum_{n=1}^N(y^n -w_0 - sum_{j=1}^p A_{nj}w_j)^2$$



A - design matrix;
w - vector; y - vector; $w_0$ - first element of w



Edit
Where it said k it should have been n - now fixed










share|cite|improve this question















I'm trying to compute the gradient of a complex loss function but I'm stuck on calculating the derivative of part of the expression,namely:



with respect to $w_i$



$$sum_{n=1}^N(y^n -w_0 - sum_{j=1}^p A_{nj}w_j)^2$$



A - design matrix;
w - vector; y - vector; $w_0$ - first element of w



Edit
Where it said k it should have been n - now fixed







derivatives partial-derivative






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 25 '18 at 11:19

























asked Nov 25 '18 at 10:16









Sreten Jocić

174




174












  • How can $y$ be a vector? Should it be $y_n$ rather than $y^n$?
    – smcc
    Nov 25 '18 at 11:14


















  • How can $y$ be a vector? Should it be $y_n$ rather than $y^n$?
    – smcc
    Nov 25 '18 at 11:14
















How can $y$ be a vector? Should it be $y_n$ rather than $y^n$?
– smcc
Nov 25 '18 at 11:14




How can $y$ be a vector? Should it be $y_n$ rather than $y^n$?
– smcc
Nov 25 '18 at 11:14










1 Answer
1






active

oldest

votes


















0














For $iin{1,ldots,p}$:



$$begin{align*}&phantom{=} , frac{partial}{partial w_i}sum_{n=1}^Nleft[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nfrac{partial}{partial w_i}left[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)frac{partial}{partial w_i}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( -sum_{j=1}^p A_{nj}frac{partial w_j}{partial w_i}right)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( - A_{ni}right)right]\
&=-2sum_{n=1}^Nleft[A_{ni}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]
end{align*}$$






share|cite|improve this answer























  • I'm so sorry I just noticed my mistake where it sais k it should be n, will substituting it everywhere be sufficient?
    – Sreten Jocić
    Nov 25 '18 at 11:20












  • Yes, it does not matter whether the upper limit of the sum is called $N$ or $K$.
    – smcc
    Nov 25 '18 at 11:22










  • I meant "k" as the index, sorry
    – Sreten Jocić
    Nov 25 '18 at 11:22










  • Changing $k$ to $j$ in $A_{kj}$ just changes the last lines. I have updated my answer.
    – smcc
    Nov 25 '18 at 11:26











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3012658%2fderivative-of-function-with-2-summations-and-powers%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














For $iin{1,ldots,p}$:



$$begin{align*}&phantom{=} , frac{partial}{partial w_i}sum_{n=1}^Nleft[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nfrac{partial}{partial w_i}left[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)frac{partial}{partial w_i}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( -sum_{j=1}^p A_{nj}frac{partial w_j}{partial w_i}right)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( - A_{ni}right)right]\
&=-2sum_{n=1}^Nleft[A_{ni}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]
end{align*}$$






share|cite|improve this answer























  • I'm so sorry I just noticed my mistake where it sais k it should be n, will substituting it everywhere be sufficient?
    – Sreten Jocić
    Nov 25 '18 at 11:20












  • Yes, it does not matter whether the upper limit of the sum is called $N$ or $K$.
    – smcc
    Nov 25 '18 at 11:22










  • I meant "k" as the index, sorry
    – Sreten Jocić
    Nov 25 '18 at 11:22










  • Changing $k$ to $j$ in $A_{kj}$ just changes the last lines. I have updated my answer.
    – smcc
    Nov 25 '18 at 11:26
















0














For $iin{1,ldots,p}$:



$$begin{align*}&phantom{=} , frac{partial}{partial w_i}sum_{n=1}^Nleft[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nfrac{partial}{partial w_i}left[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)frac{partial}{partial w_i}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( -sum_{j=1}^p A_{nj}frac{partial w_j}{partial w_i}right)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( - A_{ni}right)right]\
&=-2sum_{n=1}^Nleft[A_{ni}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]
end{align*}$$






share|cite|improve this answer























  • I'm so sorry I just noticed my mistake where it sais k it should be n, will substituting it everywhere be sufficient?
    – Sreten Jocić
    Nov 25 '18 at 11:20












  • Yes, it does not matter whether the upper limit of the sum is called $N$ or $K$.
    – smcc
    Nov 25 '18 at 11:22










  • I meant "k" as the index, sorry
    – Sreten Jocić
    Nov 25 '18 at 11:22










  • Changing $k$ to $j$ in $A_{kj}$ just changes the last lines. I have updated my answer.
    – smcc
    Nov 25 '18 at 11:26














0












0








0






For $iin{1,ldots,p}$:



$$begin{align*}&phantom{=} , frac{partial}{partial w_i}sum_{n=1}^Nleft[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nfrac{partial}{partial w_i}left[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)frac{partial}{partial w_i}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( -sum_{j=1}^p A_{nj}frac{partial w_j}{partial w_i}right)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( - A_{ni}right)right]\
&=-2sum_{n=1}^Nleft[A_{ni}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]
end{align*}$$






share|cite|improve this answer














For $iin{1,ldots,p}$:



$$begin{align*}&phantom{=} , frac{partial}{partial w_i}sum_{n=1}^Nleft[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nfrac{partial}{partial w_i}left[left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)^2right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)frac{partial}{partial w_i}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( -sum_{j=1}^p A_{nj}frac{partial w_j}{partial w_i}right)right]\
&=sum_{n=1}^Nleft[2left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)left( - A_{ni}right)right]\
&=-2sum_{n=1}^Nleft[A_{ni}left(y^n -w_0 - sum_{j=1}^p A_{nj}w_jright)right]
end{align*}$$







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Nov 25 '18 at 11:25

























answered Nov 25 '18 at 11:13









smcc

4,297517




4,297517












  • I'm so sorry I just noticed my mistake where it sais k it should be n, will substituting it everywhere be sufficient?
    – Sreten Jocić
    Nov 25 '18 at 11:20












  • Yes, it does not matter whether the upper limit of the sum is called $N$ or $K$.
    – smcc
    Nov 25 '18 at 11:22










  • I meant "k" as the index, sorry
    – Sreten Jocić
    Nov 25 '18 at 11:22










  • Changing $k$ to $j$ in $A_{kj}$ just changes the last lines. I have updated my answer.
    – smcc
    Nov 25 '18 at 11:26


















  • I'm so sorry I just noticed my mistake where it sais k it should be n, will substituting it everywhere be sufficient?
    – Sreten Jocić
    Nov 25 '18 at 11:20












  • Yes, it does not matter whether the upper limit of the sum is called $N$ or $K$.
    – smcc
    Nov 25 '18 at 11:22










  • I meant "k" as the index, sorry
    – Sreten Jocić
    Nov 25 '18 at 11:22










  • Changing $k$ to $j$ in $A_{kj}$ just changes the last lines. I have updated my answer.
    – smcc
    Nov 25 '18 at 11:26
















I'm so sorry I just noticed my mistake where it sais k it should be n, will substituting it everywhere be sufficient?
– Sreten Jocić
Nov 25 '18 at 11:20






I'm so sorry I just noticed my mistake where it sais k it should be n, will substituting it everywhere be sufficient?
– Sreten Jocić
Nov 25 '18 at 11:20














Yes, it does not matter whether the upper limit of the sum is called $N$ or $K$.
– smcc
Nov 25 '18 at 11:22




Yes, it does not matter whether the upper limit of the sum is called $N$ or $K$.
– smcc
Nov 25 '18 at 11:22












I meant "k" as the index, sorry
– Sreten Jocić
Nov 25 '18 at 11:22




I meant "k" as the index, sorry
– Sreten Jocić
Nov 25 '18 at 11:22












Changing $k$ to $j$ in $A_{kj}$ just changes the last lines. I have updated my answer.
– smcc
Nov 25 '18 at 11:26




Changing $k$ to $j$ in $A_{kj}$ just changes the last lines. I have updated my answer.
– smcc
Nov 25 '18 at 11:26


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3012658%2fderivative-of-function-with-2-summations-and-powers%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Plaza Victoria

In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...