I have a question about linear splines. A computer package I am using has the option to use linear splines, but there is no user manual I can find.

I am having problems with the kind of inputs the package wants.

  • The first input is a vector x with values sorted in ascending order with N+1 values. This is ok.

  • The second is a vector of zero order coefficients. This vector can be of length N or N+1. What I do not understand here is that it doesn't have to be of the same length as the x-vector, why is that?

  • The third is a vector with the slopes. This vector has to be of length N. Again why does it not have to be the same length as the x vector?

Here is a link to the documentation: link, the relevant info is in the first box under "Public constructors."

So what I am struggling with is that the vectors are of different length. If they were of the same length it would make better sense, because then it would be the x-value and the function value and the slope at each point. But with different lengths, what is is they are actually asking for?

  • $\begingroup$ $N+1$ x-values means you have $N$ subintervals and on each subinterval the slope is constant, so it makes sense that the 3rd argument should have length $N$. $\endgroup$ – Coolwater Mar 3 at 8:27
  • $\begingroup$ @Coolwater But why do we even have to provide the slope? When we provide the values the slope can be calculated? And why can the values have length N? $\endgroup$ – user394334 Mar 3 at 18:20
  • $\begingroup$ You can reverse engineer this if you like. $\endgroup$ – VorKir Mar 4 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.