<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sai-2025 on Medium]]></title>
        <description><![CDATA[Stories by Sai-2025 on Medium]]></description>
        <link>https://medium.com/@sai2025?source=rss-674f9d1c3c52------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pzvORz74QG_InAN4</url>
            <title>Stories by Sai-2025 on Medium</title>
            <link>https://medium.com/@sai2025?source=rss-674f9d1c3c52------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 18:44:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sai2025/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Interrupts vs. Polling in Embedded Systems: ESP32 & STM32 Deep Dive]]></title>
            <link>https://sai2025.medium.com/interrupts-vs-polling-in-embedded-systems-esp32-stm32-deep-dive-1e90f05cf0be?source=rss-674f9d1c3c52------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e90f05cf0be</guid>
            <category><![CDATA[stm32]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[interrupt-pending]]></category>
            <category><![CDATA[firmware]]></category>
            <category><![CDATA[iot]]></category>
            <dc:creator><![CDATA[Sai-2025]]></dc:creator>
            <pubDate>Mon, 13 Oct 2025 13:47:08 GMT</pubDate>
            <atom:updated>2025-10-13T14:04:51.528Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0k4WRtddcsbta8N8JnSUEA.png" /><figcaption>Interrupts vs. Polling</figcaption></figure><p>When building responsive, power-efficient, and scalable embedded systems — whether it’s an IoT sensor node on an <strong>ESP32</strong> or a motor controller on an <strong>STM32</strong> — one of the most foundational decisions you’ll make is <strong>how your firmware reacts to external events</strong>.</p><p>Do you <strong>continuously check</strong> for changes (polling)?<br> Or do you <strong>wait to be notified</strong> the moment something happens (interrupts)?</p><p>This isn’t just a coding style choice — it’s a <strong>system architecture decision</strong> that impacts <strong>real-time performance</strong>, <strong>power consumption</strong>, <strong>CPU utilization</strong>, and even <strong>hardware reliability</strong>.</p><p>Let’s explore how these two paradigms work <strong>under the hood</strong>, why modern MCUs like the ESP32 and STM32 are optimized for interrupts, and when you should lean toward one over the other.</p><h3>Polling: The “Ask Repeatedly” Approach</h3><h3>🧩 How It Works Internally</h3><p>In polling, the CPU <strong>actively and repeatedly reads</strong> a hardware register (e.g., a GPIO input pin, UART status flag, or ADC conversion complete bit) in a loop to check if a condition has changed.</p><ul><li>The CPU <strong>never sleeps</strong> during this check — it’s fully engaged in reading and evaluating.</li><li>Every iteration consumes clock cycles, even when nothing has happened.</li><li>On ESP32 (dual-core Xtensa LX6) or STM32 (ARM Cortex-M), this means one core or thread is <strong>blocked</strong> in a busy-wait loop.</li></ul><h3>🔄 Data Flow in Polling</h3><pre>CPU → Reads peripheral register → Checks flag → (No event?) → Loop again<br>                              ↘ (Event detected?) → Process data</pre><h3>When Polling Makes Sense</h3><ul><li><strong>Infrequent or predictable events</strong> (e.g., reading a configuration switch at boot)</li><li><strong>Simple systems</strong> with no strict timing requirements</li><li><strong>Debugging or prototyping</strong>, where determinism and visibility matter more than efficiency</li></ul><h3>⚠️ Hidden Costs</h3><ul><li><strong>Wasted CPU cycles</strong>: Even at 80 MHz, those cycles could be used for other tasks.</li><li><strong>Higher power draw</strong>: The CPU stays awake, preventing entry into low-power modes.</li><li><strong>Poor scalability</strong>: Adding more polled peripherals increases CPU load linearly.</li></ul><h3>⚡ Interrupts: The “Notify Me” Paradigm</h3><h3>🧩 How It Works Internally</h3><p>Interrupts flip the model: instead of the CPU asking, the <strong>hardware tells the CPU</strong> when something important happens.</p><p>On both <strong>ESP32</strong> and <strong>STM32</strong>, this is managed by a dedicated <strong>Nested Vectored Interrupt Controller (NVIC)</strong> (on STM32) or a <strong>similar interrupt matrix</strong> (on ESP32). Here’s what happens when an event occurs:</p><ol><li>A peripheral (e.g., GPIO, UART, timer) asserts an <strong>interrupt request (IRQ)</strong>.</li><li>The interrupt controller checks:</li></ol><ul><li>Is the interrupt <strong>enabled</strong>?</li><li>What is its <strong>priority</strong>? (STM32 supports 0–15 priority levels; ESP32 uses similar schemes)</li><li>If allowed, the CPU <strong>pauses</strong> the current execution context.</li></ul><ol><li>It <strong>saves the program counter and registers</strong> (minimal context) onto the stack.</li><li>It <strong>jumps to a pre-defined Interrupt Service Routine (ISR)</strong>.</li><li>After the ISR finishes, the CPU <strong>restores context</strong> and resumes normal execution.</li></ol><h3>🔄 Data Flow in Interrupt-Driven Systems</h3><pre>Peripheral event → IRQ signal → NVIC/interrupt matrix → CPU halts main thread<br>               → Save context → Execute ISR → Restore context → Resume main code</pre><h3>🚀 Why ESP32 &amp; STM32 Excel at Interrupts</h3><ul><li><strong>Hardware acceleration</strong>: Both MCUs have <strong>dedicated logic</strong> to handle interrupts with minimal latency (often &lt; 100 ns on STM32 Cortex-M).</li><li><strong>Priority preemption</strong>: Higher-priority interrupts can <strong>interrupt lower-priority ISRs</strong> (on STM32 with proper configuration).</li><li><strong>Low-power synergy</strong>: The CPU can sleep in <strong>deep-sleep or stop modes</strong>, waking <strong>only</strong> when an interrupt arrives — critical for battery-powered ESP32 IoT devices.</li></ul><h3>🧠 Real-World Use Cases</h3><ul><li><strong>UART reception</strong>: Don’t miss a single byte — interrupt on RXNE (receive not empty).</li><li><strong>Sensor triggers</strong>: A PIR motion sensor pulls a GPIO line → wake up and log.</li><li><strong>CAN bus messages</strong>: Critical in automotive STM32 apps — handled instantly via interrupt.</li><li><strong>Timer overflows</strong>: Precise timing for PWM, sampling, or watchdogs.</li></ul><h3>⚖️ The Trade-Offs: Latency, Complexity, and Determinism</h3><p>Factor Polling Interrupts <strong>Latency</strong> High (depends on loop speed) Very low (hardware-triggered) <strong>CPU Usage</strong> High (100% while polling) Near-zero when idle <strong>Power Efficiency</strong> Poor (CPU always on) Excellent (CPU sleeps until event) <strong>Complexity</strong> Simple, linear logic Requires careful ISR design <strong>Race Conditions</strong> Rare (single-threaded flow) Possible (shared data between ISR &amp; main) <strong>Debugging</strong> Easy (predictable flow) Harder (asynchronous, timing-sensitive)</p><blockquote><em>💡 </em><strong><em>Key Insight</em></strong><em>: Interrupts introduce </em><strong><em>asynchronicity</em></strong><em>. Your main code and ISR may access the same variable — without protection (e.g., disabling interrupts or using atomics), data corruption can occur.</em></blockquote><h3>🛠️ Best Practices: The Hybrid Architecture (What Pros Actually Use)</h3><p>In real-world ESP32 and STM32 firmware, <strong>pure polling or pure interrupts rarely win</strong>. Instead, seasoned embedded developers use a <strong>hybrid approach</strong>:</p><h3>✅ Use Interrupts for:</h3><ul><li><strong>Time-critical events</strong>: Communication (UART/SPI/I²C/CAN), encoder pulses, emergency stops</li><li><strong>Low-duty-cycle sensors</strong>: Wake-on-change GPIOs (e.g., door open/close)</li><li><strong>Precise timing</strong>: Timer-based sampling or waveform generation</li></ul><h3>✅ Use Polling (or better: RTOS tasks) for:</h3><ul><li><strong>Non-urgent background work</strong>: System health checks, LED blinking, logging</li><li><strong>High-throughput data processing</strong>: Once data is captured via interrupt, process it in a main loop or task</li><li><strong>User interfaces</strong>: Button debouncing (often polled with timers) or display updates</li></ul><blockquote><em>🔧 </em><strong><em>Pro Tip</em></strong><em>: On ESP32 (with FreeRTOS) or STM32 (with CMSIS-RTOS or bare-metal), </em><strong><em>queue data from ISRs to tasks</em></strong><em>. The ISR captures the event quickly; the task handles heavy lifting later — best of both worlds.</em></blockquote><h3>🔍 Why This Matters for ESP32 &amp; STM32 Specifically</h3><ul><li><strong>ESP32</strong>: Dual-core, Wi-Fi/BLE radio, and rich peripherals mean <strong>efficient interrupt handling is non-negotiable</strong>. Let the CPU sleep while waiting for Wi-Fi packets or sensor triggers.</li><li><strong>STM32</strong>: Cortex-M cores are <strong>designed around interrupts</strong> — NVIC, SysTick, and low-latency wake-up make them ideal for hard real-time control (e.g., motor drives, industrial PLCs).</li></ul><p>Both platforms provide <strong>extensive documentation</strong> (ST’s RM0008 for STM32, Espressif’s Technical Reference Manual for ESP32) detailing interrupt vector tables, priority grouping, and wake-up sources — proof that interrupts are <strong>first-class citizens</strong> in their architecture.</p><h3>Final Thoughts</h3><p>Choosing between interrupts and polling isn’t about “which is better” — it’s about <strong>matching the mechanism to the event’s nature</strong>.</p><ul><li><strong>Need instant response?</strong> → Interrupts</li><li><strong>Processing bulk data or non-critical status?</strong> → Polling (or better: a scheduled task)</li><li><strong>Building a battery-powered ESP32 sensor?</strong> → Sleep + interrupt wake-up</li><li><strong>Controlling a drone with STM32?</strong> → Prioritized interrupts for IMU and ESC signals</li></ul><p>Master this balance, and you’ll write firmware that’s not just functional — but <strong>efficient, responsive, and robust</strong>.</p><h3>📚 Further Learning</h3><ul><li><strong>STM32 Reference Manual (RM0008)</strong> — <em>Interrupts and NVIC chapter</em></li><li><strong>ESP32 Technical Reference Manual</strong> — <em>Interrupt Matrix &amp; GPIO chapters</em></li><li><strong>ARM Cortex-M3/M4 Technical Guide</strong> — <em>Exception Model &amp; Interrupt Handling</em></li><li><strong>FreeRTOS Documentation</strong> — <em>ISR-to-task communication patterns</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e90f05cf0be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Can You Trust Your Model If You Can’t Trust Its Coefficients?]]></title>
            <link>https://sai2025.medium.com/can-you-trust-your-model-if-you-cant-trust-its-coefficients-b18b9ed3f726?source=rss-674f9d1c3c52------2</link>
            <guid isPermaLink="false">https://medium.com/p/b18b9ed3f726</guid>
            <category><![CDATA[ridge-regression]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[model-interpretation]]></category>
            <category><![CDATA[data-science-interview]]></category>
            <category><![CDATA[multicollinearity]]></category>
            <dc:creator><![CDATA[Sai-2025]]></dc:creator>
            <pubDate>Tue, 24 Jun 2025 11:01:42 GMT</pubDate>
            <atom:updated>2025-06-24T11:30:25.223Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6dkhAfCuucaeiFZ2H9RK1w.png" /></figure><blockquote>“A model that predicts well but explains poorly is like a doctor who treats symptoms without knowing the disease.</blockquote><blockquote>📖 Description</blockquote><p>Even when your regression gives near-perfect predictions, <strong>collinearity among features</strong> can quietly sabotage your model — making its <strong>interpretations unreliable or even dangerous</strong>.</p><p>In this post, we break down <strong>why</strong> this happens, <strong>how</strong> to detect it, and most importantly — <strong>what you can do about it</strong>.</p><p>We walk step-by-step through the math of linear regression, explain how collinearity disrupts it, and visualize the impact on model trust and stability.</p><h3>🚀 Table of Contents</h3><ol><li>Linear Regression Setup</li><li>Estimating the Coefficients</li><li>Solving the Optimization</li><li>Collinearity Enters the Scene</li><li>How Collinearity Affects Weight Stability</li><li>High Variance and Why It Matters</li><li>Visual Comparisons &amp; Geometric Intuition</li><li>Summary &amp; Remedies</li></ol><h3>Step 1: Linear Regression Setup</h3><p>You’re given:</p><ul><li>n data samples</li><li>p input features</li><li>Input matrix X (n x p)</li><li>Target vector y (n x 1)</li></ul><p>The regression model:</p><blockquote><strong>y = Xβ + ε</strong></blockquote><p>Where:</p><ul><li>β = vector of coefficients</li><li>ε = Gaussian noise (mean 0, variance σ²)</li></ul><h3>Step 2: Goal — Estimate β</h3><p>We want to find β̂ that minimizes:</p><p><strong>J(β) = || y — Xβ ||²</strong></p><p>This is the residual sum of squares — the core of regression.</p><h3>Step 3: Derive the Normal Equation</h3><p><strong>Loss function:</strong></p><p>J(β) = (y — Xβ)ᵀ(y — Xβ)</p><p>J(β) = yᵀy — 2βᵀXᵀy + βᵀXᵀXβ</p><p><strong>Gradient:</strong></p><p>∂J/∂β = 2XᵀXβ — 2Xᵀy = 0</p><p><strong>Normal Equation:</strong></p><p>XᵀXβ = Xᵀy</p><p><strong>Solution:</strong></p><p><strong>β̂ = (XᵀX)⁻¹Xᵀy</strong></p><p><em>(Assumes XᵀX is invertible)</em></p><h3>Step 4: When Is the Matrix Well-Conditioned?</h3><p>If features are <strong>uncorrelated or weakly correlated</strong>, then:</p><ul><li>XᵀX is well-conditioned</li><li>(XᵀX)⁻¹ is stable</li><li>Coefficients are <strong>interpretable and consistent</strong></li></ul><h3>Step 5: Now — What Is Collinearity?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CblnR02Bsv1kq2hV9h7law.png" /></figure><p>Collinearity happens when one feature is almost a linear combo of others:</p><p><strong>X_j ≈ ∑ α_k X_k</strong> (for k ≠ j)</p><p>This makes it hard for the model to distinguish their contributions.</p><p>Simplify, Colinear means as `correlation as among input variables`</p><h3>Step 6: Breakdown of XᵀX</h3><p>With collinearity:</p><ul><li>XᵀX becomes nearly <strong>singular</strong></li><li>Determinant is close to 0</li><li>Inverse (XᵀX)⁻¹ becomes <strong>unstable or undefined</strong></li></ul><h3>Step 7: Effect on Weights</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OfEuM-rO6jBM2vTt9vlIAA.png" /></figure><p>As a result:</p><ul><li>β̂ becomes <strong>very sensitive</strong> to small changes in y</li><li>Coefficients may explode or flip signs</li><li>Interpretation becomes <strong>untrustworthy</strong></li></ul><h3>Step 8: Variance of β̂</h3><p>The variance of the weights is:</p><p><strong>Var(β̂) = σ² (XᵀX)⁻¹</strong></p><p>When collinearity exists:</p><ul><li>Variance becomes <strong>large</strong></li><li>Confidence intervals widen</li><li>Coefficient significance breaks down</li></ul><h3>📊 Interpretation Table</h3><pre>| **Term*    | **Meaning**                                                                           |<br>| ----------- | ------------------------------------------------------------------------------------- |<br>| β̂     | Estimated regression coefficients                                                     |<br>| Var(β̂)     |    Variance (uncertainty) of each coefficient                                            |<br>| σ²**      | Variance of the noise in the data                                                     |<br>|  (XᵀX)⁻¹  | Inverse of feature correlation matrix; becomes unstable or explodes with collinearity |</pre><h3>⚠️ Why High Variance Matters</h3><ul><li><strong>Unstable coefficients</strong>: Small data tweaks → big weight changes</li><li><strong>Low interpretability</strong>: Coefficient values mean less</li><li><strong>Wide confidence intervals</strong>: Model is unsure</li></ul><h3>Stepwise Visual Contrast</h3><pre>| **What Changes**      | **Without Collinearity**          | **With Collinearity**    |<br>|----------------------|----------------------------------|----------------------------|<br>| **XᵀX**              | Invertible, stable               | Nearly singular            |<br>| **(XᵀX)⁻¹**          | Small, controlled                | Large, unstable            |<br>| **β̂**               | Unique, interpretable             | Exploding or unreliable    |<br>| **Variance of β̂**   | Low                              | High                        |</pre><h3>Summary &amp; Remedies</h3><p>✅ <strong>Key points:</strong></p><ul><li>Collinearity makes XᵀX unstable</li><li>Variance of β̂ increases</li><li>Interpretations become untrustworthy</li><li>Model may still predict well, but <strong>explanation is broken</strong></li></ul><h3>💡 How to Fix It</h3><ul><li>Use <strong>VIF (Variance Inflation Factor)</strong> to detect collinearity</li><li>Drop or combine correlated features</li><li>Use <strong>PCA</strong> to remove redundancy</li><li>Use <strong>Ridge Regression</strong> (L2 penalty) to reduce variance</li></ul><h3>🔍 Geometric Intuition</h3><p>Imagine features as vectors.<br> If two features point almost in the same direction (i.e., nearly parallel), the model can’t tell which one explains the outcome.<br> That’s <strong>collinearity</strong> — it’s confusion in the math.</p><h3>🧠 Final Takeaway</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vIIpTjxqRunMo7O-3iLTkw.png" /></figure><blockquote><strong><em>High prediction accuracy ≠ trustworthy coefficients</em></strong></blockquote><blockquote><em>Always ask:<br> </em>“Can I trust the weights I’m interpreting?”</blockquote><h3>👨‍🏫 Bonus Notes</h3><ul><li><strong>Correlation</strong> = relationship between any 2 variables</li><li><strong>Multicollinearity</strong> = correlation among input variables</li><li>Detect with <strong>VIF</strong>, solve with <strong>PCA</strong> or <strong>regularization</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b18b9ed3f726" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[100 Days, 100 Data Science Interview Questions — Master Your Prep!]]></title>
            <link>https://sai2025.medium.com/100-days-100-data-science-interview-questions-master-your-prep-86d3e351218d?source=rss-674f9d1c3c52------2</link>
            <guid isPermaLink="false">https://medium.com/p/86d3e351218d</guid>
            <category><![CDATA[compare-two-distributions]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science-interview]]></category>
            <category><![CDATA[probability-distributions]]></category>
            <category><![CDATA[distribution-comparison]]></category>
            <dc:creator><![CDATA[Sai-2025]]></dc:creator>
            <pubDate>Fri, 21 Mar 2025 12:50:49 GMT</pubDate>
            <atom:updated>2025-03-21T12:50:49.633Z</atom:updated>
            <content:encoded><![CDATA[<h3>100 Days — 100 Data Science Interview Questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2zCziL3O47mDLo80X79hw.jpeg" /><figcaption>Comparing Two dataset</figcaption></figure><p>Day 1: How to Compare Two Datasets — A Simple Trick!</p><h4>In data science, this is a common question !</h4><p>We need to check if two datasets come from the same kind of numbers (same distribution) or not. ? Imagine you have two big lists of numbers. You want to know:<br> 👉 <strong>Are they similar distribution, or are they different?</strong></p><h4><strong>Problem Statement:</strong></h4><p>You are provided with two datasets: <strong>X_test</strong> (testing data) and <strong>X_val</strong> (validation data). Your task is to determine if these two datasets originate from the same distribution or different distributions. Provide a statistical explanation for your conclusion, and implement the necessary code to support your findings.</p><p>Xtest= [194, 245, 238, 141, 183, 330, 313, 326, 158, 205, 289, 151, 282, 117, 252, 441, 277, 193, 167, 400, 164, 246, 351, 231, 149, 248, 206, 254, 23, 309, 291, 370, 290, 86, 214, 141, 194, 272, 115, 260, 200, 101, 85, 457, 139, 258, 303, 288, 286, 306, 186, 248, 45, 282, 480, 239, 332, 195, 239, 263, 503, 142, 366, 222, 334, 231, 119, 299, 228, 213, 206, 325, 192, 273, 251, 286, 356, 286, 422, 240, 328, 397, 183, 323, 293, 202, 325, 163, 309, 215, 259, 202, 244, 314, 348, 291, 155, 221, 369, 435, 278, 301, 261, 269, 390, 250, 161, 345, 94, 234, 278, 345, 227, 292, 234, 415, 232, 246, 221, 261, 250, 227, 361, 284, 276, 404, 314, 316, 242, 249, 206, 239, 210, 334, 316]</p><p>Xval = [452.0, 125.0, 141.0, 427.0, 106.0, 291.0, 474.0, 357.0, 201.0, 299.0, 470.0, 148.0, 405.0, 31.0, 333.0, 279.0, 124.0, 482.0, 289.0, 321.0, 261.0, 492.0, 77.0, 190.0, 334.0, 390.0, 118.0, 51.0, 260.0, 481.0, 225.0, 94.0, 291.0, 143.0, 38.0, 107.0, 169.0, 471.0, 447.0, 125.0, 375.0, 323.0, 410.0, 109.0, 496.0, 471.0, 97.0, 199.0, 416.0, 58.0, 51.0, 117.0, 39.0, 482.0, 438.0, 482.0, 318.0, 412.0, 225.0, 389.0, 210.0, 330.0, 403.0, 286.0, 401.0, 112.0, 426.0, 230.0, 340.0, 237.0, 240.0, 344.0, 118.0, 95.0, 307.0, 209.0, 116.0, 203.0, 202.0, 71.0, 360.0, 36.0, 90.0, 108.0, 471.0, 207.0, 482.0, 344.0, 162.0, 107.0, 269.0, 151.0, 48.0, 197.0, 314.0, 455.0, 351.0, 288.0, 303.0, 346.0, 466.0, 370.0, 173.0, 94.0, 108.0, 443.0, 59.0, 161.0, 189.0]</p><h4><strong>Solution:</strong></h4><p><em>Quantile-Quantile (QQ) plots are a powerful visualization technique used to determine whether a dataset follows a specific distribution, often focusing on normal (Gaussian) distributions. While QQ plots are commonly used to check if a dataset matches a known distribution, they can also provide insights into the similarity between two datasets. In this problem, you will compare two datasets, </em><strong><em>X_test</em></strong><em> and </em><strong><em>X_val</em></strong><em>, using a QQ plot to assess whether their distributions are similar. Follow the steps below to implement and interpret the QQ plot:</em></p><ol><li>Sort the Data:</li></ol><p>Arrange the elements of <strong>X_test </strong>and <strong>X_val</strong> in ascending order to align their quantiles as showin in sorting the data fig 01</p><figure><img alt="sorting the data fig 01" src="https://cdn-images-1.medium.com/max/553/1*EANPoYgK0zZZ-PAtykzK8A.png" /><figcaption>sorting the data fig 01</figcaption></figure><p>2. For The give the data was the Compute the percentiles corresponding to 1 through 100 for both datasets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*dZbvRfkevuSeNw8u2nHG_A.png" /><figcaption>Computing Percentiles</figcaption></figure><p>3. Plot the computed percentiles of X_test against those of X_val using a pair plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*UjnPrNxTU-1sgY2WgXHwXg.png" /><figcaption>Pair’s plot on two datasets</figcaption></figure><p>4. Analyze the plot:</p><p>Once you have plotted the percentiles of <strong>X_test</strong> against the percentiles of <strong>X_val</strong>, the next step is to analyze the resulting graph. The goal of this analysis is to determine if the two datasets come from similar distributions. If the points on the <strong><em>plot align closely to a straight diagonal line</em></strong>, it indicates that the two datasets share a <strong><em>similar distribution.</em></strong> This happens because, at each percentile, the values in <strong>X_test</strong> and <strong>X_val</strong> are proportionally similar. A straight line signifies that there is a consistent relationship between the percentiles of the two datasets. However, if the points deviate significantly from a straight line — forming curves, clusters, or showing irregular patterns — this suggests that the distributions of <strong>X_test</strong> and <strong>X_val</strong> are different. The deviations indicate inconsistencies in the data, meaning that at corresponding percentiles, the values in the two datasets do not match in a proportional way.</p><p>This method provides a visual and intuitive way to compare distributions and identify similarities or differences between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*Keg0BM3FHAIEvfa7jibabQ.png" /><figcaption>QQ plot of two distributions</figcaption></figure><p>Now, Observe that points significantly deviate from a straight line, forming curves or clusters, Xtest and Xval come from different distributions.</p><h4>🔗 Code for This Question</h4><p>You can find the full implementation of this solution here:<br> 👉 <strong>GitHub:</strong> <a href="https://github.com/sAI-2025/Blogs/tree/main/Simmillarity%20of%20two%20distribution">Similarity of Two Distributions</a></p><h4>Connect with Me</h4><p>📍 <strong>Sai Krishna Chowdary. Chundru</strong> | Andhra Pradesh, India<br> 📧 <strong>Email:</strong> cchsaikrishnachowdary@gmail.com<br> 🔗 <strong>LinkedIn:</strong> <a href="https://www.linkedin.com/in/sai-krishna-chowdary-chundru">Click here<br></a> 💻 <strong>GitHub:</strong> <a href="https://github.com/sAI-2025">Click here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86d3e351218d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>