yt-project annotate_scale

void yt_project_annotate_scale(double data, int size, double scale, double *result) {
    // Step 1: Check if input parameters are valid
    if (data == NULL || scale == NULL || result == NULL || size <= 0) {
        return;
    }

    // Step 2: Calculate the mean of the data
    double mean = 0.0;
    for (int i = 0; i < size; i++) {
        mean += data[i];
    }
    mean /= size;

    // Step 3: Calculate the standard deviation of the data
    double variance = 0.0;
    for (int i = 0; i < size; i++) {
        double diff = data[i] - mean;
        variance += diff * diff;
    }
    double stddev = sqrt(variance / size);

    // Step 4: Scale the data based on the calculated mean and standard deviation
    for (int i = 0; i < size; i++) {
        result[i] = (data[i] - mean) / stddev * scale[i % size];
    }
}