Skip to content

refactor(metrics): population_variance/2 + std_dev/1 in CodeQA.Math #70

Description

@aspala

Was & Warum

indentation.ex:52-55 und identifier_length_variance.ex:32-35 bauen dieselbe Populations-Varianz von Hand:

variance =
  values
  |> Enum.reduce(0.0, fn v, acc -> acc + :math.pow(v - mean, 2) end)
  |> Kernel./(length(values))

CodeQA.Math (lib/codeqa/math.ex) existiert genau für solche geteilten Mathe-Utilities, enthält aber bisher nur linear_regression und Pearson-Korrelation — keine Varianz/StdDev.

Umsetzung

  • CodeQA.Math.population_variance(values, mean) und CodeQA.Math.std_dev(variance) ergänzen.
  • Beide Module darauf umstellen.
  • Direkt-Tests für die Helper in CodeQA.Math (bisher hat das Modul vermutlich keine eigenen Tests — kurz prüfen).

Nutzen

~12 Zeilen Duplikation weg, Varianz an einer Stelle definiert + testbar. Identischer Algorithmus an beiden Stellen → sehr niedriges Risiko.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions