Approxfun uses the two-point formula [1] for a line:
y = y_1 + (y_2 - y_1) * (x - x_1) / (x_2 - x_1)
so in the first simplified case you get
y = 1 + (1 - 1) * (0 - (-1000)) / (Inf - (-1000))
= 1 + 0 * 1000 / Inf
= 1 + 0 / Inf
= 1 + 0
= 1
while in the second case you get
y = 1 + (1 - 1)
I think you're just seeing undefined behaviour. In most cases it
doesn't make sense to interpolate linearly between the points (-Inf, y0)
and (-1, y1). In your example with y0 == y1 it's fine, but if you had
approxfun(x=c(-Inf, 0), y = c(1, 2))
what would you expect the result to be when e
2 matches
Mail list logo