Skip to content

feat: allow optional precalculated stats to be used with gini, kurtosis and atkinson index#18

Open
Copilot wants to merge 1 commit intoaddl-unsorted-gini_kurtosis_percentil-on-rank_atkinson_indexfrom
copilot/sub-pr-17
Open

feat: allow optional precalculated stats to be used with gini, kurtosis and atkinson index#18
Copilot wants to merge 1 commit intoaddl-unsorted-gini_kurtosis_percentil-on-rank_atkinson_indexfrom
copilot/sub-pr-17

Conversation

Copy link

Copilot AI commented Dec 21, 2025

Adds optional precalculated statistic parameters to gini, kurtosis, and atkinson functions to avoid redundant computation when these values are already known from prior calculations.

Changes

  • gini(it, precalc_sum) - accepts optional pre-computed sum
  • kurtosis(it, precalc_mean, precalc_variance) - accepts optional pre-computed mean and/or variance
  • atkinson(it, epsilon, precalc_mean, precalc_geometric_sum) - accepts optional pre-computed mean and/or geometric sum (used when ε=1)

When precalculated values are None, functions compute them as before. When provided, they skip the corresponding computation pass.

Usage

use stats::{kurtosis, atkinson, gini};

let data = vec![1, 2, 3, 4, 5];

// If you already have mean and variance from a previous computation
let mean = 3.0;
let variance = 2.0;
let kurt = kurtosis(data.iter(), Some(mean), Some(variance));

// Or compute everything from scratch
let kurt = kurtosis(data.iter(), None, None);

// Similarly for atkinson with epsilon=1 when you have geometric_sum
let geometric_sum = data.iter().map(|&x| (x as f64).ln()).sum();
let atk = atkinson(data.iter(), 1.0, Some(mean), Some(geometric_sum));

// And for gini when you have the sum
let sum = 15.0;
let g = gini(data.iter(), Some(sum));

Tests verify that precalculated values produce identical results to computed values.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add optional precalculated stats for gini, kurtosis, and atkinson index feat: allow optional precalculated stats to be used with gini, kurtosis and atkinson index Dec 21, 2025
Copilot AI requested a review from jqnatividad December 21, 2025 23:45
@jqnatividad jqnatividad marked this pull request as ready for review December 21, 2025 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants