<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Yahya Izadi</title>
<link>https://yahaiz.github.io/blog/</link>
<atom:link href="https://yahaiz.github.io/blog/index.xml" rel="self" type="application/rss+xml"/>
<description>A blog built with Quarto</description>
<generator>quarto-1.8.26</generator>
<lastBuildDate>Fri, 02 Jan 2026 20:30:00 GMT</lastBuildDate>
<item>
  <title>Stop Memorizing Syntax: The Art of Effective Googling</title>
  <dc:creator>Yahya Izadi</dc:creator>
  <link>https://yahaiz.github.io/blog/posts/stop-memorizing-syntax/</link>
  <description><![CDATA[ 






<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>In the rapidly evolving landscape of technical disciplines—ranging from software development to data science and systems programming—the definition of competency has shifted. Proficiency is no longer solely defined by the memorization of syntax, libraries, or statistical formulas, but rather by the ability to retrieve accurate information efficiently.</p>
<p>Whether debugging a complex neural network in PyTorch or resolving a race condition in a distributed system, the mechanism of solving the unknown remains constant. This article outlines a systematic approach to effective Googling, a critical methodology for reducing debugging time and ensuring the implementation of optimal solutions across all technical fields.</p>
</section>
<section id="why-you-should-google-in-english" class="level2">
<h2 class="anchored" data-anchor-id="why-you-should-google-in-english">Why You Should Google in English</h2>
<p>While localization exists, English remains the <em>lingua franca</em> of the global technology sector. The overwhelming majority of technical documentation, research papers, community discussions (Stack Overflow, Cross Validated), and repository issues are authored in English.</p>
<p>Searching in a native language often introduces a translation layer that degrades query precision. Technical terms often lack accurate equivalents, or the translated terms yield results from a significantly smaller dataset.</p>
<p><strong>Tip:</strong></p>
<p>Regardless of linguistic proficiency, technical queries should be formulated in English to ensure access to the primary source of truth.</p>
<ul>
<li><p><strong>Ineffective:</strong> <code>خطای اتصال دیتابیس</code> (Limited dataset, potential ambiguity)</p></li>
<li><p><strong>Effective:</strong> <code>Database connection timeout error</code> (Direct mapping to technical terminology)</p></li>
</ul>
</section>
<section id="anatomy-of-a-perfect-search-query" class="level2">
<h2 class="anchored" data-anchor-id="anatomy-of-a-perfect-search-query">Anatomy of a Perfect Search Query</h2>
<p>Search engines utilize keyword-matching algorithms. Providing a query in conversational language introduces noise that dilutes the relevance of the results. An optimal query acts as a filter, prioritizing context.</p>
<p>A robust query structure typically consists of three components:</p>
<ol type="1">
<li><p><strong>The Context:</strong> The language, framework, or library (e.g., <code>Python</code>, <code>Pandas</code>, <code>React</code>).</p></li>
<li><p><strong>The Operation:</strong> What was being attempted (e.g., <code>merge dataframes</code>, <code>render component</code>).</p></li>
<li><p><strong>The Symptom:</strong> The specific error or outcome (e.g., <code>NaN values</code>, <code>infinite loop</code>).</p></li>
</ol>
<section id="comparative-analysis" class="level3">
<h3 class="anchored" data-anchor-id="comparative-analysis">Comparative Analysis</h3>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Domain</th>
<th style="text-align: left;">❌ Bad Search (Vague)</th>
<th style="text-align: left;">✅ Good Search (Specific)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><strong>Web Dev</strong></td>
<td style="text-align: left;"><code>button not working</code></td>
<td style="text-align: left;"><code>HTML button onclick event not firing in React</code></td>
</tr>
<tr class="even">
<td style="text-align: left;"><strong>Data Science</strong></td>
<td style="text-align: left;"><code>excel file error python</code></td>
<td style="text-align: left;"><code>Pandas read_excel engine openpyxl dependency error</code></td>
</tr>
</tbody>
</table>
<p><strong>The Ultimate Goal: Official Documentation</strong></p>
<p>Google is not the answer; it is the vehicle to get you to the answer. Your goal should always be to land on the <strong>Official Documentation</strong> (e.g., MDN, Pandas Docs, Scikit-Learn Guide).</p>
<p>Stack Overflow provides the <em>fix</em>, but the documentation provides the <em>understanding</em>. Treat the docs as the single source of truth to verify any solution you find.</p>
</section>
</section>
<section id="google-search-operators-you-need-to-know" class="level2">
<h2 class="anchored" data-anchor-id="google-search-operators-you-need-to-know">Google Search Operators You Need to Know</h2>
<p>To refine search results, professionals should utilize boolean operators and search syntax modifiers.</p>
<section id="exact-match" class="level3">
<h3 class="anchored" data-anchor-id="exact-match">Exact Match (<code>""</code>)</h3>
<p>Enclosing a phrase in double quotes forces the search engine to locate that exact string sequence. This is critical for searching unique error codes.</p>
<ul>
<li><p><em>Usage:</em> <code>"Uncaught TypeError: Cannot read property 'map' of undefined"</code></p></li>
<li><p><em>Usage:</em> <code>"SettingWithCopyWarning: A value is trying to be set on a copy of a slice"</code></p></li>
</ul>
</section>
<section id="exclusion--" class="level3">
<h3 class="anchored" data-anchor-id="exclusion--">Exclusion (<code>-</code>)</h3>
<p>The minus operator removes results containing specific terms. This is particularly useful for disambiguating terms that have multiple meanings.</p>
<ul>
<li><p><em>Usage:</em> <code>python tutorial -snake</code> (Removes zoological results)</p></li>
<li><p><em>Usage:</em> <code>java -minecraft</code> (Focuses on the language, excluding gaming content)</p></li>
</ul>
</section>
<section id="source-filtering-site" class="level3">
<h3 class="anchored" data-anchor-id="source-filtering-site">Source Filtering (<code>site:</code>)</h3>
<p>Limiting the search scope to reputable domains ensures the reliability of the information.</p>
<ul>
<li><p><em>Usage:</em> <code>site:stackoverflow.com sort dictionary by value</code></p></li>
<li><p><em>Usage:</em> <code>site:kaggle.com random forest hyperparameter tuning</code></p></li>
</ul>
</section>
</section>
<section id="filter-by-date-dont-copy-deprecated-code" class="level2">
<h2 class="anchored" data-anchor-id="filter-by-date-dont-copy-deprecated-code">Filter by Date (Don’t Copy Deprecated Code)</h2>
<p>Technical ecosystems evolve rapidly. A solution that was standard practice three years ago may be deprecated or inefficient today. This is particularly true in Data Science (e.g., changes in Scikit-learn or TensorFlow APIs) and Frontend Development.</p>
<p><strong>Methodology:</strong></p>
<p>Utilize the search engine’s “Tools” feature to restrict results to the <strong>“Past Year”</strong>.</p>
<ul>
<li><p>This mitigates the risk of implementing legacy code.</p></li>
<li><p>It ensures compatibility with current library versions.</p></li>
</ul>
</section>
<section id="how-to-google-error-messages" class="level2">
<h2 class="anchored" data-anchor-id="how-to-google-error-messages">How to Google Error Messages</h2>
<p>A common pitfall is copying a raw stack trace directly into a search engine. Stack traces contain two types of information: generic error descriptions and local environment details.</p>
<p>Searching for specific information (like local file paths) will yield zero results because those paths do not exist on other machines.</p>
<p><strong>Sanitization Process:</strong></p>
<p>Before searching, the error message must be stripped of local context.</p>
<ol type="1">
<li><p><strong>Raw Error:</strong> <code>FileNotFoundError: [Errno 2] No such file or directory: '/Users/Yahya/Data/dataset.csv'</code></p></li>
<li><p><strong>Sanitized Query:</strong> <code>"FileNotFoundError" "No such file or directory" python</code></p></li>
</ol>
</section>
<section id="beware-of-the-xy-problem" class="level2">
<h2 class="anchored" data-anchor-id="beware-of-the-xy-problem">Beware of the “XY Problem”</h2>
<p>The “XY Problem” happens when you try to solve problem <em>X</em>, come up with a solution <em>Y</em>, get stuck on <em>Y</em>, and then ask for help with <em>Y</em>.</p>
<p>This is counter-productive because <em>Y</em> might not even be the right way to solve <em>X</em>.</p>
<p><strong>Example:</strong></p>
<ul>
<li><p><strong>The Goal (X):</strong> Remove rows with missing values from a dataset.</p></li>
<li><p><strong>The Attempt (Y):</strong> Write a for-loop to check and delete rows one by one.</p></li>
<li><p><strong>The Bad Search:</strong> “How to delete row in for loop python pandas.”</p></li>
<li><p><strong>The Good Search:</strong> “Pandas drop missing values.” (Which gives you <code>dropna()</code>).</p></li>
</ul>
<p><strong>Rule of Thumb:</strong></p>
<p>Always ask yourself: “Am I searching for how to do what I <em>think</em> is the solution, or for the actual problem I’m trying to solve?”</p>
</section>
<section id="using-ai-wisely-chatgpt-copilot" class="level2">
<h2 class="anchored" data-anchor-id="using-ai-wisely-chatgpt-copilot">Using AI Wisely (ChatGPT &amp; Copilot)</h2>
<p>AI tools like ChatGPT and GitHub Copilot are amazing for finding answers, but they aren’t perfect.</p>
<p><strong>Good Use Cases:</strong></p>
<ul>
<li><p><strong>Explaining Syntax:</strong> “What does this regex do?” or “Explain this SQL query.”</p></li>
<li><p><strong>Comparing Concepts:</strong> “XGBoost vs.&nbsp;LightGBM trade-offs.”</p></li>
</ul>
<p><strong>The Danger:</strong></p>
<p>AI models can “hallucinate”—confidently giving you code that looks right but is completely wrong or uses non-existent libraries. Always verify AI-generated code against official documentation.</p>
<hr>
<p>Mastering the art of Googling changes how you code. It turns a frustrating error into a quick fix and a learning moment. By using these techniques, you don’t just solve the problem—you become a better developer.</p>
<p>Remember: The best developers don’t have all the answers memorized—they just know exactly how to find them.</p>


</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Technical Skills</category>
  <category>Data Science</category>
  <category>Professional Development</category>
  <guid>https://yahaiz.github.io/blog/posts/stop-memorizing-syntax/</guid>
  <pubDate>Fri, 02 Jan 2026 20:30:00 GMT</pubDate>
  <media:content url="https://yahaiz.github.io/blog/posts/stop-memorizing-syntax/information-retrieval-technical-disciplines.png" medium="image" type="image/png" height="108" width="144"/>
</item>
<item>
  <title>Application of Approximation Theory in Data Science</title>
  <dc:creator>Yahya Izadi</dc:creator>
  <link>https://yahaiz.github.io/blog/posts/approximation-theory-data-science/</link>
  <description><![CDATA[ 






<section id="introduction-connecting-math-to-reality" class="level2">
<h2 class="anchored" data-anchor-id="introduction-connecting-math-to-reality">Introduction: Connecting Math to Reality</h2>
<p>In quantitative analysis, we face a constant challenge: Reality is complex, but we need simple functions to model it. This is exactly what <strong>Approximation Theory</strong> is about.</p>
<p>While it has roots in Numerical Analysis, for us in Data Science, it boils down to two main tasks:</p>
<ol type="1">
<li><p><strong>Simplification:</strong> Turning heavy functions (like complex exponentials) into easy-to-handle polynomials.</p></li>
<li><p><strong>Data Fitting:</strong> Finding a curve that best represents a set of scattered data points.</p></li>
</ol>
<p>In modern Data Science, “Data Fitting” isn’t just theory—it is the backbone of <strong>Supervised Learning</strong>.</p>
</section>
<section id="the-discrete-problem-linear-algebra-and-regression" class="level2">
<h2 class="anchored" data-anchor-id="the-discrete-problem-linear-algebra-and-regression">The Discrete Problem: Linear Algebra and Regression</h2>
<p>Let’s start with a classic scenario: we have a dataset comparing <strong>Marketing Budget (<img src="https://latex.codecogs.com/png.latex?x">)</strong> to <strong>Sales (<img src="https://latex.codecogs.com/png.latex?y">)</strong>. We want to find a function <img src="https://latex.codecogs.com/png.latex?f(x)"> so that for our data, <img src="https://latex.codecogs.com/png.latex?f(x_i)%20%5Capprox%20y_i">.</p>
<p>If we assume the relationship is linear, we are essentially trying to solve this system:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Bcases%7D%0Aa%20x_1%20+%20b%20=%20y_1%20%5C%5C%0A%5Cvdots%20%5C%5C%0Aa%20x_m%20+%20b%20=%20y_m%0A%5Cend%7Bcases%7D%0A%5Cimplies%20A%5Cmathbf%7Bx%7D%20=%20%5Cmathbf%7Bb%7D%0A"></p>
<section id="the-overdetermined-system" class="level3">
<h3 class="anchored" data-anchor-id="the-overdetermined-system">The Overdetermined System</h3>
<p>Here is the catch: in data science, we almost always have more data points (<img src="https://latex.codecogs.com/png.latex?m">) than variables (<img src="https://latex.codecogs.com/png.latex?n">). This creates an <strong>overdetermined system</strong>, meaning there is no exact solution for <img src="https://latex.codecogs.com/png.latex?Ax=b">.</p>
<p>To fix this, we use <strong>Discrete Least Squares</strong>. Instead of chasing an impossible exact solution, we minimize the error (the Euclidean norm of the residual <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Br%7D%20=%20%5Cmathbf%7Bb%7D%20-%20A%5Cmathbf%7Bx%7D">):</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cmin_%7B%5Cmathbf%7Bx%7D%7D%20%5C%7C%20A%5Cmathbf%7Bx%7D%20-%20%5Cmathbf%7Bb%7D%20%5C%7C_2%5E2"></p>
<p>Calculus gives us the answer where the gradient is zero, leading to the famous <strong>Normal Equations</strong>:</p>
<p><img src="https://latex.codecogs.com/png.latex?A%5ET%20A%20%5Cmathbf%7Bx%7D%20=%20A%5ET%20%5Cmathbf%7Bb%7D"></p>
<p>This single equation is the engine behind Linear Regression and many machine learning techniques we use daily.</p>
</section>
</section>
<section id="feature-engineering-and-the-vandermonde-matrix" class="level2">
<h2 class="anchored" data-anchor-id="feature-engineering-and-the-vandermonde-matrix">Feature Engineering and the Vandermonde Matrix</h2>
<p>Often, a straight line doesn’t cut it. We might suspect a quadratic relationship: <img src="https://latex.codecogs.com/png.latex?P(x)%20=%20a_0%20+%20a_1%20x%20+%20a_2%20x%5E2">. This allows us to ask deeper questions:</p>
<ol type="1">
<li><p>What are the base sales? (<img src="https://latex.codecogs.com/png.latex?a_0">)</p></li>
<li><p>How does the budget drive sales? (<img src="https://latex.codecogs.com/png.latex?a_1">)</p></li>
<li><p>Does the budget lose effectiveness over time? (<img src="https://latex.codecogs.com/png.latex?a_2">)</p></li>
</ol>
<p>To solve this, we build the <strong>Vandermonde Matrix</strong> to hold our features:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AV%20=%20%5Cbegin%7Bbmatrix%7D%0A1%20&amp;%20x_1%20&amp;%20x_1%5E2%20%5C%5C%0A1%20&amp;%20x_2%20&amp;%20x_2%5E2%20%5C%5C%0A%5Cvdots%20&amp;%20%5Cvdots%20&amp;%20%5Cvdots%20%5C%5C%0A1%20&amp;%20x_m%20&amp;%20x_m%5E2%0A%5Cend%7Bbmatrix%7D%0A"></p>
<p><strong>Interpretation:</strong> If <img src="https://latex.codecogs.com/png.latex?a_2"> turns out negative, we have mathematically proven “Diminishing Returns.”</p>
<section id="visualizing-the-bias-variance-tradeoff" class="level3">
<h3 class="anchored" data-anchor-id="visualizing-the-bias-variance-tradeoff">Visualizing the Bias-Variance Tradeoff</h3>
<p>Choosing the right model complexity is tricky.</p>
<p><strong>1. Underfitting (High Bias):</strong> If the model is too simple (Degree 1), we miss the pattern entirely.</p>
<div id="cell-fig-underfitting" class="cell" data-execution_count="1">
<div class="cell-output cell-output-display">
<div id="fig-underfitting" class="quarto-float quarto-figure quarto-figure-center anchored" width="794" data-fig-align="center" height="510">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-underfitting-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://yahaiz.github.io/blog/posts/approximation-theory-data-science/index_files/figure-html/fig-underfitting-output-1.png" id="fig-underfitting" class="quarto-figure quarto-figure-center anchored figure-img" width="794" height="510">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-underfitting-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1
</figcaption>
</figure>
</div>
</div>
</div>
<div style="page-break-after: always;"></div>
<p><strong>2. Optimal Fit:</strong> A degree 2 polynomial hits the sweet spot, capturing the trend without memorizing noise.</p>
<div id="cell-fig-optimal-fit" class="cell" data-execution_count="2">
<div class="cell-output cell-output-display">
<div id="fig-optimal-fit" class="quarto-float quarto-figure quarto-figure-center anchored" width="794" data-fig-align="center" height="510">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-optimal-fit-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://yahaiz.github.io/blog/posts/approximation-theory-data-science/index_files/figure-html/fig-optimal-fit-output-1.png" id="fig-optimal-fit" class="quarto-figure quarto-figure-center anchored figure-img" width="794" height="510">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-optimal-fit-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2
</figcaption>
</figure>
</div>
</div>
</div>
<div style="page-break-after: always;"></div>
<p><strong>3. Overfitting (High Variance):</strong> If the degree is too high (e.g., 15), the model connects the dots blindly, capturing noise instead of the signal.</p>
<div id="cell-fig-overfitting" class="cell" data-execution_count="3">
<div class="cell-output cell-output-display">
<div id="fig-overfitting" class="quarto-float quarto-figure quarto-figure-center anchored" width="794" data-fig-align="center" height="510">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-overfitting-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://yahaiz.github.io/blog/posts/approximation-theory-data-science/index_files/figure-html/fig-overfitting-output-1.png" id="fig-overfitting" class="quarto-figure quarto-figure-center anchored figure-img" width="794" height="510">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-overfitting-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;3
</figcaption>
</figure>
</div>
</div>
</div>
<div style="page-break-after: always;"></div>
</section>
<section id="selecting-the-best-model" class="level3">
<h3 class="anchored" data-anchor-id="selecting-the-best-model">Selecting the Best Model</h3>
<p>To find the right degree (<img src="https://latex.codecogs.com/png.latex?n">), we look at the <strong>Mean Squared Error (MSE)</strong>. As complexity goes up, training error always drops, but test error (generalization) will eventually spike.</p>
<div id="cell-fig-bias-variance" class="cell" data-execution_count="4">
<div class="cell-output cell-output-display">
<div id="fig-bias-variance" class="quarto-float quarto-figure quarto-figure-center anchored" width="822" data-fig-align="center" height="449">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-bias-variance-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://yahaiz.github.io/blog/posts/approximation-theory-data-science/index_files/figure-html/fig-bias-variance-output-1.png" id="fig-bias-variance" class="quarto-figure quarto-figure-center anchored figure-img" width="822" height="449">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-bias-variance-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;4
</figcaption>
</figure>
</div>
</div>
</div>
<div style="page-break-after: always;"></div>
</section>
</section>
<section id="beyond-2d-multiple-regression" class="level2">
<h2 class="anchored" data-anchor-id="beyond-2d-multiple-regression">Beyond 2D: Multiple Regression</h2>
<p>Real-world problems rarely have just one variable. Suppose we add <strong>Competitor’s Price (<img src="https://latex.codecogs.com/png.latex?z">)</strong>. Now, our model is a plane in 3D: <img src="https://latex.codecogs.com/png.latex?y%20=%20a_0%20+%20a_1%20x%20+%20a_2%20z">.</p>
<p>Mathematically, nothing changes. We solve the same normal equations, just with a larger matrix <img src="https://latex.codecogs.com/png.latex?A">.</p>
<div id="cell-fig-multiple-regression" class="cell" data-execution_count="5">
<div class="cell-output cell-output-display">
<div id="fig-multiple-regression" class="quarto-float quarto-figure quarto-figure-center anchored" width="408" data-fig-align="center" height="417">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-multiple-regression-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://yahaiz.github.io/blog/posts/approximation-theory-data-science/index_files/figure-html/fig-multiple-regression-output-1.png" id="fig-multiple-regression" class="quarto-figure quarto-figure-center anchored figure-img" width="408" height="417">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-multiple-regression-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;5
</figcaption>
</figure>
</div>
</div>
</div>
<div style="page-break-after: always;"></div>
</section>
<section id="the-continuous-problem-signal-processing" class="level2">
<h2 class="anchored" data-anchor-id="the-continuous-problem-signal-processing">The Continuous Problem: Signal Processing</h2>
<p>Discrete data is standard in business, but fields like audio processing or ECG analysis deal with <strong>continuous signals</strong>. Here, we want to approximate a complex function <img src="https://latex.codecogs.com/png.latex?f(x)"> with a polynomial for compression or speed.</p>
<section id="minimizing-the-integral" class="level3">
<h3 class="anchored" data-anchor-id="minimizing-the-integral">Minimizing the Integral</h3>
<p>Since we are dealing with functions, not points, we switch from summation to integration. We minimize the <strong>Integral of Squared Error</strong>:</p>
<p><img src="https://latex.codecogs.com/png.latex?E%20=%20%5C%7C%20f%20-%20P_n%20%5C%7C_2%5E2%20=%20%5Cint_a%5Eb%20(f(x)%20-%20P_n(x))%5E2%20dx"></p>
</section>
<section id="the-trap-standard-basis-vs.-orthogonality" class="level3">
<h3 class="anchored" data-anchor-id="the-trap-standard-basis-vs.-orthogonality">The Trap: Standard Basis vs.&nbsp;Orthogonality</h3>
<p>A beginner might try the standard basis (<img src="https://latex.codecogs.com/png.latex?1,%20x,%20x%5E2,%20x%5E3">). Here is the problem: on the interval <img src="https://latex.codecogs.com/png.latex?%5B0,%201%5D">, <img src="https://latex.codecogs.com/png.latex?x%5E2"> and <img src="https://latex.codecogs.com/png.latex?x%5E3"> look very similar. They are highly correlated (multicollinearity). This confuses the model and makes coefficients unstable.</p>
<p>The fix is <strong>Orthogonality</strong>. We need features that are independent, meaning their inner product is zero:</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Clangle%20%5Cphi_i,%20%5Cphi_j%20%5Crangle%20=%20%5Cint_a%5Eb%20%5Cphi_i(x)%20%5Cphi_j(x)%20dx%20=%200%20%5Cquad%20(i%20%5Cneq%20j)"></p>
<p>Orthogonal bases (like Legendre Polynomials) give us:</p>
<ol type="1">
<li><p><strong>Decoupling:</strong> We can calculate each coefficient separately.</p></li>
<li><p><strong>Stability:</strong> Adding a higher-degree term doesn’t mess up the previous ones.</p></li>
</ol>
<div id="cell-fig-basis-correlation" class="cell" data-execution_count="6">
<div class="cell-output cell-output-display">
<div id="fig-basis-correlation" class="quarto-float quarto-figure quarto-figure-center anchored" width="1123" data-fig-align="center" height="469">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-basis-correlation-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://yahaiz.github.io/blog/posts/approximation-theory-data-science/index_files/figure-html/fig-basis-correlation-output-1.png" id="fig-basis-correlation" class="quarto-figure quarto-figure-center anchored figure-img" width="1123" height="469">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-basis-correlation-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;6
</figcaption>
</figure>
</div>
</div>
</div>
</section>
</section>
<section id="final-simulation-reconstructing-a-complex-signal" class="level2">
<h2 class="anchored" data-anchor-id="final-simulation-reconstructing-a-complex-signal">Final Simulation: Reconstructing a Complex Signal</h2>
<p>To show the power of Continuous Least Squares, let’s reconstruct a complex signal (mixed sine, cosine, and exponentials) using Legendre polynomials. Because of orthogonality, we can compute the “contribution” of each degree independently.</p>
<div id="cell-fig-continuous-reconstruction" class="cell" data-execution_count="7">
<div class="cell-output cell-output-display">
<div id="fig-continuous-reconstruction" class="quarto-float quarto-figure quarto-figure-center anchored" width="954" data-fig-align="center" height="523">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-continuous-reconstruction-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://yahaiz.github.io/blog/posts/approximation-theory-data-science/index_files/figure-html/fig-continuous-reconstruction-output-1.png" id="fig-continuous-reconstruction" class="quarto-figure quarto-figure-center anchored figure-img" width="954" height="523">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig quarto-uncaptioned" id="fig-continuous-reconstruction-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;7
</figcaption>
</figure>
</div>
</div>
</div>
<p>This process highlights the elegance of the math: by projecting complex realities onto simpler orthogonal structures, we get both speed and clarity.</p>
<hr>
<p><strong>Course Info:</strong></p>
<ul>
<li><p><strong>Instructor:</strong> Dr.&nbsp;Najmeh Hosseini Monjezi</p></li>
<li><p><strong>University:</strong> University of Isfahan</p></li>
</ul>


</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Data Science</category>
  <category>Machine Learning</category>
  <category>Numerical Analysis</category>
  <category>Mathematics</category>
  <guid>https://yahaiz.github.io/blog/posts/approximation-theory-data-science/</guid>
  <pubDate>Mon, 29 Dec 2025 20:30:00 GMT</pubDate>
  <media:content url="https://yahaiz.github.io/blog/posts/approximation-theory-data-science/approximation-ds.png" medium="image" type="image/png" height="107" width="144"/>
</item>
<item>
  <title>Java Scanner: The Ultimate Beginner’s Guide</title>
  <dc:creator>Yahya Izadi</dc:creator>
  <dc:creator>Pooyan Motamedi</dc:creator>
  <link>https://yahaiz.github.io/blog/posts/java-scanner/</link>
  <description><![CDATA[ 






<section id="introduction-the-scanner-machine" class="level2">
<h2 class="anchored" data-anchor-id="introduction-the-scanner-machine">Introduction: The Scanner Machine</h2>
<p>By default, the variables you write in code are fixed. But what if we want to ask the user for the numbers?</p>
<p>Think of the <strong>Scanner</strong> like a physical scanner machine in an office. Usually, when you put a paper in a physical scanner, it scans the <strong>entire</strong> page at once.</p>
<p>In Java, our Scanner is a bit different. It looks at what the user types on the keyboard, but we can be very specific about <strong>what</strong> to scan. We can tell it: <em>“Only scan the next number (int)”</em> or <em>“Only scan the next decimal point (float).”</em></p>
<hr>
</section>
<section id="the-3-steps" class="level2">
<h2 class="anchored" data-anchor-id="the-3-steps">The 3 Steps</h2>
<p>To use the Scanner, follow these three steps.</p>
<section id="step-1-the-import-line" class="level3">
<h3 class="anchored" data-anchor-id="step-1-the-import-line">Step 1: The Import Line</h3>
<p>Java hides the Scanner tool in a specific library. You need to tell Java where to find it. Put this line at the <strong>very top</strong> of your file.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode java code-with-copy"><code class="sourceCode java"><span id="cb1-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">import</span> <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">java</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">util</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">Scanner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span></code></pre></div></div>
</section>
<section id="step-2-turn-on-the-scanner" class="level3">
<h3 class="anchored" data-anchor-id="step-2-turn-on-the-scanner">Step 2: Turn on the Scanner</h3>
<p>Inside your code (in the <code>main</code> section), you need to write a specific line to set up the scanner.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>This line looks a bit complicated with keywords like <code>new</code> and <code>System.in</code>. <strong>For now, please just accept this line as a rule.</strong> Copy and paste it exactly as it is.</p>
</div>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode java code-with-copy"><code class="sourceCode java"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// This line prepares the scanner to read from the keyboard</span></span>
<span id="cb2-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Scanner</span> input <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">new</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Scanner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">System</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">in</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span></code></pre></div></div>
</section>
<section id="step-3-scan-the-data" class="level3">
<h3 class="anchored" data-anchor-id="step-3-scan-the-data">Step 3: Scan the Data</h3>
<p>Now, you command the scanner to wait for the user to type something and store it in a variable.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode java code-with-copy"><code class="sourceCode java"><span id="cb3-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> age <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> input<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextInt</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span></code></pre></div></div>
<hr>
</section>
</section>
<section id="cheat-sheet-which-command-to-use" class="level2">
<h2 class="anchored" data-anchor-id="cheat-sheet-which-command-to-use">Cheat Sheet: Which Command to Use?</h2>
<p>Depending on the <strong>Data Type</strong> (variable) you want to fill, you must use a specific command.</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Data Type</th>
<th style="text-align: left;">Command</th>
<th style="text-align: left;">Example Use Case</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>int</code></td>
<td style="text-align: left;"><code>input.nextInt()</code></td>
<td style="text-align: left;">Whole numbers (Age, Year)</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>long</code></td>
<td style="text-align: left;"><code>input.nextLong()</code></td>
<td style="text-align: left;">Large whole numbers (Population)</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>float</code></td>
<td style="text-align: left;"><code>input.nextFloat()</code></td>
<td style="text-align: left;">Decimal numbers (Temperature)</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>double</code></td>
<td style="text-align: left;"><code>input.nextDouble()</code></td>
<td style="text-align: left;">Decimal numbers (Price, GPA)</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>boolean</code></td>
<td style="text-align: left;"><code>input.nextBoolean()</code></td>
<td style="text-align: left;">True/False answers</td>
</tr>
</tbody>
</table>
<hr>
</section>
<section id="full-code-example" class="level2">
<h2 class="anchored" data-anchor-id="full-code-example">💻 Full Code Example</h2>
<p>Here is a complete program. It asks for a student’s number and age.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode java code-with-copy"><code class="sourceCode java"><span id="cb4-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">import</span> <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">java</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">util</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">Scanner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// Step 1</span></span>
<span id="cb4-2"></span>
<span id="cb4-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">public</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> Main <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb4-4">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">public</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">void</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">main</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">String</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> args<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb4-5">    </span>
<span id="cb4-6">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// Step 2: Setup the Scanner </span></span>
<span id="cb4-7">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// (Remember: Just copy this line for now!)</span></span>
<span id="cb4-8">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Scanner</span> input <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">new</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Scanner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">System</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">in</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb4-9"></span>
<span id="cb4-10">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// Step 3: Ask and Scan</span></span>
<span id="cb4-11">        </span>
<span id="cb4-12">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 1. Ask for an Integer</span></span>
<span id="cb4-13">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">System</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">out</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Enter your Student Number: "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb4-14">        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> studentNumber <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> input<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextInt</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb4-15"></span>
<span id="cb4-16">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 2. Ask for an Integer</span></span>
<span id="cb4-17">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">System</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">out</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Enter your age: "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb4-18">        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> age <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> input<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nextInt</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb4-19"></span>
<span id="cb4-20">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// Print the results back to see if it worked</span></span>
<span id="cb4-21">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">System</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">out</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">println</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- Result ---"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb4-22">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">System</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">out</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">println</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Student Number: "</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> studentNumber<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb4-23">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">System</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">out</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">println</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Age: "</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> age<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb4-24">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb4-25"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
<hr>
</section>
<section id="summary" class="level2">
<h2 class="anchored" data-anchor-id="summary">Summary</h2>
<ol type="1">
<li><strong>Import</strong> the tool at the top: <code>import java.util.Scanner;</code></li>
<li><strong>Setup</strong> the tool inside main: <code>Scanner input = new Scanner(System.in);</code></li>
<li><strong>Scan</strong> the specific type you need: <code>nextInt()</code> or <code>nextDouble()</code>.</li>
</ol>
<p>Happy Coding! 🚀</p>


</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Java</category>
  <category>Programming</category>
  <category>Beginners</category>
  <category>Tutorial</category>
  <guid>https://yahaiz.github.io/blog/posts/java-scanner/</guid>
  <pubDate>Sun, 23 Nov 2025 20:30:00 GMT</pubDate>
  <media:content url="https://yahaiz.github.io/blog/posts/java-scanner/java-scanner.png" medium="image" type="image/png" height="108" width="144"/>
</item>
</channel>
</rss>
