SShortSingh.
Back to feed

How trend calculation works: the math behind linear regression explained

0
·1 views

A tutorial published on DEV Community walks through the mathematical foundations of trend calculation, a key tool in data science. The goal of trend analysis is to find a function that best fits a set of data points plotted over time, such as a company's revenue at different intervals. Because the relationship between time and measured values is stochastic, only an approximation — typically a linear function — can be fitted to the data. The quality of this fit is measured using SSE (Sum of Squared Errors) and MSE (Mean Squared Error), which quantify the difference between actual data points and the fitted line. To find the optimal parameters for the line, calculus is applied: the SSE is minimized by taking partial derivatives with respect to each parameter and setting them to zero.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

PaymentOps Memory Agent Uses Persistent Memory to Speed Up Recurring Payment Incident Probes

A developer built a prototype called PaymentOps Memory Agent to address a gap in payment incident investigations, where teams repeatedly start from scratch on similar issues. The tool demonstrates how storing the outcome of a resolved incident — such as a Stripe timeout resolved by rerouting through another processor — can inform the handling of a later, similar incident. Built with FastAPI and a plain web frontend, the app offers two analysis paths: one stateless and one memory-aware, using Hindsight's API to retain and recall past incident resolutions. The memory-aware path queries a Hindsight bank named paymentops-demo and displays retrieved evidence alongside the agent's response for transparency. All payment data in the prototype is synthetic and no real processor connections are made, keeping the focus on demonstrating memory behavior rather than a live payment system.

0
ProgrammingDEV Community ·

Environment Drift: The Silent Force Behind Most Production Failures

A persistent gap between development, staging, and production environments — known as environment drift — is a leading but under-acknowledged cause of software incidents. Drift accumulates through small, undocumented changes such as manual server patches, mismatched library versions, and inconsistent configuration secrets across environments. Because failures are typically logged as 'flaky deployments' or 'insufficient QA,' the root cause often goes unaddressed in post-mortems. Over time, the erosion of trust in the release process leads teams to slow down deployments, increase manual checks, and struggle to onboard new engineers effectively. The Twelve-Factor App methodology identified this pattern years ago, yet the problem persists and grows more complex as modern systems add more services and moving parts.

0
ProgrammingDEV Community ·

Indie Dev Shares Early Lessons Monetizing an HTML5 Word Game

A solo developer has published an HTML5 word game called PalabraPlay on Netlify while awaiting approval from game platform CrazyGames. After three months, the game has received only 27 impressions, highlighting the challenge of generating traffic without platform distribution. The developer noted that CrazyGames can pay per play but has a slow approval process, while freelance work on Fiverr proved a more immediate source of income. The next planned step is adding a leaderboard and comments section to improve player retention. The developer is also seeking community input on which platforms — such as Itch.io, CrazyGames, or self-hosted sites — work best for web games.

0
ProgrammingDEV Community ·

Vanguard Uses Persistent Agent Memory to Track Competitor Strategies Over Time

Developers built Vanguard, an AI agent system designed to help analyze competitor strategies by leveraging persistent memory rather than one-off queries. The team found that standard retrieval-augmented generation (RAG) using top-k semantic search struggles to capture long-term cause-and-effect relationships between events. Vanguard addresses this by connecting historical data points to reveal broader strategic shifts, such as patterns behind pricing changes. A hybrid retrieval approach combining semantic similarity, keyword matching, and temporal relevance was found to produce more meaningful context than any single method alone. The project, built with Go, Python, FastAPI, Next.js, and TypeScript, concludes that structured memory architecture matters more than simply feeding an AI more raw context.

How trend calculation works: the math behind linear regression explained · ShortSingh