/** * Regression Trend Analyzer * * Analyzes metric trends to predict potential regressions. * Uses linear regression and change point detection. */ import type { TimeSeriesPoint, RegressionTrend, RegressionDetection } from './types.js'; /** * Trend analysis result */ export interface TrendAnalysis { /** Slope of trend */ slope: number; /** Intercept */ intercept: number; /** Correlation coefficient (R²) */ rSquared: number; /** Is trend significant? */ significant: boolean; /** Direction */ direction: 'increasing' | 'decreasing' | 'stable'; /** Projected value at future timestamp */ project(ms: number): number; } /** * Change point detection result */ export interface ChangePoint { /** Index of change point */ index: number; /** Timestamp of change */ timestamp: number; /** Mean before change */ beforeMean: number; /** Mean after change */ afterMean: number; /** Magnitude of change */ magnitude: number; /** Statistical significance */ pValue: number; } /** * Regression Trend Analyzer class */ export declare class RegressionTrendAnalyzer { /** * Analyze trend for a metric */ analyzeTrend(data: TimeSeriesPoint[], windowMs?: number): RegressionTrend | null; /** * Perform linear regression on time series */ linearRegression(data: TimeSeriesPoint[]): TrendAnalysis; /** * Detect change points in time series */ detectChangePoints(data: TimeSeriesPoint[], minSegmentSize?: number): ChangePoint[]; /** * Estimate p-value for change point */ private estimatePValue; /** * Project trend forward */ private projectTrend; /** * Get trend direction for reporting */ private getTrendDirection; /** * Calculate time until threshold breach */ calculateTimeToThreshold(data: TimeSeriesPoint[], threshold: number, isIncreasingBad: boolean): number | null; /** * Compare two periods for regression */ comparePeriods(baseline: TimeSeriesPoint[], current: TimeSeriesPoint[], metric: string): RegressionDetection | null; /** * Infer regression type from metric name */ private inferType; /** * Check if change direction indicates regression */ private isRegressionDirection; /** * Normal CDF approximation */ private normalCDF; /** * Get trend description */ getTrendDescription(trend: RegressionTrend): string; /** * Format time to threshold */ formatTimeToThreshold(ms: number): string; } /** * Create a regression trend analyzer */ export declare function createRegressionTrendAnalyzer(): RegressionTrendAnalyzer;