• + 0 comments

    no idea why not work pythonic

    import numpy as np
    
    P = np.array([15, 12, 8, 8, 7, 7, 7, 6, 5, 3])
    H = np.array([10, 25, 17, 11, 13, 17, 20, 13, 9, 15])
    
    fit = np.polyfit(P, H, deg=1)
    a = fit[0]
    b = fit[1]
    
    pred = a * 10 + b
    print(round(pred, 1))
    

    R

    x <- c(15, 12, 8, 8, 7, 7, 7, 6, 5, 3)
    y <- c(10, 25, 17, 11, 13, 17, 20, 13, 9, 15) 
    linearMod <- lm(y ~ x)
    pred <- as.vector(linearMod$coefficients)[1] + as.vector(linearMod$coefficients)[2]*10
    round(pred,1)