Page 159 - Data Science Algorithms in a Week
P. 159

Regression


            Where v is the initial velocity of the object, τ is an angle at which the object was fired and g
            is the gravitational force exerted by the planet on the object. Note that the angle τ and the
            gravitational force g do not change. Therefore define a constant            . Then the
            distance on the explored planet can be explained in terms of the velocity by the equation:




            Although d and v are not in the linear relationship, d and the square of v are. Therefore we
            can still apply the linear regression to determine the relationship between d and v.
            Analysis using R:

            Input:

                source_code/6/speed_distance.r
                trajectories = data.frame(
                    squared_speed = c(160000,360000,640000),
                    distance = c(38098, 85692, 152220)
                )
                model = lm(squared_speed ~ distance, data = trajectories)
                print(model)
            Output:

                $ Rscript speed_distance.r
                Call:
                lm(formula = squared_speed ~ distance, data = trajectories)
                Coefficients:
                (Intercept)     distance
                   -317.708        4.206
            Therefore the relationship between the squared velocity and the distance is predicted by the
            regression to be:

                                              2
                                             v  = 4.206 * d - 317.708.
















                                                    [ 147 ]
   154   155   156   157   158   159   160   161   162   163   164