Skip to main content

Posts

Search

Search Search Any Topic from Any Website Search
Recent posts

AI Chatbot Pipeline Documentation

AI Chatbot Pipeline Documentation Pipeline Overview User Query ↓ Encoder (Transformer) ↓ Vector Search ↓ FAQ priority match? ↓ Website content match? ↓ Answer synthesis (RAG) This is a retrieval-first, safe, and efficient pipeline (no hallucination). Tech Stack FastAPI – API Sentence-Transformer – encoder FAISS – vector search Any LLM – for final answer synthesis (optional) FAQs stored separately from website content Project Structure app/ ├── main.py ├── embeddings.py ├── vector_store.py ├── rag.py ├── data/ │ ├── faqs.json │ ├── website_chunks.json Load Encoder (Transformer) # embeddings.py from sentence_transformers import SentenceTransformer model = SentenceTransformer("all-MiniLM-L6-v2") def encode(text: str): return...

JS Array & Matrix Concepts

JavaScript Array & Matrix Concepts Demo This demo covers key JavaScript array and matrix operations used in signal processing and general programming. 1. Array Manipulation (1D) // Original binary array let inputBits = [0, 1, 1, 0, 1, 0]; // map(): Convert bits to BPSK symbols (0 -> -1, 1 -> 1) let inputSymbols = inputBits.map(bit => bit===0 ? -1 : 1); console.log('map():', inputSymbols); // [-1, 1, 1, -1, 1, -1] // filter(): Split even and odd indices let s1 = inputSymbols.filter((_, i) => i % 2 === 0); // Even indices let s2 = inputSymbols.filter((_, i) => i % 2 === 1); // Odd indices console.log('filter() s1:', s1); // [-1, 1, 1] console.log('filter() s2:', s2); // [1, -1, -1] // reduce(): Sum of all bits let sumBits = inputBits.reduce((sum, b) => sum + b, 0); console.log('reduce() sum:', sumBits); // 3 // some() / every(): Check conditions let allValid = inputBits.every(b => b===0 || b===1); console.log('ev...

Event Delegation in Javascript

  Event Delegation is a powerful technique in JavaScript that allows you to manage events efficiently by attaching a single event listener to a parent element rather than adding multiple listeners to individual child elements. This approach is widely used in modern web applications, including frameworks like React, to improve performance and scalability.  Event Delegation solves this by attaching one listener to a common ancestor (parent container) and handling events for all child elements that trigger it.    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Event Delegation Bit Validator</title> <style> body{ font-family: Arial, sans-serif; background:#f4f6f9; margin:40px; } .container{ max-width:600px; margin:auto; background:white; padding:30px; border-radius:8px; ...

Z-Transform of Delta Function

Z-Transform of the Delta Function Definition of Delta Function The discrete-time delta function is written as: δ[n] It is defined as: δ[0] = 1 δ[n] = 0 for n ≠ 0 The delta function represents a unit impulse that occurs only at n = 0. Z-Transform Definition X(z) = Σ x[n] z⁻ⁿ (n = 0 to ∞) Substitute x[n] = δ[n] X(z) = Σ δ[n] z⁻ⁿ Since δ[n] is non-zero only when n = 0: X(z) = 1 × z⁰ Final Result Z{ δ[n] } = 1 Region of Convergence (ROC) ROC = Entire z-plane The delta function acts like a sampling impulse , so its Z-transform becomes 1 . Z-Transform of Shifted Delta Functions 1. Z-Transform of δ[n-1] X(z) = Σ δ[n-1] z⁻ⁿ δ[n-1] is non-zero only when n = 1. X(z) = z⁻¹ Z{ δ[n-1] } = z⁻¹ 2. Z-Transform of δ[n-k] X(z) = Σ δ[n-k] z⁻ⁿ δ[n-k] is non-zero only when n = k. X(z) = z⁻ᵏ Z{ δ[n-k] } = z⁻ᵏ Important Rule: Z{ δ[n-k] } = z⁻ᵏ Summary Table Sequence Z-Transform δ[n] 1 δ[n...

Z-Plane Poles and Stability Explained

Stability of Discrete-Time Systems Given Poles z = 0 ,   z = -0.9 ,   z = 0.9 What is Stability? A discrete-time system is BIBO Stable (Bounded Input Bounded Output) if every bounded input produces a bounded output. Stability Condition: For a discrete-time LTI system: All poles must lie inside the unit circle. |z| < 1 Unit Circle in Z-Plane The unit circle is a circle centered at the origin with radius = 1. Inside circle → Stable On circle → Marginally Stable Outside circle → Unstable Check Each Pole Pole Magnitude Inside Unit Circle? z = 0 |0| = 0 Yes z = -0.9 |-0.9| = 0.9 Yes z = 0.9 |0.9| = 0.9 Yes Conclusion All poles lie inside the unit circle → The system is STABLE. Steps to Check Stability Find the poles of the system. Calculate magnitude of each pole. Compare magnitude with 1. If all |z| < 1 → Stable. Examples Poles Result 0.5 , -0.3 Stable 1 , -0.5 ...

Z-Transform Examples and Solutions

Z-Transform Examples and Solutions 1. Z-Transform of a n Given: x[n] = a n Definition of Z-transform: X(z) = ∑ n=0 to ∞ x[n]z⁻ⁿ Substitute x[n] = a n X(z) = ∑ aⁿ z⁻ⁿ = ∑ (az⁻¹)ⁿ Using geometric series: ∑ rⁿ = 1 / (1 - r) X(z) = 1/(1 − az⁻¹) = z/(z − a) ROC: |z| > |a| 2. Z-Transform of Unit Step u[n] Given: x[n] = u[n] X(z) = ∑ z⁻ⁿ This is a geometric series. X(z) = 1 / (1 − z⁻¹) = z / (z − 1) ROC: |z| > 1 3. Z-Transform of n Given: x[n] = n X(z) = ∑ n z⁻ⁿ X(z) = z / (z − 1)² ROC: |z| > 1 4. Z-Transform of n a n Given: x[n] = n a n Using differentiation property of Z-transform. X(z) = az / (z − a)² ROC: |z| > |a| 5. Z-Transform of a n u[n] Given: x[n] = a n u[n] X(z) = ∑ aⁿ z⁻ⁿ X(z) = 1 / (1 − az⁻¹) ROC: |z| > |a| Summary Table Sequence x[n] Z-Transform X(z) ROC a n z / (z − a) |z| > |a| u[n] z / (z − 1) |z| > 1 ...

Real-Time Input Validator Using JavaScript

  Introduction In modern web applications, validating user input in real-time is a key aspect of user experience. For developers working with digital systems, communication protocols, or binary data, ensuring that users enter valid bits (0s and 1s) is crucial. In this tutorial, we will create a Real-Time Bit Input Validator using HTML, CSS, and JavaScript , which checks for valid binary input and even-length sequences instantly without needing to submit a form.     <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Real-Time Input Bit Validator</title> <style> body{ font-family: Arial, sans-serif; background:#f4f6f9; margin:40px; } .container{ max-width:600px; margin:auto; background:white; padding:30px; border-radius:8px; box-shadow:0 3px 12px rgba(0,0,0,0.1); } h1{ co...

Cross-Spectrum Explained (with MATLAB)

Cross-Spectrum: Concept and Mathematics The cross-spectrum measures the frequency-domain correlation between two signals, showing how the signals relate in magnitude and phase at each frequency. For two discrete-time signals x[n] and y[n] , the cross-spectral density is defined as: S xy (f) = X(f) · Y * (f) X(f) = FFT{x[n]} → Fourier transform of x[n] Y(f) = FFT{y[n]} → Fourier transform of y[n] Y*(f) → Complex conjugate of Y(f) |S xy (f)| → Magnitude shows correlation strength at each frequency ∠S xy (f) → Phase shows relative phase difference Cross-spectrum is widely used in: Beamforming Coherence analysis Direction-of-arrival estimation (DoA) Identifying frequency-dependent relationships between signals MATLAB Code Example This MATLAB example demonstrates the cross-spectrum between two sinusoidal signals with a phase difference: %% Cross-Spectrum Demonstration clc; clear; clo...

People are good at skipping over material they already know!

View Related Topics to







Contact Us

Name

Email *

Message *