R version 2.14.1 (2011-12-22) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-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. > library( miscTools ) > > eps <- 1e-7 > > x <- (-40:40)/10 > > ## standard normal distribution > ddnorm( x ) [1] 0.0005353209 0.0007747563 0.0011093983 0.0015716870 0.0022028469 [6] 0.0030543894 0.0041895452 0.0056844775 0.0076290822 0.0101271391 [11] 0.0132955452 0.0172623440 0.0221632644 0.0281365240 0.0353157200 [16] 0.0438207512 0.0537468727 0.0651521868 0.0780441043 0.0923655516 [21] 0.1079819330 0.1246700481 0.1421102849 0.1598834315 0.1774733355 [26] 0.1942763935 0.2096184519 0.2227791697 0.2330232660 0.2396373947 [31] 0.2419707245 0.2394767249 0.2317532422 0.2185777534 0.1999347617 [36] 0.1760326634 0.1473080561 0.1144163446 0.0782085388 0.0396952547 [41] 0.0000000000 -0.0396952547 -0.0782085388 -0.1144163446 -0.1473080561 [46] -0.1760326634 -0.1999347617 -0.2185777534 -0.2317532422 -0.2394767249 [51] -0.2419707245 -0.2396373947 -0.2330232660 -0.2227791697 -0.2096184519 [56] -0.1942763935 -0.1774733355 -0.1598834315 -0.1421102849 -0.1246700481 [61] -0.1079819330 -0.0923655516 -0.0780441043 -0.0651521868 -0.0537468727 [66] -0.0438207512 -0.0353157200 -0.0281365240 -0.0221632644 -0.0172623440 [71] -0.0132955452 -0.0101271391 -0.0076290822 -0.0056844775 -0.0041895452 [76] -0.0030543894 -0.0022028469 -0.0015716870 -0.0011093983 -0.0007747563 [81] -0.0005353209 > all.equal( ddnorm(x), ( dnorm( x + eps ) - dnorm( x - eps ) ) / ( 2 * eps ) ) [1] TRUE > > ## normal distribution (non-standard) > x <- (0:100)/10 > ddnorm( x, mean = 5, sd = 2 ) [1] 0.010955188 0.012150380 0.013436718 0.014815704 0.016288047 [6] 0.017853554 0.019511026 0.021258147 0.023091388 0.025005910 [11] 0.026995483 0.029052419 0.031167512 0.033330004 0.035527571 [16] 0.037746327 0.039970858 0.042184281 0.044368334 0.046503488 [21] 0.048569098 0.050543580 0.052404613 0.054129373 0.055694792 [26] 0.057077839 0.058255816 0.059206677 0.059909349 0.060344062 [31] 0.060492681 0.060339026 0.059869181 0.059071788 0.057938311 [36] 0.056463269 0.054644438 0.052483008 0.049983690 0.047154780 [41] 0.044008166 0.040559283 0.036827014 0.032833530 0.028604086 [46] 0.024166757 0.019552135 0.014792975 0.009923814 0.004980549 [51] 0.000000000 -0.004980549 -0.009923814 -0.014792975 -0.019552135 [56] -0.024166757 -0.028604086 -0.032833530 -0.036827014 -0.040559283 [61] -0.044008166 -0.047154780 -0.049983690 -0.052483008 -0.054644438 [66] -0.056463269 -0.057938311 -0.059071788 -0.059869181 -0.060339026 [71] -0.060492681 -0.060344062 -0.059909349 -0.059206677 -0.058255816 [76] -0.057077839 -0.055694792 -0.054129373 -0.052404613 -0.050543580 [81] -0.048569098 -0.046503488 -0.044368334 -0.042184281 -0.039970858 [86] -0.037746327 -0.035527571 -0.033330004 -0.031167512 -0.029052419 [91] -0.026995483 -0.025005910 -0.023091388 -0.021258147 -0.019511026 [96] -0.017853554 -0.016288047 -0.014815704 -0.013436718 -0.012150380 [101] -0.010955188 > all.equal( ddnorm( x, mean = 5, sd = 2), + ( dnorm( x + eps, mean = 5, sd = 2 ) - dnorm( x - eps, mean = 5, sd = 2 ) ) + / ( 2 * eps ) ) [1] TRUE > >
Generated by dwww version 1.15 on Wed Jun 26 01:28:37 CEST 2024.