6
$\begingroup$

I'm struggling with mathematics behind linear regression. In the following lines I pasted the text from the book Pattern Recognition and Machine Learning (p. 46) where author derives the regression function $\mathbb{E}_{t} [t | \mathbf{x}]$. I want to understand the procedure from the equation (2) to the final result. Could somebody please provide me some useful pointers (and/or links) which concept from the calculus of variations should I study.

The average, expected, loss is given by

$$ \mathbb{E}[L] = \int \int L(t, x (\mathbf{x})) p (\mathbf{x}, t) \, d\mathbf{x} \, dt. \tag{1} $$

A common choice of loss function in linear regression is the squared loss given by $L (t, y(\mathbf{x})) = \{ y (\mathbf{x}) - t \}^{2}$. In this case, the expected loss can be written as

$$ \mathbb{E}[L] = \int \int \{ y (\mathbf{x}) - t \}^{2} p (\mathbf{x}, t) \, d\mathbf{x} \, dt. \tag{2} $$

Our goal is to choose $y (\mathbf{x})$ so as to minimize $\mathbb{E} [L]$. We can do this using the calculus of variations to give

$$ \dfrac{\delta \mathbb{E} [L]}{\delta y (\mathbf{x})} = 2 \int \{ y (\mathbf{x}) - t \} p (\mathbf{x}, t) \, dt = 0. \tag{3} $$

Solving for $y (\mathbf{x})$, and using the sum and product rules of probability, we obtain

$$ y (\mathbf{x}) = \dfrac{\int tp (\mathbf{x}, t) \, dt}{p (\mathbf{x})} = \int t p (t | \mathbf{x}) \, dt = \mathbb{E}_{t} [t | \mathbf{x}] \tag{4} $$

$\endgroup$

2 Answers 2

3
$\begingroup$

I am assuming your difficulty is in the jump between Eq.2 and Eq.3. All you need is an Euler-Lagrange equation, as in their equation (3). In their notation $f(x,y,\dot y)=\int \{y(x)-t\}^2p(x,t)dx$, so that $df/d\dot{y}=0$, for instance.

UPDATE: answering comments to make a more verbose explanation.

The Eq. (2) can be rewritten as: $$E[L]=\int f(t,y) dt$$

The stationary (optimal) solution is when in my link to E-L the condition (3) is satisfied, but since our $f(t,y,\dot y)\equiv f(t,y)$ doesn't have $\dot y$ in it, only the first term matters and it becomes: $$\frac{\partial f}{\partial y}=0$$ This is Eq. (3) in the question. If you have trouble arriving to it, then review the Leibnitz integral rule. However, in this case it's unnecessary, because the integral is over $t$, so you can simply apply differentiation wrt $y$ trivially.

$\endgroup$
3
  • 2
    $\begingroup$ I have stumbled across the same problem about how it went from Eq.2 to Eq.3. I still could not understand the solution given by you. It would be great if you can explain a bit more in detail. Thanks! $\endgroup$
    – Tejas
    Commented Dec 2, 2021 at 7:00
  • $\begingroup$ To be concrete, I could not understand the derivation of $δE[L]/δy(x)$ (how did it result into the LHS of Eq.3) and why did $dx$ go away. $\endgroup$
    – Tejas
    Commented Dec 2, 2021 at 7:23
  • $\begingroup$ I still couldn't understand the steps between (2) and (3) reading this answer. In case a reader is still interested in the problem, here's a much clearer explanation. $\endgroup$
    – Celdor
    Commented Mar 27, 2023 at 14:18
4
$\begingroup$

I don't think you need calculus of variations. First, define the loss for every fixed $\bf x$,

$$\mathbb{E}[L | {\bf x}] = \int \{ y (\mathbf{x}) - t \}^{2} p (t | \mathbf{x}) \, dt. \tag{2*}$$

and the minimizer of that is $y (\mathbf{x}) = \mathbb{E}_{t} [t | \mathbf{x}]$

and then just $$\mathbb{E}[L] = \int \mathbb{E}[L|x] f(x)\, dx$$

$\endgroup$
2
  • 2
    $\begingroup$ Thanks for your reply. But, I still want to use calculus of variations. $\endgroup$
    – Andrej
    Commented May 10, 2014 at 15:40
  • $\begingroup$ The calculus of variations is just a set of rules to justify formal derivative computations. Expanding $(y(\mathbf{x})-t)^2=y(\mathbf{x})^2+t^2-2y(\mathbf{x})t$, it is absolutely clear that the minimizer is unique and attained at the value $y(\mathbf{x})$ you mentioned. That is all the "calculus of variations" you need. $\endgroup$
    – phils
    Commented May 12, 2014 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.