<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged linear</title>
<link>https://coderlegion.com/tag/linear</link>
<description>Powered by Question2Answer</description>
<item>
<title>Mathematical Intuition of Linear Regression</title>
<link>https://coderlegion.com/21641/mathematical-intuition-of-linear-regression</link>
<description>
&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href=&quot;https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;h2&gt;
  
  
  Linear Regression Line
&lt;/h2&gt;

&lt;p&gt;The line is drawn between two axes, X and Y.&lt;/p&gt;

&lt;p&gt;We can draw infinite lines with different points. But only one will be best fit for the given points.&lt;/p&gt;

&lt;p&gt;For a set of 2D points (x_i,y_i), the simplest linear regression model is:&lt;/p&gt;

&lt;p&gt;y = mx + b&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(m) = slope&lt;/li&gt;
&lt;li&gt;(b) = intercept&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To compute them from your points:&lt;/p&gt;

&lt;p&gt;Slope:&lt;/p&gt;

&lt;p&gt;m = (n&amp;sum;xy&amp;minus;(&amp;sum;x)(&amp;sum;y)) / (n&amp;sum;x^2&amp;minus;(&amp;sum;x)^2)&lt;/p&gt;

&lt;p&gt;Intercept:&lt;/p&gt;

&lt;p&gt;b = (&amp;sum;y&amp;minus;m&amp;sum;x) / n&lt;/p&gt;

&lt;p&gt;Then your best-fit line is:&lt;/p&gt;

&lt;p&gt;y = mx + b&lt;/p&gt;

&lt;h2&gt;
  
  
  Calculation of Slope
&lt;/h2&gt;

&lt;p&gt;For example points:&lt;/p&gt;

&lt;div class=&quot;table-wrapper-paragraph&quot;&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;x&lt;/th&gt;
&lt;th&gt;y&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Result:&lt;br&gt;
m = 0.8&lt;br&gt;
b = 1.5&lt;/p&gt;

&lt;p&gt;Best-fit line:&lt;br&gt;
y = 0.8x + 1.5&lt;/p&gt;

&lt;p&gt;Finally we get the result:&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Few64hqcrljd446ltg4jz.png&quot; class=&quot;article-body-image-wrapper&quot;&gt;&lt;img src=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Few64hqcrljd446ltg4jz.png&quot; alt=&quot;&quot; width=&quot;361&quot; height=&quot;299&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;&lt;img src=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png&quot; alt=&quot;git-lrc&quot; width=&quot;800&quot; height=&quot;373&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It&amp;rsquo;s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;&amp;#11088; &lt;a href=&quot;https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;
</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/21641/mathematical-intuition-of-linear-regression</guid>
<pubDate>Mon, 06 Jul 2026 18:58:15 +0000</pubDate>
</item>
</channel>
</rss>