Create a TypeScript function that analyzes a user's mood journal entries over time and returns a structured trend report. ```typescript analyzeMoodTrends(entries: MoodEntry[]): TrendReport // MoodEntry: { date: string (ISO), mood: 1 | 2 | 3 | 4 | 5, note?: string } // TrendReport: { // average: number, // trend: 'improving' | 'declining' | 'stable', // streaks: { best: number, current: number }, // consecutive days with mood >= 4 // volatility: number, // standard deviation of mood scores // weeklyAverages: { week: string, avg: number }[] // ISO week string // } ``` Trend logic: - Compute a 7-day moving average - 'improving' if the last MA value is >= 0.3 higher than the first MA value - 'declining' if >= 0.3 lower - 'stable' otherwise - Return `trend: 'stable'` and empty arrays if fewer than 3 entries Write unit tests for 5 scenarios: improving trajectory, declining trajectory, stable, single entry, empty input.
No contributions yet.