# NOT RUN {
#
## Legendre polynomial 5th order
f=function(x){(63/8)*x^5-(35/4)*x^3+(15/8)*x}
x=seq(-1,1,0.001)
set.seed(2019-07-26);r=0.05;y=f(x)+runif(length(x),-r,r)
plot(x,y,pch=19,cex=0.5)
rn=scan_noisy_curve(x,y)
rn
## $study
## j dj interval i1 i2 root
## 3 97 351 TRUE 97 448 FALSE
## 18 477 502 TRUE 477 979 FALSE
## 39 1021 505 TRUE 1021 1526 FALSE
## 54 1558 343 TRUE 1558 1901 FALSE
##
## $roots_average
## x1 x2 chi yvalue
## 1 -0.906 -0.904 -0.9050 -0.002342389
## 2 -0.553 -0.524 -0.5385 0.005003069
## 3 -0.022 0.020 -0.0010 0.003260937
## 4 0.525 0.557 0.5410 -0.007956680
## 5 0.900 0.911 0.9055 -0.008015683
##
## $roots_optim
## x1 x2 chi yvalue
## 1 -0.909 -0.901 -0.9050 -0.023334404
## 2 -0.531 -0.527 -0.5290 0.029256059
## 3 0.001 0.003 0.0020 0.001990572
## 4 0.530 0.565 0.5475 0.019616283
## 5 0.909 0.912 0.9105 0.009288338
##
## $extremes
## x1 x2 chi yvalue
## [1,] -0.773 -0.766 -0.7695 0.4102010
## [2,] -0.280 -0.274 -0.2770 -0.3804006
## [3,] 0.308 0.316 0.3120 0.3372764
## [4,] 0.741 0.744 0.7425 -0.4414494
##
## $inflections
## x1 x2 chi yvalue
## [1,] -0.772 -0.275 -0.5235 -0.076483193
## [2,] -0.275 0.281 0.0030 -0.007558037
## [3,] 0.301 0.776 0.5385 0.018958334
#
# }
Run the code above in your browser using DataLab