Domain: Human Resources & Employee Management

You are given `SHOPPING.csv` in the working directory.

A retail analytics division wants to quantify high-value engagement intensity among loyalty subscribers who actively redeemed discounts in order to detect structural dispersion, tail concentration, and variability patterns in adjusted transactional spending.

Restrict the analysis strictly to customers where:

- `Subscription Status = 'Yes'`
- `Discount Applied = 'Yes'`

Treat each remaining row as a unique transaction.

Define:

`Spending Intensity = Purchase Amount (USD) * (1 + Previous Purchases / 100)`

Use this derived variable only, and compute the following statistics:

- total transaction count
- mean
- median
- population standard deviation
- population variance
- mean absolute deviation about the mean
- coefficient of variation
- 25th percentile
- 75th percentile
- interquartile range
- 90th percentile
- 95th percentile
- skewness
- proportion of observations strictly above the 90th percentile threshold
- number of observations with absolute z-score greater than 3 using population standard deviation
- number of IQR-based outliers using the 1.5×IQR rule
- percentile rank, defined as the percentage of values strictly below the median `Spending Intensity`
- mean `Spending Intensity` among the top 5% highest observations, defined using the inclusive 95th percentile threshold
- maximum season-wise mean of `Spending Intensity` across the `Season` column
- population covariance between `Purchase Amount (USD)` and `Spending Intensity`

## Cleaning and calculation rules

1. Normalize `Subscription Status` and `Discount Applied` by trimming whitespace and lowercasing before filtering.
2. Coerce `Purchase Amount (USD)` and `Previous Purchases` to numeric.
3. Drop rows missing either of those numeric fields or missing `Season` before computing `Spending Intensity`.
4. Use population formulas where population statistics are requested.
5. For skewness, use the population third standardized moment.
6. For percentile calculations, use linear interpolation.
7. For percentile rank of the median, use the percentage of observations strictly below the median value.
8. For the top-5% mean, use all observations with `Spending Intensity >= 95th percentile threshold`.

## Required reporting format

Report these values with every numeric value rounded to 3 decimal places:

- `total_transaction_count`
- `mean_spending_intensity`
- `median_spending_intensity`
- `population_standard_deviation_spending_intensity`
- `population_variance_spending_intensity`
- `mean_absolute_deviation_about_mean_spending_intensity`
- `coefficient_of_variation_spending_intensity`
- `skewness_spending_intensity`
- `proportion_strictly_above_90th_percentile_threshold`
- `count_abs_zscore_greater_than_3_using_population_standard_deviation`
- `count_iqr_based_outliers_using_1p5_iqr_rule`
- `percentile_rank_of_median_spending_intensity_percentage_strictly_below`
- `mean_spending_intensity_top_5_percent_using_95th_percentile_threshold`
- `maximum_season_wise_mean_spending_intensity`
- `population_covariance_purchase_amount_vs_spending_intensity`

Return a single JSON object with exactly those keys.

Print only the final JSON object.


Grading rubric:
criterion: The final output is a valid JSON object containing exactly the 15 required keys listed in the prompt.
weight: 10
criterion: `total_transaction_count` equals `1037`.
weight: 10
criterion: `mean_spending_intensity` equals `74.925`.
weight: 10
criterion: `median_spending_intensity` equals `73.440`.
weight: 10
criterion: `population_standard_deviation_spending_intensity` equals `31.277` and `population_variance_spending_intensity` equals `978.260`.
weight: 10
criterion: `mean_absolute_deviation_about_mean_spending_intensity` equals `26.494` and `coefficient_of_variation_spending_intensity` equals `0.417`.
weight: 10
criterion: `skewness_spending_intensity` equals `0.207`.
weight: 10
criterion: `proportion_strictly_above_90th_percentile_threshold` equals `0.100`.
weight: 10
criterion: `count_abs_zscore_greater_than_3_using_population_standard_deviation` equals `0` and `count_iqr_based_outliers_using_1p5_iqr_rule` equals `0`.
weight: 10
criterion: `percentile_rank_of_median_spending_intensity_percentage_strictly_below` equals `49.952`.
weight: 10
criterion: `mean_spending_intensity_top_5_percent_using_95th_percentile_threshold` equals `136.162`.
weight: 10
criterion: `maximum_season_wise_mean_spending_intensity` equals `96.220`.
weight: 10
criterion: `population_covariance_purchase_amount_vs_spending_intensity` equals `707.773`.
weight: 10

Golden answer:
```python
import csv
import json
import math
from collections import defaultdict
from pathlib import Path


DATA_PATH = Path(__file__).resolve().parent / "SHOPPING.csv"


def to_float(value):
    try:
        if value is None or str(value).strip() == "":
            return None
        return float(str(value).strip())
    except (TypeError, ValueError):
        return None


def pop_var(values):
    mean_value = sum(values) / len(values)
    return sum((value - mean_value) ** 2 for value in values) / len(values)


def pop_std(values):
    return math.sqrt(pop_var(values))


def mad_mean(values):
    mean_value = sum(values) / len(values)
    return sum(abs(value - mean_value) for value in values) / len(values)


def percentile_linear(values, percentile):
    ordered = sorted(values)
    position = (len(ordered) - 1) * percentile / 100.0
    lower = int(math.floor(position))
    upper = int(math.ceil(position))
    if lower == upper:
        return ordered[lower]
    fraction = position - lower
    return ordered[lower] * (1.0 - fraction) + ordered[upper] * fraction


def pop_skew(values):
    mean_value = sum(values) / len(values)
    std_value = pop_std(values)
    if std_value == 0:
        return float("nan")
    return sum(((value - mean_value) / std_value) ** 3 for value in values) / len(values)


def rank_avg_ties(values):
    indexed = sorted(enumerate(values), key=lambda item: (item[1], item[0]))
    ranks = [0.0] * len(values)
    i = 0
    while i < len(values):
        j = i
        while j + 1 < len(values) and indexed[j + 1][1] == indexed[i][1]:
            j += 1
        average_rank = ((i + 1) + (j + 1)) / 2.0
        for k in range(i, j + 1):
            ranks[indexed[k][0]] = average_rank
        i = j + 1
    return ranks


def pearson_corr(xs, ys):
    mean_x = sum(xs) / len(xs)
    mean_y = sum(ys) / len(ys)
    centered_x = [x - mean_x for x in xs]
    centered_y = [y - mean_y for y in ys]
    denom = math.sqrt(sum(x * x for x in centered_x) / len(xs)) * math.sqrt(sum(y * y for y in centered_y) / len(ys))
    if denom == 0:
        return float("nan")
    return (sum(x * y for x, y in zip(centered_x, centered_y)) / len(xs)) / denom


def spearman_corr(xs, ys):
    return pearson_corr(rank_avg_ties(xs), rank_avg_ties(ys))


def pop_cov(xs, ys):
    mean_x = sum(xs) / len(xs)
    mean_y = sum(ys) / len(ys)
    return sum((x - mean_x) * (y - mean_y) for x, y in zip(xs, ys)) / len(xs)


def r3(value):
    return round(float(value), 3)


def solve():
    filtered_rows = []
    with DATA_PATH.open(newline="", encoding="utf-8") as handle:
        reader = csv.DictReader(handle)
        for row in reader:
            subscription_status = (row.get("Subscription Status") or "").strip().lower()
            discount_applied = (row.get("Discount Applied") or "").strip().lower()
            if subscription_status != "yes" or discount_applied != "yes":
                continue

            purchase_amount = to_float(row.get("Purchase Amount (USD)"))
            previous_purchases = to_float(row.get("Previous Purchases"))
            season = (row.get("Season") or "").strip()
            if purchase_amount is None or previous_purchases is None or season == "":
                continue

            spending_intensity = purchase_amount * (1.0 + previous_purchases / 100.0)
            filtered_rows.append(
                {
                    "purchase_amount": purchase_amount,
                    "previous_purchases": previous_purchases,
                    "season": season,
                    "spending_intensity": spending_intensity,
                }
            )

    intensities = [row["spending_intensity"] for row in filtered_rows]
    purchase_amounts = [row["purchase_amount"] for row in filtered_rows]
    n = len(intensities)

    mean_intensity = sum(intensities) / n
    ordered = sorted(intensities)
    median_intensity = ordered[n // 2] if n % 2 == 1 else (ordered[n // 2 - 1] + ordered[n // 2]) / 2.0
    std_intensity = pop_std(intensities)
    var_intensity = pop_var(intensities)
    mad_intensity = mad_mean(intensities)
    coefficient_of_variation = std_intensity / mean_intensity
    p25 = percentile_linear(intensities, 25)
    p75 = percentile_linear(intensities, 75)
    iqr = p75 - p25
    p90 = percentile_linear(intensities, 90)
    p95 = percentile_linear(intensities, 95)
    skewness = pop_skew(intensities)
    proportion_above_p90 = sum(1 for value in intensities if value > p90) / n
    abs_zscore_gt_3 = 0 if std_intensity == 0 else sum(1 for value in intensities if abs((value - mean_intensity) / std_intensity) > 3)
    lower_bound = p25 - 1.5 * iqr
    upper_bound = p75 + 1.5 * iqr
    iqr_outliers = sum(1 for value in intensities if value < lower_bound or value > upper_bound)
    percentile_rank_median = 100.0 * sum(1 for value in intensities if value < median_intensity) / n
    top_5_mean = sum(value for value in intensities if value >= p95) / sum(1 for value in intensities if value >= p95)

    season_groups = defaultdict(list)
    for row in filtered_rows:
        season_groups[row["season"]].append(row["spending_intensity"])
    maximum_season_mean = max(sum(values) / len(values) for values in season_groups.values())

    results = {
        "total_transaction_count": n,
        "mean_spending_intensity": r3(mean_intensity),
        "median_spending_intensity": r3(median_intensity),
        "population_standard_deviation_spending_intensity": r3(std_intensity),
        "population_variance_spending_intensity": r3(var_intensity),
        "mean_absolute_deviation_about_mean_spending_intensity": r3(mad_intensity),
        "coefficient_of_variation_spending_intensity": r3(coefficient_of_variation),
        "skewness_spending_intensity": r3(skewness),
        "proportion_strictly_above_90th_percentile_threshold": r3(proportion_above_p90),
        "count_abs_zscore_greater_than_3_using_population_standard_deviation": abs_zscore_gt_3,
        "count_iqr_based_outliers_using_1p5_iqr_rule": iqr_outliers,
        "percentile_rank_of_median_spending_intensity_percentage_strictly_below": r3(percentile_rank_median),
        "mean_spending_intensity_top_5_percent_using_95th_percentile_threshold": r3(top_5_mean),
        "maximum_season_wise_mean_spending_intensity": r3(maximum_season_mean),
        "population_covariance_purchase_amount_vs_spending_intensity": r3(pop_cov(purchase_amounts, intensities)),
    }
    print(json.dumps(results, sort_keys=True))
    return results


if __name__ == "__main__":
    solve()
```

**Reasoning**

The local `SHOPPING.csv` supports the intended spending-intensity analysis directly. After trimming and lowercasing `Subscription Status` and `Discount Applied`, filtering to loyalty subscribers with active discounts, coercing `Purchase Amount (USD)` and `Previous Purchases` to numeric, and dropping rows missing those required values or `Season`, the derived metric is computed as `Purchase Amount (USD) * (1 + Previous Purchases / 100)`. The requested population statistics, percentile-based diagnostics, outlier counts, and covariance are then computed from that derived vector. Most of the draft expected values match the local file, but the true `maximum_season_wise_mean_spending_intensity` is `96.220`, not `116.820`.

```json
{"coefficient_of_variation_spending_intensity": 0.417, "count_abs_zscore_greater_than_3_using_population_standard_deviation": 0, "count_iqr_based_outliers_using_1p5_iqr_rule": 0, "maximum_season_wise_mean_spending_intensity": 96.22, "mean_absolute_deviation_about_mean_spending_intensity": 26.494, "mean_spending_intensity": 74.925, "mean_spending_intensity_top_5_percent_using_95th_percentile_threshold": 136.162, "median_spending_intensity": 73.44, "percentile_rank_of_median_spending_intensity_percentage_strictly_below": 49.952, "population_covariance_purchase_amount_vs_spending_intensity": 707.773, "population_standard_deviation_spending_intensity": 31.277, "population_variance_spending_intensity": 978.26, "proportion_strictly_above_90th_percentile_threshold": 0.1, "skewness_spending_intensity": 0.207, "total_transaction_count": 1037}
```