blob: 7170c116b2478a78bc4753be2d3062b63f194155 [file] [log] [blame]
R version 3.6.2 Patched (2020-02-12 r77795) -- "Dark and Stormy Night"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
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.
> options(digits=7)
>
> ## powers
> outer(a <- -4:12, -2:7, "^")
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 0.062500000 -0.25000000 1 -4 16 -64 256 -1024 4096 -16384
[2,] 0.111111111 -0.33333333 1 -3 9 -27 81 -243 729 -2187
[3,] 0.250000000 -0.50000000 1 -2 4 -8 16 -32 64 -128
[4,] 1.000000000 -1.00000000 1 -1 1 -1 1 -1 1 -1
[5,] Inf Inf 1 0 0 0 0 0 0 0
[6,] 1.000000000 1.00000000 1 1 1 1 1 1 1 1
[7,] 0.250000000 0.50000000 1 2 4 8 16 32 64 128
[8,] 0.111111111 0.33333333 1 3 9 27 81 243 729 2187
[9,] 0.062500000 0.25000000 1 4 16 64 256 1024 4096 16384
[10,] 0.040000000 0.20000000 1 5 25 125 625 3125 15625 78125
[11,] 0.027777778 0.16666667 1 6 36 216 1296 7776 46656 279936
[12,] 0.020408163 0.14285714 1 7 49 343 2401 16807 117649 823543
[13,] 0.015625000 0.12500000 1 8 64 512 4096 32768 262144 2097152
[14,] 0.012345679 0.11111111 1 9 81 729 6561 59049 531441 4782969
[15,] 0.010000000 0.10000000 1 10 100 1000 10000 100000 1000000 10000000
[16,] 0.008264463 0.09090909 1 11 121 1331 14641 161051 1771561 19487171
[17,] 0.006944444 0.08333333 1 12 144 1728 20736 248832 2985984 35831808
>
> for (n1 in 1:7)
+ print(zapsmall(polyroot(1:n1), digits = 10))
complex(0)
[1] -0.5+0i
[1] -0.3333333+0.4714045i -0.3333333-0.4714045i
[1] -0.0720852+0.6383267i -0.6058296+0.0000000i -0.0720852-0.6383267i
[1] 0.1378323+0.6781544i -0.5378323+0.3582847i -0.5378323-0.3582847i
[4] 0.1378323-0.6781544i
[1] 0.2941946+0.6683671i -0.3756952+0.5701752i -0.3756952-0.5701752i
[4] 0.2941946-0.6683671i -0.6703320+0.0000000i
[1] 0.4106842+0.6398894i -0.6341119+0.2876550i -0.2051437-0.6837970i
[4] 0.4106842-0.6398894i -0.2051437+0.6837970i -0.6341119-0.2876550i
>
> ## lowess() {incl. sort, etc}:
> options(digits = 5)
>
> lowess(c(3,2,6,3,8,4))$y # this used to differ on Linux
[1] 2.4259 3.4293 3.9896 5.2832 5.3386 4.9822
>
> y1 <- c(3,1:2,5:2,4,1:3,3)
> lowess(y1)$y
[1] 2.0723 2.4362 2.7508 3.0038 3.2036 3.2435 2.8485 2.4832 2.4197 2.5231
[11] 2.6286 2.7813
> lowess(y1, f = .4)$y
[1] 2.7030 1.9593 2.4351 3.4933 4.0000 3.0000 2.4651 1.8579 1.7357 2.0000
[11] 2.7103 3.1184
>
> lowess(c(y1,100), f = .4)$y
[1] 2.2135 2.2468 2.5459 3.7984 4.0000 3.0000 2.8427 2.4999 2.1512 2.0000
[11] 2.7129 3.1195 3.4172
>
> ## this is the test sample from Cleveland's original lowess.doc:
> x <- c(1:5, rep(6,10),8,10,12,14,50)
> y <- c(18,2,15,6,10,4,16,11,7,3,14,17,20,12,9,13,1,8,5,19)
> lowess(x,y, f = .25, iter = 0, delta = 0)$y
[1] 13.6588 11.1446 8.7012 9.7220 10.0000 11.3000 11.3000 11.3000 11.3000
[10] 11.3000 11.3000 11.3000 11.3000 11.3000 11.3000 13.0000 6.4399 5.5959
[19] 5.4557 18.9982
> lowess(x,y, f = .25, iter = 0, delta = 3)$y
[1] 13.6588 12.3466 11.0343 9.7220 10.5110 11.3000 11.3000 11.3000 11.3000
[10] 11.3000 11.3000 11.3000 11.3000 11.3000 11.3000 13.0000 6.4399 5.5959
[19] 5.4557 18.9982
> lowess(x,y, f = .25, iter = 2, delta = 0)$y
[1] 14.8112 12.1154 8.9838 9.6757 10.0000 11.3460 11.3460 11.3460 11.3460
[10] 11.3460 11.3460 11.3460 11.3460 11.3460 11.3460 13.0000 6.7345 5.7437
[19] 5.4147 18.9981
>
>