(xs: list[float], ys: list[float])
| 140 | |
| 141 | |
| 142 | def regression(xs: list[float], ys: list[float]) -> tuple[float, float]: |
| 143 | x_bar = sum(xs) / len(xs) |
| 144 | y_bar = sum(ys) / len(ys) |
| 145 | slope = sum((x - x_bar) * (y - y_bar) for x, y in zip(xs, ys)) / sum((x - x_bar) ** 2 for x in xs) |
| 146 | intercept = y_bar - slope * x_bar |
| 147 | return slope, intercept |
| 148 | |
| 149 | |
| 150 | def draw_rotated_axis_label(base: Image.Image, text: str) -> None: |