// utils.h
#ifndef UTILS_H
#define UTILS_H

#include "health_analytics_engine.h"
#include <random>
#include <limits>
#include <numeric>

// Declare all utility functions from utils.cpp
double calculateMean(const double* values, int length);
double calculateWeightedMean(const double* values, const double* weights, int length);
double calculateVariance(const double* values, int length, double mean);
double calculateStdDev(const double* values, int length, double mean);
double calculateMedian(double* values, int length);
double calculateCorrelation(const double* x, const double* y, int length);
double calculateSpearmanCorrelation(const double* x, const double* y, int length);
double calculateQuantile(const double* values, int length, double q);
double calculateIQR(const double* values, int length);
double calculateSkewness(const double* values, int length, double mean, double stdDev);
double calculateKurtosis(const double* values, int length, double mean, double stdDev);
bool calculateLinearRegression(const double* x, const double* y, int length, double& slope, double& intercept, double& r_squared);
double calculateAutocorrelation(const double* values, int length, int lag);
int detectOutliers(const double* values, int length, std::vector<int>& outlierIndices, double threshold);
void calculateMovingAverage(const double* values, int length, int window, double* result);
void calculateExponentialMovingAverage(const double* values, int length, double alpha, double* result);
bool decomposeTimeSeries(const double* values, int length, int seasonality, double* trend, double* seasonal, double* residual);
int calculatePACF(const double* values, int length, int maxLag, double* pacf);
int kMeansClustering(const double** data, int nSamples, int nFeatures, int k, int maxIter, double** centroids, int* assignments);
double calculateSilhouetteCoefficient(const double** data, int nSamples, int nFeatures, const int* assignments, int k);

#endif // UTILS_H