def total_sum_of_squares(y: Vector) -> float: """the total squared variation of y_i's from their mean""" return sum(v ** 2 for v in de_mean(y))
def total_sum_of_squares(y: Vector) -> float: """the total squared variation of y_i's from their mean""" return sum(v**2 for v in de_mean(y))
def total_sum_of_squares(y: Vector) -> float: """Suma odchyleń kwadratów wartości y_i od średniej.""" return sum(v**2 for v in de_mean(y))
from typing import Tuple from scratch.linear_algebra import Vector from scratch.statistics import correlation, standard_deviation, mean, de_mean def least_squares_fit(x, y): beta = correlation(x, y) * standard_deviation(y) / standard_deviation(x) alpha = mean(y) - beta * mean(x) return alpha, beta x = [i for i in range(-100, 110, 10)] y = [3 * i - 5 for i in x] print(de_mean([1, 2, 3, 4, 5])) print("x :", x) print("y :", y) print(least_squares_fit(x, y))
def total_sum_of_squares(y: Vector) -> float: return sum(y_i**2 for y_i in de_mean(y))