R Under development (unstable) (2023-11-08 r85496 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## > ## p c h i p . R Test suite > ## > > > pchip <- pracma::pchip > > x <- c(1, 2, 3, 4, 5, 6) > y <- c(16, 18, 21, 17, 15, 12) > > xs <- c(1.5, 2.5, 3.5, 4.5, 5.5) > ys <- pchip(x, y, xs) > # ys <- interp1(x, y, xs, method="cubic") # the same > # 16.88750 19.80000 19.33333 15.96667 13.63750 > > yml <- c(16.887499999999999, 19.800000000000001, 19.333333333333332, + 15.966666666666667, 13.637499999999999) > > all.equal(ys, yml, tolerance = 1e-7) [1] TRUE > > proc.time() user system elapsed 0.18 0.03 0.15