(xs: list[float], ys: list[float])
| 135 | |
| 136 | |
| 137 | def pearson(xs: list[float], ys: list[float]) -> float: |
| 138 | x_bar = sum(xs) / len(xs) |
| 139 | y_bar = sum(ys) / len(ys) |
| 140 | numerator = sum((x - x_bar) * (y - y_bar) for x, y in zip(xs, ys)) |
| 141 | den_x = math.sqrt(sum((x - x_bar) ** 2 for x in xs)) |
| 142 | den_y = math.sqrt(sum((y - y_bar) ** 2 for y in ys)) |
| 143 | return numerator / (den_x * den_y) |
| 144 | |
| 145 | |
| 146 | def regression(xs: list[float], ys: list[float]) -> tuple[float, float]: |
no outgoing calls
no test coverage detected