"""
DataAnalyzer
Generated by Eden via recursive self-improvement
2025-10-28 01:53:57.030970
"""

class DataAnalyzer:
    """
    A class to analyze numerical data and compute basic statistics.
    
    This capability allows you to quickly get insights into your data by computing 
    common statistical measures like mean, median, mode, standard deviation, etc.
    """

    def __init__(self, data):
        """Initialize the DataAnalyzer with a dataset."""
        self.data = data

    def compute_mean(self):
        """Calculate and return the arithmetic mean of the data."""
        if not self.data:
            raise ValueError("Data is empty.")
        return sum(self.data) / len(self.data)

    def compute_median(self):
        """Calculate and return the median value of the data."""
        sorted_data = sorted(self.data)
        n = len(sorted_data)
        mid = n // 2
        if n % 2 == 1:
            return sorted_data[mid]
        else:
            return (sorted_data[mid-1] + sorted_data[mid]) / 2

    def compute_mode(self):
        """Calculate and return the mode(s) of the data."""
        from collections import defaultdict
        counts = defaultdict(int)
        for num in self.data:
            counts[num] += 1
        max_count = max(counts.values())
        modes = [num for num, cnt in counts.items() if cnt == max_count]
        return modes

    def compute_standard_deviation(self):
        """Calculate and return the standard deviation of the data."""
        mean = self.compute_mean()
        squared_diffs = [(x - mean)**2 for x in self.data]
        variance = sum(squared_diffs) / len(self.data)
        return variance ** 0.5

    def compute_min_max(self):
        """Calculate and return the minimum and maximum values of the data."""
        if not self.data:
            raise ValueError("Data is empty.")
        min_val = min(self.data)
        max_val = max(self.data)
        return (min_val, max_val)

# Example usage:
if __name__ == "__main__":
    import random
    # Create sample data
    data = [random.randint(1, 100) for _ in range(20)]
    
    analyzer = DataAnalyzer(data)
    print("Mean:", analyzer.compute_mean())
    print("Median:", analyzer.compute_median())
    print("Mode:", analyzer.compute_mode())
    print("Standard Deviation:", analyzer.compute_standard_deviation())
    print("Min and Max:", analyzer.compute_min_max())