MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / pearson

Function pearson

experiments/analysis/analyze_human_score_correlation.py:28–37  ·  view source on GitHub ↗
(pairs: Iterable[Tuple[float, float]])

Source from the content-addressed store, hash-verified

26
27
28def pearson(pairs: Iterable[Tuple[float, float]]) -> float:
29 xs, ys = zip(*pairs)
30 x_mean = sum(xs) / len(xs)
31 y_mean = sum(ys) / len(ys)
32 numerator = sum((x - x_mean) * (y - y_mean) for x, y in zip(xs, ys))
33 x_den = math.sqrt(sum((x - x_mean) ** 2 for x in xs))
34 y_den = math.sqrt(sum((y - y_mean) ** 2 for y in ys))
35 if x_den <= 0 or y_den <= 0:
36 return 0.0
37 return numerator / (x_den * y_den)
38
39
40def ranks(values: List[float]) -> List[float]:

Callers 2

spearmanFunction · 0.70
build_resultFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected