use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConfidenceInterval {
pub estimate: f64,
pub lower_bound: f64,
pub upper_bound: f64,
pub confidence: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatisticsReport {
pub basic: BasicStatistics,
pub patterns: PatternStatistics,
pub temporal: TemporalStatistics,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BasicStatistics {
pub total_matches: usize,
pub unique_patterns: usize,
pub match_rate: f64,
pub avg_confidence: f64,
pub median_confidence: f64,
pub std_dev_confidence: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PatternStatistics {
pub by_pattern: HashMap<String, PatternMetrics>,
pub correlations: Vec<PatternCorrelation>,
pub top_performers: Vec<PatternPerformance>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PatternMetrics {
pub occurrences: usize,
pub success_rate: f64,
pub avg_value: f64,
pub avg_duration: f64,
pub reliability_score: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PatternCorrelation {
pub pattern_a: String,
pub pattern_b: String,
pub correlation: f64,
pub co_occurrence_rate: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PatternPerformance {
pub pattern_name: String,
pub score: f64,
pub metrics: PatternMetrics,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemporalStatistics {
pub best_hours: Vec<TimePeriodStats>,
pub best_days: Vec<TimePeriodStats>,
pub best_months: Vec<TimePeriodStats>,
pub seasonality: SeasonalityAnalysis,
pub trends: TrendAnalysis,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TimePeriodStats {
pub period: String,
pub success_rate: f64,
pub avg_value: f64,
pub occurrence_count: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SeasonalityAnalysis {
pub daily_pattern: bool,
pub weekly_pattern: bool,
pub monthly_pattern: bool,
pub quarterly_pattern: bool,
pub strength: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TrendAnalysis {
pub pattern_frequency_trend: f64,
pub success_rate_trend: f64,
pub value_trend: f64,
pub trend_direction: TrendDirection,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TrendDirection {
Increasing,
Decreasing,
Stable,
}