0
$\begingroup$

please give me an advice.

I have points ("data", x and y coordinates). For these points, I created a residual function

function = LinearModelFit [dat, x, x]

Now I have to determine the point that has the smallest and largest distance from this line. And also a point that lies on a straight line. Unfortunately, I don't know how to do it. I only know how to calculate the smallest / largest distance (Min [function ["FitResiduals"]]) or Max [function ["FitResiduals"]]. But I would now need to see the given point with the corresponding coordinates (eg [0.2, 5])

Thank you for your answer

$\endgroup$
2
  • 2
    $\begingroup$ You can use Ordering[function["FitResiduals"], 1] to find the position of the smallest residual and then use that position to find the corresponding point in dat. You can use Ordering[..., -1] to find the position of the largest residual in the same manner. $\endgroup$ Apr 30, 2021 at 8:40
  • $\begingroup$ MinimalBy and MaximalBy would work. $\endgroup$
    – Roman
    Apr 30, 2021 at 9:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.