MML Discourse archived in May, 2026

Single Parameter Linear Regression

mark

(10 pts)

For this assignment, your task is to perform a single parameter linear regression for data that's symmetric about the origin, as described in this class note. Your data will be based on your name. Specifically, you'll have 4 points with

  • the x-coordinates equal to \pm position of the first character in your first and last name and
  • the y-coordinates equal to \pm position of the second character in your first and last name.

For example, my name is Mark McClure. Thus,

  • Since M is the 13^{\text{th}} letter of the alphabet, the x-coordinates are \pm13 and \pm13
  • Since a is the 1^{\text{st}} letter and c is the 3^{\text{rd}}, the y-coordinates are \pm 1 and \pm3.

Thus, my four points are

\{(13,1), (-13,-1), (13,3), (-13,-3)\}.

Those points, with the regression line, look like so:

Desmos will give me the line, as I've done here. The real task, though, is to use the technique described in the simple linear regression notes to derive and explain the formula for the line.

User 003

From my name, the four points are:

{(18,25),(-18,-25),(19,20),(-19,-20)}

Given the symmetry of the data,

f(x)=ax

To calculate the total squared error,

E(a)=\sum_{i=1}^{N} (y_i-f(x_i))
E(a)=(25-18a)^2+(-25+18a)^2+(20-19a)^2+(-20+19a)^2

To find the minimum total squared error, find where the derivative is 0.

E'(a)=2(25-18a)(-18)+2(-25+18a)(18)+2(20-19a)(-19)+(-20+19a)(19)

which simplifies to

E'(a) = -3320 + 2740a \stackrel{?}{=} 0
a=1.212

So the line fitting these 4 points is f(x)=1.212x, shown below.

User 002

My points are (14,15), (-14,-15), (3,1), (-3,-1).
This is the formula for total squared error:

E(a)=\sum_{i=1}^{N}(y_i - f(x_i)).

Here's what I did: ((14a-15)^2)+((-14a+15)^2)+((-3a+1)^2)+((3a-1)^2).
Taking the derivative of this avoids having to expand these terms out. I used the chain rule.

E'= (2)(14a-15)(14)+ (2)(14a-15)(-14)+(2)(3a-1)(3)+(2)(3a+1)(-3).

Simplified, it's 56(14a-15)+12(3a-1). Expanded out:

820a-876=0.

Solving for a, we get 876/820=a or 1.06829.

User 008

My points are:

{(5,4), (-5,-4), (4,15), (-4,-15)}

Applying these coordinates in the total squared error looks like this:

\begin{align*} E(a) &= (5a - 4)^2 + (-5a + 4)^2 + (4a - 15)^2 + (-4a + 15)^2 \\ &= 2((5a - 4)^2 + (4a - 15)^2) \end{align*}

To find the smallest value of a, we find E'(a) = 0 :

\begin{align*} E'(a) &= 2 (2 (5) (5a-4) + 2 (4) (4a-15)) \\ &= 4 (5 (5a-4) + 4(4a-15)) \\ &= 4 (25a - 20 + 16a - 60) \\ &= 4 (41a - 80) \stackrel{?}{=} 0 \end{align*}

The solution is a = \frac{80}{41} ; which is approximately 1.9512195122.
The regression line ends up being f(x) = \frac{80}{41}x .
Putting together the four points and regression line looks like this:

User 013

My points are:

(1,9), (-1,-9), (20,15), (-20,15)

The formula for the total squared area is:

E(a) = \sum_{i=1}^{n} (y_i - f(x_i))^2

Plugging in my values, I get:

E(a) = (9-a)^2 + (-9+a)^2 + (15-20a)^2 + (-15+20a)^2

Taking the derivative gives us:

E'(a) = 2(9-a)(-1)+2(-9+a)(1)+2(15-20a)(-20)+2(-15+20a)(20)

This simplifies to:

E'(a) = 1604a - 1236

Setting this derivative to 0 and solving gives us:

1604a - 1236 = 0
a = 0.77057

This is the equation for the line:

f(x) = 0.77057x

This is the graph when the points are plotted with the line:

mark

@User 030 Could you edit that and add your model function? That is, f(x)=\,?

User 012

My points are

\{(3,15),\;(-3,-15),\;(3,8),\;(-3,-8)\}.

Plugging in my points to the total squared error formula yields

\begin{aligned} E(a) &= (3a - 15)^2 + (-3a + 15)^2 + (3a - 8)^2 + (-3a + 8)^2 \\ &= 2\big((3a - 15)^2 + (3a - 8)^2\big) \end{aligned}.

To find the minimum total squared error, we take the derivative

E'(a) = 2\big(2(3a-15)3 + 2(3a-8)3\big) = 12(6a-23)

and then solve for E'(a) = 0 which is at a = \frac{23}{6} meaning our line of best fit is

f(x) = \frac{23}{6}x.

The graph of my points and the resulting linear regression line looks like so:

User 006

My points are: (5,12),(-5,-12),(2,1),(-2,-1)

Applying these coordinates in the total squared error looked like this:

E(a) = (12-5a)^2+(-12+5a)^2+(1-2a)^2+(-1+2a)^2

After foiling and simplifying we are left with:

58a^2-248a+290

Taking the derivative got me:

116a-248=0

Then I solved for a and got:

a = \frac{62}{29}

Thus,

f(x) = \frac{62}{29}x.

User 015

From my name, my four points are:

\{(1,22),\;(-1,-22),\;(19,3),\;(-19,-3)\}

I need to find a in the function

f(x) = a x

To do this, I need to use the formula for total squared error

\sum_{i=1}^{n} (a x_i - y_i)^2

So my total squared error equation is:

E(a) = (a-22)^2 + (-a+22)^2 + (19a-3)^2 + (-19a+3)^2

In order to find the minimum, I need to take the derivative and set it equal to zero

\begin{aligned} E'(a) &= 2(a-22)(1) + 2(-a + 22)(-1) + 2(19a-3)(19) + 2(-19a + 3)(-19) \\ &= 2(a-22) - 2(-a+22) + 38(19a-3) - 38(-19a +3)\\ &= (2a-44) + (2a-44) + (722a-114) + (722a-114)\\ &=1448a - 316\\ \end{aligned}
\begin{aligned} 0 &= 1448a - 316\\ 316 &= 1448a&\\ \frac{316}{1448} &= a\\ \end{aligned}

Simplified,

a = \frac{79}{362}

So the formula for my line is:

f(x) = \frac{79}{362} x

Here is it plotted:

User 014

My points are:

\{(1,7),\;(-1,-7),\;(14,15),\;(-14,-15)\}

Plugging in my points gets me:

\begin{aligned} E(a) &= (a-7)^2 +(-a+7)^2 + (14a-15)^2 +(-14a +15)^2 \\ &= 2\big((a-7)^2 + (14a-15)^2\big) \end{aligned}

The derivative would be:

E'(a) = 2\big(2(a-2) + 2(14a-15)14\big) = 4\big((a-2) + 14(14a -15)\big)

Solving for E'(a) = 0 shows a = \frac{848}{788}, this shows the line of best fit at

f(x) = \frac{848}{788} x

This is the graph of those points and line:

User 017

The four points are:

(4,\;1),\;(-4,\;-1),\;(13,\;3),\;(-13,\;-3)

Symmetry of the data,

f(x)=ax

To calculate the total squared error

E(a)=\sum_{i=1}^{4}\left(y_i-f(x_i)\right)^2 \;=\;\sum_{i=1}^{4}\left(y_i-ax_i\right)^2
E(a)=(1-4a)^2+(-1+4a)^2+(3-13a)^2+(-3+13a)^2

To find the minimum total squared error, find where the derivative is 0.

E'(a)=2(1-4a)(-4)+2(-1+4a)(4)+2(3-13a)(-13)+2(-3+13a)(13)

which simplifies to

E'(a)=740a-172=0
a=\frac{172}{740}=\frac{43}{185}\approx 0.2324

So the line fitting these four points is f(x)=\frac{43}{185}x \approx 0.2324x.

This is the graph of line

User 009

Name: BRady JEnkins
Points

(2,18),(-2,-18),(10,5),(-10,-5)

Formula:

E(a) = (18-2a)^2+(-18+2a)^2+(5-10a)^2+(-5+10a)^2
\begin{aligned} E'(a) &= 2(18-2a)(-2)+2(-18+2a)(2)+2(5-10a)(-10)+2(-5+10a)(10) \\ &= -4(18-2a)+4(-18+2a)-20(5-10a)+20(-5+10a) \\ &= -72+8a-72+8a-100+200a-100+200a \\ &= -344 + 416a \\ \end{aligned}

Set equal to 0 and solve

\begin{aligned} -344 + 416a = 0 \\ 416a = 344 \\ a = \frac{344}{416} \\ \end{aligned}

Siplified

a = \frac{43}{52}

Thus

f(x) = \frac{43}{52}x

Graph

User 022

For my name, my 4 points are:

(12,21),(-12,-21),(19,1),(-19,1)

My points plugged in:

E(a) = (12a - 21)^2 + (-12a + 21)^2 + (19a - 1)^2 + (-19a + 1)^2 == 2((12a-21)^2+(19a-1)^2))

The derivative of the equation:

E'(a)=2(2(12a-21)(12)+2(19a-1)(19))

Solved for 0:

a = \frac{271}{505} == f(x) = \frac{271}{505} x.

Graph:

User 018

My points are: \{(4,1), (-4,-1), (4,5), (-4,-5)\}

The formula for the total squared error is: \sum_{i=1}^{n} (y_i - \hat{y}_i)^2

To calculate it: E(a) = (1-4a)^2 + (-1+4a)^2 + (5-4a)^2 + (-5+4a)^2

E'(a) = 2(1-4a)(-4) + 2(-1+4a)(4) + 2(5-4a)(-4) + 2(-5+4a)(4)
E'(a) = 16(4a-1) + 16(4a-5)
\begin{aligned} E'(a) &= 64a - 16 + 64a - 80 \\ &= 128a - 96 \end{aligned}
128a - 96 = 0
a = \frac{96}{128} = \frac{3}{4}

So the line is f(x) = \frac{3}{4}x.

User 010

My points:

(18,25),\;(-18,-25),\;(19,20),\;(-19,-20)

Model function:

f(x)=\alpha x

Applying these points to the total squared error:

E(\alpha)=(25-18\alpha)^2+(-25+18\alpha)^2+(20-19\alpha)^2+(-20+19\alpha)^2

Finding minimum error:

\begin{aligned} E'(\alpha)=&\,2(25-18\alpha)(-18)+2(-25+18\alpha)(18)\\ &+2(20-19\alpha)(-19)+2(-20+19\alpha)(19) \end{aligned}

Simplifies to:

E'(\alpha)=-3320+2740\alpha=0
\alpha=\frac{3320}{2740}=\frac{166}{137}

Final regression function:

{f(x)=\frac{166}{137}x}
User 019

My points are: (2,18), (-2, -18), (13, 1), (-13, -1)

The formula for the total squared error is: \sum_{i = 1}^n (y_i - \hat{y})^2

Applying these points to the total squared error:

E(a) = (18-2a)^2 + (-18+2a)^2 + (1-13a)^2 + (-1+13a)^2
E'(a) = 2(18-2a)(-2) + 2(-18+2a)(2) + 2(1 - 13a)(-13) + 2(-1 + 13a)(13)
E'(a) = -4(18-2a) + 4(-18+2a) - 26(1 - 13a) + 26(-1 + 13a)
E'(a) = (-72 + 8a) + (-72 + 8a) + (-26 + 338a) + (-26 + 338a) \\ E'(a) = 692a - 196
692a - 196 = 0
a = \frac{196}{692} = \frac{49}{173}

So the line is f(x) = \frac{49}{173}x.

User 020

My points are: (10, 15), (-10, -15), (7, 1), (-7, 1).

Using formula:

\text{total squared error} = \sum_{i=1}^{n} (a x_i - y_i)^2

Plugging in values from the four points:

E(a) = (10a - 15)^2 + (-10a + 15)^2 + (7a - 1)^2 + (-7a + 1)^2

or

E(a) = 200a^2 - 530a + 452.

Then taking the derivative with respect to a:

E'(a) = 400a - 530.

To find the regression line we set E'(a) to zero and solve for a:

a = \frac{530}{400} \text{ or simplified further } a = \frac{53}{40}.

So the line of best fit is

f(x) = \frac{53}{40}x.

On a graph below:

User 004

My four points based on my name are:

(13,1),\ (-13,-1),\ (3,15),\ (-3,-15)

Applying these points in the total squared error I get using f(x) = ax:

E(a) = (-1 + 13a)^2 + (1 - 13a)^2 + (-15 + 3a)^2 + (15 - 3a)^2

Deriving E(a) I get:

\begin{aligned} E'(a) &= 2(-1 + 13a)(13) + 2(1 - 13a)(-13) + 2(-15 + 3a)(3) + 2(15 - 3a)(-3) \\ E'(a) &= -26 + 338a - 26 + 338a - 90 + 18a - 90 + 18a \\ E'(a) &= -232 + 712a \end{aligned}

Setting equal to zero I get:

-232 + 712a = 0 \quad \rightarrow \quad 712a = 232 \quad \rightarrow \quad a = \frac{232}{712} \quad \rightarrow \quad a = \frac{29}{89}

Thus, the regression line of best fit is:

f(x) = \frac{29}{89}x

And looks like:

User 024

My points are

{(5,26), (-5,-26), (3, 1), (-3,-1)}

When putting them into the formula for total squared error, it becomes
E(a) = (5a-26)^2 + (-5a+26)^2 + (3a-1)^2 + (-3a+1)^2
= 2((5a-26)^2 + (3a-1)^2)
The derivative is
E'(a) = 2(5a-26)(5) + 2(-5a+26)(-5) + 2(3a-1)(3) + 2(-3a+1)(-3)
=136a-532
0=136a-532
a = \frac{532}{126}\

So, the line's equation is f(x) = \frac{532}{126}x

User 016

My points are
{(13,1) (-13,-1) (12, 9) (-12,-9)}
Given the symmetry of the data
f(x)=ax
to calculate the total squared error

𝐸(𝑎)=(13a−1)^2+(−13a+1)^2+(−9𝑎+12)^2+(9𝑎-12)^2

taking the derivative

E'(a)=2(2(13a-1)(13)+2(12a-9)(12))

This simplifies to

626a-242=0
a= .387

Thus,

f(x) = 0.387x.

User 031

My points are (-18,-25), (-9,-26), (9,26), (18,25).

Using the total squared error formula:

E(a) = \sum (a x_i - y_i)^2.

My points in the total squared error formula were

E(a)=(-18a-(-25))^2+(-9a+(-1))^2+(9a-26)^2+(18a+25)^2

In calculating the derivative i found that E'(a) = 1620a-450 or about 5/18
So the line best fitting my 4 points is f(x)=5/18x or about 0.27 repeating.
And the graph looks like:

mark