From 80492d3788738910b80dc16f918511057b7321d6 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Fri, 4 Oct 2019 12:21:16 +0530 Subject: updated the git ignore --- .gitignore | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.gitignore b/.gitignore index 26fad6fa..49869479 100644 --- a/.gitignore +++ b/.gitignore @@ -5,15 +5,6 @@ # Session Data files .RData -# Example code in package build process -*-Ex.R - -# Output files from R CMD build -/*.tar.gz - -# Output files from R CMD check -/*.Rcheck/ - # RStudio files .Rproj.user/ -- cgit From b3f3a8ecd454359a2e992161844f2fb599f8238a Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Fri, 4 Oct 2019 12:24:07 +0530 Subject: Initial commit/added all books --- .../CH1/EX2.a/Ex1_2a.R | 7 + .../CH1/EX2.b/Ex1_2b.R | 8 ++ .../CH1/EX2.c/Ex1_2c.R | 5 + .../CH1/EX2.e/Ex1_2e.R | 12 ++ .../CH1/EX3.a/Ex1_3a.R | 5 + .../CH1/EX3.b.a/Ex1_3ba.R | 6 + .../CH1/EX3.b.b/Ex1_3bb.R | 6 + .../CH1/EX3.c/Ex1_3c.R | 11 ++ .../CH1/EX3.d/Ex1_3d.R | 9 ++ .../CH1/EX3.e/Ex1_3e.R | 8 ++ .../CH1/EX3.f/Ex1_3f.R | 7 + .../CH1/EX4.a/Ex1_4a.R | 6 + .../CH1/EX4.b/Ex1_4b.R | 15 +++ .../CH1/EX5.a/Ex1_5a.R | 7 + .../CH1/EX5.b/Ex1_5b.R | 6 + .../CH1/EX5.c/Ex1_5c.R | 6 + .../CH1/EX5.d/Ex1_5d.R | 9 ++ .../CH1/EX6.a/Ex1_6a.R | 6 + .../CH1/EX6.b/Ex1_6b.R | 10 ++ .../CH2/EX3.b/Ex2_3b.R | 5 + .../CH2/EX4.a/Ex2_4a.R | 6 + .../CH2/EX5.a/Ex2_5a.R | 9 ++ .../CH2/EX5.b/Ex2_5b.R | 15 +++ .../CH2/EX5.c/Ex2_5c.R | 13 ++ .../CH2/EX5.f/Ex2_5f.R | 7 + .../CH2/EX5.g/Ex2_5g.R | 7 + .../CH2/EX5.h.a/Ex2_5ha.R | 8 ++ .../CH2/EX5.h.b/Ex2_5hb.R | 9 ++ .../CH2/EX5.i/Ex2_5i.R | 11 ++ .../CH2/EX5.k/Ex2_5k.R | 12 ++ .../CH2/EX5.l/Ex2_5l.R | 11 ++ .../CH2/EX5.n/Ex2_5n.R | 10 ++ .../CH2/EX7.a/Ex2_7a.R | 13 ++ .../CH3/EX2.a/Ex3_2a.R | 11 ++ .../CH3/EX2.b.a/Ex3_2ba.R | 10 ++ .../CH3/EX2.b.b/Ex3_2bb.R | 10 ++ .../CH3/EX2.c/Ex3_2c.R | 6 + .../CH3/EX2.e/Ex3_2e.R | 10 ++ .../CH3/EX2.f.a/Ex3_2fa.R | 15 +++ .../CH3/EX2.h/Ex3_2h.R | 10 ++ .../CH3/EX3.a.1/Ex3_3a1.R | 9 ++ .../CH3/EX3.a.2/Ex3_3a2.R | 11 ++ .../CH3/EX3.d/Ex3_3d.R | 9 ++ .../CH3/EX3.e/Ex3_3e.R | 9 ++ .../CH3/EX3.f/Ex3_3f.R | 9 ++ .../CH3/EX3.i/Ex3_3i.R | 12 ++ .../CH3/EX3.l/Ex3_3l.R | 17 +++ .../CH3/EX3.n.a/Ex3_3na.R | 13 ++ .../CH3/EX3.n.b/Ex3_3nb.R | 25 ++++ .../CH3/EX3.o/Ex3_3o.R | 41 ++++++ .../CH3/EX4.h/Ex3_4h.R | 18 +++ .../CH3/EX5.a/Ex3_5a.R | 16 +++ .../CH4/EX1.b/Ex4_1b.R | 17 +++ .../CH4/EX1.d/Ex4_1d.R | 16 +++ .../CH4/EX10.a/Ex4_10a.R | 49 +++++++ .../CH4/EX3.a/Ex4_3a.R | 8 ++ .../CH4/EX3.d/Ex4_3d.R | 11 ++ .../CH4/EX4.a/Ex4_4a.R | 11 ++ .../CH4/EX5.a/Ex4_5a.R | 16 +++ .../CH4/EX6.a/Ex4_6a.R | 13 ++ .../CH4/EX6.b/Ex4_6b.R | 6 + .../CH4/EX6.c/Ex4_6c.R | 13 ++ .../CH4/EX6.d/Ex4_6d.R | 7 + .../CH4/EX6.h/Ex4_6h.R | 9 ++ .../CH4/EX6.i/Ex4_6i.R | 8 ++ .../CH4/EX7.a/Ex4_7a.R | 4 + .../CH4/EX7.b/Ex4_7b.R | 11 ++ .../CH4/EX7.c/Ex4_7c.R | 5 + .../CH4/EX7.e.a/Ex4_7ea.R | 6 + .../CH4/EX7.f/Ex4_7f.R | 9 ++ .../CH4/EX8.g/Ex4_8g.R | 11 ++ .../CH4/EX8.i/Ex4_8i.R | 11 ++ .../CH5/EX1.a.a/Ex5_1aa.R | 10 ++ .../CH5/EX1.a.b/Ex5_1ab.R | 12 ++ .../CH5/EX1.b.a/Ex5_1ba.R | 11 ++ .../CH5/EX1.b.b/Ex5_1bb.R | 10 ++ .../CH5/EX1.c/Ex5_1c.R | 14 ++ .../CH5/EX2.a/Ex5_2a.R | 9 ++ .../CH5/EX2.e/Ex5_2e.R | 14 ++ .../CH5/EX3.b/Ex5_3b.R | 18 +++ .../CH5/EX3.c/Ex5_3c.R | 19 +++ .../CH5/EX4.b/Ex5_4b.R | 13 ++ .../CH5/EX4.c/Ex5_4c.R | 5 + .../CH5/EX4.d/Ex5_4d.R | 8 ++ .../CH5/EX4.e/Ex5_4e.R | 6 + .../CH5/EX4.f/Ex5_4f.R | 11 ++ .../CH5/EX4.g/Ex5_4g.R | 9 ++ .../CH5/EX4.h/Ex5_4h.R | 9 ++ .../CH5/EX4.i/Ex5_4i.R | 20 +++ .../CH5/EX5.b/Ex5_5b.R | 7 + .../CH5/EX5.e/Ex5_5e.R | 8 ++ .../CH6/EX1.a/Ex6_1a.R | 18 +++ .../CH6/EX1.b/Ex6_1b.R | 18 +++ .../CH6/EX1.c.a/Ex6_1ca.R | 16 +++ .../CH6/EX1.c.b/Ex6_1cb.R | 19 +++ .../CH6/EX2.c/Ex6_2c.R | 16 +++ .../CH6/EX3.c.a/Ex6_3ca.R | 16 +++ .../CH6/EX3.c.b/Ex6_3cb.R | 17 +++ .../CH6/EX3.d.a/Ex6_3da.R | 6 + .../CH6/EX3.d.b/Ex6_3db.R | 9 ++ .../CH6/EX4.a/Ex6_4a.R | 18 +++ .../CH6/EX6.b/Ex6_6b.R | 10 ++ .../CH7/EX2.r/Ex7_2r.R | 10 ++ .../CH7/EX5.e.a/Ex7_5ea.R | 27 ++++ .../CH7/EX5.e.b/Ex7_5eb.R | 27 ++++ .../CH7/EX5.e.c/Ex7_5ec.R | 44 +++++++ .../CH8/EX2.b/Ex8_2b.R | 12 ++ .../CH8/EX3.a/Ex8_3a.R | 12 ++ .../CH8/EX3.b/Ex8_3b.R | 6 + .../CH8/EX3.c/Ex8_3c.R | 18 +++ .../CH8/EX3.d/Ex8_3d.R | 11 ++ .../CH8/EX3.e/Ex8_3e.R | 9 ++ .../CH8/EX5.a/Ex8_5a.R | 7 + .../CH8/EX5.b/Ex8_5b.R | 14 ++ .../README.txt | 18 +++ .../CH10/EX10.1/Ex10_1.r | 18 +++ .../CH10/EX10.10/Ex10_10.r | 15 +++ .../CH10/EX10.11/Ex10_11.r | 28 ++++ .../CH10/EX10.12/Ex10_12.r | 38 ++++++ .../CH10/EX10.13/Ex10_13.r | 15 +++ .../CH10/EX10.14/Ex10_14.r | 15 +++ .../CH10/EX10.15/Ex10_15.r | 12 ++ .../CH10/EX10.16/Ex10_16.r | 18 +++ .../CH10/EX10.17/Ex10_17.r | 22 ++++ .../CH10/EX10.2/Ex10_2.r | 29 +++++ .../CH10/EX10.3/Ex10_3.r | 13 ++ .../CH10/EX10.4/Ex10_4.r | 15 +++ .../CH10/EX10.5/Ex10_5.r | 23 ++++ .../CH10/EX10.6/Ex10_6.r | 15 +++ .../CH10/EX10.7/Ex10_7.r | 21 +++ .../CH10/EX10.8/Ex10_8.r | 10 ++ .../CH10/EX10.9/Ex10_9.r | 14 ++ .../CH11/EX11.10/Ex11_10.r | 14 ++ .../CH11/EX11.11/Ex11_11.r | 26 ++++ .../CH11/EX11.12/Ex11_12.r | 14 ++ .../CH11/EX11.13/Ex11_13.r | 7 + .../CH11/EX11.14/Ex11_14.r | 8 ++ .../CH11/EX11.15/Ex11_15.r | 20 +++ .../CH11/EX11.16/Ex11_16.r | 4 + .../CH11/EX11.17/Ex11_17.zip | Bin 0 -> 419 bytes .../CH11/EX11.2/Ex11_2.r | 14 ++ .../CH11/EX11.3/Ex11_3.r | 9 ++ .../CH11/EX11.4/Ex11_4.r | 17 +++ .../CH11/EX11.7/Ex11_7.r | 12 ++ .../CH11/EX11.8/Ex11_8.r | 8 ++ .../CH12/EX12.11/Ex12_11.r | 24 ++++ .../CH12/EX12.12/Ex12_12.r | 15 +++ .../CH12/EX12.13/Ex12_13.r | 13 ++ .../CH12/EX12.14/Ex12_14.r | 13 ++ .../CH12/EX12.15/Ex12_15.r | 11 ++ .../CH12/EX12.16/Ex12_16.r | 11 ++ .../CH12/EX12.17/Ex12_17.r | 28 ++++ .../CH12/EX12.2/Ex12_2.r | 16 +++ .../CH12/EX12.21/Ex12_21.zip | Bin 0 -> 792 bytes .../CH12/EX12.22/Ex12_22.r | 9 ++ .../CH12/EX12.26/Ex12_26.r | 13 ++ .../CH12/EX12.27/Ex12_27.r | 14 ++ .../CH12/EX12.28/Ex12_28.r | 11 ++ .../CH12/EX12.29/Ex12_29.r | 13 ++ .../CH12/EX12.3/Ex12_3.r | 8 ++ .../CH12/EX12.30/Ex12_30.r | 15 +++ .../CH12/EX12.31/Ex12_31.r | 15 +++ .../CH12/EX12.5/Ex12_5.r | 18 +++ .../CH12/EX12.6/Ex12_6.r | 8 ++ .../CH12/EX12.8/Ex12_8.r | 15 +++ .../CH12/EX12.9/Ex12_9.r | 12 ++ .../CH13/EX13.10/Ex13_10.zip | Bin 0 -> 801 bytes .../CH13/EX13.12/Ex13_12.zip | Bin 0 -> 440 bytes .../CH13/EX13.14/Ex13_14.zip | Bin 0 -> 609 bytes .../CH13/EX13.15/Ex13_15.zip | Bin 0 -> 766 bytes .../CH13/EX13.19/Ex13_19.zip | Bin 0 -> 387 bytes .../CH13/EX13.3/Ex13_3.zip | Bin 0 -> 813 bytes .../CH13/EX13.7/Ex13_7.zip | Bin 0 -> 751 bytes .../CH13/EX13.9/Ex13_9.zip | Bin 0 -> 465 bytes .../CH14/EX14.1/Ex14_1.r | 5 + .../CH14/EX14.10/Ex14_10.zip | Bin 0 -> 525 bytes .../CH14/EX14.11/Ex14_11.r | 20 +++ .../CH14/EX14.12/Ex14_12.r | 9 ++ .../CH14/EX14.13/Ex14_13.r | 10 ++ .../CH14/EX14.2/Ex14_2.r | 25 ++++ .../CH14/EX14.6/Ex14_6.zip | Bin 0 -> 467 bytes .../CH14/EX14.7/Ex14_7.zip | Bin 0 -> 721 bytes .../CH15/EX15.1/Ex15_1.zip | Bin 0 -> 516 bytes .../CH15/EX15.11/Ex15_11.r | 9 ++ .../CH15/EX15.12/Ex15_12.zip | Bin 0 -> 744 bytes .../CH15/EX15.5/Ex15_5.zip | Bin 0 -> 501 bytes .../CH15/EX15.7/Ex15_7.r | 9 ++ .../CH3/EX3.1/Ex3_1.R | 12 ++ .../CH3/EX3.10/Ex3_10.r | 11 ++ .../CH3/EX3.12/Ex3_12.r | 14 ++ .../CH3/EX3.13/Ex3_13.r | 10 ++ .../CH3/EX3.14/Ex3_14.r | 16 +++ .../CH3/EX3.15/Ex3_15.r | 4 + .../CH3/EX3.16/Ex3_16.r | 10 ++ .../CH3/EX3.2/Ex3_2.R | 17 +++ .../CH3/EX3.3/Ex3_3.R | 20 +++ .../CH3/EX3.4/Ex3_4.r | 34 +++++ .../CH3/EX3.5/Ex3_5.r | 12 ++ .../CH3/EX3.6/Ex3_6.r | 13 ++ .../CH3/EX3.7/Ex3_7.r | 9 ++ .../CH3/EX3.8/Ex3_8.r | 8 ++ .../CH3/EX3.9/Ex3_9.r | 4 + .../CH4/EX4.1/Ex4_1.r | 12 ++ .../CH4/EX4.10/Ex4_10.r | 10 ++ .../CH4/EX4.11/Ex4_11.r | 15 +++ .../CH4/EX4.12/Ex4_12.r | 18 +++ .../CH4/EX4.13/Ex4_13.r | 17 +++ .../CH4/EX4.15/Ex4_15.r | 5 + .../CH4/EX4.16/Ex4_16.r | 5 + .../CH4/EX4.17/Ex4_17.r | 8 ++ .../CH4/EX4.18/Ex4_18.r | 4 + .../CH4/EX4.19/Ex4_19.r | 11 ++ .../CH4/EX4.2/Ex4_2.r | 4 + .../CH4/EX4.20/Ex4_20.r | 7 + .../CH4/EX4.21/Ex4_21.r | 5 + .../CH4/EX4.22/Ex4_22.r | 9 ++ .../CH4/EX4.24/Ex4_24.r | 17 +++ .../CH4/EX4.25/Ex4_25.r | 9 ++ .../CH4/EX4.26/Ex4_26.r | 9 ++ .../CH4/EX4.27/Ex4_27.r | 8 ++ .../CH4/EX4.28/Ex4_28.r | 10 ++ .../CH4/EX4.3/Ex4_3.r | 10 ++ .../CH4/EX4.4/Ex4_4.r | 20 +++ .../CH4/EX4.7/Ex4_7.r | 14 ++ .../CH4/EX4.8/Ex4_8.r | 8 ++ .../CH4/EX4.9/Ex4_9.r | 12 ++ .../CH5/EX5.1/Ex5_1.r | 11 ++ .../CH5/EX5.10/Ex5_10.r | 17 +++ .../CH5/EX5.11/Ex5_11.r | 9 ++ .../CH5/EX5.12/Ex5_12.r | 17 +++ .../CH5/EX5.13/Ex5_13.r | 17 +++ .../CH5/EX5.14/Ex5_14.r | 20 +++ .../CH5/EX5.15/Ex5_15.r | 17 +++ .../CH5/EX5.17/Ex5_17.r | 17 +++ .../CH5/EX5.18/Ex5_18.r | 15 +++ .../CH5/EX5.19/Ex5_19.r | 18 +++ .../CH5/EX5.2/Ex5_2.r | 11 ++ .../CH5/EX5.20/Ex5_20.r | 6 + .../CH5/EX5.21/Ex5_21.r | 6 + .../CH5/EX5.23/Ex5_23.r | 13 ++ .../CH5/EX5.3/Ex5_3.r | 10 ++ .../CH5/EX5.4/Ex5_4.r | 8 ++ .../CH5/EX5.5/Ex5_5.r | 15 +++ .../CH5/EX5.6/Ex5_6.r | 17 +++ .../CH5/EX5.7/Ex5_7.r | 18 +++ .../CH5/EX5.8/Ex5_8.r | 25 ++++ .../CH5/EX5.9/Ex5_9.r | 16 +++ .../CH6/EX6.1/Ex6_1.r | 24 ++++ .../CH6/EX6.10/Ex6_10.r | 7 + .../CH6/EX6.11/Ex6_11.r | 9 ++ .../CH6/EX6.2/Ex6_2.r | 19 +++ .../CH6/EX6.3/Ex6_3.r | 34 +++++ .../CH6/EX6.4/Ex6_4.r | 24 ++++ .../CH6/EX6.5/Ex6_5.r | 22 ++++ .../CH6/EX6.6/Ex6_6.r | 16 +++ .../CH6/EX6.7/Ex6_7.r | 3 + .../CH6/EX6.8/Ex6_8.r | 6 + .../CH6/EX6.9/Ex6_9.r | 18 +++ .../CH7/EX7.1/Ex7_1.r | 21 +++ .../CH7/EX7.2/Ex7_2.r | 28 ++++ .../CH7/EX7.4/Ex7_4.r | 5 + .../CH7/EX7.5/Ex7_5.r | 15 +++ .../CH7/EX7.6/Ex7_6.r | 17 +++ .../CH7/EX7.7/Ex7_7.r | 15 +++ .../CH7/EX7.8/Ex7_8.r | 15 +++ .../CH7/EX7.9/Ex7_9.r | 10 ++ .../CH8/EX8.1/Ex8_1.r | 18 +++ .../CH8/EX8.2/Ex8_2.r | 15 +++ .../CH8/EX8.3/Ex8_3.r | 17 +++ .../CH8/EX8.4/Ex8_4.r | 43 ++++++ .../CH8/EX8.7/Ex8_7.r | 15 +++ .../CH9/EX9.1/Ex9_1.r | 21 +++ .../CH9/EX9.11/Ex9_11.r | 18 +++ .../CH9/EX9.13/Ex9_13.r | 30 +++++ .../CH9/EX9.14/Ex9_14.r | 77 +++++++++++ .../CH9/EX9.2/Ex9_2.r | 38 ++++++ .../CH9/EX9.3/Ex9_3.r | 61 +++++++++ .../CH9/EX9.5/Ex9_5.r | 29 +++++ .../CH9/EX9.6/Ex9_6.r | 11 ++ .../CH9/EX9.7/Ex9_7.r | 9 ++ .../CH9/EX9.9/Ex9_9.r | 18 +++ .../README.txt | 18 +++ .../CH10/EX10.1/EX10_1.R | 26 ++++ .../CH10/EX10.10/EX10_10.R | 9 ++ .../CH10/EX10.11/EX10_11.R | 22 ++++ .../CH10/EX10.12/EX10_12.R | 12 ++ .../CH10/EX10.13/EX10_13.R | 17 +++ .../CH10/EX10.15/EX10_15.R | 19 +++ .../CH10/EX10.16/EX10_16.R | 21 +++ .../CH10/EX10.17/EX10_17.R | 13 ++ .../CH10/EX10.2/EX10_2.R | 8 ++ .../CH10/EX10.3/EX10_3.R | 16 +++ .../CH10/EX10.4/EX10_4.R | 16 +++ .../CH10/EX10.5/EX10_5.R | 24 ++++ .../CH10/EX10.6/EX10_6.R | 29 +++++ .../CH10/EX10.8/EX10_8.R | 14 ++ .../CH10/EX10.9/EX10_9.R | 22 ++++ .../CH11/EX11.1/EX11_1.R | 8 ++ .../CH11/EX11.2/EX11_2.R | 25 ++++ .../CH11/EX11.3/EX11_3.R | 9 ++ .../CH11/EX11.4/EX11_4.R | 12 ++ .../CH11/EX11.5/EX11_5.R | 16 +++ .../CH11/EX11.6/EX11_6.R | 14 ++ .../CH11/EX11.8/EX11_8.R | 23 ++++ .../CH12/EX12.1/EX12_1.R | 9 ++ .../CH12/EX12.11/EX12_11.R | 24 ++++ .../CH12/EX12.12/EX12_12.R | 27 ++++ .../CH12/EX12.13/EX12_13.R | 13 ++ .../CH12/EX12.2/EX12_2.R | 38 ++++++ .../CH12/EX12.3/EX12_3.R | 11 ++ .../CH12/EX12.4/EX12_4.R | 40 ++++++ .../CH12/EX12.5/EX12_5.R | 31 +++++ .../CH12/EX12.6/EX12_6.R | 9 ++ .../CH12/EX12.7/EX12_7.R | 30 +++++ .../CH12/EX12.8/EX12_8.R | 33 +++++ .../CH12/EX12.9/EX12_9.R | 34 +++++ .../CH13/EX13.1/EX13_1.R | 58 +++++++++ .../CH13/EX13.2/EX13_2.R | 35 +++++ .../CH13/EX13.4/EX13_4.R | 20 +++ .../CH13/EX13.5/EX13_5.R | 24 ++++ .../CH14/EX14.1/EX14_1.R | 69 ++++++++++ .../CH14/EX14.3/EX14_3.R | 30 +++++ .../CH14/EX14.4/EX14_4.R | 17 +++ .../CH14/EX14.5/EX14_5.R | 6 + .../CH14/EX14.6/EX14_6.R | 24 ++++ .../CH14/EX14.8/EX14_8.R | 26 ++++ .../CH15/EX15.1/EX15_1.R | 36 +++++ .../CH15/EX15.2/EX15_2.R | 23 ++++ .../CH15/EX15.3/EX15_3.R | 23 ++++ .../CH15/EX15.4/EX15_4.R | 20 +++ .../CH15/EX15.5/EX15_5.R | 15 +++ .../CH15/EX15.6/EX15_6.R | 12 ++ .../CH15/EX15.7/EX15_7.R | 14 ++ .../CH2/EX2.1/EX2_1.R | 21 +++ .../CH2/EX2.10/EX2_10.R | 7 + .../CH2/EX2.11/EX2_11.R | 7 + .../CH2/EX2.12/EX2_12.R | 12 ++ .../CH2/EX2.13/EX2_13.R | 7 + .../CH2/EX2.14/EX2_14.R | 20 +++ .../CH2/EX2.15/EX2_15.R | 8 ++ .../CH2/EX2.16/Ex2_16.R | 22 ++++ .../CH2/EX2.17/EX2_17.R | 10 ++ .../CH2/EX2.18/EX2_18.R | 19 +++ .../CH2/EX2.19/EX2_19.R | 15 +++ .../CH2/EX2.20/EX2_20.R | 14 ++ .../CH2/EX2.22/EX2_22.R | 12 ++ .../CH2/EX2.23/EX2_23.R | 39 ++++++ .../CH2/EX2.24/EX2_24.R | 12 ++ .../CH2/EX2.25/EX2_25.R | 13 ++ .../CH2/EX2.26/EX2_26.R | 7 + .../CH2/EX2.27/EX2_27.R | 14 ++ .../CH2/EX2.28/EX2_28.R | 12 ++ .../CH2/EX2.29/EX2_29.R | 14 ++ .../CH2/EX2.30/EX2_30.R | 13 ++ .../CH2/EX2.31/EX2_31.R | 11 ++ .../CH2/EX2.32/EX2_32.R | 8 ++ .../CH2/EX2.33/EX2_33.R | 11 ++ .../CH2/EX2.34/EX2_34.R | 14 ++ .../CH2/EX2.35/EX2_35.R | 10 ++ .../CH2/EX2.37/EX2_37.R | 12 ++ .../CH2/EX2.4/EX2_4.R | 23 ++++ .../CH2/EX2.5/EX2_5.R | 25 ++++ .../CH2/EX2.8/EX2_8.R | 18 +++ .../CH2/EX2.9/EX2_9.R | 8 ++ .../CH3/EX3.10/EX3_10.R | 20 +++ .../CH3/EX3.11/EX3_11.R | 14 ++ .../CH3/EX3.12/EX3_12.R | 12 ++ .../CH3/EX3.14/EX3_14.R | 12 ++ .../CH3/EX3.15/EX3_15.R | 13 ++ .../CH3/EX3.16/EX3_16.R | 15 +++ .../CH3/EX3.17/EX3_17.R | 14 ++ .../CH3/EX3.18/EX3_18.R | 16 +++ .../CH3/EX3.19/EX3_19.R | 11 ++ .../CH3/EX3.2/EX3_2.R | 8 ++ .../CH3/EX3.20/EX3_20.R | 9 ++ .../CH3/EX3.21/EX3_21.R | 10 ++ .../CH3/EX3.22/EX3_22.R | 11 ++ .../CH3/EX3.24/EX3_24.R | 8 ++ .../CH3/EX3.25/EX3_25.R | 11 ++ .../CH3/EX3.26/EX3_26.R | 16 +++ .../CH3/EX3.27/EX3_27.R | 24 ++++ .../CH3/EX3.28/EX3_28.R | 13 ++ .../CH3/EX3.29/EX3_29.R | 10 ++ .../CH3/EX3.31/EX3_31.R | 19 +++ .../CH3/EX3.32/EX3_32.R | 18 +++ .../CH3/EX3.5/EX3_5.R | 20 +++ .../CH3/EX3.6/EX3_6.R | 14 ++ .../CH3/EX3.7/EX3_7.R | 19 +++ .../CH3/EX3.8/EX3_8.R | 25 ++++ .../CH3/EX3.9/EX3_9.R | 16 +++ .../CH4/EX4.1/EX4_1.R | 10 ++ .../CH4/EX4.12/EX4_12.R | 25 ++++ .../CH4/EX4.13/EX4_13.R | 10 ++ .../CH4/EX4.14/EX4_14.R | 19 +++ .../CH4/EX4.15/EX4_15.R | 6 + .../CH4/EX4.16/EX4_16.R | 22 ++++ .../CH4/EX4.18/EX4_18.R | 8 ++ .../CH4/EX4.19/EX4_19.R | 15 +++ .../CH4/EX4.2/EX4_2.R | 13 ++ .../CH4/EX4.20/EX4_20.R | 6 + .../CH4/EX4.21/EX4_21.R | 19 +++ .../CH4/EX4.22/EX4_22.R | 16 +++ .../CH4/EX4.23/EX4_23.R | 10 ++ .../CH4/EX4.24/EX4_24.R | 24 ++++ .../CH4/EX4.25/EX4_25.R | 10 ++ .../CH4/EX4.26/EX4_26.R | 19 +++ .../CH4/EX4.27/EX4_27.R | 10 ++ .../CH4/EX4.28/EX4_28.R | 13 ++ .../CH4/EX4.5/EX4_5.R | 9 ++ .../CH4/EX4.6/EX4_6.R | 13 ++ .../CH4/EX4.7/EX4_7.R | 7 + .../CH4/EX4.8/EX4_8.R | 15 +++ .../CH4/EX4.9/EX4_9.R | 19 +++ .../CH5/EX5.12/EX5_12.R | 20 +++ .../CH5/EX5.14/EX5_14.R | 11 ++ .../CH5/EX5.15/EX5_15.R | 12 ++ .../CH5/EX5.16/EX5_16.R | 18 +++ .../CH5/EX5.18/EX5_18.R | 21 +++ .../CH5/EX5.19/EX5_19.R | 22 ++++ .../CH5/EX5.2/EX5_2.R | 7 + .../CH5/EX5.21/EX5_21.R | 23 ++++ .../CH5/EX5.23/EX5_23.R | 32 +++++ .../CH5/EX5.24/EX5_24.R | 15 +++ .../CH5/EX5.25/EX5_25.R | 5 + .../CH5/EX5.3/EX5_3.R | 9 ++ .../CH5/EX5.31/EX5_31.R | 5 + .../CH5/EX5.32/EX5_32.R | 15 +++ .../CH5/EX5.33/EX5_33.R | 12 ++ .../CH5/EX5.4/EX5_4.R | 10 ++ .../CH5/EX5.5/EX5_5.R | 15 +++ .../CH5/EX5.6/EX5_6.R | 10 ++ .../CH5/EX5.8/EX5_8.R | 10 ++ .../CH5/EX5.9/EX5_9.R | 8 ++ .../CH6/EX6.1/EX6_1.R | 7 + .../CH6/EX6.2/EX6_2.R | 9 ++ .../CH6/EX6.3/EX6_3.R | 11 ++ .../CH7/EX7.1/EX7_1.R | 13 ++ .../CH7/EX7.17/EX7_17.R | 10 ++ .../CH7/EX7.3/EX7_3.R | 22 ++++ .../CH7/EX7.5/EX7_5.R | 9 ++ .../CH7/EX7.9/EX7_9.R | 13 ++ .../CH8/EX8.1/EX8_1.R | 11 ++ .../CH8/EX8.10/EX8_10.R | 12 ++ .../CH8/EX8.11/EX8_11.R | 12 ++ .../CH8/EX8.12/EX8_12.R | 16 +++ .../CH8/EX8.2/EX8_2.R | 10 ++ .../CH8/EX8.3/EX8_3.R | 10 ++ .../CH8/EX8.4/EX8_4.R | 15 +++ .../CH8/EX8.5/EX8_5.R | 11 ++ .../CH8/EX8.6/EX8_6.R | 7 + .../CH8/EX8.7/EX8_7.R | 10 ++ .../CH8/EX8.8/EX8_8.R | 15 +++ .../CH8/EX8.9/EX8_9.R | 14 ++ .../CH9/EX9.10/EX9_10.R | 24 ++++ .../CH9/EX9.11/EX9_11.R | 17 +++ .../CH9/EX9.12/EX9_12.R | 39 ++++++ .../CH9/EX9.13/EX9_13.R | 21 +++ .../CH9/EX9.14/EX9_14.R | 57 ++++++++ .../CH9/EX9.15/EX9_15.R | 22 ++++ .../CH9/EX9.16/EX9_16.R | 18 +++ .../CH9/EX9.17/EX9_17.R | 39 ++++++ .../CH9/EX9.2/EX9_2.R | 22 ++++ .../CH9/EX9.3/EX9_3.R | 17 +++ .../CH9/EX9.4/EX9_4.R | 11 ++ .../CH9/EX9.6/EX9_6.R | 18 +++ .../CH9/EX9.7/EX9_7.R | 12 ++ .../CH9/EX9.8/EX9_8.R | 22 ++++ .../CH9/EX9.9/EX9_9.R | 10 ++ .../README.txt | 18 +++ .../CH11/EX11.18/Ex11_18.R | 18 +++ .../CH11/EX11.19/Ex11_19.R | 18 +++ .../CH11/EX11.22/Ex11_22.R | 11 ++ .../CH11/EX11.24/Ex11_24.R | 11 ++ .../CH11/EX11.28/Ex11_28.R | 10 ++ .../CH13/EX13.17/Ex13_17.R | 22 ++++ .../CH13/EX13.18/Ex13_18.R | 18 +++ .../CH13/EX13.4/Ex13_4.R | 9 ++ .../CH14/EX14.18/Ex14_18.R | 31 +++++ .../CH14/EX14.19/Ex14_19.R | 31 +++++ .../CH14/EX14.22/Ex14_22.R | 34 +++++ .../CH14/EX14.26/Ex14_26.R | 27 ++++ .../CH14/EX14.5/Ex14_5.R | 31 +++++ .../CH14/EX14.7/Ex14_7.R | 31 +++++ .../CH15/EX15.1/Ex15_1.R | 6 + .../CH15/EX15.2/Ex15_2.R | 7 + .../CH15/EX15.3/Ex15_3.R | 6 + .../CH15/EX15.4/Ex15_4.R | 6 + .../CH15/EX15.6/Ex15_6.R | 6 + .../CH16/EX16.1/Ex16_1.R | 6 + .../CH16/EX16.15/Ex16_15.R | 19 +++ .../CH16/EX16.18/Ex16_18.R | 34 +++++ .../CH16/EX16.19/Ex16_19.R | 25 ++++ .../CH16/EX16.2/Ex16_2.R | 20 +++ .../CH16/EX16.3/Ex16_3.R | 18 +++ .../CH16/EX16.4/Ex16_4.R | 12 ++ .../CH16/EX16.5/Ex16_5.R | 12 ++ .../CH22/EX22.1/Ex22_1.R | 14 ++ .../CH22/EX22.10/Ex22_10.R | 5 + .../CH22/EX22.11/Ex22_11.R | 7 + .../CH22/EX22.2/Ex22_2.R | 16 +++ .../CH22/EX22.3/Ex22_3.R | 25 ++++ .../CH22/EX22.4/Ex22_4.R | 22 ++++ .../CH22/EX22.5/Ex22_5.R | 39 ++++++ .../CH22/EX22.6/Ex22_6.R | 45 +++++++ .../CH22/EX22.8/Ex22_8.R | 11 ++ .../CH22/EX22.9/Ex22_9.R | 15 +++ .../CH26/EX26.10/Ex26_10.R | 27 ++++ .../CH26/EX26.11/Ex26_11.R | 12 ++ .../CH26/EX26.12/Ex26_12.R | 13 ++ .../CH26/EX26.13/Ex26_13.R | 18 +++ .../CH26/EX26.14/Ex26_14.R | 18 +++ .../CH26/EX26.15/Ex26_15.R | 19 +++ .../CH26/EX26.16/Ex26_16.R | 16 +++ .../CH26/EX26.17/Ex26_17.R | 15 +++ .../CH26/EX26.18/Ex26_18.R | 17 +++ .../CH26/EX26.2/Ex26_2.R | 17 +++ .../CH26/EX26.3/Ex26_3.R | 23 ++++ .../CH26/EX26.4/Ex26_4.R | 21 +++ .../CH26/EX26.5/Ex26_5.R | 17 +++ .../CH26/EX26.6/Ex26_6.R | 15 +++ .../CH26/EX26.7/Ex26_7.R | 22 ++++ .../CH26/EX26.8/Ex26_8.R | 16 +++ .../CH27/EX27.1/Ex27_1.R | 12 ++ .../CH27/EX27.10/Ex27_10.R | 22 ++++ .../CH27/EX27.11/Ex27_11.R | 10 ++ .../CH27/EX27.12/Ex27_12.R | 21 +++ .../CH27/EX27.13/Ex27_13.R | 27 ++++ .../CH27/EX27.15/Ex27_15.R | 20 +++ .../CH27/EX27.16/Ex27_16.R | 13 ++ .../CH27/EX27.2/Ex27_2.R | 13 ++ .../CH27/EX27.3/Ex27_3.R | 14 ++ .../CH27/EX27.4/Ex27_4.R | 17 +++ .../CH27/EX27.5/Ex27_5.R | 22 ++++ .../CH27/EX27.6/Ex27_6.R | 15 +++ .../CH27/EX27.8/Ex27_8.R | 13 ++ .../CH27/EX27.9/Ex27_9.R | 14 ++ .../CH28/EX28.1/Ex28_1.R | 14 ++ .../CH28/EX28.11/Ex28_11.R | 15 +++ .../CH28/EX28.12/Ex28_12.R | 8 ++ .../CH28/EX28.13/Ex28_13.R | 20 +++ .../CH28/EX28.15/Ex28_15.R | 12 ++ .../CH28/EX28.18/Ex28_18.R | 11 ++ .../CH28/EX28.23/Ex28_23.R | 42 ++++++ .../CH28/EX28.24/Ex28_24.R | 10 ++ .../CH28/EX28.29/Ex28_29.R | 21 +++ .../CH28/EX28.4/Ex28_4.R | 11 ++ .../CH28/EX28.5/Ex28_5.R | 10 ++ .../CH28/EX28.9/Ex28_9.R | 7 + .../CH33/EX33.1/Ex33_1.R | 11 ++ .../CH33/EX33.2/Ex33_2.R | 11 ++ .../CH33/EX33.3/Ex33_3.R | 18 +++ .../CH33/EX33.4/Ex33_4.R | 38 ++++++ .../CH33/EX33.5/Ex33_5.R | 6 + .../CH33/EX33.6/Ex33_6.R | 18 +++ .../CH34/EX34.1/Ex34_1.R | 16 +++ .../CH34/EX34.2/Ex34_2.R | 15 +++ .../CH34/EX34.3/Ex34_3.R | 17 +++ .../CH34/EX34.4/Ex34_4.R | 18 +++ .../CH34/EX34.5/Ex34_5.R | 22 ++++ .../CH34/EX34.6/Ex34_6.R | 22 ++++ .../CH34/EX34.7/Ex34_7.R | 26 ++++ .../CH34/EX34.8/Ex34_8.R | 9 ++ .../CH34/EX34.9/Ex34_9.R | 18 +++ .../CH35/EX35.11/Ex35_11.R | 12 ++ .../CH35/EX35.12/Ex35_12.R | 9 ++ .../CH35/EX35.16/Ex35_16.R | 9 ++ .../CH35/EX35.25/Ex35_25.R | 11 ++ .../CH35/EX35.6/Ex35_6.R | 9 ++ .../CH35/EX35.9/Ex35_9.R | 9 ++ .../CH36/EX36.18/Ex36_18.R | 8 ++ .../CH36/EX36.20/Ex36_20.R | 8 ++ .../CH36/EX36.22/Ex36_22.R | 8 ++ .../CH36/EX36.24/Ex36_24.R | 8 ++ .../CH37/EX37.10/Ex37_10.R | 21 +++ .../CH37/EX37.12/Ex37_12.R | 15 +++ .../CH37/EX37.14/Ex37_14.R | 15 +++ .../CH37/EX37.16/Ex37_16.R | 46 +++++++ .../CH37/EX37.20/Ex37_20.R | 18 +++ .../CH37/EX37.22/Ex37_22.R | 15 +++ .../CH37/EX37.23/Ex37_23.R | 14 ++ .../CH37/EX37.4/Ex37_4.R | 19 +++ .../CH5/EX5.1/Ex5_1.R | 7 + .../CH5/EX5.10/Ex5_10.R | 19 +++ .../CH5/EX5.12/Ex5_12.R | 20 +++ .../CH5/EX5.14/Ex5_14.R | 15 +++ .../CH5/EX5.15/Ex5_15.R | 12 ++ .../CH5/EX5.18/Ex5_18.R | 14 ++ .../CH5/EX5.21/Ex5_21.R | 15 +++ .../CH5/EX5.23/Ex5_23.R | 8 ++ .../CH5/EX5.4/Ex5_4.R | 10 ++ .../CH5/EX5.7/Ex5_7.R | 10 ++ .../CH1/EX1.4.1/Ex1_4_1.R | 29 +++++ .../CH1/EX1.4.2/Ex1_4_2.R | 35 +++++ .../CH10/EX10.3.1/Ex10_3_1.R | 18 +++ .../CH10/EX10.4.1/Ex10_4_1.R | 18 +++ .../CH10/EX10.4.2/Ex10_4_2.R | 15 +++ .../CH10/EX10.4.3/Ex10_4_3.R | 17 +++ .../CH10/EX10.5.1/Ex10_5_1.R | 19 +++ .../CH10/EX10.6.1/Ex10_6_1.R | 16 +++ .../CH10/EX10.6.2/Ex10_6_2.R | 42 ++++++ .../CH11/EX11.1.1/Ex11_1_1.R | 11 ++ .../CH11/EX11.1.2/Ex11_1_2.R | 21 +++ .../CH11/EX11.2.1/Ex11_2_1.R | 44 +++++++ .../CH11/EX11.2.2/Ex11_2_2.R | 41 ++++++ .../CH11/EX11.3.1/Ex11_3_1.R | 17 +++ .../CH11/EX11.4.1/Ex11_4_1.R | 19 +++ .../CH11/EX11.4.2/Ex11_4_2.R | 42 ++++++ .../CH12/EX12.3.2/Ex12_3_2.R | 27 ++++ .../CH12/EX12.3.3/Ex12_3_3.R | 24 ++++ .../CH12/EX12.3.4/Ex12_3_4.R | 16 +++ .../CH12/EX12.3.5/Ex12_3_5.R | 17 +++ .../CH12/EX12.4.1/Ex12_4_1.R | 16 +++ .../CH12/EX12.4.2/Ex12_4_2.R | 15 +++ .../CH12/EX12.5.1/Ex12_5_1.R | 16 +++ .../CH12/EX12.6.1/Ex12_6_1.R | 15 +++ .../CH12/EX12.7.1/Ex12_7_1.R | 17 +++ .../CH12/EX12.7.2/Ex12_7_2.R | 15 +++ .../CH13/EX13.10.1/Ex13_10_1.R | 9 ++ .../CH13/EX13.10.2/Ex13_10_2.R | 12 ++ .../CH13/EX13.3.1/Ex13_3_1.R | 18 +++ .../CH13/EX13.3.2/Ex13_3_2.R | 17 +++ .../CH13/EX13.4.1/Ex13_4_1.R | 8 ++ .../CH13/EX13.5.1/Ex13_5_1.R | 21 +++ .../CH13/EX13.6.1/Ex13_6_1.R | 8 ++ .../CH13/EX13.7.1/Ex13_7_1.R | 9 ++ .../CH13/EX13.8.1/Ex13_8_1.R | 14 ++ .../CH13/EX13.8.2/Ex13_8_2.R | 16 +++ .../CH13/EX13.9.1/Ex13_9_1.R | 14 ++ .../CH13/EX13.9.2/Ex13_9_2.R | 14 ++ .../CH2/EX2.2.1/Ex2_2_1.R | 24 ++++ .../CH2/EX2.3.1/Ex2_3_1.R | 32 +++++ .../CH2/EX2.3.2/Ex2_3_2.R | 26 ++++ .../CH2/EX2.4.1/Ex2_4_1.R | 24 ++++ .../CH2/EX2.4.2/Ex2_4_2.R | 26 ++++ .../CH2/EX2.4.3/Ex2_4_3.R | 24 ++++ .../CH2/EX2.4.4/Ex2_4_4.R | 28 ++++ .../CH2/EX2.4.5/Ex2_4_5.R | 29 +++++ .../CH2/EX2.4.6/Ex2_4_6.R | 27 ++++ .../CH2/EX2.5.1/Ex2_5_1.R | 25 ++++ .../CH2/EX2.5.2/Ex2_5_2.R | 28 ++++ .../CH2/EX2.5.3/Ex2_5_3.R | 17 +++ .../CH2/EX2.5.4/Ex2_5_4.R | 27 ++++ .../CH2/EX2.5.5/Ex2_5_5.R | 7 + .../CH3/EX3.4.1/Ex3_4_1.R | 12 ++ .../CH3/EX3.4.2/Ex3_4_2.R | 15 +++ .../CH3/EX3.4.3/Ex3_4_3.R | 12 ++ .../CH3/EX3.4.4/Ex3_4_4.R | 15 +++ .../CH3/EX3.4.5/Ex3_4_5.R | 15 +++ .../CH3/EX3.4.6/Ex3_4_6.R | 17 +++ .../CH3/EX3.4.7/Ex3_4_7.R | 18 +++ .../CH3/EX3.4.8/Ex3_4_8.R | 9 ++ .../CH3/EX3.4.9/Ex3_4_9.R | 22 ++++ .../CH3/EX3.5.1/Ex3_5_1.R | 23 ++++ .../CH4/EX4.2.1/Ex4_2_1.R | 17 +++ .../CH4/EX4.2.2/Ex4_2_2.R | 18 +++ .../CH4/EX4.2.3/Ex4_2_3.R | 21 +++ .../CH4/EX4.2.4/Ex4_2_4.R | 15 +++ .../CH4/EX4.2.5/Ex4_2_5.R | 15 +++ .../CH4/EX4.2.6/Ex4_2_6.R | 15 +++ .../CH4/EX4.2.7/Ex4_2_7.R | 17 +++ .../CH4/EX4.2.8/Ex4_2_8.R | 20 +++ .../CH4/EX4.3.1/Ex4_3_1.R | 8 ++ .../CH4/EX4.3.2/Ex4_3_2.R | 8 ++ .../CH4/EX4.3.3/Ex4_3_3.R | 16 +++ .../CH4/EX4.3.4/Ex4_3_4.R | 13 ++ .../CH4/EX4.4.1/Ex4_4_1.R | 7 + .../CH4/EX4.4.2/Ex4_4_2.R | 7 + .../CH4/EX4.4.3/Ex4_4_3.R | 6 + .../CH4/EX4.4.4/Ex4_4_4.R | 7 + .../CH4/EX4.4.5/Ex4_4_5.R | 6 + .../CH4/EX4.6.1/Ex4_6_1.R | 14 ++ .../CH4/EX4.6.2/Ex4_6_2.R | 17 +++ .../CH4/EX4.6.3/Ex4_6_3.R | 15 +++ .../CH4/EX4.6.4/Ex4_6_4.R | 17 +++ .../CH4/EX4.6.5/Ex4_6_5.R | 16 +++ .../CH4/EX4.7.1/Ex4_7_1.R | 17 +++ .../CH4/EX4.7.2/Ex4_7_2.R | 17 +++ .../CH4/EX4.7.3/Ex4_7_3.R | 9 ++ .../CH5/EX5.3.2/Ex5_3_2.R | 17 +++ .../CH5/EX5.3.3/Ex5_3_3.R | 12 ++ .../CH5/EX5.4.1/Ex5_4_1.R | 12 ++ .../CH5/EX5.4.2/Ex5_4_2.R | 14 ++ .../CH5/EX5.5.2/Ex5_5_2.R | 13 ++ .../CH5/EX5.6.1/Ex5_6_1.R | 14 ++ .../CH5/EX5.6.2/Ex5_6_2.R | 13 ++ .../CH6/EX6.10.1/Ex6_10_1.R | 11 ++ .../CH6/EX6.2.1/Ex6_2_1.R | 15 +++ .../CH6/EX6.2.2/Ex6_2_2.R | 13 ++ .../CH6/EX6.2.3/Ex6_2_3.R | 11 ++ .../CH6/EX6.2.4/Ex6_2_4.R | 15 +++ .../CH6/EX6.3.1/Ex6_3_1.R | 11 ++ .../CH6/EX6.4.1/Ex6_4_1.R | 12 ++ .../CH6/EX6.4.2/Ex6_4_2.R | 12 ++ .../CH6/EX6.4.3/Ex6_4_3.R | 13 ++ .../CH6/EX6.4.4/Ex6_4_4.R | 16 +++ .../CH6/EX6.5.1/Ex6_5_1.R | 11 ++ .../CH6/EX6.6.1/Ex6_6_1.R | 12 ++ .../CH6/EX6.7.1/Ex6_7_1.R | 8 ++ .../CH6/EX6.8.1/Ex6_8_1.R | 7 + .../CH6/EX6.9.1/Ex6_9_1.R | 11 ++ .../CH7/EX7.2.1/Ex7_2_1.R | 13 ++ .../CH7/EX7.2.2/Ex7_2_2.R | 14 ++ .../CH7/EX7.2.3/Ex7_2_3.R | 14 ++ .../CH7/EX7.2.4/Ex7_2_4.R | 14 ++ .../CH7/EX7.2.5/Ex7_2_5.R | 15 +++ .../CH7/EX7.3.1/Ex7_3_1.R | 13 ++ .../CH7/EX7.3.2/Ex7_3_2.R | 10 ++ .../CH7/EX7.3.3/Ex7_3_3.R | 16 +++ .../CH7/EX7.3.4/Ex7_3_4.R | 14 ++ .../CH7/EX7.4.1/Ex7_4_1.R | 13 ++ .../CH7/EX7.5.1/Ex7_5_1.R | 16 +++ .../CH7/EX7.6.1/Ex7_6_1.R | 15 +++ .../CH7/EX7.7.1/Ex7_7_1.R | 16 +++ .../CH7/EX7.8.1/Ex7_8_1.R | 14 ++ .../CH7/EX7.8.2/Ex7_8_2.R | 12 ++ .../CH8/EX8.2.1/Ex8_2_1.R | 23 ++++ .../CH8/EX8.2.2/Ex8_2_2.R | 29 +++++ .../CH8/EX8.3.1/Ex8_3_1.R | 18 +++ .../CH9/EX9.3.1/Ex9_3_1.R | 19 +++ .../CH9/EX9.4.1/Ex9_4_1.R | 13 ++ .../CH9/EX9.4.2/Ex9_4_2.R | 13 ++ .../CH9/EX9.4.3/Ex9_4_3.R | 16 +++ .../CH9/EX9.7.1/Ex9_7_1.R | 16 +++ .../CH9/EX9.7.2/Ex9_7_2.R | 16 +++ .../README.txt | 18 +++ .../CH10/EX10.1/Ex10_1.R | 25 ++++ .../CH2/EX2.6/Ex2_6.R | 12 ++ .../CH3/EX3.1/Ex3_1.R | 6 + .../CH3/EX3.10/Ex3_10.R | 8 ++ .../CH3/EX3.2/Ex3_2.R | 4 + .../CH3/EX3.3/Ex3_3.R | 13 ++ .../CH3/EX3.7/Ex3_7.R | 5 + .../CH3/EX3.8/Ex3_8.R | 15 +++ .../CH3/EX3.9/Ex3_9.R | 18 +++ .../CH4/EX4.10/Ex4_10.R | 17 +++ .../CH4/EX4.11/Ex4_11.R | 7 + .../CH4/EX4.12/Ex4_12.R | 9 ++ .../CH4/EX4.13/Ex4_13.R | 7 + .../CH4/EX4.14/Ex4_14.R | 11 ++ .../CH4/EX4.15/Ex4_15.R | 9 ++ .../CH4/EX4.3/Ex4_3.R | 13 ++ .../CH4/EX4.4/Ex4_4.R | 6 + .../CH4/EX4.5/Ex4_5.R | 5 + .../CH4/EX4.8/Ex4_8.R | 11 ++ .../CH5/EX5.1/Ex5_1.R | 4 + .../CH5/EX5.2/Ex5_2.R | 9 ++ .../CH5/EX5.3/Ex5_3.R | 14 ++ .../CH5/EX5.4.a/Ex5_4_a.R | 12 ++ .../CH5/EX5.4.b/Ex5_4_b.R | 9 ++ .../CH5/EX5.5/Ex5_5.R | 9 ++ .../CH7/EX7.1/7_1.R | 6 + .../CH7/EX7.2/7_2.R | 6 + .../CH7/EX7.3/7_3.R | 9 ++ .../CH7/EX7.4/7_4.R | 8 ++ .../CH8/EX8.1/8_1.R | 12 ++ .../CH8/EX8.2/8_2.R | 12 ++ .../CH8/EX8.3/8_3.R | 18 +++ .../CH8/EX8.4/Ex8_4.R | 11 ++ .../CH9/EX9.6/Ex9_6.R | 12 ++ .../CH10/EX10.1/Ex10_1.R | 31 +++++ .../CH10/EX10.2/10_2.R | 15 +++ .../CH10/EX10.3/Ex10_3.R | 20 +++ .../CH10/EX10.4/Ex10_4.R | 25 ++++ .../CH10/EX10.5/10_5.R | 35 +++++ .../CH10/EX10.6/10_6.R | 22 ++++ .../CH10/EX10.7/Ex10_7.R | 19 +++ .../CH11/EX11.1/Ex11_1.R | 23 ++++ .../CH11/EX11.2/Ex11_2.R | 34 +++++ .../CH11/EX11.3/Ex11_3.R | 34 +++++ .../CH11/EX11.4/Ex11_4.R | 38 ++++++ .../CH12/EX12.1/Ex12_1.R | 17 +++ .../CH12/EX12.2/12_2.R | 39 ++++++ .../CH12/EX12.3/12_3.R | 49 +++++++ .../CH12/EX12.4/12_4.R | 55 ++++++++ .../CH12/EX12.5/Ex12_5.R | 22 ++++ .../CH12/EX12.6/Ex12_6.R | 19 +++ .../CH12/EX12.7/Ex12_7.R | 20 +++ .../CH13/EX13.1/Ex13_1.R | 22 ++++ .../CH13/EX13.2/Ex13_2.R | 19 +++ .../CH14/EX14.1/Ex14_1.R | 27 ++++ .../CH15/EX15.1.a/15_1_a.R | 34 +++++ .../CH15/EX15.1.b/15_1_b.R | 51 ++++++++ .../CH15/EX15.2/Ex15_2.R | 29 +++++ .../CH15/EX15.3/Ex15_3.R | 46 +++++++ .../CH15/EX15.4/Ex15_4.R | 16 +++ .../CH15/EX15.5/Ex15_5.R | 52 ++++++++ .../CH16/EX16.1/Ex16_1.R | 25 ++++ .../CH16/EX16.2/Ex16_2.R | 32 +++++ .../CH16/EX16.3/Ex16_3.R | 20 +++ .../CH16/EX16.4/Ex16_4.R | 21 +++ .../CH17/EX17.1/Ex17_1.R | 24 ++++ .../CH17/EX17.2/Ex17_2.R | 28 ++++ .../CH17/EX17.3/Ex17_3.R | 40 ++++++ .../CH17/EX17.4/Ex17_4.R | 29 +++++ .../CH17/EX17.5/Ex17_5.R | 15 +++ .../CH17/EX17.6/Ex17_6.R | 26 ++++ .../CH2/EX2.1.a/Ex2_1a.R | 28 ++++ .../CH2/EX2.1.b/Ex2_1b.R | 34 +++++ .../CH2/EX2.1.c/Ex2_1c.R | 43 ++++++ .../CH2/EX2.2/2_2.R | 8 ++ .../CH2/EX2.3.a/2_3_a.R | 21 +++ .../CH2/EX2.3.b/2_3_b.R | 24 ++++ .../CH2/EX2.4/2_4.R | 15 +++ .../CH3/EX3.1.a/3_1_a.R | 19 +++ .../CH3/EX3.1.b/Ex3_1b.R | 13 ++ .../CH3/EX3.1.c/Ex3_1c.R | 13 ++ .../CH3/EX3.2/Ex3_2.R | 10 ++ .../CH3/EX3.3/Ex3_3.R | 31 +++++ .../CH3/EX3.5/3_5.R | 32 +++++ .../CH3/EX3.6.a/3_6_a.R | 15 +++ .../CH3/EX3.6.b/Ex3_6b.R | 20 +++ .../CH3/EX3.7/Ex3_7.R | 52 ++++++++ .../CH4/EX4.1/4_1.R | 28 ++++ .../CH4/EX4.11/4_11.R | 17 +++ .../CH4/EX4.12/4_12.R | 20 +++ .../CH4/EX4.3/4_3.R | 32 +++++ .../CH4/EX4.5/4_5.R | 19 +++ .../CH4/EX4.6/Ex4_6.R | 25 ++++ .../CH4/EX4.8/4_8.R | 23 ++++ .../CH4/EX4.9/4_9.R | 26 ++++ .../CH5/EX5.1/5_1.R | 41 ++++++ .../CH5/EX5.10/Ex5_10.R | 19 +++ .../CH5/EX5.11/Ex5_11.R | 14 ++ .../CH5/EX5.2/5_2.R | 16 +++ .../CH5/EX5.3/Ex5_3.R | 11 ++ .../CH5/EX5.5/Ex5_5.R | 14 ++ .../CH5/EX5.6/Ex5_6.R | 19 +++ .../CH5/EX5.7/5_7.R | 41 ++++++ .../CH5/EX5.8/Ex5_8.R | 13 ++ .../CH5/EX5.9/Ex5_9.R | 12 ++ .../CH6/EX6.1/6_1.R | 21 +++ .../CH6/EX6.10/Ex6_10.R | 27 ++++ .../CH6/EX6.11/6_11.R | 16 +++ .../CH6/EX6.2/Ex6_2.R | 17 +++ .../CH6/EX6.3/Ex6_3.R | 8 ++ .../CH6/EX6.4/Ex6_4.R | 18 +++ .../CH6/EX6.5/Ex6_5.R | 14 ++ .../CH6/EX6.6/Ex6_6.R | 14 ++ .../CH6/EX6.7/Ex6_7.R | 10 ++ .../CH6/EX6.8/Ex6_8.R | 11 ++ .../CH6/EX6.9/6_9.R | 37 ++++++ .../CH7/EX7.1/Ex7_1.R | 22 ++++ .../CH7/EX7.2/Ex7_2.R | 12 ++ .../CH7/EX7.3/Ex7_3.R | 12 ++ .../CH8/EX8.1/Ex8_1.R | 13 ++ .../CH8/EX8.2/8_2.R | 14 ++ .../CH8/EX8.3/Ex8_3.R | 14 ++ .../CH8/EX8.4/8_4.R | 15 +++ .../CH8/EX8.5/Ex8_5.R | 15 +++ .../CH8/EX8.6/Ex8_6.R | 19 +++ .../CH8/EX8.7/8_7.R | 9 ++ .../CH8/EX8.8/8_8.R | 10 ++ .../CH9/EX9.1/Ex9_1.R | 20 +++ .../CH9/EX9.2/Ex9_2.R | 19 +++ .../CH9/EX9.3/Ex9_3.R | 20 +++ .../CH9/EX9.4/Ex9_4.R | 29 +++++ .../CH9/EX9.5/9-5.R | 11 ++ .../CH9/EX9.6/Ex9_6.R | 26 ++++ .../README.txt | 18 +++ .../CH8/EX1.1/Ex8_1.R | 9 ++ Chemical_Simulation_by_Prof_Kannan/README.txt | 18 +++ .../CH10/EX10.1/Ex10_1.R | 11 ++ .../CH10/EX10.2/Ex10_2.R | 53 ++++++++ .../CH10/EX10.3/Ex10_3.R | 21 +++ .../CH10/EX10.4/Ex10_4.R | 16 +++ .../CH10/EX10.7/Ex10_7.R | 19 +++ .../CH10/EX10.8/Ex10_8.R | 23 ++++ .../CH11/EX11.14/Ex11_14.R | 24 ++++ .../CH11/EX11.16/Ex11_16.R | 26 ++++ .../CH11/EX11.19/Ex11_19.R | 21 +++ .../CH11/EX11.21/Ex11_21.R | 26 ++++ .../CH11/EX11.23/Ex11_23.R | 22 ++++ .../CH11/EX11.3/Ex11_3.zip | Bin 0 -> 602 bytes .../CH11/EX11.5/Ex11_5.R | 7 + .../CH11/EX11.7/Ex11_7.R | 31 +++++ .../CH12/EX12.1/Ex12_1.R | 7 + .../CH12/EX12.10/Ex12_10.R | 7 + .../CH12/EX12.12/Ex12_12.R | 7 + .../CH12/EX12.13/Ex12_13.R | 7 + .../CH12/EX12.14/Ex12_14.R | 10 ++ .../CH12/EX12.15/Ex12_15.R | 17 +++ .../CH12/EX12.16/Ex12_16.R | 18 +++ .../CH12/EX12.18/Ex12_18.R | 10 ++ .../CH12/EX12.20/Ex12_20.R | 8 ++ .../CH12/EX12.24/Ex12_24.R | 7 + .../CH12/EX12.25/Ex12_25.R | 13 ++ .../CH12/EX12.7/Ex12_7.R | 14 ++ .../CH12/EX12.8/Ex12_8.R | 4 + .../CH12/EX12.9/Ex12_9.R | 8 ++ .../CH2/EX2.10/Ex2_10.R | 9 ++ .../CH2/EX2.11/Ex2_11.R | 5 + .../CH2/EX2.12/Ex2_12.R | 10 ++ .../CH2/EX2.13/Ex2_13.R | 6 + .../CH2/EX2.15/Ex2_15.R | 4 + .../CH2/EX2.18/Ex2_18.R | 22 ++++ .../CH2/EX2.19/Ex2_19.R | 16 +++ .../CH2/EX2.20/Ex2_20.R | 13 ++ .../CH2/EX2.21/Ex2_21.R | 43 ++++++ .../CH2/EX2.23/Ex2_23.R | 23 ++++ .../CH2/EX2.6.1/Ex2_6.R | 5 + .../CH2/EX2.7/Ex2_7.R | 3 + .../CH2/EX2.8/Ex2_8.R | 9 ++ .../CH2/EX2.9/Ex2_9.R | 13 ++ .../CH3/EX3.1/Ex3_1.R | 8 ++ .../CH3/EX3.2/Ex3_2.R | 28 ++++ .../CH3/EX3.3/Ex3_3.R | 4 + .../CH3/EX3.4/Ex3_4.R | 9 ++ .../CH3/EX3.5/Ex3_5.R | 9 ++ .../CH3/EX3.6/Ex3_6.R | 20 +++ .../CH4/EX4.10/Ex4_10.zip | Bin 0 -> 1164 bytes .../CH4/EX4.11/Ex4_11.zip | Bin 0 -> 1220 bytes .../CH4/EX4.13/Ex4_13.zip | Bin 0 -> 831 bytes .../CH4/EX4.3/Ex4_3.R | 43 ++++++ .../CH4/EX4.4/Ex4_4.R | 100 ++++++++++++++ .../CH4/EX4.6/Ex4_6.R | 49 +++++++ .../CH4/EX4.8/Ex4_8.R | 10 ++ .../CH4/EX4.9/Ex4_9.R | 49 +++++++ .../CH5/EX5.10/EX5_10.R | 134 +++++++++++++++++++ .../CH5/EX5.11/EX5_11.R | 2 + .../CH5/EX5.14/Ex5_14.zip | Bin 0 -> 769 bytes .../CH5/EX5.15/Ex5_15.zip | Bin 0 -> 747 bytes .../CH5/EX5.16/Ex5_16.zip | Bin 0 -> 806 bytes .../CH5/EX5.9/EX5_9.R | 137 +++++++++++++++++++ .../CH6/EX6.2/Ex6_2.zip | Bin 0 -> 675 bytes .../CH6/EX6.3/Ex6_3.zip | Bin 0 -> 647 bytes .../CH6/EX6.4/Ex6_4.zip | Bin 0 -> 665 bytes .../CH6/EX6.8/Ex6_8.zip | Bin 0 -> 686 bytes .../CH6/EX6.9/EX6_9.R | 13 ++ .../CH7/EX7.1/EX7_1.R | 12 ++ .../CH7/EX7.12/EX7_12.R | 20 +++ .../CH7/EX7.13/EX7_13.R | 26 ++++ .../CH7/EX7.15/EX7_15.R | 28 ++++ .../CH7/EX7.2/EX7_2.R | 14 ++ .../CH7/EX7.3/EX7_3.R | 16 +++ .../CH7/EX7.6/EX7_6.R | 18 +++ .../CH8/EX8.1/Ex8_1.zip | Bin 0 -> 815 bytes .../CH8/EX8.10/Ex8_10.R | 20 +++ .../CH8/EX8.11/Ex8_11.R | 15 +++ .../CH8/EX8.2/Ex8_2.zip | Bin 0 -> 790 bytes .../CH8/EX8.3/Ex8_3.zip | Bin 0 -> 828 bytes .../CH8/EX8.4/Ex8_4.zip | Bin 0 -> 988 bytes .../CH8/EX8.6/Ex8_6.zip | Bin 0 -> 851 bytes .../CH8/EX8.7/Ex8_7.zip | Bin 0 -> 783 bytes .../CH8/EX8.8/Ex8_8.zip | Bin 0 -> 796 bytes .../CH8/EX8.9/Ex8_9.R | 19 +++ .../CH9/EX9.1/Ex9_1.R | 25 ++++ .../CH9/EX9.3/Ex9_3.R | 30 +++++ .../README.txt | 18 +++ .../CH10/EX10.1/ex10_1.R.zip | Bin 0 -> 280 bytes .../CH10/EX10.10/ex10_10.R.zip | Bin 0 -> 305 bytes .../CH10/EX10.12/ex10_12.R | 5 + .../CH10/EX10.13/ex10_13.R.zip | Bin 0 -> 304 bytes .../CH10/EX10.14/ex10_14.R | 5 + .../CH10/EX10.15/ex10_15.R | 7 + .../CH10/EX10.16/ex10_16.R | 7 + .../CH10/EX10.17/ex10_17.R | 7 + .../CH10/EX10.2/ex10_2.R.zip | Bin 0 -> 305 bytes .../CH10/EX10.3/ex10_3.R.zip | Bin 0 -> 305 bytes .../CH10/EX10.4/ex10_4.R.zip | Bin 0 -> 270 bytes .../CH10/EX10.5/ex10_5.R.zip | Bin 0 -> 262 bytes .../CH10/EX10.6/ex10_6.R.zip | Bin 0 -> 267 bytes .../CH10/EX10.7/ex10_7.R.zip | Bin 0 -> 247 bytes .../CH10/EX10.8/ex10_8.R.zip | Bin 0 -> 260 bytes .../CH10/EX10.9/ex10_9.R.zip | Bin 0 -> 307 bytes .../CH11/EX11.1/ex11_1.R | 2 + .../CH11/EX11.2/ex11_2.R.zip | Bin 0 -> 317 bytes .../CH11/EX11.3/ex11_3.R.zip | Bin 0 -> 313 bytes .../CH11/EX11.4/ex11_4.R.zip | Bin 0 -> 530 bytes .../CH11/EX11.5/ex11_5.R | 7 + .../CH11/EX11.6/ex11_6.R | 7 + .../CH11/EX11.7/ex11_7.R | 7 + .../CH12/EX12.1/ex12_1.R | 6 + .../CH12/EX12.2/ex12_2.R | 5 + .../CH12/EX12.3/ex12_3.R | 10 ++ .../CH12/EX12.4/ex12_4.R | 9 ++ .../CH12/EX12.5/ex12_5.R | 7 + .../CH13/EX13.1/ex13_1.R | 4 + .../CH13/EX13.10/ex13_10.R | 5 + .../CH13/EX13.2/ex13_2.R.zip | Bin 0 -> 280 bytes .../CH13/EX13.3/ex13_3.R | 4 + .../CH13/EX13.4/ex13_4.R.zip | Bin 0 -> 244 bytes .../CH13/EX13.5/ex13_5.R.zip | Bin 0 -> 233 bytes .../CH13/EX13.6/ex13_6.R | 4 + .../CH13/EX13.7/ex13_7.R.zip | Bin 0 -> 247 bytes .../CH2/EX2.1/ex2_1.R | 4 + .../CH2/EX2.10/ex2_10.R | 4 + .../CH2/EX2.11/ex2_11.R | 7 + .../CH2/EX2.12/ex2_12.zip | Bin 0 -> 299 bytes .../CH2/EX2.13/ex2_13.zip | Bin 0 -> 232 bytes .../CH2/EX2.14/ex2_14.zip | Bin 0 -> 239 bytes .../CH2/EX2.15/ex2_15.zip | Bin 0 -> 326 bytes .../CH2/EX2.2/ex2_2.R | 13 ++ .../CH2/EX2.3/ex2_3.R | 19 +++ .../CH2/EX2.4/ex2_4.R | 7 + .../CH2/EX2.5/ex2_5.R | 8 ++ .../CH2/EX2.6/ex2_6.R | 10 ++ .../CH2/EX2.7/ex2_7.R | 14 ++ .../CH2/EX2.8/ex2_8.R | 4 + .../CH2/EX2.9/ex2_9.R | 5 + .../CH3/EX3.1/ex3_1.zip | Bin 0 -> 213 bytes .../CH3/EX3.10/ex3_10.zip | Bin 0 -> 323 bytes .../CH3/EX3.11/ex3_11.zip | Bin 0 -> 285 bytes .../CH3/EX3.12/ex3_12.zip | Bin 0 -> 297 bytes .../CH3/EX3.13/ex3_13.zip | Bin 0 -> 325 bytes .../CH3/EX3.14/ex3_14.zip | Bin 0 -> 333 bytes .../CH3/EX3.15/ex3_15.zip | Bin 0 -> 260 bytes .../CH3/EX3.16/ex3_16.zip | Bin 0 -> 273 bytes .../CH3/EX3.17/ex3_17.zip | Bin 0 -> 256 bytes .../CH3/EX3.18/ex3_18.zip | Bin 0 -> 270 bytes .../CH3/EX3.19/ex3_19.zip | Bin 0 -> 285 bytes .../CH3/EX3.2/ex3_2.zip | Bin 0 -> 220 bytes .../CH3/EX3.20/ex3_20.zip | Bin 0 -> 251 bytes .../CH3/EX3.21/ex3_21.zip | Bin 0 -> 295 bytes .../CH3/EX3.22/ex3_22.zip | Bin 0 -> 295 bytes .../CH3/EX3.23/ex3_23.zip | Bin 0 -> 269 bytes .../CH3/EX3.24/ex3_24.zip | Bin 0 -> 342 bytes .../CH3/EX3.25/ex3_25.zip | Bin 0 -> 339 bytes .../CH3/EX3.26/ex3_26.zip | Bin 0 -> 343 bytes .../CH3/EX3.27/ex3_27.zip | Bin 0 -> 263 bytes .../CH3/EX3.28/ex3_28.zip | Bin 0 -> 260 bytes .../CH3/EX3.29/ex3_29.zip | Bin 0 -> 332 bytes .../CH3/EX3.3/ex3_3.zip | Bin 0 -> 257 bytes .../CH3/EX3.30/ex3_30.zip | Bin 0 -> 322 bytes .../CH3/EX3.31/ex3_31.zip | Bin 0 -> 264 bytes .../CH3/EX3.32/ex3_32.zip | Bin 0 -> 310 bytes .../CH3/EX3.33/ex3_33.zip | Bin 0 -> 272 bytes .../CH3/EX3.34/ex3_34.zip | Bin 0 -> 279 bytes .../CH3/EX3.35/ex3_35.zip | Bin 0 -> 279 bytes .../CH3/EX3.36/ex3_36.zip | Bin 0 -> 255 bytes .../CH3/EX3.37/ex3_37.zip | Bin 0 -> 309 bytes .../CH3/EX3.38/ex3_38.zip | Bin 0 -> 233 bytes .../CH3/EX3.39/ex3_39.zip | Bin 0 -> 291 bytes .../CH3/EX3.4/ex3_4.zip | Bin 0 -> 207 bytes .../CH3/EX3.5/ex3_5.zip | Bin 0 -> 209 bytes .../CH3/EX3.6/ex3_6.zip | Bin 0 -> 210 bytes .../CH3/EX3.7/ex3_7.zip | Bin 0 -> 207 bytes .../CH3/EX3.8/ex3_8.zip | Bin 0 -> 185 bytes .../CH3/EX3.9/ex3_9.zip | Bin 0 -> 281 bytes .../CH4/EX4.11/ex4_11.zip | Bin 0 -> 246 bytes .../CH4/EX4.12/ex4_12.zip | Bin 0 -> 277 bytes .../CH4/EX4.13/ex4_13.zip | Bin 0 -> 253 bytes .../CH4/EX4.14/ex4_14.zip | Bin 0 -> 292 bytes .../CH4/EX4.17/ex4_17.R | 4 + .../CH4/EX4.18/ex4_18.zip | Bin 0 -> 236 bytes .../CH4/EX4.19/ex4_19.zip | Bin 0 -> 224 bytes .../CH4/EX4.20/ex4_20.zip | Bin 0 -> 259 bytes .../CH4/EX4.21/ex4_21.R | 8 ++ .../CH4/EX4.22/ex4_22.R | 6 + .../CH4/EX4.23/ex4_23.zip | Bin 0 -> 245 bytes .../CH4/EX4.24/ex4_24.zip | Bin 0 -> 239 bytes .../CH4/EX4.25/ex4_25.zip | Bin 0 -> 241 bytes .../CH4/EX4.26/ex4_26.zip | Bin 0 -> 203 bytes .../CH4/EX4.27/ex4_27.R | 4 + .../CH4/EX4.28/ex4_28.R | 8 ++ .../CH4/EX4.29/ex4_29.R | 4 + .../CH4/EX4.30/ex4_30.R | 8 ++ .../CH4/EX4.42/ex4_42.R | 2 + .../CH4/EX4.43/ex4_43.R | 4 + .../CH4/EX4.44/ex4_44.R | 4 + .../CH4/EX4.45/ex4_45.R | 4 + .../CH4/EX4.47/ex4_47.R | 4 + .../CH4/EX4.48/ex4_48.R | 4 + .../CH4/EX4.49/ex4_49.R | 6 + .../CH4/EX4.5/ex4_5.zip | Bin 0 -> 290 bytes .../CH4/EX4.50/ex4_50.R | 6 + .../CH4/EX4.51.a/ex4_51a.R | 8 ++ .../CH4/EX4.51.b/ex4_51b.R | 6 + .../CH4/EX4.51.c/ex4_51c.R | 4 + .../CH4/EX4.51.d/ex4_51d.R | 6 + .../CH4/EX4.52/ex4_52.R | 8 ++ .../CH4/EX4.6/ex4_6.zip | Bin 0 -> 293 bytes .../CH4/EX4.7/ex4_7.zip | Bin 0 -> 287 bytes .../CH4/EX4.8/ex4_8.zip | Bin 0 -> 305 bytes .../CH4/EX4.9/ex4_9.zip | Bin 0 -> 261 bytes .../CH5/EX5.1/ex5_1.zip | Bin 0 -> 220 bytes .../CH5/EX5.10/ex5_10.R | 7 + .../CH5/EX5.11/ex5_11.R | 12 ++ .../CH5/EX5.12/ex5_12.R | 5 + .../CH5/EX5.13/ex5_13.R | 5 + .../CH5/EX5.14/ex5_14.R | 15 +++ .../CH5/EX5.15/ex5_15.R.zip | Bin 0 -> 243 bytes .../CH5/EX5.16/ex5_16.R | 5 + .../CH5/EX5.17/ex5_17.R | 5 + .../CH5/EX5.19.a/ex5_19a.R | 1 + .../CH5/EX5.19.b/ex5_19b.R | 1 + .../CH5/EX5.19.c/ex5_19c.R | 1 + .../CH5/EX5.2/ex5_2.R | 5 + .../CH5/EX5.20/ex5_20.R | 1 + .../CH5/EX5.21/ex5_21.R.zip | Bin 0 -> 252 bytes .../CH5/EX5.22/ex5_22.R.zip | Bin 0 -> 270 bytes .../CH5/EX5.23/ex5_23.R.zip | Bin 0 -> 270 bytes .../CH5/EX5.24/ex5_24.R | 10 ++ .../CH5/EX5.25/ex5_25.R | 10 ++ .../CH5/EX5.26/ex5_26.R | 11 ++ .../CH5/EX5.27/ex5_27.R | 7 + .../CH5/EX5.28.a/ex5_28a.R | 4 + .../CH5/EX5.28.b/ex5_28b.R | 4 + .../CH5/EX5.28.c/ex5_28c.R | 4 + .../CH5/EX5.29/ex5_29.R | 7 + .../CH5/EX5.30/ex5_30.zip | Bin 0 -> 220 bytes .../CH5/EX5.31/ex5_31.zip | Bin 0 -> 255 bytes .../CH5/EX5.32/ex5_32.zip | Bin 0 -> 253 bytes .../CH5/EX5.5/ex5_5.R | 5 + .../CH5/EX5.6/ex5_6.R | 5 + .../CH5/EX5.7/ex5_7.R | 3 + .../CH5/EX5.8/ex5_8.R | 5 + .../CH5/EX5.9/ex5_9.R | 7 + .../CH6/EX6.1/ex6_1.R.zip | Bin 0 -> 323 bytes .../CH6/EX6.10/ex6_10.R.zip | Bin 0 -> 292 bytes .../CH6/EX6.11/ex6_11.R | 12 ++ .../CH6/EX6.12/ex6_12.R | 12 ++ .../CH6/EX6.13/ex6_13.R.zip | Bin 0 -> 306 bytes .../CH6/EX6.14/ex6_14.R.zip | Bin 0 -> 324 bytes .../CH6/EX6.15/ex6_15.R | 10 ++ .../CH6/EX6.16/ex6_16.R.zip | Bin 0 -> 331 bytes .../CH6/EX6.17/ex6_17.R.zip | Bin 0 -> 334 bytes .../CH6/EX6.18/ex6_18.R.zip | Bin 0 -> 332 bytes .../CH6/EX6.19/ex6_19.R.zip | Bin 0 -> 338 bytes .../CH6/EX6.2/ex6_2.R.zip | Bin 0 -> 322 bytes .../CH6/EX6.3/ex6_3.R.zip | Bin 0 -> 336 bytes .../CH6/EX6.4.a/ex6_4a.R.zip | Bin 0 -> 318 bytes .../CH6/EX6.4.b/ex6_4b.R.zip | Bin 0 -> 317 bytes .../CH6/EX6.4.c/ex6_4c.R.zip | Bin 0 -> 317 bytes .../CH6/EX6.6/ex6_6.R.zip | Bin 0 -> 290 bytes .../CH6/EX6.7/ex6_7.R | 12 ++ .../CH6/EX6.8/ex6_8.R.zip | Bin 0 -> 284 bytes .../CH7/EX7.1/ex7_1.R | 8 ++ .../CH7/EX7.10/ex7_10.R | 8 ++ .../CH7/EX7.11/ex7_11.R | 7 + .../CH7/EX7.12/ex7_12.R | 10 ++ .../CH7/EX7.13/ex7_13.R.zip | Bin 0 -> 191 bytes .../CH7/EX7.14/ex7_14.R | 10 ++ .../CH7/EX7.15/ex7_15.R | 11 ++ .../CH7/EX7.2/ex7_2.R | 7 + .../CH7/EX7.3/ex7_3.R | 10 ++ .../CH7/EX7.4/ex7_4.R | 9 ++ .../CH7/EX7.5/ex7_5.R | 1 + .../CH7/EX7.6/ex7_6.R | 9 ++ .../CH7/EX7.7/ex7_7.R | 8 ++ .../CH7/EX7.8/ex7_8.R.zip | Bin 0 -> 223 bytes .../CH7/EX7.9/ex7_9.R | 9 ++ .../CH8/EX8.10/ex8_10.R.zip | Bin 0 -> 238 bytes .../CH8/EX8.11/ex8_11.R.zip | Bin 0 -> 231 bytes .../CH8/EX8.12/ex8_12.R.zip | Bin 0 -> 310 bytes .../CH8/EX8.13/ex8_13.R | 2 + .../CH8/EX8.14/ex8_14.R.zip | Bin 0 -> 234 bytes .../CH8/EX8.15/ex8_15.R.zip | Bin 0 -> 235 bytes .../CH8/EX8.16/ex8_16.R.zip | Bin 0 -> 316 bytes .../CH8/EX8.17/ex8_17.R | 11 ++ .../CH8/EX8.18/ex8_18.R | 10 ++ .../CH8/EX8.19/ex8_19.R.zip | Bin 0 -> 297 bytes .../CH8/EX8.2.a/ex8_2a.R.zip | Bin 0 -> 279 bytes .../CH8/EX8.2.b/ex8_2b.R.zip | Bin 0 -> 289 bytes .../CH8/EX8.2.c/ex8_2c.R.zip | Bin 0 -> 278 bytes .../CH8/EX8.20/ex8_20.R.zip | Bin 0 -> 295 bytes .../CH8/EX8.21/ex8_21.R.zip | Bin 0 -> 226 bytes .../CH8/EX8.22/ex8_22.R.zip | Bin 0 -> 226 bytes .../CH8/EX8.23/ex8_23.R | 2 + .../CH8/EX8.24/ex8_24.R.zip | Bin 0 -> 347 bytes .../CH8/EX8.25/ex8_25.R | 5 + .../CH8/EX8.26/ex8_26.R.zip | Bin 0 -> 277 bytes .../CH8/EX8.27/ex8_27.R.zip | Bin 0 -> 239 bytes .../CH8/EX8.28/ex8_28.R.zip | Bin 0 -> 220 bytes .../CH8/EX8.29/ex8_29.R.zip | Bin 0 -> 268 bytes .../CH8/EX8.3/ex8_3.R | 19 +++ .../CH8/EX8.30/ex8_30.R | 15 +++ .../CH8/EX8.31/ex8_31.R | 16 +++ .../CH8/EX8.4/ex8_4.R | 2 + .../CH8/EX8.5/ex8_5.R | 19 +++ .../CH8/EX8.6/ex8_6.R.zip | Bin 0 -> 300 bytes .../CH8/EX8.7/ex8_7.R.zip | Bin 0 -> 298 bytes .../CH8/EX8.8/ex8_8.R.zip | Bin 0 -> 229 bytes .../CH8/EX8.9/ex8_9.R.zip | Bin 0 -> 224 bytes .../CH9/EX9.1/ex9_1.R | 11 ++ .../CH9/EX9.10/ex9_10.R | 15 +++ .../CH9/EX9.11/ex9_11.R | 19 +++ .../CH9/EX9.12/ex9_12.R.zip | Bin 0 -> 225 bytes .../CH9/EX9.13/ex9_13.R.zip | Bin 0 -> 249 bytes .../CH9/EX9.14/ex9_14.R.zip | Bin 0 -> 365 bytes .../CH9/EX9.15/ex9_15.R.zip | Bin 0 -> 392 bytes .../CH9/EX9.16/ex9_16.R.zip | Bin 0 -> 425 bytes .../CH9/EX9.2/ex9_2.R.zip | Bin 0 -> 437 bytes .../CH9/EX9.3/ex9_3.R | 16 +++ .../CH9/EX9.4/ex9_4.R | 16 +++ .../CH9/EX9.5/ex9_5.R | 17 +++ .../CH9/EX9.6/ex9_6.R | 3 + .../CH9/EX9.7/ex9_7.R | 3 + .../CH9/EX9.8/ex9_8.R | 6 + .../CH9/EX9.9/ex9_9.R | 15 +++ .../README.txt | 18 +++ .../CH10/EX10.1/EX10_1.R | 21 +++ .../CH10/EX10.14/EX10_14.R | 20 +++ .../CH10/EX10.15/EX10_15.R | 26 ++++ .../CH10/EX10.17/EX10_17.R | 13 ++ .../CH10/EX10.18/EX10_18.R | 19 +++ .../CH10/EX10.19/EX10_19.R | 15 +++ .../CH10/EX10.2/EX10_2.R | 16 +++ .../CH11/EX11.1/EX11_1.R | 26 ++++ .../CH11/EX11.2/EX11_2.R | 15 +++ .../CH11/EX11.3/EX11_3.R | 30 +++++ .../CH11/EX11.6/EX11_6.R | 17 +++ .../CH11/EX11.7/EX11_7.R | 18 +++ .../CH12/EX12.7/EX12_7.R | 12 ++ .../CH12/EX12.8/EX12_8.R | 41 ++++++ .../CH12/EX12.9/EX12_9.R | 21 +++ .../CH13/EX13.11/EX13_11.R | 23 ++++ .../CH13/EX13.12/EX13_12.R | 28 ++++ .../CH13/EX13.14/EX13_14.R | 27 ++++ .../CH13/EX13.15/EX13_15.R | 26 ++++ .../CH13/EX13.2/EX13_2.R | 16 +++ .../CH14/EX14.1/EX14_1.R | 19 +++ .../CH14/EX14.10/EX14_10.R | 17 +++ .../CH14/EX14.15/EX14_15.R | 16 +++ .../CH14/EX14.18/EX14_18.R | 21 +++ .../CH14/EX14.2/EX14_2.R | 13 ++ .../CH14/EX14.26/EX14_26.R | 15 +++ .../CH14/EX14.28/EX14_28.R | 21 +++ .../CH14/EX14.30/EX14_30.R | 23 ++++ .../CH14/EX14.4/EX14_4.R | 17 +++ .../CH14/EX14.6/EX14_6.R | 8 ++ .../CH14/EX14.7/EX14_7.R | 16 +++ .../CH15/EX15.12/EX15_12.R | 17 +++ .../CH15/EX15.14/EX15_14.R | 23 ++++ .../CH15/EX15.15/EX15_15.R | 16 +++ .../CH15/EX15.18/EX15_18.R | 16 +++ .../CH15/EX15.20/EX15_20.R | 23 ++++ .../CH15/EX15.9/EX15_9.R | 18 +++ .../CH16/EX16.10/EX16_10.R | 35 +++++ .../CH16/EX16.12/EX16_12.R | 43 ++++++ .../CH16/EX16.15/EX16_15.R | 63 +++++++++ .../CH16/EX16.18/EX16_18.R | 25 ++++ .../CH16/EX16.26/EX16_26.R | 14 ++ .../CH16/EX16.27/EX16_27.R | 26 ++++ .../CH16/EX16.6/EX16_6.R | 14 ++ .../CH16/EX16.7/EX16_7.R | 23 ++++ .../CH2/EX2.1/EX2_1.R | 23 ++++ .../CH2/EX2.12/EX2_12.R | 12 ++ .../CH2/EX2.15/EX2_15.R | 14 ++ .../CH2/EX2.17/EX2_17.R | 18 +++ .../CH2/EX2.18/EX2_18.R | 32 +++++ .../CH2/EX2.19/EX2_19.R | 13 ++ .../CH2/EX2.2/EX2_2.R | 14 ++ .../CH2/EX2.20/EX2_20.R | 24 ++++ .../CH2/EX2.21/EX2_21.R | 28 ++++ .../CH2/EX2.23/EX2_23.R | 28 ++++ .../CH2/EX2.24/EX2_24.R | 33 +++++ .../CH2/EX2.26/EX2_26.R | 17 +++ .../CH2/EX2.27/EX2_27.R | 19 +++ .../CH2/EX2.28/EX2_28.R | 37 ++++++ .../CH2/EX2.29/EX2_29.R | 17 +++ .../CH2/EX2.3/EX2_3.R | 17 +++ .../CH2/EX2.34/EX2_34.R | 45 +++++++ .../CH2/EX2.35/EX2_35.R | 30 +++++ .../CH2/EX2.36/EX2_36.R | 29 +++++ .../CH2/EX2.4/EX2_4.R | 44 +++++++ .../CH2/EX2.40/EX2_40.R | 36 +++++ .../CH2/EX2.42/EX2_42.R | 19 +++ .../CH2/EX2.43/EX2_43.R | 53 ++++++++ .../CH2/EX2.6/EX2_6.R | 10 ++ .../CH2/EX2.7/EX2_7.R | 15 +++ .../CH2/EX2.8/EX2_8.R | 14 ++ .../CH2/EX2.9/EX2_9.R | 24 ++++ .../CH20/EX20.1/EX20_1.R | 16 +++ .../CH20/EX20.2/EX20_2.R | 21 +++ .../CH3/EX3.2/EX3_2.R | 39 ++++++ .../CH3/EX3.24/EX3_24.R | 25 ++++ .../CH3/EX3.29/EX3_29.R | 13 ++ .../CH3/EX3.3/EX3_3.R | 32 +++++ .../CH3/EX3.30/EX3_30.R | 26 ++++ .../CH3/EX3.37/EX3_37.R | 31 +++++ .../CH3/EX3.4/EX3_4.R | 53 ++++++++ .../CH4/EX4.1/EX4_1.R | 32 +++++ .../CH4/EX4.10/EX4_10.R | 25 ++++ .../CH4/EX4.16/EX4_16.R | 32 +++++ .../CH4/EX4.18/EX4_18.R | 28 ++++ .../CH4/EX4.2/EX4_2.R | 23 ++++ .../CH4/EX4.20/EX4_20.R | 18 +++ .../CH4/EX4.3/EX-4_3.R | 24 ++++ .../CH4/EX4.4/EX4_4.R | 24 ++++ .../CH4/EX4.9/EX4_9.R | 22 ++++ .../CH5/EX5.1/EX5_1.R | 61 +++++++++ .../CH5/EX5.12/EX5_12.R | 74 +++++++++++ .../CH5/EX5.13/EX5_13.R | 33 +++++ .../CH5/EX5.19/EX5_19.R | 32 +++++ .../CH5/EX5.2/EX5_2.R | 22 ++++ .../CH5/EX5.22/EX5_22.R | 23 ++++ .../CH5/EX5.24/EX5_24.R | 38 ++++++ .../CH5/EX5.3/EX5_3.R | 18 +++ .../CH5/EX5.4/EX5_4.R | 58 +++++++++ .../CH5/EX5.5/EX5_5.R | 43 ++++++ .../CH6/EX6.1/EX6_1.R | 16 +++ .../CH6/EX6.2/EX6_2.R | 20 +++ .../CH6/EX6.29/EX6_29.R | 34 +++++ .../CH6/EX6.3/EX6_3.R | 19 +++ .../CH6/EX6.30/EX6_30.R | 35 +++++ .../CH6/EX6.4/EX6_4.R | 14 ++ .../CH6/EX6.5/EX6_5.R | 12 ++ .../CH7/EX7.12/EX7_12.R | 18 +++ .../CH7/EX7.13/EX7_13.R | 11 ++ .../CH7/EX7.14/EX7_14.R | 10 ++ .../CH7/EX7.17/EX7_17.R | 17 +++ .../CH7/EX7.18/EX7_18.R | 25 ++++ .../CH7/EX7.19/EX7_19.R | 17 +++ .../CH8/EX8.1/EX8_1.R | 17 +++ .../CH8/EX8.10/EX8_10.R | 30 +++++ .../CH8/EX8.12/EX8_12.R | 16 +++ .../CH8/EX8.2/EX8_2.R | 12 ++ .../CH8/EX8.21/EX8_21.R | 19 +++ .../CH8/EX8.22/EX8_22.R | 59 +++++++++ .../CH8/EX8.3/EX8_3.R | 14 ++ .../CH8/EX8.33/EX8_33.R | 11 ++ .../CH8/EX8.34/EX8_34.R | 10 ++ .../CH8/EX8.37/EX8_37.R | 8 ++ .../CH8/EX8.4/EX8_4.R | 12 ++ .../CH8/EX8.41/EX8_41.R | 8 ++ .../CH8/EX8.55/EX8_55.R | 19 +++ .../CH8/EX8.56/EX8_56.R | 16 +++ .../CH8/EX8.57/EX8_57.R | 21 +++ .../CH8/EX8.6/EX8_6.R | 25 ++++ .../CH8/EX8.63/EX8_63.R | 19 +++ .../CH8/EX8.7/EX8_7.R | 22 ++++ .../CH8/EX8.9/EX8_9.R | 12 ++ .../CH9/EX9.1/EX9_1.R | 36 +++++ .../CH9/EX9.12/EX9_12.R | 24 ++++ .../CH9/EX9.13/EX9_13.R | 21 +++ .../CH9/EX9.14/EX9_14.R | 27 ++++ .../CH9/EX9.15/EX9_15.R | 28 ++++ .../CH9/EX9.21/EX9_21.R | 31 +++++ .../CH9/EX9.22/EX9_22.R | 15 +++ .../CH9/EX9.3/EX9_3.R | 40 ++++++ .../CH9/EX9.4/EX9_4.R | 28 ++++ .../CH9/EX9.5/EX9_5.R | 25 ++++ .../CH9/EX9.7/EX9_7.R | 31 +++++ .../CH9/EX9.8/EX9_8.R | 10 ++ .../CH9/EX9.9/EX9_9.R | 25 ++++ .../README.txt | 18 +++ .../CH1/EX1.1/Ex1_1_1.zip | Bin 0 -> 440 bytes .../CH1/EX2.2/Ex1_2_2.zip | Bin 0 -> 639 bytes .../CH1/EX3.3/Ex1_3_3.zip | Bin 0 -> 578 bytes .../CH1/EX3.4/Ex1_3_4.zip | Bin 0 -> 643 bytes .../CH1/EX3.5/Ex1_3_5.zip | Bin 0 -> 466 bytes .../CH1/EX3.6/Ex1_3_6.zip | Bin 0 -> 527 bytes .../CH1/EX3.7/Ex1_3_7.zip | Bin 0 -> 537 bytes .../CH1/EX4.10/Ex1_4_10.zip | Bin 0 -> 666 bytes .../CH1/EX4.11/Ex1_4_11.zip | Bin 0 -> 563 bytes .../CH1/EX4.12/Ex1_4_12.zip | Bin 0 -> 703 bytes .../CH1/EX4.13/Ex1_4_13.zip | Bin 0 -> 657 bytes .../CH1/EX4.14/Ex1_4_14.zip | Bin 0 -> 606 bytes .../CH1/EX4.15/Ex1_4_15.zip | Bin 0 -> 602 bytes .../CH1/EX4.8/Ex1_4_8.zip | Bin 0 -> 568 bytes .../CH1/EX4.9/Ex1_4_9.zip | Bin 0 -> 679 bytes .../CH1/EX5.16/Ex1_5_16.zip | Bin 0 -> 673 bytes .../CH1/EX5.17/Ex1_5_17.zip | Bin 0 -> 656 bytes .../CH1/EX5.18/Ex1_5_18.zip | Bin 0 -> 638 bytes .../CH1/EX5.19/Ex1_5_19.zip | Bin 0 -> 635 bytes .../CH1/EX5.20/Ex1_5_20.zip | Bin 0 -> 773 bytes .../CH1/EX5.21/Ex1_5_21.zip | Bin 0 -> 810 bytes .../CH2/EX1.22/Ex2_1_22.zip | Bin 0 -> 397 bytes .../CH2/EX1.23/Ex2_1_23.zip | Bin 0 -> 371 bytes .../CH2/EX2.24/Ex2_2_24.zip | Bin 0 -> 382 bytes .../CH2/EX2.25/Ex2_2_25.zip | Bin 0 -> 333 bytes .../CH2/EX2.26/Ex2_2_26.zip | Bin 0 -> 326 bytes .../CH2/EX2.27/Ex2_2_27.zip | Bin 0 -> 375 bytes .../CH2/EX2.28/Ex2_2_28.zip | Bin 0 -> 303 bytes .../CH2/EX2.29/Ex2_2_29.zip | Bin 0 -> 396 bytes .../CH2/EX2.30/Ex2_2_30.zip | Bin 0 -> 364 bytes .../CH2/EX3.31/Ex2_3_31.zip | Bin 0 -> 407 bytes .../CH2/EX3.32/Ex2_3_32.zip | Bin 0 -> 398 bytes .../CH2/EX3.33/Ex2_3_33.zip | Bin 0 -> 408 bytes .../CH2/EX3.34/Ex2_3_34.zip | Bin 0 -> 417 bytes .../CH2/EX3.35/Ex2_3_35.zip | Bin 0 -> 447 bytes .../CH2/EX3.36/Ex2_3_36.zip | Bin 0 -> 430 bytes .../CH2/EX3.37/Ex2_3_37.zip | Bin 0 -> 398 bytes .../CH2/EX3.38/Ex2_3_38.zip | Bin 0 -> 360 bytes .../CH2/EX3.39/Ex2_3_39.zip | Bin 0 -> 348 bytes .../CH2/EX3.40/Ex2_3_40.zip | Bin 0 -> 506 bytes .../CH2/EX3.41/Ex2_3_41.zip | Bin 0 -> 527 bytes .../CH2/EX3.42/Ex2_3_42.zip | Bin 0 -> 566 bytes .../CH2/EX4.43/Ex2_4_43.zip | Bin 0 -> 433 bytes .../CH2/EX4.44/Ex2_4_44.zip | Bin 0 -> 695 bytes .../CH2/EX4.45/Ex2_4_45.zip | Bin 0 -> 714 bytes .../CH2/EX4.46/Ex2_4_46.zip | Bin 0 -> 796 bytes .../CH2/EX4.47/Ex2_4_47.zip | Bin 0 -> 822 bytes .../CH2/EX4.48/Ex2_4_48.zip | Bin 0 -> 773 bytes .../CH2/EX4.49/Ex2_4_49.zip | Bin 0 -> 448 bytes .../CH2/EX4.50/Ex2_4_50.zip | Bin 0 -> 567 bytes .../CH2/EX5.51/Ex2_5_51.zip | Bin 0 -> 439 bytes .../CH2/EX5.52/Ex2_5_52.zip | Bin 0 -> 441 bytes .../CH2/EX6.53/Ex2_6_53.zip | Bin 0 -> 448 bytes .../CH2/EX6.54/Ex2_6_54.zip | Bin 0 -> 462 bytes .../CH2/EX6.55/Ex2_6_55.zip | Bin 0 -> 475 bytes .../CH2/EX6.56/Ex2_6_56.zip | Bin 0 -> 315 bytes .../CH2/EX6.57/Ex2_6_57.zip | Bin 0 -> 365 bytes .../CH2/EX7.58/Ex2_7_58.zip | Bin 0 -> 373 bytes .../CH2/EX7.59/Ex2_7_59.zip | Bin 0 -> 469 bytes .../CH3/EX1.60/Ex3_1_60.zip | Bin 0 -> 317 bytes .../CH3/EX1.61/Ex3_1_61.zip | Bin 0 -> 382 bytes .../CH3/EX1.62/Ex3_1_62.zip | Bin 0 -> 458 bytes .../CH3/EX1.63/Ex3_1_63.zip | Bin 0 -> 298 bytes .../CH3/EX1.64/Ex3_1_64.zip | Bin 0 -> 343 bytes .../CH3/EX1.65/Ex3_1_65.zip | Bin 0 -> 270 bytes .../CH3/EX1.66/Ex3_1_66.zip | Bin 0 -> 278 bytes .../CH3/EX2.67/Ex3_2_67.zip | Bin 0 -> 445 bytes .../CH3/EX3.68/Ex3_3_68.zip | Bin 0 -> 331 bytes .../CH3/EX3.69/Ex3_3_69.zip | Bin 0 -> 486 bytes .../CH3/EX3.70/Ex3_3_70.zip | Bin 0 -> 479 bytes .../CH3/EX3.71/Ex3_3_71.zip | Bin 0 -> 412 bytes .../CH3/EX3.72/Ex3_3_72.zip | Bin 0 -> 411 bytes .../CH3/EX3.73/Ex3_3_73.zip | Bin 0 -> 444 bytes .../CH3/EX4.74/Ex3_4_74.zip | Bin 0 -> 441 bytes .../CH3/EX4.75/Ex3_4_75.zip | Bin 0 -> 323 bytes .../CH3/EX4.76/Ex3_4_76.zip | Bin 0 -> 428 bytes .../CH3/EX4.77/Ex3_4_77.zip | Bin 0 -> 399 bytes .../CH3/EX4.78/Ex3_4_78.zip | Bin 0 -> 363 bytes .../CH3/EX4.79/Ex3_4_79.zip | Bin 0 -> 380 bytes .../CH3/EX4.80/Ex3_4_80.zip | Bin 0 -> 376 bytes .../CH3/EX4.81/Ex3_4_81.zip | Bin 0 -> 291 bytes .../CH3/EX5.82/Ex3_5_82.zip | Bin 0 -> 392 bytes .../CH3/EX5.83/Ex3_5_83.zip | Bin 0 -> 374 bytes .../CH4/EX1.84/Ex4_1_84.zip | Bin 0 -> 298 bytes .../CH4/EX1.85/Ex4_1_85.zip | Bin 0 -> 610 bytes .../CH4/EX1.86/Ex4_1_86.zip | Bin 0 -> 623 bytes .../CH4/EX1.87/Ex4_1_87.zip | Bin 0 -> 621 bytes .../CH4/EX1.88/Ex4_1_88.zip | Bin 0 -> 725 bytes .../CH4/EX1.89/Ex4_1_89.zip | Bin 0 -> 734 bytes .../CH4/EX2.90/Ex4_2_90.zip | Bin 0 -> 308 bytes .../CH4/EX2.91/Ex4_2_91.zip | Bin 0 -> 491 bytes .../CH4/EX2.92/Ex4_2_92.zip | Bin 0 -> 613 bytes .../CH5/EX1.93/Ex5_1_93.zip | Bin 0 -> 499 bytes .../CH5/EX1.94/Ex5_1_94.zip | Bin 0 -> 495 bytes .../CH5/EX1.95/Ex5_1_95.zip | Bin 0 -> 546 bytes .../CH5/EX1.96/Ex5_1_96.zip | Bin 0 -> 668 bytes .../CH5/EX1.97/Ex5_1_97.zip | Bin 0 -> 760 bytes .../CH5/EX2.100/Ex5_2_100.zip | Bin 0 -> 506 bytes .../CH5/EX2.101/Ex5_2_101.zip | Bin 0 -> 669 bytes .../CH5/EX2.102/Ex5_2_102.zip | Bin 0 -> 401 bytes .../CH5/EX2.98/Ex5_2_98.zip | Bin 0 -> 424 bytes .../CH5/EX2.99/Ex5_2_99.zip | Bin 0 -> 423 bytes .../CH5/EX3.103/Ex5_3_103.zip | Bin 0 -> 500 bytes .../CH5/EX3.104/Ex5_3_104.zip | Bin 0 -> 457 bytes .../CH5/EX3.105/Ex5_3_105.zip | Bin 0 -> 497 bytes .../CH5/EX3.106/Ex5_3_106.zip | Bin 0 -> 537 bytes .../CH5/EX3.107/Ex5_3_107.zip | Bin 0 -> 531 bytes .../CH5/EX3.108/Ex5_3_108.zip | Bin 0 -> 535 bytes .../CH5/EX3.109/Ex5_3_109.zip | Bin 0 -> 543 bytes .../CH5/EX3.110/Ex5_3_110.zip | Bin 0 -> 319 bytes .../README.txt | 18 +++ .../CH1/EX1.1/Ex1_1.R | 6 + .../CH1/EX1.2.1/Ex1.2_1.R | 14 ++ .../CH1/EX1.2.2/Ex1.2_2.R | 11 ++ .../CH1/EX1.2.5/Ex1.2_5.R | 11 ++ .../CH1/EX1.2.a/Ex1_1.2A.R | 17 +++ .../CH1/EX1.2.b/Ex1_1.2B.R | 10 ++ .../CH1/EX1.2.c/Ex1_1.2C.R | 6 + .../CH1/EX1.3.a/Ex1_1.3A.R | 4 + .../CH10/EX10.1.1/Ex10.1_1.r | 13 ++ .../CH10/EX10.2.1/EX10.2_1.r | 13 ++ .../CH2/EX2.1.1/Ex2.1_1.r | 27 ++++ .../CH2/EX2.1.a/Ex2_2.1a.r | 11 ++ .../CH2/EX2.2.a/Ex2_2.2a.r | 14 ++ .../CH2/EX2.3.1/Ex2.3_1.r | 12 ++ .../CH2/EX2.3.2/Ex2.3_2.r | 9 ++ .../CH2/EX2.3.b/Ex2_2.3b.r | 18 +++ .../CH2/EX2.3.c/Ex2_2.3C.R | 18 +++ .../CH2/EX2.4.1/Ex2.4_1.R | 6 + .../CH2/EX2.4.2/Ex2.4_2.R | 6 + .../CH2/EX2.4.a/Ex2_2.4A.R | 8 ++ .../CH2/EX2.4.b/Ex2_2.4B.R | 9 ++ .../CH2/EX2.4.c/Ex2_2.4C.R | 6 + .../CH2/EX2.5.2/Ex2.5_2.r | 6 + .../CH2/EX2.5.3/Ex2.5_3.r | 14 ++ .../CH2/EX2.5.4/Ex2.5_4.r | 16 +++ .../CH2/EX2.5.5/Ex2.5_5.r | 16 +++ .../CH2/EX2.5.a/Ex2_2.5A.r | 6 + .../CH2/EX2.5.b/Ex2_2.5B.r | 12 ++ .../CH2/EX2.5.c/Ex2_2.5C.r | 16 +++ .../CH2/EX2.6.1/Ex2.6_1.r | 13 ++ .../CH2/EX2.6.2/Ex2.6_2.r | 13 ++ .../CH2/EX2.6.3/Ex2.6_3.r | 19 +++ .../CH2/EX2.6.a/Ex2_2.6A.r | 12 ++ .../CH2/EX2.6.b/Ex2_2.6B.r | 17 +++ .../CH2/EX2.7.1/Ex2.7_1.r | 12 ++ .../CH2/EX2.7.4/Ex2.7_4.r | 8 ++ .../CH2/EX2.7.a/Ex2_2.7A.r | 11 ++ .../CH2/EX2.7.b/Ex2_2.7B.r | 25 ++++ .../CH3/EX3.2.2/Ex3.2_2.r | 59 +++++++++ .../CH3/EX3.2.3/Ex3.2_3.r | 69 ++++++++++ .../CH3/EX3.2.4/Ex3.2_4.r | 60 +++++++++ .../CH3/EX3.2.a/Ex3_3.2A.r | 14 ++ .../CH3/EX3.2.b/Ex3_3.2b.r | 73 +++++++++++ .../CH3/EX3.3.a/Ex3_3.3A.r | 64 +++++++++ .../CH3/EX3.3.c/Ex3_3.3C.r | 69 ++++++++++ .../CH3/EX3.4.2/Ex3.4_2.r | 67 ++++++++++ .../CH3/EX3.4.a/Ex3_3.4A.r | 72 ++++++++++ .../CH3/EX3.4.c/Ex3_3.4C.r | 72 ++++++++++ .../CH3/EX3.5.1/Ex3.5_1.r | 16 +++ .../CH3/EX3.6.1/Ex3.6_1.r | 17 +++ .../CH3/EX3.6.2/Ex3.6_2.r | 16 +++ .../CH3/EX3.6.a/Ex3_3.6A.r | 70 ++++++++++ .../CH4/EX4.1.3/Ex4.1_3.r | 10 ++ .../CH4/EX4.1.a/Ex4_4.1A.r | 11 ++ .../CH4/EX4.1.b/Ex4_4.1B.r | 71 ++++++++++ .../CH4/EX4.2.1/Ex4.2_1.r | 23 ++++ .../CH4/EX4.2.2/Ex4.2_2.r | 17 +++ .../CH4/EX4.2.3/Ex4.2_3.r | 27 ++++ .../CH4/EX4.2.a/Ex4_4.2A.r | 32 +++++ .../CH4/EX4.2.b/Ex4_4.2B.r | 15 +++ .../CH4/EX4.3.1/Ex4.3_1.r | 27 ++++ .../CH4/EX4.3.2/Ex4.3_2.r | 27 ++++ .../CH4/EX4.3.3/Ex4.3_3.r | 29 +++++ .../CH4/EX4.3.a/Ex4_4.3A.r | 31 +++++ .../CH4/EX4.3.b/Ex4_4.3B.r | 31 +++++ .../CH4/EX4.4.4/Ex4.4_4.r | 21 +++ .../CH4/EX4.4.5/Ex4.4_5.r | 27 ++++ .../CH5/EX5.2.1/Ex5.2_1.r | 10 ++ .../CH5/EX5.2.5/Ex5.2_5.r | 6 + .../CH5/EX5.2.7/Ex5.2_7.r | 4 + .../CH5/EX5.3.1/Ex5.3_1.r | 13 ++ .../CH5/EX5.3.3/Ex5.3_3.r | 6 + .../CH5/EX5.3.7/Ex5.3_7.r | 14 ++ .../CH5/EX5.3.8/Ex5.3_8.r | 15 +++ .../CH5/EX5.3.9/Ex5.3_9.r | 15 +++ .../CH5/EX5.3.a/Ex5_5.3A.r | 28 ++++ .../CH5/EX5.3.b/Ex5_5.3B.r | 46 +++++++ .../CH6/EX6.1.1/Ex6.1_1.r | 19 +++ .../CH6/EX6.1.2/Ex6.1_2.r | 13 ++ .../CH6/EX6.1.3/Ex6.1_3.r | 8 ++ .../CH6/EX6.1.4/Ex6.1_4.r | 81 ++++++++++++ .../CH6/EX6.1.a/Ex6_6.1A.r | 31 +++++ .../CH6/EX6.1.b/Ex6_6.1B.r | 19 +++ .../CH6/EX6.2.1/Ex6.2_1.r | 20 +++ .../CH6/EX6.2.2/Ex6.2_2.r | 16 +++ .../CH6/EX6.2.b/Ex6_6.2B.r | 33 +++++ .../CH6/EX6.3.1/Ex6.3_1.r | 22 ++++ .../CH6/EX6.3.2/Ex6.3_2.r | 18 +++ .../CH6/EX6.3.6/Ex6.3_6.r | 18 +++ .../CH6/EX6.3.b/Ex6_6.3B.r | 18 +++ .../CH6/EX6.4.1/Ex6.4_1.r | 14 ++ .../CH6/EX6.4.4/Ex6.4_4.r | 23 ++++ .../CH6/EX6.4.b/Ex6_6.4B.r | 32 +++++ .../CH6/EX6.5.1/Ex6.5_1.r | 18 +++ .../CH6/EX6.6.1/Ex6.6_1.r | 17 +++ .../CH6/EX6.6.2/Ex6.6_2.r | 10 ++ .../CH6/EX6.6.3/Ex6.6_3.r | 9 ++ .../CH6/EX6.6.a/Ex6_6.6A.r | 9 ++ .../CH6/EX6.7.3/Ex6.7_3.r | 8 ++ .../CH6/EX6.7.4/Ex6.7_4.r | 8 ++ .../CH7/EX7.3.1/Ex7.3_1.r | 7 + .../CH7/EX7.3.2/Ex7.3_2.r | 13 ++ .../CH7/EX7.3.3/Ex7.3_3.r | 12 ++ .../CH7/EX7.3.4/Ex7.3_4.r | 12 ++ .../CH7/EX7.3.a/Ex7_7.3A.r | 24 ++++ .../CH8/EX8.1.1/Ex8.1_1.r | 14 ++ .../CH8/EX8.1.2/Ex8.1_2.r | 15 +++ .../CH8/EX8.2.1/Ex8.2_1.r | 15 +++ .../CH8/EX8.3.1/Ex8.3_1.r | 8 ++ .../CH8/EX8.3.3/Ex8.3_3.r | 11 ++ .../CH8/EX8.3.4/Ex8.3_4.r | 10 ++ .../CH8/EX8.3.5/Ex8.3_5.r | 10 ++ .../CH8/EX8.5.2/Ex8.5_2.r | 19 +++ .../CH8/EX8.6.2/Ex8.6_6.r | 6 + .../CH9/EX9.2.2/Ex9.2_2.r | 11 ++ .../CH9/EX9.2.3/Ex9.2_3.r | 7 + .../CH9/EX9.3.1/Ex9.3_1.r | 20 +++ .../README.txt | 18 +++ .../CH10/EX10.3.a/Ex10_3a.R | 30 +++++ .../CH10/EX10.3.b/Ex10_3b.R | 23 ++++ .../CH10/EX10.3.c/Ex10_3c.R | 31 +++++ .../CH10/EX10.4.b/Ex10_4b.R | 22 ++++ .../CH10/EX10.5.a/Ex10_5a.R | 41 ++++++ .../CH11/EX11.2.a/Ex11_2a.R | 25 ++++ .../CH11/EX11.2.b/Ex11_2b.R | 14 ++ .../CH11/EX11.2.d/Ex11_2d.R | 18 +++ .../CH11/EX11.3.a/Ex11_3a.R | 38 ++++++ .../CH11/EX11.4.a/Ex11_4a.R | 34 +++++ .../CH11/EX11.4.b/Ex11_4b.R | 30 +++++ .../CH11/EX11.5.a/Ex11_5a.R | 38 ++++++ .../CH11/EX11.5.b/Ex11_5b.R | 40 ++++++ .../CH11/EX11.6.a/Ex11_6a.R | 11 ++ .../CH12/EX12.2.a/Ex12_2a.R | 9 ++ .../CH12/EX12.2.b/Ex12_2b.R | 7 + .../CH12/EX12.3.b/Ex12_3b.R | 20 +++ .../CH12/EX12.3.c/Ex12_3c.R | 18 +++ .../CH12/EX12.4.a/Ex12_4a.R | 17 +++ .../CH12/EX12.4.b/Ex12_4b.R | 31 +++++ .../CH12/EX12.4.c/Ex12_4c.R | 33 +++++ .../CH12/EX12.4.d/Ex12_4d.R | 32 +++++ .../CH12/EX12.4.e/Ex12_4e.R | 16 +++ .../CH12/EX12.5.a/Ex12_5a.R | 33 +++++ .../CH12/EX12.5.c/Ex12_5c.R | 10 ++ .../CH13/EX13.2.a/Ex13_2a.R | 17 +++ .../CH13/EX13.2.b/Ex13_2b.R | 12 ++ .../CH13/EX13.3.a/Ex13_3a.R | 32 +++++ .../CH13/EX13.4.a/Ex13_4a.R | 23 ++++ .../CH13/EX13.5.a/Ex13_5a.R | 35 +++++ .../CH13/EX13.6.b/Ex13_6b.R | 16 +++ .../CH13/EX13.6.c/Ex13_6c.R | 30 +++++ .../CH13/EX13.6.d/Ex13_6d.R | 21 +++ .../CH14/EX14.3.a/Ex14_3a.R | 14 ++ .../CH14/EX14.3.b/Ex14_3b.R | 5 + .../CH14/EX14.3.c/Ex14_3c.R | 12 ++ .../CH14/EX14.3.d/Ex14_3d.R | 9 ++ .../CH14/EX14.3.e/Ex14_3e.R | 8 ++ .../CH14/EX14.4.a/Ex14_4a.R | 10 ++ .../CH2/EX2.2.a/Ex2_2a.R | 5 + .../CH2/EX2.2.b/Ex2_2b.R | 6 + .../CH2/EX2.3.a/Ex2_3a.R | 4 + .../CH2/EX2.3.b/Ex2_3b.R | 6 + .../CH2/EX2.3.c/Ex2_3c.R | 12 ++ .../CH2/EX2.3.d/Ex2_3d.R | 6 + .../CH2/EX2.3.e/Ex2_3e.R | 23 ++++ .../CH2/EX2.3.f/Ex2_3f.R | 4 + .../CH2/EX2.3.g/Ex2_3g.R | 3 + .../CH2/EX2.3.h/Ex2_3h.R | 5 + .../CH2/EX2.3.i/Ex2_3i.R | 2 + .../CH2/EX2.4.a/Ex2_4a.R | 5 + .../CH2/EX2.5.a/Ex2_5a.R | 4 + .../CH2/EX2.6.a/Ex2_6a.R | 14 ++ .../CH2/EX2.6.b/Ex2_6b.R | 14 ++ .../CH3/EX3.4.a/Ex3_4a.R | 5 + .../CH3/EX3.5.a/Ex3_5a.R | 7 + .../CH3/EX3.5.b/Ex3_5b.R | 6 + .../CH3/EX3.5.c/Ex3_5c.R | 6 + .../CH3/EX3.5.d/Ex3_5d.R | 7 + .../CH3/EX3.5.f/Ex3_5f.R | 21 +++ .../CH3/EX3.6.a/Ex3_6a.R | 4 + .../CH3/EX3.6.b/Ex3_6b.R | 5 + .../CH3/EX3.6.c/Ex3_6c.R | 3 + .../CH3/EX3.7.a/Ex3_7a.R | 5 + .../CH3/EX3.7.b/Ex3_7b.R | 6 + .../CH3/EX3.7.c/Ex3_7c.R | 3 + .../CH3/EX3.7.d/Ex3_7d.R | 5 + .../CH3/EX3.7.e/Ex3_7e.R | 5 + .../CH3/EX3.7.f/Ex3_7f.R | 8 ++ .../CH3/EX3.8.a/Ex3_8a.R | 3 + .../CH4/EX4.1.a/Ex4_1a.R | 30 +++++ .../CH4/EX4.1.c/Ex4_1c.R | 15 +++ .../CH4/EX4.2.a/Ex4_2a.R | 11 ++ .../CH4/EX4.2.b/Ex4_2b.R | 17 +++ .../CH4/EX4.3.a/Ex4_3a.R | 20 +++ .../CH4/EX4.3.b/Ex4_3b.R | 39 ++++++ .../CH4/EX4.3.c/Ex4_3c.R | 48 +++++++ .../CH4/EX4.3.d/Ex4_3d.R | 26 ++++ .../CH4/EX4.3.e/Ex4_3e.R | 16 +++ .../CH4/EX4.3.f/Ex4_3f.R | 26 ++++ .../CH4/EX4.3.g/Ex4_3g.R | 31 +++++ .../CH4/EX4.4.a/Ex4_4a.R | 16 +++ .../CH4/EX4.4.d/Ex4_4d.R | 16 +++ .../CH4/EX4.5.a/Ex4_5a.R | 20 +++ .../CH4/EX4.5.b/Ex4_5b.R | 15 +++ .../CH4/EX4.5.c/Ex4_5c.R | 20 +++ .../CH4/EX4.5.d/Ex4_5d.R | 15 +++ .../CH4/EX4.5.e/Ex4_5e.R | 20 +++ .../CH4/EX4.5.g/Ex4_5g.R | 15 +++ .../CH4/EX4.6.a/Ex4_6a.R | 19 +++ .../CH4/EX4.7.a/Ex4_7a.R | 20 +++ .../CH4/EX4.7.b/Ex4_7b.R | 17 +++ .../CH4/EX4.9.a/Ex4_9a.R | 24 ++++ .../CH5/EX5.1.a/Ex5_1a.R | 7 + .../CH5/EX5.1.b/Ex5_1b.R | 7 + .../CH5/EX5.1.e/Ex5_1e.R | 10 ++ .../CH5/EX5.1.f/Ex5_1f.R | 2 + .../CH5/EX5.2.a/Ex5_2a.R | 4 + .../CH5/EX5.2.b/Ex5_2b.R | 1 + .../CH5/EX5.2.c/Ex5_2c.R | 1 + .../CH5/EX5.2.d/Ex5_2d.R | 8 ++ .../CH5/EX5.2.f/Ex5_2f.R | 2 + .../CH5/EX5.3.a/Ex5_3a.R | 1 + .../CH5/EX5.3.b/Ex5_3b.R | 8 ++ .../CH5/EX5.3.c/Ex5_3c.R | 9 ++ .../CH5/EX5.4.a/Ex5_4a.R | 18 +++ .../CH5/EX5.4.b/Ex5_4b.R | 15 +++ .../CH5/EX5.4.c/Ex5_4c.R | 5 + .../CH5/EX5.5.a/Ex5_5a.R | 6 + .../CH5/EX5.5.b/Ex5_5b.R | 4 + .../CH5/EX5.5.c/Ex5_5c.R | 6 + .../CH5/EX5.5.d/Ex5_5d.R | 4 + .../CH5/EX5.6.a/Ex5_6a.R | 1 + .../CH5/EX5.6.b/Ex5_6b.R | 5 + .../CH5/EX5.6.c/Ex5_6c.R | 7 + .../CH5/EX5.8.a/Ex5_8a.R | 1 + .../CH5/EX5.8.b/Ex5_8b.R | 1 + .../CH5/EX5.8.c/Ex5_8c.R | 1 + .../CH5/EX5.8.d/Ex5_8d.R | 3 + .../CH5/EX5.8.e/Ex5_8e.R | 4 + .../CH5/EX5.8.f/Ex5_8f.R | 1 + .../CH6/EX6.3.a/Ex6_3a.R | 1 + .../CH6/EX6.3.c/Ex6_3c.R | 1 + .../CH6/EX6.3.d/Ex6_3d.R | 4 + .../CH6/EX6.3.e/Ex6_3e.R | 3 + .../CH6/EX6.5.a/Ex6_5a.R | 4 + .../CH6/EX6.6.a/Ex6_6a.R | 10 ++ .../CH6/EX6.6.b/Ex6_6b.R | 8 ++ .../CH7/EX7.2.a/Ex7_2a.R | 3 + .../CH7/EX7.2.b/Ex7_2b.R | 5 + .../CH7/EX7.2.c/Ex7_2c.R | 3 + .../CH7/EX7.2.d/Ex7_2d.R | 5 + .../CH7/EX7.2.e/Ex7_2e.R | 9 ++ .../CH7/EX7.2.f/Ex7_2f.R | 13 ++ .../CH7/EX7.2.g/Ex7_2g.R | 3 + .../CH7/EX7.3.a/Ex7_3a.R | 8 ++ .../CH7/EX7.3.b/Ex7_3b.R | 10 ++ .../CH7/EX7.3.c/Ex7_3c.R | 18 +++ .../CH7/EX7.3.d/Ex7_3d.R | 4 + .../CH7/EX7.3.e/Ex7_3e.R | 18 +++ .../CH7/EX7.3.f/Ex7_3f.R | 14 ++ .../CH7/EX7.3.g/Ex7_3g.R | 26 ++++ .../CH7/EX7.3.h/Ex7_3h.R | 11 ++ .../CH7/EX7.4.a/Ex7_4a.R | 19 +++ .../CH7/EX7.4.b/Ex7_4b.R | 22 ++++ .../CH7/EX7.5.a/Ex7_5a.R | 7 + .../CH7/EX7.5.b/Ex7_5b.R | 5 + .../CH7/EX7.5.c/Ex7_5c.R | 13 ++ .../CH7/EX7.6.a/Ex7_6a.R | 14 ++ .../CH7/EX7.7.a/Ex7_7a.R | 6 + .../CH7/EX7.7.b/Ex7_7b.R | 10 ++ .../CH7/EX7.7.c/Ex7_7c.R | 4 + .../CH7/EX7.8.a/Ex7_8a.R | 3 + .../CH7/EX7.8.b/Ex7_8b.R | 8 ++ .../CH7/EX7.8.d/Ex7_8d.R | 23 ++++ .../CH8/EX8.3.a/Ex8_3a.R | 12 ++ .../CH8/EX8.3.b/Ex8_3b.R | 14 ++ .../CH8/EX8.3.c/Ex8_3c.R | 10 ++ .../CH8/EX8.3.d/Ex8_3d.R | 14 ++ .../CH8/EX8.3.e/Ex8_3e.R | 7 + .../CH8/EX8.3.f/Ex8_3f.R | 8 ++ .../CH8/EX8.3.g/Ex8_3g.R | 5 + .../CH8/EX8.3.h/Ex8_3h.R | 15 +++ .../CH8/EX8.3.i/Ex8_3i.R | 18 +++ .../CH8/EX8.3.j/Ex8_3j.R | 10 ++ .../CH8/EX8.4.a/Ex8_4a.R | 12 ++ .../CH8/EX8.4.b/Ex8_4b.R | 19 +++ .../CH8/EX8.4.c/Ex8_4c.R | 14 ++ .../CH8/EX8.4.d/Ex8_4d.R | 10 ++ .../CH8/EX8.5.a/Ex8_5a.R | 7 + .../CH8/EX8.5.b/Ex8_5b.R | 11 ++ .../CH8/EX8.6.a/Ex8_6a.R | 6 + .../CH8/EX8.6.b/Ex8_6b.R | 9 ++ .../CH8/EX8.6.c/Ex8_6c.R | 7 + .../CH8/EX8.7.a/Ex8_7a.R | 5 + .../CH8/EX8.7.b/Ex8_7b.R | 11 ++ .../CH8/EX8.7.c/Ex8_7c.R | 7 + .../CH9/EX9.1.a/Ex9_1a.R | 5 + .../CH9/EX9.10.a/Ex9_10a.R | 33 +++++ .../CH9/EX9.10.b/Ex9_10b.R | 38 ++++++ .../CH9/EX9.10.c/Ex9_10c.R | 41 ++++++ .../CH9/EX9.10.d/Ex9_10d.R | 45 +++++++ .../CH9/EX9.11.a/Ex9_11a.R | 5 + .../CH9/EX9.2.a/Ex9_2a.R | 9 ++ .../CH9/EX9.3.a/Ex9_3a.R | 32 +++++ .../CH9/EX9.4.a/Ex9_4a.R | 36 +++++ .../CH9/EX9.4.b/Ex9_4b.R | 33 +++++ .../CH9/EX9.4.c/Ex9_4c.R | 38 ++++++ .../CH9/EX9.4.d/Ex9_4d.R | 28 ++++ .../CH9/EX9.4.e/Ex9_4e.R | 29 +++++ .../CH9/EX9.4.f/Ex9_4f.R | 29 +++++ .../CH9/EX9.5.a/Ex9_5a.R | 28 ++++ .../CH9/EX9.7.a/Ex9_7a.R | 37 ++++++ .../CH9/EX9.8.b/Ex9_8b.R | 29 +++++ .../CH9/EX9.9.a/Ex9_9a.R | 27 ++++ .../README.txt | 18 +++ .../CH1/EX1.10/Ex1_10.R | 4 + .../CH1/EX1.11/Ex1_11.R | 5 + .../CH1/EX1.3/Ex1_3.R | 11 ++ .../CH1/EX1.4/Ex1_4.R | 4 + .../CH1/EX1.5/Ex1_5.R | 7 + .../CH1/EX1.6/Ex1_6.R | 6 + .../CH1/EX1.7/Ex1_7.R | 2 + .../CH1/EX1.8/Ex1_8.R | 2 + .../CH10/EX10.11/Ex10_11.R | 13 ++ .../CH10/EX10.12/Ex10_12.R | 15 +++ .../CH10/EX10.13/Ex10_13.R | 6 + .../CH10/EX10.14/Ex10_14.R | 16 +++ .../CH10/EX10.15/Ex10_15.R | 12 ++ .../CH10/EX10.16/Ex10_16.R | 14 ++ .../CH10/EX10.2/Ex10_2.R | 3 + .../CH10/EX10.3/Ex10_3.R | 3 + .../CH10/EX10.4/Ex10_4.R | 9 ++ .../CH10/EX10.5/Ex10_5.R | 24 ++++ .../CH10/EX10.6/Ex10_6.R | 5 + .../CH10/EX10.7/Ex10_7.R | 7 + .../CH10/EX10.8/Ex10_8.R | 11 ++ .../CH10/EX10.9/Ex10_9.R | 6 + .../CH11/EX11.10/Ex11_10.R | 42 ++++++ .../CH11/EX11.12/Ex11_12.R | 6 + .../CH11/EX11.4/Ex11_4.R | 32 +++++ .../CH11/EX11.5/Ex11_5.R | 44 +++++++ .../CH11/EX11.6/Ex11_6.R | 33 +++++ .../CH11/EX11.7/Ex11_7.R | 34 +++++ .../CH11/EX11.8/Ex11_8.R | 14 ++ .../CH11/EX11.9/Ex11_9.R | 18 +++ .../CH12/EX12.1/Ex12_1.R | 6 + .../CH12/EX12.2/Ex12_2.R | 33 +++++ .../CH12/EX12.3/Ex12_3.R | 9 ++ .../CH12/EX12.4/Ex12_4.R | 13 ++ .../CH12/EX12.5/Ex12_5.R | 15 +++ .../CH12/EX12.6/Ex12_6.R | 15 +++ .../CH12/EX12.7/Ex12_7.R | 4 + .../CH12/EX12.8/Ex12_8.R | 6 + .../CH13/EX13.2/Ex13_2.R | 10 ++ .../CH13/EX13.3/Ex13_3.R | 4 + .../CH13/EX13.4/Ex13_4.R | 6 + .../CH13/EX13.6/Ex13_6.R | 16 +++ .../CH13/EX13.7/Ex13_7.R | 12 ++ .../CH13/EX13.8/Ex13_8.R | 36 +++++ .../CH14/EX14.1/Ex14_1.R | 9 ++ .../CH14/EX14.2/Ex14_2.R | 24 ++++ .../CH14/EX14.4/Ex14_4.R | 10 ++ .../CH14/EX14.5/Ex14_5.R | 7 + .../CH14/EX14.7/Ex14_7.R | 7 + .../CH15/EX15.1/Ex15_1.R | 15 +++ .../CH15/EX15.10/Ex15_10.R | 9 ++ .../CH15/EX15.11/Ex15_11.R | 12 ++ .../CH15/EX15.2/Ex15_2.R | 28 ++++ .../CH15/EX15.3/Ex15_3.R | 7 + .../CH15/EX15.4/Ex15_4.R | 10 ++ .../CH15/EX15.5/Ex15_5.R | 14 ++ .../CH15/EX15.6/Ex15_6.R | 18 +++ .../CH15/EX15.8/Ex15_8.R | 31 +++++ .../CH15/EX15.9/Ex15_9.R | 11 ++ .../CH2/EX2.1/Ex2_1.R | 4 + .../CH2/EX2.10/Ex2_10.R | 5 + .../CH2/EX2.11/Ex2_11.R | 5 + .../CH2/EX2.13/Ex2_13.R | 6 + .../CH2/EX2.14/Ex2_14.R | 10 ++ .../CH2/EX2.2/Ex2_2.R | 3 + .../CH2/EX2.3/Ex2_3.R | 3 + .../CH2/EX2.5/Ex2_5.R | 5 + .../CH2/EX2.6/Ex2_6.R | 9 ++ .../CH2/EX2.7/Ex2_7.R | 11 ++ .../CH2/EX2.9/Ex2_9.R | 6 + .../CH3/EX3.1/Ex3_1.R | 7 + .../CH3/EX3.2/Ex3_2.R | 15 +++ .../CH3/EX3.3/Ex3_3.R | 3 + .../CH3/EX3.4/Ex3_4.R | 9 ++ .../CH3/EX3.5/Ex3_5.R | 4 + .../CH3/EX3.6/Ex3_6.R | 4 + .../CH3/EX3.7/Ex3_7.R | 9 ++ .../CH4/EX4.10/Ex4_10.R | 2 + .../CH4/EX4.11/Ex4_11.R | 4 + .../CH4/EX4.12/Ex4_12.R | 2 + .../CH4/EX4.13/Ex4_13.R | 2 + .../CH4/EX4.14/Ex4_14.R | 3 + .../CH4/EX4.15/Ex4_15.R | 4 + .../CH4/EX4.17/Ex4_17.R | 5 + .../CH4/EX4.18/Ex4_18.R | 13 ++ .../CH4/EX4.19/Ex4_19.R | 7 + .../CH4/EX4.20/Ex4_20.R | 9 ++ .../CH4/EX4.21/Ex4_21.R | 13 ++ .../CH4/EX4.22/Ex4_22.R | 9 ++ .../CH4/EX4.23/Ex4_23.R | 12 ++ .../CH4/EX4.24/Ex4_24.R | 12 ++ .../CH4/EX4.26/Ex4_26.R | 11 ++ .../CH4/EX4.27/Ex4_27.R | 6 + .../CH4/EX4.5/Ex4_5.R | 3 + .../CH4/EX4.6/Ex4_6.R | 5 + .../CH4/EX4.7/Ex4_7.R | 3 + .../CH4/EX4.8/Ex4_8.R | 3 + .../CH4/EX4.9/Ex4_9.R | 3 + .../CH5/EX5.10/Ex5_10.R | 10 ++ .../CH5/EX5.11/Ex5_11.R | 18 +++ .../CH5/EX5.12/Ex5_12.R | 5 + .../CH5/EX5.3/Ex5_3.R | 5 + .../CH5/EX5.4/Ex5_4.R | 8 ++ .../CH5/EX5.5/Ex5_5.R | 9 ++ .../CH5/EX5.6/Ex5_6.R | 5 + .../CH5/EX5.7/Ex5_7.R | 8 ++ .../CH5/EX5.8/Ex5_8.R | 8 ++ .../CH5/EX5.9/Ex5_9.R | 6 + .../CH6/EX6.1/Ex6_1.R | 3 + .../CH6/EX6.10/Ex6_10.R | 5 + .../CH6/EX6.11/Ex6_11.R | 11 ++ .../CH6/EX6.12/Ex6_12.R | 9 ++ .../CH6/EX6.13/Ex6_13.R | 9 ++ .../CH6/EX6.2/Ex6_2.R | 4 + .../CH6/EX6.3/Ex6_3.R | 3 + .../CH6/EX6.4/Ex6_4.R | 4 + .../CH6/EX6.5/Ex6_5.R | 6 + .../CH6/EX6.6/Ex6_6.R | 7 + .../CH6/EX6.7/Ex6_7.R | 5 + .../CH6/EX6.8/Ex6_8.R | 6 + .../CH6/EX6.9/Ex6_9.R | 6 + .../CH7/EX7.1/Ex7_1.R | 3 + .../CH7/EX7.4/Ex7_4.R | 14 ++ .../CH7/EX7.5/Ex7_5.R | 7 + .../CH7/EX7.6/Ex7_6.R | 7 + .../CH7/EX7.7/Ex7_7.R | 8 ++ .../CH7/EX7.8/Ex7_8.R | 16 +++ .../CH7/EX7.9/Ex7_9.R | 10 ++ .../CH8/EX8.10/Ex8_10.R | 14 ++ .../CH8/EX8.11/Ex8_11.R | 20 +++ .../CH8/EX8.12/Ex8_12.R | 10 ++ .../CH8/EX8.13/Ex8_13.R | 7 + .../CH8/EX8.14/Ex8_14.R | 7 + .../CH8/EX8.4/Ex8_4.R | 5 + .../CH8/EX8.5/Ex8_5.R | 6 + .../CH8/EX8.6/Ex8_6.R | 8 ++ .../CH8/EX8.7/Ex8_7.R | 8 ++ .../CH8/EX8.8/Ex8_8.R | 12 ++ .../CH8/EX8.9/Ex8_9.R | 14 ++ .../CH9/EX9.10/Ex9_10.R | 18 +++ .../CH9/EX9.11/Ex9_11.R | 7 + .../CH9/EX9.12/Ex9_12.R | 15 +++ .../CH9/EX9.3/Ex9_3.R | 9 ++ .../CH9/EX9.4/Ex9_4.R | 14 ++ .../CH9/EX9.5/Ex9_5.R | 13 ++ .../CH9/EX9.6/Ex9_6.R | 9 ++ .../CH9/EX9.7/Ex9_7.R | 16 +++ .../CH9/EX9.8/Ex9_8.R | 20 +++ .../CH9/EX9.9/Ex9_9.R | 19 +++ .../README.txt | 18 +++ .../CH1/EX1.10/EX1_10.R | 45 +++++++ .../CH1/EX1.11/EX1_11.R | 27 ++++ .../CH1/EX1.12/EX1_12.R | 11 ++ .../CH1/EX1.18/EX1_18.R | 12 ++ .../CH1/EX1.2/EX1_2.R | 17 +++ .../CH1/EX1.28/EX1_28.R | 8 ++ .../CH1/EX1.29/EX1_29.R | 35 +++++ .../CH1/EX1.3/EX1_3.R | 34 +++++ .../CH1/EX1.30/EX1_30.R | 15 +++ .../CH1/EX1.6/EX1_6.R | 23 ++++ .../CH1/EX1.8/EX1_8.R | 21 +++ .../CH1/EX1.9/EX1_9.R | 32 +++++ .../CH2/EX2.1/EX_2_1.R | 40 ++++++ .../CH2/EX2.11/EX_2_11.R | 17 +++ .../CH2/EX2.13/EX_2_13.R | 42 ++++++ .../CH2/EX2.14/EX_2_14.R | 13 ++ .../CH2/EX2.16/EX_2_16.R | 52 ++++++++ .../CH2/EX2.18/EX_2_18.R | 16 +++ .../CH2/EX2.2/EX_2_2.R | 28 ++++ .../CH2/EX2.3/EX_2_3.R | 59 +++++++++ .../CH2/EX2.4/EX_2_4.R | 23 ++++ .../CH2/EX2.5/EX_2_5.R | 19 +++ .../CH2/EX2.7/EX_2_7.R | 21 +++ .../CH2/EX2.8/EX_2_8.R | 13 ++ .../CH2/EX2.9/EX_2_9.R | 7 + .../CH3/EX3.11/EX_3_11.R | 30 +++++ .../CH3/EX3.12/EX_3_12.R | 19 +++ .../CH3/EX3.2/EX_3_2.R | 18 +++ .../CH3/EX3.22/EX_3_22.R | 30 +++++ .../CH3/EX3.3/EX_3_3.R | 18 +++ .../CH3/EX3.4/EX_3_4.R | 26 ++++ .../CH3/EX3.5/EX_3_5.R | 16 +++ .../CH3/EX3.7/EX_3_7.R | 22 ++++ .../CH3/EX3.8/EX_3_8.R | 26 ++++ .../CH3/EX3.9/EX_3_9.R | 17 +++ .../CH4/EX4.1/EX_4_1.R | 12 ++ .../CH4/EX4.13/EX_4_13.R | 61 +++++++++ .../CH4/EX4.16/EX_4_16.R | 18 +++ .../CH4/EX4.20/EX_4_20.R | 38 ++++++ .../CH4/EX4.21/EX_4_21.R | 11 ++ .../CH4/EX4.4/EX_4_4.R | 15 +++ .../CH4/EX4.5/EX_4_5.R | 16 +++ .../CH4/EX4.6/EX_4_6.R | 21 +++ .../CH4/EX4.7/EX_4_7.R | 11 ++ .../CH4/EX4.9/EX_4_9.R | 11 ++ .../CH5/EX5.12/EX_5_12.R | 13 ++ .../CH5/EX5.17/EX_5_17.R | 12 ++ .../CH5/EX5.5/EX_5_5.R | 27 ++++ .../CH5/EX5.6/EX_5_6.R | 9 ++ .../CH5/EX5.7/EX_5_7.R | 13 ++ .../CH5/EX5.9/EX_5_9.R | 7 + .../CH6/EX6.1/EX_6_1.R | 9 ++ .../CH6/EX6.11/EX_6_11.R | 23 ++++ .../CH6/EX6.13/EX_6_13.R | 17 +++ .../CH6/EX6.14/EX_6_14.R | 15 +++ .../CH6/EX6.2/EX_6_2.R | 26 ++++ .../CH6/EX6.4/EX_6_4.R | 10 ++ .../CH7/EX7.1/EX_7_1.R | 32 +++++ .../CH7/EX7.10/EX_7_10.R | 20 +++ .../CH7/EX7.11/EX_7_11.R | 31 +++++ .../CH7/EX7.4/EX_7_4.R | 9 ++ .../CH7/EX7.8/EX_7_8.R | 22 ++++ .../CH7/EX7.9/EX_7_9.R | 15 +++ .../README.txt | 18 +++ .../CH1/EX1.1.1/example1_sect1_1.zip | Bin 0 -> 468 bytes .../CH1/EX1.1.3/example3_sec1_1.R | 6 + .../CH1/EX1.1.4/example4_sec1_1.zip | Bin 0 -> 371 bytes .../CH1/EX1.1.5/example5_sec1_1.zip | Bin 0 -> 332 bytes .../CH1/EX1.1.6/example6_sec1_1.zip | Bin 0 -> 332 bytes .../CH1/EX1.2.10/example10_sec1_2.zip | Bin 0 -> 309 bytes .../CH1/EX1.2.12/example12_sec1_2.zip | Bin 0 -> 271 bytes .../CH1/EX1.2.14/example14_sec1_2.zip | Bin 0 -> 302 bytes .../CH1/EX1.2.15/example15_sec1_2.zip | Bin 0 -> 339 bytes .../CH1/EX1.2.3/example3_sec1_2.zip | Bin 0 -> 359 bytes .../CH1/EX1.3.1/example1_sec1_3.zip | Bin 0 -> 323 bytes .../CH1/EX1.3.10/example10_sec1_3.zip | Bin 0 -> 340 bytes .../CH1/EX1.3.21/example21_sec1_3.zip | Bin 0 -> 1023 bytes .../CH1/EX1.3.23/example23_sec1_3.zip | Bin 0 -> 278 bytes .../CH1/EX1.3.4/example4_sec1_3.zip | Bin 0 -> 276 bytes .../CH1/EX1.3.5/example5_sec1_3.zip | Bin 0 -> 374 bytes .../CH1/EX1.4.10/example10_sec1_4.zip | Bin 0 -> 405 bytes .../CH1/EX1.4.11/example11_sec1_4.zip | Bin 0 -> 329 bytes .../CH1/EX1.4.2/example2_sec_1_4.R | 6 + .../CH1/EX1.4.5/example5_sec1_4.zip | Bin 0 -> 358 bytes .../CH1/EX1.5.3/example3_sec1_5.zip | Bin 0 -> 397 bytes .../CH1/EX1.6.4/example4_sec1_6.zip | Bin 0 -> 436 bytes .../CH1/EX1.6.5/example5_sec1_6.zip | Bin 0 -> 975 bytes .../CH1/EX1.7.4/example4_sec1_7.zip | Bin 0 -> 334 bytes .../CH1/EX1.7.5/example5_sec1_7.zip | Bin 0 -> 324 bytes .../CH1/EX1.7.6/example6_sec1_7.zip | Bin 0 -> 425 bytes .../CH10/EX10.1.2/example2_sec10_1.zip | Bin 0 -> 495 bytes .../CH10/EX10.2.12/example12_sec10_2.zip | Bin 0 -> 601 bytes .../CH10/EX10.2.3/example3_sec10_2.zip | Bin 0 -> 390 bytes .../CH2/EX2.2.12/example12_sec2_2.zip | Bin 0 -> 336 bytes .../CH2/EX2.2.14/2.2.14.R | 45 +++++++ .../CH2/EX2.2.5/example5_sec2_2.zip | Bin 0 -> 458 bytes .../CH2/EX2.2.6/example6_sec2_2.zip | Bin 0 -> 387 bytes .../CH2/EX2.4.1/example1_sec2_4.zip | Bin 0 -> 823 bytes .../CH2/EX2.5.1/example1_sec2_5.zip | Bin 0 -> 424 bytes .../CH2/EX2.5.3/example3_sec2_5.zip | Bin 0 -> 645 bytes .../CH2/EX2.5.7/example7_sec2_5.zip | Bin 0 -> 441 bytes .../CH2/EX7.2.2/example2_sec7_2.zip | Bin 0 -> 488 bytes .../CH3/EX3.1.10/example10_sec3_1.zip | Bin 0 -> 333 bytes .../CH3/EX3.1.11/example11_sec3_1.zip | Bin 0 -> 422 bytes .../CH3/EX3.1.18/example18_sec3_1.zip | Bin 0 -> 384 bytes .../CH3/EX3.1.19/example19_sec3_1.zip | Bin 0 -> 350 bytes .../CH3/EX3.1.5/example5_sec3_1.zip | Bin 0 -> 336 bytes .../CH3/EX3.1.7/example7_sec3_1.zip | Bin 0 -> 246 bytes .../CH3/EX3.1.9/example9_sec3_1.zip | Bin 0 -> 330 bytes .../CH3/EX3.2.1/example1_sec3_2.zip | Bin 0 -> 435 bytes .../CH3/EX3.2.2/example2_sec3_2.zip | Bin 0 -> 382 bytes .../CH3/EX3.2.5/example5_sec3_2.R | 8 ++ .../CH3/EX3.2.7/example7_sec3_2.zip | Bin 0 -> 412 bytes .../CH3/EX3.2.9/example9_sec3_2.zip | Bin 0 -> 501 bytes .../CH3/EX3.3.14/example14_sec3_3.zip | Bin 0 -> 399 bytes .../CH4/EX4.1.14/example14_sec4_1.zip | Bin 0 -> 491 bytes .../CH4/EX4.1.15/example15_sec4_1.zip | Bin 0 -> 326 bytes .../CH4/EX4.1.16/example16_sec4_1.zip | Bin 0 -> 338 bytes .../CH4/EX4.1.3/4.1.3.R | 9 ++ .../CH4/EX4.1.6/example6_sec4_1.zip | Bin 0 -> 307 bytes .../CH4/EX4.1.7/example7_sec4_1.zip | Bin 0 -> 351 bytes .../CH4/EX4.1.8/example8_sec4_1.zip | Bin 0 -> 381 bytes .../CH4/EX4.1.9/example9_sec4_1.zip | Bin 0 -> 284 bytes .../CH4/EX4.2.10/example10_sec4_2.zip | Bin 0 -> 635 bytes .../CH4/EX4.2.13/example13_sec4_2.zip | Bin 0 -> 429 bytes .../CH4/EX4.2.2/example2_sec4_2.zip | Bin 0 -> 256 bytes .../CH4/EX4.2.3/example3_sec4_2.zip | Bin 0 -> 254 bytes .../CH4/EX4.3.2/example2_sec4_3.zip | Bin 0 -> 351 bytes .../CH4/EX4.3.5/example5_sec4_3.zip | Bin 0 -> 510 bytes .../CH5/EX5.1.1/example1_sec5_1.zip | Bin 0 -> 416 bytes .../CH5/EX5.1.4/example4_sec5_1.zip | Bin 0 -> 754 bytes .../CH5/EX5.1.6/example6_sec5_1.zip | Bin 0 -> 693 bytes .../CH6/EX6.1.7/example7_sec6_1.zip | Bin 0 -> 385 bytes .../CH6/EX6.2.11/example11_sec6_2.zip | Bin 0 -> 501 bytes .../CH6/EX6.2.12/example12_sec6_2.zip | Bin 0 -> 405 bytes .../CH6/EX6.2.3/example3_sec6_2.zip | Bin 0 -> 577 bytes .../CH6/EX6.3.2/example2_sec6_3.zip | Bin 0 -> 413 bytes .../CH6/EX6.3.8/example8_sec6_3.zip | Bin 0 -> 443 bytes .../CH6/EX6.4.2/example2_sec6_4.zip | Bin 0 -> 630 bytes .../CH6/EX6.4.5/6.4.5.R | 57 ++++++++ .../CH6/EX6.5.3/example3_sec6_5.zip | Bin 0 -> 395 bytes .../CH6/EX6.6.5/example5_sec6_6.zip | Bin 0 -> 346 bytes .../CH6/EX6.6.8/example8_sec6_6.zip | Bin 0 -> 339 bytes .../CH6/EX6.7.1/example1_sec6_7.zip | Bin 0 -> 403 bytes .../CH6/EX6.8.4/example4_sec6_8.zip | Bin 0 -> 640 bytes .../CH7/EX7.2.1/example1_sec7_2.zip | Bin 0 -> 421 bytes .../CH7/EX7.2.2/example2_sec7_2.zip | Bin 0 -> 488 bytes .../CH7/EX7.2.4/example4_sec7_2.zip | Bin 0 -> 477 bytes .../CH8/EX8.1.2/example2_sec8_1.zip | Bin 0 -> 274 bytes .../CH8/EX8.1.3/example3_sec8_1.zip | Bin 0 -> 260 bytes .../CH8/EX8.1.5/example5_sec8_1.zip | Bin 0 -> 378 bytes .../CH8/EX8.1.6/example6_sec8_1.zip | Bin 0 -> 418 bytes .../CH8/EX8.1.8/example8_sec8_1.zip | Bin 0 -> 350 bytes .../CH8/EX8.2.1/example1_sec8_2.zip | Bin 0 -> 361 bytes .../CH8/EX8.2.3/example3_sec8_2.zip | Bin 0 -> 481 bytes .../CH8/EX8.3.1/example1_sec8_3.zip | Bin 0 -> 441 bytes .../CH8/EX8.3.5/example5_sec8_3.zip | Bin 0 -> 608 bytes .../CH9/EX9.2.5/example5_sec9_2.zip | Bin 0 -> 472 bytes .../CH9/EX9.2.6/example6_sec9_2.zip | Bin 0 -> 481 bytes .../CH9/EX9.4.7/example7_sec9_4.zip | Bin 0 -> 458 bytes .../CH1/EX1.1/Ex1.1.R | 41 ++++++ .../CH1/EX1.10/Ex1.10.R | 30 +++++ .../CH1/EX1.11/Ex1.11.R | 71 ++++++++++ .../CH1/EX1.12/Ex1.12.R | 43 ++++++ .../CH1/EX1.13/Ex1.13.R | 34 +++++ .../CH1/EX1.14/Ex1.14.R | 28 ++++ .../CH1/EX1.15/Ex1.15.R | 45 +++++++ .../CH1/EX1.16/Ex1.16.R | 29 +++++ .../CH1/EX1.17/Ex1.17.R | 26 ++++ .../CH1/EX1.18/Ex1.18.R | 29 +++++ .../CH1/EX1.19/Ex1.19.R | 76 +++++++++++ .../CH1/EX1.2/Ex1.2.R | 25 ++++ .../CH1/EX1.20/Ex1.20.R | 50 +++++++ .../CH1/EX1.21/Ex1.21.R | 46 +++++++ .../CH1/EX1.22/Ex1.22.R | 34 +++++ .../CH1/EX1.23/Ex1.23.R | 26 ++++ .../CH1/EX1.24/Ex1.24.R | 56 ++++++++ .../CH1/EX1.25/Ex1.25.R | 27 ++++ .../CH1/EX1.26/Ex1.26.R | 26 ++++ .../CH1/EX1.27/Ex1.27.R | 36 +++++ .../CH1/EX1.28/Ex1.28.R | 39 ++++++ .../CH1/EX1.29/Ex1.29.R | 46 +++++++ .../CH1/EX1.3/Ex1.3.R | 43 ++++++ .../CH1/EX1.30/Ex1.30.R | 52 ++++++++ .../CH1/EX1.31/Ex1.31.R | 93 +++++++++++++ .../CH1/EX1.32/Ex1.32.R | 38 ++++++ .../CH1/EX1.4/Ex1.4.R | 24 ++++ .../CH1/EX1.5/Ex1.5.R | 30 +++++ .../CH1/EX1.6/Ex1.6.R | 34 +++++ .../CH1/EX1.7/Ex1.7.R | 30 +++++ .../CH1/EX1.8/Ex1.8.R | 32 +++++ .../CH1/EX1.9/Ex1.9.R | 29 +++++ .../CH2/EX2.1/Ex2.1.R | 29 +++++ .../CH2/EX2.10/Ex2.10.R | 32 +++++ .../CH2/EX2.11/Ex2.11.R | 41 ++++++ .../CH2/EX2.12/Ex2.12.R | 23 ++++ .../CH2/EX2.13/Ex2.13.R | 31 +++++ .../CH2/EX2.14/Ex2.14.R | 28 ++++ .../CH2/EX2.15/Ex2.15.R | 27 ++++ .../CH2/EX2.16/Ex2.16.R | 35 +++++ .../CH2/EX2.17/Ex2.17.R | 33 +++++ .../CH2/EX2.18/Ex2.18.R | 42 ++++++ .../CH2/EX2.19/Ex2.19.R | 50 +++++++ .../CH2/EX2.2/Ex2.2.R | 18 +++ .../CH2/EX2.20/Ex2.20.R | 38 ++++++ .../CH2/EX2.21/Ex2.21.R | 20 +++ .../CH2/EX2.22/Ex2.22.R | 22 ++++ .../CH2/EX2.23/Ex2.23.R | 38 ++++++ .../CH2/EX2.3/Ex2.3.R | 49 +++++++ .../CH2/EX2.4/Ex2.4.R | 31 +++++ .../CH2/EX2.5/Ex2.5.R | 19 +++ .../CH2/EX2.6/Ex2.6.R | 23 ++++ .../CH2/EX2.7/Ex2.7.R | 23 ++++ .../CH2/EX2.8/Ex2.8.R | 54 ++++++++ .../CH2/EX2.9/Ex2.9.R | 62 +++++++++ .../CH3/EX3.1/Ex3.1.R | 20 +++ .../CH3/EX3.10/Ex3.10.R | 37 ++++++ .../CH3/EX3.11/Ex3.11.R | 66 ++++++++++ .../CH3/EX3.12/Ex3.12.R | 22 ++++ .../CH3/EX3.2/Ex3.2.R | 20 +++ .../CH3/EX3.3/Ex3.3.R | 37 ++++++ .../CH3/EX3.4/Ex3.4.R | 25 ++++ .../CH3/EX3.5/Ex3.5.R | 17 +++ .../CH3/EX3.6/Ex3.6.R | 30 +++++ .../CH3/EX3.7/Ex3.7.R | 37 ++++++ .../CH3/EX3.8/Ex3.8.R | 37 ++++++ .../CH3/EX3.9/Ex3.9.R | 35 +++++ .../CH4/EX4.1/Ex4.1.R | 41 ++++++ .../CH4/EX4.10/Ex4.10.R | 36 +++++ .../CH4/EX4.11/Ex4.11.R | 24 ++++ .../CH4/EX4.12/Ex4.12.R | 29 +++++ .../CH4/EX4.13/Ex4.13.R | 37 ++++++ .../CH4/EX4.14/Ex4.14.R | 29 +++++ .../CH4/EX4.15/Ex4.15.R | 22 ++++ .../CH4/EX4.16/Ex4.16.R | 19 +++ .../CH4/EX4.17/Ex4.17.R | 21 +++ .../CH4/EX4.18/Ex4.18.R | 27 ++++ .../CH4/EX4.19/Ex4.19.R | 25 ++++ .../CH4/EX4.2/Ex4.2.R | 27 ++++ .../CH4/EX4.20/Ex4.20.R | 37 ++++++ .../CH4/EX4.21/Ex4.21.R | 26 ++++ .../CH4/EX4.3/Ex4.3.R | 34 +++++ .../CH4/EX4.4/Ex4.4.R | 18 +++ .../CH4/EX4.5/Ex4.5.R | 42 ++++++ .../CH4/EX4.6/Ex4.6.R | 41 ++++++ .../CH4/EX4.7/Ex4.7.R | 43 ++++++ .../CH4/EX4.8/Ex4.8.R | 42 ++++++ .../CH4/EX4.9/Ex4.9.R | 26 ++++ .../CH5/EX5.1/Ex5.1.R | 21 +++ .../CH5/EX5.10/Ex5.10.R | 40 ++++++ .../CH5/EX5.11/Ex5.11.R | 60 +++++++++ .../CH5/EX5.12/Ex5.12.R | 78 +++++++++++ .../CH5/EX5.13/Ex5.13.R | 28 ++++ .../CH5/EX5.14/Ex5.14.R | 20 +++ .../CH5/EX5.15/Ex5.15.R | 26 ++++ .../CH5/EX5.16/Ex5.16.R | 24 ++++ .../CH5/EX5.17/Ex5.17.R | 33 +++++ .../CH5/EX5.18/Ex5.18.R | 21 +++ .../CH5/EX5.19/Ex5.19.R | 23 ++++ .../CH5/EX5.2/Ex5.2.R | 38 ++++++ .../CH5/EX5.20/Ex5.20.R | 33 +++++ .../CH5/EX5.21/Ex5.21.R | 27 ++++ .../CH5/EX5.22/Ex5.22.R | 24 ++++ .../CH5/EX5.23/Ex5.23.R | 25 ++++ .../CH5/EX5.24/Ex5.24.R | 36 +++++ .../CH5/EX5.3/Ex5.3.R | 64 +++++++++ .../CH5/EX5.4/Ex5.4.R | 19 +++ .../CH5/EX5.5/Ex5.5.R | 20 +++ .../CH5/EX5.6/Ex5.6.R | 21 +++ .../CH5/EX5.7/Ex5.7.R | 21 +++ .../CH5/EX5.8/Ex5.8.R | 54 ++++++++ .../CH5/EX5.9/Ex5.9.R | 25 ++++ .../CH6/EX6.1/Ex6.1.R | 29 +++++ .../CH6/EX6.10/Ex6.10.R | 47 +++++++ .../CH6/EX6.11/Ex6.11.R | 32 +++++ .../CH6/EX6.12/Ex6.12.R | 36 +++++ .../CH6/EX6.13/Ex6.13.R | 41 ++++++ .../CH6/EX6.14/Ex6.14.R | 25 ++++ .../CH6/EX6.15/Ex6.15.R | 28 ++++ .../CH6/EX6.16/Ex6.16.R | 55 ++++++++ .../CH6/EX6.17/Ex6.17.R | 41 ++++++ .../CH6/EX6.18/Ex6.18.R | 37 ++++++ .../CH6/EX6.19/Ex6.19.R | 29 +++++ .../CH6/EX6.2/Ex6.2.R | 18 +++ .../CH6/EX6.20/Ex6.20.R | 35 +++++ .../CH6/EX6.21/Ex6.21.R | 37 ++++++ .../CH6/EX6.22/Ex6.22.R | 21 +++ .../CH6/EX6.23/Ex6.23.R | 31 +++++ .../CH6/EX6.3/Ex6.3.R | 21 +++ .../CH6/EX6.4/Ex6.4.R | 27 ++++ .../CH6/EX6.5/Ex6.5.R | 43 ++++++ .../CH6/EX6.6/Ex6.6.R | 30 +++++ .../CH6/EX6.7/Ex6.7.R | 34 +++++ .../CH6/EX6.8/Ex6.8.R | 35 +++++ .../CH6/EX6.9/Ex6.9.R | 43 ++++++ .../CH7/EX7.1/Ex7.1.R | 30 +++++ .../CH7/EX7.10/Ex7.10.R | 61 +++++++++ .../CH7/EX7.11/Ex7.11.R | 63 +++++++++ .../CH7/EX7.12/Ex7.12.R | 57 ++++++++ .../CH7/EX7.13/Ex7.13.R | 25 ++++ .../CH7/EX7.14/Ex7.14.R | 42 ++++++ .../CH7/EX7.2/Ex7.2.R | 52 ++++++++ .../CH7/EX7.3/Ex7.3.R | 102 +++++++++++++++ .../CH7/EX7.4/Ex7.4.R | 98 ++++++++++++++ .../CH7/EX7.5/Ex7.5.R | 47 +++++++ .../CH7/EX7.6/Ex7.6.R | 37 ++++++ .../CH7/EX7.7/Ex7.7.R | 37 ++++++ .../CH7/EX7.8/Ex7.8.R | 35 +++++ .../CH7/EX7.9/Ex7.9.R | 29 +++++ .../README.txt | 18 +++ Linear_Algebra_by_Jim_Hefferon/CH1/EX1.11/Ex1_11.R | 18 +++ Linear_Algebra_by_Jim_Hefferon/CH1/EX1.12/Ex1_12.R | 17 +++ Linear_Algebra_by_Jim_Hefferon/CH1/EX1.13/Ex1_13.R | 18 +++ Linear_Algebra_by_Jim_Hefferon/CH1/EX1.3/Ex1_3.R | 6 + Linear_Algebra_by_Jim_Hefferon/CH1/EX1.4/Ex1_4.R | 22 ++++ Linear_Algebra_by_Jim_Hefferon/CH1/EX1.7/Ex1_7.R | 20 +++ Linear_Algebra_by_Jim_Hefferon/CH1/EX1.8/Ex1_8.R | 17 +++ Linear_Algebra_by_Jim_Hefferon/CH1/EX1.9/Ex1_9.R | 21 +++ Linear_Algebra_by_Jim_Hefferon/CH1/EX2.1/Ex1_2_1.R | 20 +++ .../CH1/EX2.12/Ex1_2_12.R | 7 + Linear_Algebra_by_Jim_Hefferon/CH1/EX2.3/Ex1_2_3.R | 20 +++ Linear_Algebra_by_Jim_Hefferon/CH1/EX2.5/Ex1_2_5.R | 19 +++ Linear_Algebra_by_Jim_Hefferon/CH1/EX2.7/Ex1_2_7.R | 22 ++++ Linear_Algebra_by_Jim_Hefferon/CH1/EX3.3/Ex1_3_3.R | 24 ++++ Linear_Algebra_by_Jim_Hefferon/CH1/EX3.5/Ex1_3_5.R | 18 +++ .../CH2/EX1.16/Ex2_1_16.R | 16 +++ Linear_Algebra_by_Jim_Hefferon/CH2/EX1.6/Ex2_1_6.R | 19 +++ Linear_Algebra_by_Jim_Hefferon/CH2/EX1.9/Ex2_1_9.R | 8 ++ .../CH2/EX3.10/Ex2_3_10.R | 13 ++ Linear_Algebra_by_Jim_Hefferon/CH2/EX3.2/Ex2_3_2.R | 18 +++ Linear_Algebra_by_Jim_Hefferon/CH2/EX3.5/Ex2_3_5.R | 20 +++ Linear_Algebra_by_Jim_Hefferon/CH2/EX3.7/Ex2_3_7.R | 20 +++ Linear_Algebra_by_Jim_Hefferon/CH2/EX3.9/Ex2_3_9.R | 18 +++ Linear_Algebra_by_Jim_Hefferon/CH3/EX1.1/Ex3_1_1.R | 13 ++ .../CH3/EX1.11/Ex3_1_11.R | 7 + Linear_Algebra_by_Jim_Hefferon/CH3/EX1.9/Ex3_1_9.R | 8 ++ .../CH3/EX2.10/Ex3_2_10.R | 13 ++ .../CH3/EX2.11/Ex3_2_11.R | 4 + Linear_Algebra_by_Jim_Hefferon/CH3/EX2.5/Ex3_2_5.R | 14 ++ .../CH3/EX3.1.11/Ex3_3_1_11.R | 11 ++ .../CH3/EX4.1.1/Ex3_4_1_1.R | 7 + .../CH3/EX4.1.2/Ex3_4_1_2.R | 7 + .../CH3/EX4.2.4/Ex3_4_2_4.R | 4 + .../CH3/EX4.2.5/Ex3_4_2_5.R | 4 + .../CH3/EX4.2.6/Ex3_4_2_6.R | 4 + .../CH3/EX4.3.15/Ex3_4_3_15.R | 8 ++ .../CH3/EX4.4.9/Ex3_4_4_9.R | 15 +++ .../CH4/EX1.10/Ex4_1_10.R | 15 +++ Linear_Algebra_by_Jim_Hefferon/CH4/EX1.4/Ex4_1_4.R | 14 ++ Linear_Algebra_by_Jim_Hefferon/CH4/EX1.6/Ex4_1_6.R | 17 +++ Linear_Algebra_by_Jim_Hefferon/CH4/EX1.7/Ex4_1_7.R | 13 ++ Linear_Algebra_by_Jim_Hefferon/CH4/EX2.5/Ex4_2_5.R | 20 +++ Linear_Algebra_by_Jim_Hefferon/CH4/EX2.6/Ex4_2_6.R | 16 +++ Linear_Algebra_by_Jim_Hefferon/CH4/EX3.1/Ex4_3_1.R | 9 ++ Linear_Algebra_by_Jim_Hefferon/CH4/EX3.4/Ex4_3_4.R | 11 ++ Linear_Algebra_by_Jim_Hefferon/CH5/EX1.3/Ex5_1_3.R | 12 ++ .../CH5/EX2.10/Ex5_2_10.R | 16 +++ .../CH5/EX2.17/Ex5_2_17.R | 21 +++ .../CH5/EX2.18/Ex5_2_18.R | 20 +++ .../CH5/EX2.2.2/Ex5_2_2_2.R | 7 + Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2/Ex5_2_2.R | 12 ++ Linear_Algebra_by_Jim_Hefferon/CH5/EX2.4/Ex5_2_4.R | 15 +++ .../CH5/EX3.19/Ex5_3_19.R | 4 + Linear_Algebra_by_Jim_Hefferon/CH5/EX3.6/Ex5_3_6.R | 5 + Linear_Algebra_by_Jim_Hefferon/README.txt | 18 +++ .../CH1/EX1.1/EX1_1.zip | Bin 0 -> 509 bytes .../CH1/EX1.12/EX1_12.zip | Bin 0 -> 395 bytes .../CH1/EX1.13/EX1_13.zip | Bin 0 -> 489 bytes .../CH1/EX1.16/EX1_16.zip | Bin 0 -> 593 bytes .../CH1/EX1.2/EX1_2.zip | Bin 0 -> 385 bytes .../CH1/EX1.20/EX1_20.zip | Bin 0 -> 501 bytes .../CH1/EX1.22/EX1_22.zip | Bin 0 -> 454 bytes .../CH1/EX1.30/EX1_30.zip | Bin 0 -> 333 bytes .../CH1/EX1.31/EX1_31.zip | Bin 0 -> 383 bytes .../CH1/EX1.32/EX1_32.zip | Bin 0 -> 424 bytes .../CH1/EX1.4/EX1_4.zip | Bin 0 -> 507 bytes .../CH2/EX2.1/EX2_1.zip | Bin 0 -> 555 bytes .../CH2/EX2.18/EX2_18.zip | Bin 0 -> 448 bytes .../CH2/EX2.20/EX2_20.zip | Bin 0 -> 518 bytes .../CH2/EX2.21/EX2_21.zip | Bin 0 -> 457 bytes .../CH2/EX2.24/EX2_24.zip | Bin 0 -> 400 bytes .../CH2/EX2.26/EX2_26.zip | Bin 0 -> 361 bytes .../CH2/EX2.3/EX2_3.zip | Bin 0 -> 390 bytes .../CH2/EX2.36/EX2_36.zip | Bin 0 -> 422 bytes .../CH2/EX2.4/EX2_4.zip | Bin 0 -> 395 bytes .../CH2/EX2.5/EX2_5.zip | Bin 0 -> 508 bytes .../CH3/EX3.1/EX3_1.zip | Bin 0 -> 511 bytes .../CH3/EX3.10.a/EX3_10_(a).zip | Bin 0 -> 434 bytes .../CH3/EX3.10.c/EX3_10_(c).zip | Bin 0 -> 434 bytes .../CH3/EX3.13/EX3_13.zip | Bin 0 -> 436 bytes .../CH3/EX3.14/EX3_14.zip | Bin 0 -> 444 bytes .../CH3/EX3.2/EX3_2.zip | Bin 0 -> 458 bytes .../CH3/EX3.3/EX3_3.zip | Bin 0 -> 355 bytes .../CH3/EX3.4/EX3_4.zip | Bin 0 -> 360 bytes .../CH3/EX3.8/EX3_8.zip | Bin 0 -> 376 bytes .../CH4/EX4.1/EX4_1.zip | Bin 0 -> 424 bytes .../CH4/EX4.2/EX4_2.zip | Bin 0 -> 325 bytes .../CH4/EX4.3/EX4_3.zip | Bin 0 -> 326 bytes .../CH4/EX4.4/EX4_4.zip | Bin 0 -> 333 bytes .../CH4/EX4.6/EX4_6.zip | Bin 0 -> 445 bytes .../CH4/EX4.7/EX4_7.zip | Bin 0 -> 367 bytes .../CH4/EX4.8/EX4_8.zip | Bin 0 -> 507 bytes .../CH4/EX4.9/EX4_9.zip | Bin 0 -> 433 bytes .../CH5/EX5.1/EX5_1.zip | Bin 0 -> 417 bytes .../CH5/EX5.10/EX5_10.zip | Bin 0 -> 474 bytes .../CH5/EX5.12/EX5_12.zip | Bin 0 -> 485 bytes .../CH5/EX5.4/EX5_4.zip | Bin 0 -> 352 bytes .../CH5/EX5.5/EX5_5.zip | Bin 0 -> 359 bytes .../CH5/EX5.6/EX5_6.zip | Bin 0 -> 433 bytes .../CH5/EX5.8/EX5_8.zip | Bin 0 -> 385 bytes .../CH5/EX5.9/EX5_9.zip | Bin 0 -> 425 bytes .../CH6/EX6.23/EX6_23.zip | Bin 0 -> 478 bytes .../CH6/EX6.24/EX6_24.zip | Bin 0 -> 437 bytes .../CH6/EX6.25/EX6_25.zip | Bin 0 -> 422 bytes .../CH6/EX6.27/EX6_27.zip | Bin 0 -> 427 bytes .../CH6/EX6.31/EX6_31.zip | Bin 0 -> 535 bytes .../CH6/EX6.34/EX6_34.zip | Bin 0 -> 554 bytes .../CH6/EX6.37/EX6_37.zip | Bin 0 -> 559 bytes .../CH6/EX6.38/EX6_38.zip | Bin 0 -> 592 bytes .../CH6/EX6.4/EX6_4.zip | Bin 0 -> 392 bytes .../CH6/EX6.40/EX6_40.zip | Bin 0 -> 622 bytes .../CH6/EX6.41/EX6_41.zip | Bin 0 -> 775 bytes .../CH6/EX6.8/EX6_8.zip | Bin 0 -> 459 bytes .../CH7/EX7.10/EX7_10.zip | Bin 0 -> 512 bytes .../CH7/EX7.8/EX7_8.zip | Bin 0 -> 524 bytes .../CH7/EX7.9/EX7_9.zip | Bin 0 -> 517 bytes .../CH1/EX1.1/Ex1_1.zip | Bin 0 -> 347 bytes .../CH1/EX1.10/Ex1_10.zip | Bin 0 -> 497 bytes .../CH1/EX1.11/Ex1_11.zip | Bin 0 -> 511 bytes .../CH1/EX1.12/Ex1_12.zip | Bin 0 -> 546 bytes .../CH1/EX1.13/Ex1_13.zip | Bin 0 -> 374 bytes .../CH1/EX1.14/Ex1_14.zip | Bin 0 -> 374 bytes .../CH1/EX1.15/Ex1_15.zip | Bin 0 -> 368 bytes .../CH1/EX1.2/Ex1_2.zip | Bin 0 -> 433 bytes .../CH1/EX1.3/Ex1_3.zip | Bin 0 -> 436 bytes .../CH1/EX1.4/Ex1_4.zip | Bin 0 -> 478 bytes .../CH1/EX1.5/Ex1_5.zip | Bin 0 -> 364 bytes .../CH1/EX1.6/Ex1_6.zip | Bin 0 -> 338 bytes .../CH1/EX1.7/Ex1_7.zip | Bin 0 -> 361 bytes .../CH1/EX1.8/Ex1_8.zip | Bin 0 -> 319 bytes .../CH1/EX1.9/Ex1_9.zip | Bin 0 -> 331 bytes .../CH2/EX2.1/Ex2_1.R | 16 +++ .../CH2/EX2.2/Ex2_2.R | 17 +++ .../CH2/EX2.3/Ex2_3.R | 17 +++ .../CH2/EX2.4/Ex2_4.R | 17 +++ .../CH2/EX2.5/Ex2_5.R | 17 +++ .../CH2/EX2.6/Ex2_6.R | 17 +++ .../CH2/EX2.7/Ex2_7.R | 24 ++++ .../CH3/EX3.1/Ex3_1.R | 10 ++ .../CH3/EX3.2/Ex3_2.R | 19 +++ .../CH3/EX3.3/Ex3_3.R | 10 ++ .../CH3/EX3.4/Ex3_4.R | 10 ++ .../CH3/EX3.5/Ex3_5.R | 21 +++ .../CH3/EX3.6/Ex3_6.R | 28 ++++ .../CH3/EX3.7/Ex3_7.R | 20 +++ .../CH4/EX4.1/Ex4_1.R | 18 +++ .../CH4/EX4.2/Ex4_2.R | 22 ++++ .../CH4/EX4.3/Ex4_3.R | 22 ++++ .../CH4/EX4.4/Ex4_4.R | 16 +++ .../CH4/EX4.5/Ex4_5.R | 15 +++ .../CH4/EX4.6/Ex4_6.R | 15 +++ .../CH5/EX5.1/Ex5_1.R | 24 ++++ .../CH5/EX5.2/Ex5_2.R | 31 +++++ .../CH6/EX6.1/Ex6_1.R | 35 +++++ .../CH8/EX8.1/Ex8_1.R | 13 ++ .../CH9/EX9.1/Ex9_1.R | 17 +++ .../CH9/EX9.2/Ex9_2.R | 17 +++ .../CH9/EX9.3/Ex9_3.R | 18 +++ .../CH9/EX9.4/Ex9_4.R | 14 ++ .../README.txt | 18 +++ .../CH10/EX10.1/EX10_1.R | 8 ++ .../CH10/EX10.10/EX10_10.R | 17 +++ .../CH10/EX10.11/EX10_11.R | 12 ++ .../CH10/EX10.12/EX10_12.R | 16 +++ .../CH10/EX10.13/EX10_13.R | 17 +++ .../CH10/EX10.15/EX10_15.R | 14 ++ .../CH10/EX10.2/EX10_2.R | 7 + .../CH10/EX10.3/EX10_3.R | 8 ++ .../CH10/EX10.4/EX10_4.R | 7 + .../CH10/EX10.5/EX10_5.R | 11 ++ .../CH10/EX10.6/EX10_6.R | 10 ++ .../CH10/EX10.7/EX10_7.R | 14 ++ .../CH10/EX10.8/EX10_8.R | 15 +++ .../CH10/EX10.9/EX10_9.R | 16 +++ .../CH11/EX11.1/EX11_1.R | 10 ++ .../CH11/EX11.10/EX11_10.R | 15 +++ .../CH11/EX11.11/EX11_11.R | 13 ++ .../CH11/EX11.12/EX11_12.R | 15 +++ .../CH11/EX11.14/EX11_14.R | 6 + .../CH11/EX11.15/EX11_15.R | 13 ++ .../CH11/EX11.17/EX11_17.R | 12 ++ .../CH11/EX11.18/EX11_18.R | 15 +++ .../CH11/EX11.19/EX11_19.R | 18 +++ .../CH11/EX11.2/EX11_2.R | 13 ++ .../CH11/EX11.20/EX11_20.R | 24 ++++ .../CH11/EX11.21/EX11_21.R | 13 ++ .../CH11/EX11.3/EX11_3.R | 23 ++++ .../CH11/EX11.5/EX11_5.R | 9 ++ .../CH11/EX11.6/EX11_6.R | 16 +++ .../CH11/EX11.7/EX11_7.R | 39 ++++++ .../CH11/EX11.8/EX11_8.R | 15 +++ .../CH11/EX11.9/EX11_9.R | 10 ++ .../CH12/EX12.1/EX12_1.R | 20 +++ .../CH12/EX12.10/EX12_10.R | 11 ++ .../CH12/EX12.11/12_11.R | 14 ++ .../CH12/EX12.2/EX12_2.R | 16 +++ .../CH12/EX12.3/EX12_3.R | 24 ++++ .../CH12/EX12.4/EX12_4.R | 30 +++++ .../CH12/EX12.5/EX12_5.R | 24 ++++ .../CH12/EX12.6/EX12_6.R | 19 +++ .../CH12/EX12.7/EX12_7.R | 24 ++++ .../CH12/EX12.8/EX12_8.R | 29 +++++ .../CH12/EX12.9/EX12_9.R | 25 ++++ .../CH13/EX13.1/EX13_1.R | 27 ++++ .../CH13/EX13.2/EX13_2.R | 27 ++++ .../CH13/EX13.3/EX13_3.R | 24 ++++ .../CH13/EX13.4/EX13_4.R | 19 +++ .../CH14/EX14.1/EX14_1.R | 13 ++ .../CH14/EX14.2/EX14_2.R | 28 ++++ .../CH14/EX14.3/EX14_3.R | 24 ++++ .../CH14/EX14.4/EX14_4.R | 16 +++ .../CH14/EX14.5/EX14_5.R | 14 ++ .../CH14/EX14.6/EX14_6.R | 13 ++ .../CH14/EX14.7/EX14_7.R | 23 ++++ .../CH14/EX14.8/EX14_8.R | 9 ++ .../CH14/EX14.9/EX14_9.R | 6 + .../CH15/EX15.2/EX15_2.R | 12 ++ .../CH15/EX15.3/EX15_3.R | 11 ++ .../CH15/EX15.4/EX15_4.R | 13 ++ .../CH16/EX16.1/EX16_1.R | 8 ++ .../CH16/EX16.2/EX16_2.R | 11 ++ .../CH16/EX16.3/EX16_3.R | 15 +++ .../CH16/EX16.4/EX16_4.R | 15 +++ .../CH2/EX2.1/EX2_1.R | 6 + .../CH2/EX2.11/EX2_11.R | 12 ++ .../CH2/EX2.12/EX2_12.R | 3 + .../CH2/EX2.13/EX2_13.R | 18 +++ .../CH2/EX2.14/EX2_14.R | 14 ++ .../CH2/EX2.15/EX2_15.R | 10 ++ .../CH2/EX2.16/EX2_16.R | 18 +++ .../CH2/EX2.18/EX2_18.R | 8 ++ .../CH2/EX2.19/EX2_19.R | 10 ++ .../CH2/EX2.2/EX2_2.R | 13 ++ .../CH2/EX2.3/EX2_3.R | 5 + .../CH2/EX2.4/EX2_4.R | 12 ++ .../CH2/EX2.6/EX2_6.R | 10 ++ .../CH2/EX2.7/EX2_7.R | 11 ++ .../CH2/EX2.8/EX2_8.R | 11 ++ .../CH2/EX2.9/EX2_9.R | 10 ++ .../CH3/EX3.1/EX3_1.R | 15 +++ .../CH3/EX3.11/EX3_11.R | 4 + .../CH3/EX3.13/EX3_13.R | 3 + .../CH3/EX3.14/EX3_14.R | 34 +++++ .../CH3/EX3.15/EX3_15.R | 15 +++ .../CH3/EX3.16/EX3_16.R | 7 + .../CH3/EX3.17/EX3_17.R | 6 + .../CH3/EX3.18/EX3_18.R | 6 + .../CH3/EX3.19/EX3_19.R | 10 ++ .../CH3/EX3.20/EX3_20.R | 7 + .../CH3/EX3.21/EX3_21.R | 7 + .../CH3/EX3.22/EX3_22.R | 9 ++ .../CH3/EX3.24/EX3_24.R | 8 ++ .../CH3/EX3.25/EX3_25.R | 11 ++ .../CH3/EX3.26/EX3_26.R | 7 + .../CH3/EX3.28/EX3_28.R | 12 ++ .../CH3/EX3.29/EX3_29.R | 20 +++ .../CH3/EX3.30/EX3_30.R | 12 ++ .../CH3/EX3.31/EX3_31.R | 21 +++ .../CH3/EX3.5/EX3_5.R | 4 + .../CH3/EX3.6/EX3_6.R | 8 ++ .../CH4/EX4.1/EX4_1.R | 35 +++++ .../CH4/EX4.10/EX4_10.R | 6 + .../CH4/EX4.11/EX4_11.R | 6 + .../CH4/EX4.12/EX4_12.R | 4 + .../CH4/EX4.13/EX4_13.R | 7 + .../CH4/EX4.14/EX4_14.R | 9 ++ .../CH4/EX4.15/EX4_15.R | 9 ++ .../CH4/EX4.16/EX4_16.R | 7 + .../CH4/EX4.17/EX4_17.R | 6 + .../CH4/EX4.18/EX4_18.R | 7 + .../CH4/EX4.19/EX4_19.R | 10 ++ .../CH4/EX4.20/EX4_20.R | 15 +++ .../CH4/EX4.21/EX4_21.R | 12 ++ .../CH4/EX4.22/EX4_22.R | 7 + .../CH4/EX4.24/EX4_24.R | 14 ++ .../CH4/EX4.25/EX4_25.R | 21 +++ .../CH4/EX4.26/EX4_26.R | 12 ++ .../CH4/EX4.27/EX4_27.R | 5 + .../CH4/EX4.3/EX4_3.R | 15 +++ .../CH4/EX4.4/EX4_4.R | 12 ++ .../CH4/EX4.5/EX4_5.R | 6 + .../CH4/EX4.6/EX4_6.R | 11 ++ .../CH4/EX4.7/EX4_7.R | 7 + .../CH4/EX4.8/EX4_8.R | 8 ++ .../CH4/EX4.9/EX4_9.R | 11 ++ .../CH5/EX5.1/EX5_1.R | 7 + .../CH5/EX5.10/EX5_10.R | 6 + .../CH5/EX5.11/EX5_11.R | 12 ++ .../CH5/EX5.12/EX5_12.R | 5 + .../CH5/EX5.13/EX5_13.R | 10 ++ .../CH5/EX5.14/EX5_14.R | 6 + .../CH5/EX5.15/EX5_15.R | 10 ++ .../CH5/EX5.16/EX5_16.R | 11 ++ .../CH5/EX5.17/EX5_17.R | 6 + .../CH5/EX5.18/EX5_18.R | 11 ++ .../CH5/EX5.19/EX5_19.R | 9 ++ .../CH5/EX5.2/EX5_2.R | 3 + .../CH5/EX5.20/EX5_20.R | 12 ++ .../CH5/EX5.21/EX5_21.R | 13 ++ .../CH5/EX5.22/EX5_22.R | 20 +++ .../CH5/EX5.23/EX5_23.R | 4 + .../CH5/EX5.3/EX5_3.R | 5 + .../CH5/EX5.31/EX5_31.R | 7 + .../CH5/EX5.4/EX5_4.R | 13 ++ .../CH5/EX5.42/EX5_42.R | 4 + .../CH5/EX5.43/EX5_43.R | 13 ++ .../CH5/EX5.44/EX5_44.R | 4 + .../CH5/EX5.45/EX5_45.R | 14 ++ .../CH5/EX5.5/EX5_5.R | 15 +++ .../CH5/EX5.6/EX5_6.R | 4 + .../CH5/EX5.7/EX5_7.R | 12 ++ .../CH5/EX5.8/EX5_8.R | 22 ++++ .../CH5/EX5.9/EX5_9.R | 12 ++ .../CH6/EX5.54/EX6_54.R | 10 ++ .../CH6/EX6.49/EX6_49.R | 6 + .../CH6/EX6.51/EX6_51.R | 12 ++ .../CH6/EX6.52/EX6_52.R | 13 ++ .../CH6/EX6.53/EX6_53.R | 11 ++ .../CH6/EX6.55/EX6_55.R | 8 ++ .../CH7/EX7.13/EX7_13.R | 9 ++ .../CH7/EX7.15/EX7_15.R | 10 ++ .../CH7/EX7.18/EX7_18.R | 10 ++ .../CH7/EX7.19/EX7_19.R | 15 +++ .../CH7/EX7.2/EX7_2.R | 8 ++ .../CH7/EX7.20/EX7_20.R | 14 ++ .../CH7/EX7.22/EX7_22.R | 14 ++ .../CH7/EX7.23/EX7_23.R | 15 +++ .../CH7/EX7.24/EX7_24.R | 10 ++ .../CH7/EX7.3/EX7_3.R | 7 + .../CH7/EX7.4/EX7_4.R | 8 ++ .../CH7/EX7.5/EX7_5.R | 7 + .../CH7/EX7.6/EX7_6.R | 8 ++ .../CH7/EX7.7/EX7_7.R | 11 ++ .../CH7/EX7.8/EX7_8.R | 10 ++ .../CH8/EX8.10/EX8_10.R | 16 +++ .../CH8/EX8.11/EX8_11.R | 13 ++ .../CH8/EX8.12/EX8_12.R | 13 ++ .../CH8/EX8.13/EX8_13.R | 8 ++ .../CH8/EX8.14/EX8_14.R | 8 ++ .../CH8/EX8.3/EX8_3.R | 21 +++ .../CH8/EX8.4/EX8_4.R | 21 +++ .../CH8/EX8.5/EX8_5.R | 19 +++ .../CH8/EX8.6/EX8_6.R | 8 ++ .../CH8/EX8.7/EX8_7.R | 14 ++ .../CH8/EX8.8/EX8_8.R | 16 +++ .../CH8/EX8.9/EX8_9.R | 24 ++++ .../CH9/EX9.1/EX9_1.R | 9 ++ .../CH9/EX9.2/EX9_2.R | 20 +++ .../CH9/EX9.3/EX9_3.R | 15 +++ .../CH9/EX9.4/EX9_4.R | 12 ++ .../CH9/EX9.5/EX9_5.R | 13 ++ .../CH9/EX9.6/EX9_6.R | 11 ++ .../README.txt | 18 +++ .../CH1/EX1.1/Ex1_1.R | 14 ++ .../CH14/EX14.1/Ex14_1.R | 21 +++ .../CH14/EX14.2/Ex14_2.R | 11 ++ .../CH14/EX14.3/Ex14_3.R | 11 ++ .../CH14/EX14.4/Ex14_4.R | 28 ++++ .../CH15/EX15.1/Ex15_1.R | 13 ++ .../CH15/EX15.2/Ex15_2.R | 23 ++++ .../CH15/EX15.3/Ex15_3.R | 27 ++++ .../CH15/EX15.4/Ex15_4.R | 37 ++++++ .../CH15/EX15.5/Ex15_5.R | 12 ++ .../CH15/EX15.6/Ex15_6.R | 9 ++ .../CH15/EX15.7/Ex15_7.R | 7 + .../CH17/EX17.3.a/Ex17_3_a.R | 17 +++ .../CH17/EX17.3.b/Ex17_3_b.R | 17 +++ .../CH18/EX18.5/Ex18_5.R | 26 ++++ .../CH19/EX19.1/Ex19_1.R | 34 +++++ .../CH19/EX19.2/Ex19_2.R | 13 ++ .../CH19/EX19.4/Ex19_4.R | 14 ++ .../CH19/EX19.5/Ex19_5.R | 22 ++++ .../CH19/EX19.6/Ex19_6.R | 17 +++ .../CH21/EX21.1/Ex21_1.R | 28 ++++ .../CH21/EX21.2/Ex21_2.R | 31 +++++ .../CH21/EX21.3/Ex21_3.R | 145 +++++++++++++++++++++ .../CH21/EX21.4/Ex21_4.R | 32 +++++ .../CH21/EX21.5/Ex21_5.R | 45 +++++++ .../CH21/EX21.6/Ex21_6.R | 54 ++++++++ .../CH21/EX21.7/Ex21_7.R | 20 +++ .../CH21/EX21.8/Ex21_8.R | 23 ++++ .../CH21/EX21.9/Ex21_9.R | 35 +++++ .../CH23/EX23.4/Ex23_4.R | 32 +++++ .../CH23/EX23.5/Ex23_5.R | 9 ++ .../CH25/EX25.11/Ex25_11.R | 44 +++++++ .../CH25/EX25.14/Ex25_14.R | 10 ++ .../CH25/EX25.4/Ex25_4.R | 26 ++++ .../CH26/EX26.1/Ex26_1.R | 41 ++++++ .../CH27/EX27.11/Ex27_11.R | 17 +++ .../CH27/EX27.3/Ex27_3.R | 7 + .../CH27/EX27.4/Ex27_4.R | 24 ++++ .../CH27/EX27.5/Ex27_5.R | 12 ++ .../CH27/EX27.6/Ex27_6.R | 66 ++++++++++ .../CH27/EX27.7/Ex27_7.R | 23 ++++ .../CH27/EX27.8/Ex27_8.R | 24 ++++ .../CH27/EX27.9/Ex27_9.R | 17 +++ .../CH3/EX3.1/Ex3_1.R | 26 ++++ .../CH3/EX3.2/Ex3_2.R | 25 ++++ .../CH3/EX3.3/Ex3_3.R | 7 + .../CH3/EX3.4/Ex3_4.R | 9 ++ .../CH3/EX3.5/Ex3_5.R | 7 + .../CH3/EX3.6/Ex3_6.R | 13 ++ .../CH3/EX3.7/Ex3_7.R | 8 ++ .../CH3/EX3.8/Ex3_8.R | 19 +++ .../CH31/EX31.1/Ex31_1.R | 24 ++++ .../CH31/EX31.2/Ex31_2.R | 18 +++ .../CH4/EX4.1/Ex4_1.R | 91 +++++++++++++ .../CH4/EX4.2/Ex4_2.R | 113 ++++++++++++++++ .../CH4/EX4.4/Ex4_4.R | 51 ++++++++ .../CH4/EX4.5/Ex4_5.R | 11 ++ .../CH4/EX4.6/Ex4_6.R | 56 ++++++++ .../CH4/EX4.7/Ex4_7.R | 23 ++++ .../CH5/EX5.1/Ex5_1.R | 25 ++++ .../CH5/EX5.2/Ex5_2.R | 14 ++ .../CH5/EX5.3/Ex5_3.R | 38 ++++++ .../CH5/EX5.4/Ex5_4.R | 57 ++++++++ .../CH5/EX5.5/Ex5_5.R | 38 ++++++ .../CH5/EX5.6/Ex5_6.R | 74 +++++++++++ .../CH6/EX6.11/Ex6_11.R | 23 ++++ .../CH7/EX7.1/Ex7_1.R | 18 +++ .../CH7/EX7.2/Ex7_2.R | 36 +++++ .../CH7/EX7.3/Ex7_3.R | 41 ++++++ .../CH7/EX7.4/Ex7_4.R | 22 ++++ .../CH7/EX7.5/Ex7_5.R | 16 +++ .../CH7/EX7.6/Ex7_6.R | 6 + .../CH7/EX7.7/Ex7_7.R | 17 +++ .../CH7/EX7.8/Ex7_8.R | 22 ++++ .../CH9/EX9.11/Ex9_11.R | 4 + .../CH9/EX9.2/Ex9_2.R | 12 ++ .../CH9/EX9.3/Ex9_3.R | 20 +++ .../CH9/EX9.4/Ex9_4.R | 13 ++ .../CH9/EX9.5/Ex9_5.R | 24 ++++ .../CH9/EX9.6/Ex9_6.R | 13 ++ .../CH9/EX9.7/Ex9_7.R | 15 +++ .../CH9/EX9.8/Ex9_8.R | 14 ++ .../README.txt | 18 +++ .../CH10/EX10.4/Ex10_4.R | 61 +++++++++ .../CH2/EX2.10/Ex2_10.R | 111 ++++++++++++++++ .../CH2/EX2.24/Ex2_24.R | 8 ++ .../CH2/EX2.7/Ex2_7.R | 21 +++ .../CH2/EX2.8/Ex2_8.R | 10 ++ .../CH2/EX2.9/Ex2_9.R | 42 ++++++ .../CH3/EX3.11/Ex3_11.R | 10 ++ .../CH3/EX3.12/Ex3_12.R | 6 + .../CH3/EX3.13/Ex3_13.R | 30 +++++ .../CH3/EX3.14/Ex3_14.R | 32 +++++ .../CH3/EX3.15/Ex3_15.R | 16 +++ .../CH3/EX3.16/Ex3_16.R | 6 + .../CH3/EX3.17/Ex3_17.R | 26 ++++ .../CH3/EX3.18/Ex3_18.R | 46 +++++++ .../CH3/EX3.2/Ex3_2.R | 5 + .../CH3/EX3.22/Ex3_22.R | 15 +++ .../CH3/EX3.23/Ex3_23.R | 9 ++ .../CH3/EX3.24/Ex3_24.R | 9 ++ .../CH3/EX3.4/Ex3_4.R | 4 + .../CH3/EX3.6/Ex3_6.R | 9 ++ .../CH3/EX3.7/Ex3_7.R | 5 + .../CH3/EX3.8/Ex3_8.R | 19 +++ .../CH4/EX4.1/Ex4_1.R | 12 ++ .../CH4/EX4.10/Ex4_10.R | 28 ++++ .../CH4/EX4.11/Ex4_11.R | 22 ++++ .../CH4/EX4.12/Ex4_12.R | 93 +++++++++++++ .../CH4/EX4.14/Ex4_14.R | 35 +++++ .../CH4/EX4.15/Ex4_15.R | 69 ++++++++++ .../CH4/EX4.16/Ex4_16.R | 64 +++++++++ .../CH4/EX4.17/Ex4_17.R | 92 +++++++++++++ .../CH4/EX4.18/Ex4_18.R | 23 ++++ .../CH4/EX4.19/Ex4_19.R | 6 + .../CH4/EX4.2/Ex4_2.R | 7 + .../CH4/EX4.20/Ex4_20.R | 47 +++++++ .../CH4/EX4.3/Ex4_3.R | 19 +++ .../CH4/EX4.4/Ex4_4.R | 18 +++ .../CH4/EX4.5/Ex4_5.R | 24 ++++ .../CH4/EX4.6/Ex4_6.R | 18 +++ .../CH4/EX4.8/Ex4_8.R | 28 ++++ .../CH4/EX4.9/Ex4_9.R | 20 +++ .../CH5/EX5.1/Ex5_1.R | 63 +++++++++ .../CH5/EX5.3/Ex5_3.R | 33 +++++ .../CH5/EX5.4/Ex5_4.R | 31 +++++ .../CH6/EX6.1/Ex6_1.R | 26 ++++ .../CH6/EX6.12/Ex6_12.R | 13 ++ .../CH6/EX6.3/Ex6_3.R | 6 + .../CH6/EX6.5/Ex6_5.R | 10 ++ .../CH6/EX6.8/Ex6_8.R | 7 + .../CH7/EX7.1/Ex7_1.R | 20 +++ .../CH7/EX7.2/Page_409_CompLatticeBLS.R | 31 +++++ ...age_411_Luenberger_Investment Science_Ex13_11.R | 24 ++++ .../CH7/EX7.4/Page_413_SmartEurLattice.R | 57 ++++++++ .../CH7/EX7.5/Page_416_AmPutLattice.R | 32 +++++ .../CH7/EX7.6/Page_420_AmSpreadLattice.R | 43 ++++++ .../CH7/EX7.7/Page_424_EuCallTrinomial.R | 37 ++++++ .../CH8/EX8.1/Page_433_AssetPaths.R | 18 +++ .../CH8/EX8.10/Page_449_D0PutMCCond.R | 63 +++++++++ .../CH8/EX8.11/Page_453_DOPutMCCondIS.R | 76 +++++++++++ .../CH8/EX8.12/Page_455_AsianMC.R | 37 ++++++ .../CH8/EX8.13/Page_456_AsianMCCV.R | 52 ++++++++ .../CH8/EX8.14/Page_459_AsianMCGeoCV.R | 69 ++++++++++ .../CH8/EX8.15/Page_460_AsianHalton.R | 86 ++++++++++++ .../CH8/EX8.16/Page_464_GBMHaltonBridge.R | 121 +++++++++++++++++ .../CH8/EX8.17/Page_470_BlsDeltaMCNaive.R | 31 +++++ .../CH8/EX8.18/Page_472_BlsDeltaMCPath.R | 30 +++++ .../CH8/EX8.2/Page_434_AssetPathsV.R | 39 ++++++ .../CH8/EX8.3/Page_436_StopLoss.R | 63 +++++++++ .../CH8/EX8.4/Page_437_StopLossV.R | 83 ++++++++++++ .../CH8/EX8.5/Page_438_DeltaHedging.R | 87 +++++++++++++ .../CH8/EX8.6/Page_442_WienerBridge.R | 54 ++++++++ .../CH8/EX8.7/Page_444_Exchange.R | 17 +++ .../CH8/EX8.8/Page_445_ExchangeMC.R | 32 +++++ .../CH8/EX8.9/Page_446_DOPutMC.R | 41 ++++++ .../CH9/EX9.3/Page_479_EuPutExpl.R | 36 +++++ .../CH9/EX9.4/Page_484_EuPutImpl.R | 38 ++++++ .../CH9/EX9.5/Page_487_DOPutCK.R | 36 +++++ .../README.txt | 18 +++ .../CH10/EX10.1/Ex10_1.R | 30 +++++ .../CH11/EX11.5/Ex11_5.R | 39 ++++++ .../CH11/EX11.6/Ex11_6.R | 25 ++++ .../CH11/EX11.8/Ex11_8.R | 40 ++++++ .../CH12/EX12.10/Ex12_10.R | 22 ++++ .../CH12/EX12.3/Ex12_3.R | 39 ++++++ .../CH12/EX12.5/Ex12_5.R | 40 ++++++ .../CH12/EX12.6/Ex12_6.R | 20 +++ .../CH12/EX12.7/Ex12_7.R | 16 +++ .../CH12/EX12.8/Ex12_8.R | 17 +++ .../CH12/EX12.9/Ex12_9.R | 20 +++ .../CH13/EX13.10/Ex13_10.R | 53 ++++++++ .../CH13/EX13.4/Ex13_4.R | 40 ++++++ .../CH13/EX13.6/Ex13_6.R | 43 ++++++ .../CH13/EX13.7/Ex13_7.R | 21 +++ .../CH13/EX13.8/Ex13_8.R | 30 +++++ .../CH14/EX14.6/Ex14_6.R | 25 ++++ .../CH3/EX3.1/Ex3_1.R | 32 +++++ .../CH3/EX3.10/Ex3_10.R | 12 ++ .../CH3/EX3.11/Ex3_11.R | 12 ++ .../CH3/EX3.12/Ex3_12.R | 18 +++ .../CH3/EX3.2/Ex3_2.R | 6 + .../CH3/EX3.4/Ex3_4.R | 8 ++ .../CH3/EX3.6/Ex3_6.R | 21 +++ .../CH3/EX3.8/Ex3_8.R | 12 ++ .../CH3/EX3.9/Ex3_9.R | 12 ++ .../CH4/EX4.10/Ex4_10.R | 35 +++++ .../CH4/EX4.3/Ex4_3.R | 29 +++++ .../CH4/EX4.4/Ex4_4.R | 17 +++ .../CH4/EX4.5/Ex4_5.R | 31 +++++ .../CH4/EX4.6/Ex4_6.R | 31 +++++ .../CH4/EX4.7/Ex4_7.R | 33 +++++ .../CH4/EX4.9/Ex4_9.R | 28 ++++ .../CH6/EX6.1/Ex6_1.R | 22 ++++ .../CH6/EX6.11/Ex6_11.R | 21 +++ .../CH6/EX6.12/Ex6_12.R | 46 +++++++ .../CH6/EX6.14/Ex6_14.R | 37 ++++++ .../CH6/EX6.15/Ex6_15.R | 22 ++++ .../CH6/EX6.16/Ex6_16.R | 48 +++++++ .../CH6/EX6.17/Ex6_17.R | 39 ++++++ .../CH6/EX6.4/Ex6_4.R | 41 ++++++ .../CH6/EX6.5/Ex6_5.R | 37 ++++++ .../CH6/EX6.7/Ex6_7.R | 54 ++++++++ .../CH7/EX7.1/Ex7_1.R | 12 ++ .../CH7/EX7.5/Ex7_5.R | 29 +++++ .../CH8/EX8.1/Ex8_1.R | 19 +++ .../CH8/EX8.2/Ex8_2.R | 19 +++ .../CH8/EX8.3/Ex8_3.R | 16 +++ .../CH9/EX9.1/Ex9_1.R | 40 ++++++ .../CH9/EX9.11/Ex9_11.R | 24 ++++ .../CH9/EX9.12/Ex9_12.R | 22 ++++ .../CH9/EX9.2/Ex9_2.R | 40 ++++++ .../CH9/EX9.3/Ex9_3.R | 29 +++++ .../CH9/EX9.4/Ex9_4.R | 38 ++++++ .../CH9/EX9.5/Ex9_5.R | 39 ++++++ .../CH9/EX9.8/Ex9_8.R | 58 +++++++++ .../CH9/EX9.9/Ex9_9.R | 61 +++++++++ .../CH10/EX10.3.1/10.3.1.R | 13 ++ .../CH10/EX10.3.2/10.3.2.R | 13 ++ .../CH10/EX10.4.1/10.4.1.R | 21 +++ .../CH11/EX11.1.1/11.1.1.R | 24 ++++ .../CH12/EX12.2.1/12.2.1.R | 19 +++ .../CH12/EX12.3.1/12.3.1.R | 20 +++ .../CH12/EX12.3.2/12.3.2.R | 25 ++++ .../CH12/EX12.4.1/12.4.1.R | 49 +++++++ .../CH13/EX13.1.1/13.1.1.R | 29 +++++ .../CH13/EX13.1.2/13.1.2.R | 9 ++ .../CH13/EX13.1.3/13.1.3.R | 13 ++ .../CH13/EX13.2.1/13.2.1.R | 12 ++ .../CH13/EX13.2.2/13.2.2.R | 23 ++++ .../CH13/EX13.3.1/13.3.1.R | 22 ++++ .../CH13/EX13.4.1/13.4.1.R | 13 ++ .../CH13/EX13.4.3/13.4.3.R | 24 ++++ .../CH14/EX14.1.1/14.1.1.R | 20 +++ .../CH14/EX14.2.1/14.2.1.R | 21 +++ .../CH15/EX15.2.1/15.2.1.R | 17 +++ .../CH15/EX15.3.1/15.3.1.R | 8 ++ .../CH15/EX15.3.2/15.3.2.R | 14 ++ .../CH15/EX15.4.1/15.4.1.R | 12 ++ .../CH15/EX15.4.2/15.4.2.R | 15 +++ .../CH15/EX15.5.1/15.5.1.R | 8 ++ .../CH15/EX15.6.1/15.6.1.R | 13 ++ .../CH16/EX16.4.1/16.4.1.R | 13 ++ .../CH16/EX16.4.2/16.4.2.R | 31 +++++ .../CH16/EX16.6.1/16.6.1.R | 55 ++++++++ .../CH16/EX16.6.2/16.6.2.R | 16 +++ .../CH16/EX16.6.4/16.6.4.R | 10 ++ .../CH16/EX16.6.5/16.6.5.R | 17 +++ .../CH16/EX16.6.6/16.6.6.R | 11 ++ .../CH16/EX16.6.7/16.6.7.R | 13 ++ .../CH16/EX16.6.8/16.6.8.R | 20 +++ .../CH16/EX16.7.1/16.7.1.R | 21 +++ .../CH16/EX16.9.1/16.9.1.R | 35 +++++ .../CH16/EX16.9.2/16.9.2.R | 17 +++ .../CH16/EX16.9.3/16.9.3.R | 20 +++ .../CH17/EX17.1.1/17.1.1.R | 23 ++++ .../CH17/EX17.3.3/17.3.3.R | 10 ++ .../CH17/EX17.4.1/17.4.1.R | 19 +++ .../CH18/EX18.1.1/18.1.1.R | 19 +++ .../CH18/EX18.1.3/18.1.3.R | 9 ++ .../CH2/EX2.2.1/2.2.1.R | 56 ++++++++ .../CH2/EX2.2.2/2.2.2.R | 50 +++++++ .../CH2/EX2.4.1/2.4.1.R | 26 ++++ .../CH2/EX2.4.2/2.4.2.R | 43 ++++++ .../CH2/EX2.4.3/2.4.3.R | 35 +++++ .../CH2/EX2.4.4/2.4.4.R | 42 ++++++ .../CH2/EX2.4.5/2.4.5.R | 36 +++++ .../CH2/EX2.4.6/2.4.6.R | 38 ++++++ .../CH2/EX2.4.7/2.4.7.R | 45 +++++++ .../CH3/EX3.2.1/3.2.1.R | 51 ++++++++ .../CH3/EX3.3.1/3.3.1.R | 28 ++++ .../CH3/EX3.4.1/3.4.1.R | 22 ++++ .../CH3/EX3.4.2/3.4.2.R | 32 +++++ .../CH3/EX3.5.1/3.5.1.R | 19 +++ .../CH3/EX3.5.2/3.5.2.R | 19 +++ .../CH3/EX3.5.3/3.5.3.R | 18 +++ .../CH3/EX3.5.4/3.5.4.R | 18 +++ .../CH3/EX3.6.1/3.6.1.R | 26 ++++ .../CH3/EX3.6.2/3.6.2.R | 22 ++++ .../CH3/EX3.6.3/3.6.3.R | 28 ++++ .../CH4/EX4.2.1/4.2.1.R | 22 ++++ .../CH4/EX4.2.2/4.2.2.R | 16 +++ .../CH4/EX4.2.3/4.2.3.R | 20 +++ .../CH4/EX4.3.1/4.3.1.R | 29 +++++ .../CH4/EX4.3.2/4.3.2.R | 23 ++++ .../CH4/EX4.4.1/4.4.1.R | 101 ++++++++++++++ .../CH4/EX4.5.1/4.5.1.R | 13 ++ .../CH4/EX4.5.2/4.5.2.R | 15 +++ .../CH4/EX4.5.3/4.5.3.R | 51 ++++++++ .../CH4/EX4.5.4/4.5.4.R | 11 ++ .../CH5/EX5.1.1/5.1.1.R | 18 +++ .../CH5/EX5.1.2/5.1.2.R | 33 +++++ .../CH5/EX5.2.1/5.2.1.R | 17 +++ .../CH5/EX5.2.2/5.2.2.R | 29 +++++ .../CH5/EX5.3.1/5.3.1.R | 16 +++ .../CH5/EX5.3.2/5.3.2.R | 33 +++++ .../CH5/EX5.3.3/5.3.3.R | 41 ++++++ .../CH5/EX5.3.5/5.3.5.R | 15 +++ .../CH5/EX5.4.1/5.4.1.R | 32 +++++ .../CH5/EX5.4.2/5.4.2.R | 45 +++++++ .../CH6/EX6.2.1/6.2.1.R | 31 +++++ .../CH6/EX6.3.1/6.3.1.R | 34 +++++ .../CH6/EX6.3.2/6.3.2.R | 28 ++++ .../CH6/EX6.3.3/6.3.3.R | 28 ++++ .../CH6/EX6.3.4/6.3.4.R | 57 ++++++++ .../CH6/EX6.3.5/6.3.5.R | 44 +++++++ .../CH6/EX6.3.6/6.3.6.R | 31 +++++ .../CH6/EX6.4.2/6.4.2.R | 19 +++ .../CH6/EX6.4.3/6.4.3.R | 66 ++++++++++ .../CH6/EX6.5.1/6.5.1.R | 12 ++ .../CH6/EX6.5.2/6.5.2.R | 43 ++++++ .../CH6/EX6.5.3/6.5.3.R | 18 +++ .../CH6/EX6.5.4/6.5.4.R | 63 +++++++++ .../CH6/EX6.5.5/6.5.5.R | 33 +++++ .../CH7/EX7.1.2/7.1.2.R | 27 ++++ .../CH7/EX7.1.3/7.1.3.R | 22 ++++ .../CH7/EX7.2.1/7.2.1.R | 16 +++ .../CH7/EX7.3.1/7.3.1.R | 13 ++ .../CH7/EX7.4.1/7.4.1.R | 22 ++++ .../CH8/EX8.1.1/8.1.1.R | 22 ++++ .../CH8/EX8.1.2/8.1.2.R | 54 ++++++++ .../CH8/EX8.1.3/8.1.3.R | 26 ++++ .../CH8/EX8.1.4/8.1.4.R | 48 +++++++ .../CH8/EX8.2.1/8.2.1.R | 20 +++ .../CH8/EX8.2.2/8.2.2.R | 20 +++ .../CH9/EX9.2.1/9.2.1.R | 20 +++ .../CH9/EX9.2.2/9.2.2.R | 23 ++++ .../CH9/EX9.2.3/9.2.3.R | 48 +++++++ .../CH9/EX9.3.1/9.3.1.R | 45 +++++++ .../CH9/EX9.3.3/9.3.3.R | 12 ++ .../CH9/EX9.3.4/9.3.4.R | 61 +++++++++ .../README.txt | 18 +++ .../CH1/EX1.2/Ex1_2.R | 14 ++ .../CH1/EX1.3/Ex1_3.R | 30 +++++ .../CH1/EX1.4/Ex1_4.R | 29 +++++ .../CH14/EX14.1/Ex14_1.R | 19 +++ .../CH14/EX14.2/Ex14_2.R | 9 ++ .../CH14/EX14.4/Ex14_4.R | 16 +++ .../CH14/EX14.7/Ex14_7.R | 17 +++ .../CH14/EX14.8/Ex14_8.R | 11 ++ .../CH2/EX2.1/Ex2_1.R | 6 + .../CH2/EX2.10/Ex2_10.R | 12 ++ .../CH2/EX2.11/Ex2_11.R | 12 ++ .../CH2/EX2.12/Ex2_12.R | 13 ++ .../CH2/EX2.13/Ex2_13.R | 17 +++ .../CH2/EX2.15/Ex2_15.R | 14 ++ .../CH2/EX2.16/Ex2_16.R | 21 +++ .../CH2/EX2.18/Ex2_18.R | 21 +++ .../CH2/EX2.2/Ex2_2.R | 6 + .../CH2/EX2.20/Ex2_20.R | 32 +++++ .../CH2/EX2.5/Ex2_5.R | 14 ++ .../CH3/EX3.12/Ex3_12.R | 22 ++++ .../CH3/EX3.13/Ex3_13.R | 18 +++ .../CH3/EX3.14/Ex3_14.R | 19 +++ .../CH3/EX3.16/Ex3_16.R | 39 ++++++ .../CH3/EX3.17/Ex3_17.R | 28 ++++ .../CH3/EX3.3/Ex3_3.R | 13 ++ .../CH3/EX3.7/Ex3_7.R | 10 ++ .../CH3/EX3.8/Ex3_8.R | 13 ++ .../CH4/EX4.1/Ex4_1.R | 33 +++++ .../CH4/EX4.10/Ex4_10.R | 7 + .../CH4/EX4.11/Ex4_11.R | 8 ++ .../CH4/EX4.13/Ex4_13.R | 23 ++++ .../CH4/EX4.14/Ex4_14.R | 27 ++++ .../CH4/EX4.19/Ex4_19.R | 14 ++ .../CH4/EX4.20/Ex4_20.R | 16 +++ .../CH4/EX4.21/Ex4_21.R | 17 +++ .../CH4/EX4.22/Ex4_22.R | 19 +++ .../CH4/EX4.23/Ex4_23.R | 16 +++ .../CH4/EX4.24/Ex4_24.R | 46 +++++++ .../CH4/EX4.26/Ex4_26.R | 17 +++ .../CH4/EX4.27/Ex4_27.R | 13 ++ .../CH4/EX4.28/Ex4_28.R | 11 ++ .../CH4/EX4.29/Ex4_29.R | 33 +++++ .../CH4/EX4.30/Ex4_30.R | 21 +++ .../CH4/EX4.31/Ex4_31.R | 24 ++++ .../CH4/EX4.32/Ex4_32.R | 10 ++ .../CH4/EX4.4/Ex4_4.R | 23 ++++ .../CH4/EX4.9/Ex4_9.R | 15 +++ .../CH5/EX5.1/Ex5_1.R | 13 ++ .../CH5/EX5.10/Ex5_10.R | 15 +++ .../CH5/EX5.17/Ex5_17.R | 6 + .../CH5/EX5.2/Ex5_2.R | 6 + .../CH5/EX5.27/Ex5_27.R | 19 +++ .../CH5/EX5.5/Ex5_5.R | 8 ++ .../CH5/EX5.9/Ex5_9.R | 53 ++++++++ .../CH7/EX7.16/Ex7_16.R | 15 +++ .../CH7/EX7.4/Ex7_4.R | 13 ++ .../CH8/EX8.1/Ex8_1.R | 14 ++ .../CH8/EX8.2/Ex8_2.R | 11 ++ .../CH8/EX8.21/Ex8_21.R | 23 ++++ .../CH8/EX8.22/Ex8_22.R | 14 ++ .../CH8/EX8.24/Ex8_24.R | 10 ++ .../CH8/EX8.25/Ex8_25.R | 11 ++ .../CH8/EX8.26/Ex8_26.R | 12 ++ .../CH8/EX8.3/Ex8_3.R | 26 ++++ .../CH8/EX8.4/Ex8_4.R | 11 ++ .../CH8/EX8.5/Ex8_5.R | 19 +++ .../CH8/EX8.6/Ex8_6.R | 15 +++ .../CH8/EX8.7/Ex8_7.R | 27 ++++ .../CH8/EX8.8/Ex8_8.R | 20 +++ .../CH9/EX9.10/Ex9_10.R | 18 +++ .../README.txt | 18 +++ .../CH1/EX1.10.1/Ex1_10_1.R | 46 +++++++ .../CH1/EX1.4.1/Ex1_4_1.R | 11 ++ .../CH1/EX1.4.2/Ex1_4_2.R | 13 ++ .../CH1/EX1.4.3/Ex1_4_3.R | 10 ++ .../CH1/EX1.4.4/Ex1_4_4.R | 46 +++++++ .../CH1/EX1.4.5/Ex1_4_5.R | 18 +++ .../CH1/EX1.5.2/Ex1_5_2.R | 30 +++++ .../CH1/EX1.5.3/Ex1_5_3.R | 15 +++ .../CH1/EX1.5.4/Ex1_5_4.R | 59 +++++++++ .../CH1/EX1.6.2/Ex1_6_2.R | 21 +++ .../CH1/EX1.6.3/Ex1_6_3.R | 53 ++++++++ .../CH1/EX1.6.4/Ex1_6_4.R | 66 ++++++++++ .../CH1/EX1.6.5/Ex1_6_5.R | 55 ++++++++ .../CH1/EX1.7.1/Ex1_7_1.R | 33 +++++ .../CH1/EX1.7.12/Ex1_7_12.R | 21 +++ .../CH1/EX1.7.3/Ex1_7_3.R | 11 ++ .../CH1/EX1.7.4/Ex1_7_4.R | 74 +++++++++++ .../CH1/EX1.7.5/Ex1_7_5.R | 14 ++ .../CH1/EX1.7.7/Ex1_7_7.R | 13 ++ .../CH1/EX1.7.8/Ex1_7_8.R | 18 +++ .../CH1/EX1.7.9/Ex1_7_9.R | 16 +++ .../CH1/EX1.8.1/Ex1_8_1.R | 105 +++++++++++++++ .../CH1/EX1.8.10/Ex1_8_10.R | 40 ++++++ .../CH1/EX1.8.11/Ex1_8_11.R | 74 +++++++++++ .../CH1/EX1.8.12/Ex1_8_12.R | 52 ++++++++ .../CH1/EX1.8.2/Ex1_8_2.R | 21 +++ .../CH1/EX1.8.3/Ex1_8_3.R | 33 +++++ .../CH1/EX1.8.4/Ex1_8_4.R | 24 ++++ .../CH1/EX1.8.5/Ex1_8_5.R | 18 +++ .../CH1/EX1.8.6/Ex1_8_6.R | 37 ++++++ .../CH1/EX1.8.7/Ex1_8_7.R | 61 +++++++++ .../CH1/EX1.8.8/Ex1_8_8.R | 35 +++++ .../CH1/EX1.8.9/Ex1_8_9.R | 42 ++++++ .../CH1/EX1.9.1/Ex1_9_1.R | 34 +++++ .../CH1/EX1.9.2/Ex1_9_2.R | 42 ++++++ .../CH1/EX1.9.3/Ex1_9_3.R | 61 +++++++++ .../CH1/EX1.9.4/Ex1_9_4.R | 69 ++++++++++ .../CH2/EX2.1.10/Ex2_1_10.R | 15 +++ .../CH2/EX2.1.11/Ex2_1_11.R | 17 +++ .../CH2/EX2.1.12/Ex2_1_12.R | 16 +++ .../CH2/EX2.1.2/Ex2_1_2.R | 47 +++++++ .../CH2/EX2.1.3/Ex2_1_3.R | 72 ++++++++++ .../CH2/EX2.1.4/Ex2_1_4.R | 30 +++++ .../CH2/EX2.1.5/Ex2_1_5.R | 19 +++ .../CH2/EX2.1.9/Ex2_1_9.R | 25 ++++ .../CH2/EX2.2.1/Ex2_2_1.R | 49 +++++++ .../CH2/EX2.2.10/Ex2_2_10.R | 34 +++++ .../CH2/EX2.2.2/Ex2_2_2.R | 12 ++ .../CH2/EX2.2.3/Ex2_2_3.R | 27 ++++ .../CH2/EX2.2.4/Ex2_2_4.R | 73 +++++++++++ .../CH2/EX2.2.7/Ex2_2_7.R | 19 +++ .../CH2/EX2.2.9/Ex2_2_9.R | 29 +++++ .../CH2/EX2.3.2/Ex2_3_2.R | 31 +++++ .../CH2/EX2.3.3/Ex2_3_3.R | 15 +++ .../CH2/EX2.3.4/Ex2_3_4.R | 22 ++++ .../CH2/EX2.3.5/Ex2_3_5.R | 24 ++++ .../CH2/EX2.3.6/Ex2_3_6.R | 14 ++ .../CH2/EX2.3.7/Ex2_3_7.R | 88 +++++++++++++ .../CH2/EX2.3.8/Ex2_3_8.R | 89 +++++++++++++ .../CH2/EX2.4.1/Ex2_4_1.R | 9 ++ .../CH2/EX2.4.2/Ex2_4_2.R | 12 ++ .../CH3/EX3.1.1/Ex3_1_1.R | 66 ++++++++++ .../CH3/EX3.1.3/Ex3_1_3.R | 38 ++++++ .../CH3/EX3.1.5/Ex3_1_5.R | 31 +++++ .../CH3/EX3.1.6/Ex3_1_6.R | 54 ++++++++ .../CH3/EX3.1.8/Ex3_1_8.R | 23 ++++ .../CH3/EX3.10.11/Ex3_10_11.R | 26 ++++ .../CH3/EX3.10.12/Ex3_10_12.R | 40 ++++++ .../CH3/EX3.10.14/Ex3_10_14.R | 69 ++++++++++ .../CH3/EX3.10.15/Ex3_10_15.R | 54 ++++++++ .../CH3/EX3.10.2/Ex3_10_2.R | 35 +++++ .../CH3/EX3.10.4/Ex3_10_4.R | 35 +++++ .../CH3/EX3.10.5/Ex3_10_5.R | 22 ++++ .../CH3/EX3.10.7/Ex3_10_7.R | 28 ++++ .../CH3/EX3.10.8/Ex3_10_8.R | 41 ++++++ .../CH3/EX3.2.3/Ex3_2_3.R | 16 +++ .../CH3/EX3.2.4/Ex3_2_4.R | 17 +++ .../CH3/EX3.2.7/Ex3_2_7.R | 36 +++++ .../CH3/EX3.3.1/Ex3_3_1.R | 17 +++ .../CH3/EX3.3.3/Ex3_3_3.R | 20 +++ .../CH3/EX3.3.9/Ex3_3_9.R | 57 ++++++++ .../CH3/EX3.4.11/Ex3_4_11.R | 40 ++++++ .../CH3/EX3.4.12/Ex3_4_12.R | 28 ++++ .../CH3/EX3.4.3/Ex3_4_3.R | 38 ++++++ .../CH3/EX3.4.7/Ex3_4_7.R | 26 ++++ .../CH3/EX3.4.8/Ex3_4_8.R | 25 ++++ .../CH3/EX3.4.9/Ex3_4_9.R | 11 ++ .../CH3/EX3.5.2/Ex3_5_2.R | 55 ++++++++ .../CH3/EX3.5.4/Ex3_5_4.R | 26 ++++ .../CH3/EX3.5.7/Ex3_5_7.R | 88 +++++++++++++ .../CH3/EX3.5.8/Ex3_5_8.R | 57 ++++++++ .../CH3/EX3.5.9/Ex3_5_9.R | 25 ++++ .../CH3/EX3.6.1/Ex3_6_1.R | 57 ++++++++ .../CH3/EX3.6.2/Ex3_6_2.R | 44 +++++++ .../CH3/EX3.6.5/Ex3_6_5.R | 21 +++ .../CH3/EX3.6.9/Ex3_6_9.R | 17 +++ .../CH3/EX3.7.15/Ex3_7_15.R | 31 +++++ .../CH3/EX3.7.16/Ex3_7_16.R | 16 +++ .../CH3/EX3.7.7/Ex3_7_7.R | 12 ++ .../CH3/EX3.7.8/Ex3_7_8.R | 18 +++ .../CH3/EX3.7.9/Ex3_7_9.R | 10 ++ .../CH3/EX3.8.1/Ex3_8_1.R | 35 +++++ .../CH3/EX3.8.2/Ex3_8_2.R | 51 ++++++++ .../CH3/EX3.8.6/Ex3_8_6.R | 16 +++ .../CH3/EX3.9.2/Ex3_9_2.R | 46 +++++++ .../CH1/EX1.1/Ex1_1.R | 9 ++ .../CH1/EX1.10/Ex1_10.R | 21 +++ .../CH1/EX1.11/Ex1_11.R | 16 +++ .../CH1/EX1.13/Ex1_13.R | 13 ++ .../CH1/EX1.14/Ex1_14.R | 14 ++ .../CH1/EX1.15/Ex1_15.R | 18 +++ .../CH1/EX1.17/Ex1_17.R | 9 ++ .../CH1/EX1.18/Ex1_18.R | 7 + .../CH1/EX1.19/Ex1_19.R | 8 ++ .../CH1/EX1.20/Ex1_20.R | 10 ++ .../CH1/EX1.5/Ex1_5.R | 15 +++ .../CH1/EX1.8/Ex1_8.R | 8 ++ .../CH1/EX1.9/Ex1_9.R | 31 +++++ .../CH10/EX10.1/Ex10_1.R | 55 ++++++++ .../CH10/EX10.10/Ex10_10.R | 30 +++++ .../CH10/EX10.11/Ex10_11.R | 20 +++ .../CH10/EX10.2/Ex10_2.R | 41 ++++++ .../CH10/EX10.3/Ex10_3.R | 45 +++++++ .../CH10/EX10.4/Ex10_4.R | 33 +++++ .../CH10/EX10.6/Ex10_6.R | 15 +++ .../CH10/EX10.9/Ex10_9.R | 12 ++ .../CH11/EX11.1/Ex11_1.R | 11 ++ .../CH11/EX11.10/Ex11_10.R | 22 ++++ .../CH11/EX11.11/Ex11_11.R | 34 +++++ .../CH11/EX11.12/Ex11_12.R | 61 +++++++++ .../CH11/EX11.13/Ex11_13.R | 104 +++++++++++++++ .../CH11/EX11.3/Ex11_3.R | 25 ++++ .../CH11/EX11.5/Ex11_5.R | 16 +++ .../CH11/EX11.6/Ex11_6.R | 25 ++++ .../CH11/EX11.7/Ex11_7.R | 35 +++++ .../CH11/EX11.9/Ex11_9.R | 16 +++ .../CH12/EX12.1/Ex12_1.R | 12 ++ .../CH12/EX12.11/Ex12_11.R | 74 +++++++++++ .../CH12/EX12.12/Ex12_12.R | 15 +++ .../CH12/EX12.13/Ex12_13.R | 27 ++++ .../CH12/EX12.14/Ex12_14.R | 15 +++ .../CH12/EX12.15/Ex12_15.R | 9 ++ .../CH12/EX12.16/Ex12_16.R | 9 ++ .../CH12/EX12.17/Ex12_17.R | 13 ++ .../CH12/EX12.18/Ex12_18.R | 29 +++++ .../CH12/EX12.19/Ex12_19.R | 27 ++++ .../CH12/EX12.2/Ex12_2.R | 9 ++ .../CH12/EX12.3/Ex12_3.R | 31 +++++ .../CH12/EX12.4/Ex12_4.R | 16 +++ .../CH12/EX12.5/Ex12_5.R | 6 + .../CH12/EX12.6/Ex12_6.R | 20 +++ .../CH12/EX12.7/Ex12_7.R | 27 ++++ .../CH12/EX12.8/Ex12_8.R | 13 ++ .../CH12/EX12.9/Ex12_9.R | 31 +++++ .../CH13/EX13.10/Ex13_10.R | 35 +++++ .../CH13/EX13.12/Ex13_12.R | 21 +++ .../CH13/EX13.13/Ex13_13.R | 49 +++++++ .../CH13/EX13.14/Ex13_14.R | 22 ++++ .../CH13/EX13.15/Ex13_15.R | 26 ++++ .../CH13/EX13.16/Ex13_16.R | 53 ++++++++ .../CH13/EX13.18/Ex13_18.R | 14 ++ .../CH13/EX13.2/Ex13_2.R | 21 +++ .../CH13/EX13.4/Ex13_4.R | 32 +++++ .../CH13/EX13.7/Ex13_7.R | 29 +++++ .../CH13/EX13.8/Ex13_8.R | 22 ++++ .../CH13/EX13.9/Ex13_9.R | 17 +++ .../CH14/EX14.1/Ex14_1.R | 30 +++++ .../CH14/EX14.10/Ex14_10.R | 40 ++++++ .../CH14/EX14.12/Ex14_12.R | 21 +++ .../CH14/EX14.13/Ex14_13.R | 31 +++++ .../CH14/EX14.14/Ex14_14.R | 30 +++++ .../CH14/EX14.2/Ex14_2.R | 38 ++++++ .../CH14/EX14.3/Ex14_3.R | 30 +++++ .../CH14/EX14.4/Ex14_4.R | 31 +++++ .../CH14/EX14.5/Ex14_5.R | 16 +++ .../CH14/EX14.6/Ex14_6.R | 29 +++++ .../CH14/EX14.9/Ex14_9.R | 36 +++++ .../CH15/EX15.1/Ex15_1.R | 9 ++ .../CH15/EX15.10/Ex15_10.R | 44 +++++++ .../CH15/EX15.2/Ex15_2.R | 15 +++ .../CH15/EX15.3/Ex15_3.R | 15 +++ .../CH15/EX15.4/Ex15_4.R | 7 + .../CH15/EX15.5/Ex15_5.R | 36 +++++ .../CH15/EX15.6/Ex15_6.R | 10 ++ .../CH15/EX15.8/Ex15_8.R | 18 +++ .../CH15/EX15.9/Ex15_9.R | 42 ++++++ .../CH16/EX16.1/Ex16_1.R | 15 +++ .../CH16/EX16.10/Ex16_10.R | 14 ++ .../CH16/EX16.11/Ex16_11.R | 17 +++ .../CH16/EX16.12/Ex16_12.R | 61 +++++++++ .../CH16/EX16.2/Ex16_2.R | 21 +++ .../CH16/EX16.3/Ex16_3.R | 14 ++ .../CH16/EX16.4/Ex16_4.R | 31 +++++ .../CH16/EX16.5/Ex16_5.R | 36 +++++ .../CH16/EX16.6/Ex16_6.R | 26 ++++ .../CH16/EX16.7/Ex16_7.R | 35 +++++ .../CH16/EX16.8/Ex16_8.R | 16 +++ .../CH16/EX16.9/Ex16_9.R | 39 ++++++ .../CH2/EX2.11/Ex2_11.R | 13 ++ .../CH2/EX2.13/Ex2_13.R | 12 ++ .../CH2/EX2.14/Ex2_14.R | 20 +++ .../CH2/EX2.19/Ex2_19.R | 12 ++ .../CH2/EX2.21/Ex2_21.R | 10 ++ .../CH2/EX2.22/Ex2_22.R | 20 +++ .../CH2/EX2.23/Ex2_23.R | 23 ++++ .../CH2/EX2.25/Ex2_25.R | 21 +++ .../CH2/EX2.26/Ex2_26.R | 34 +++++ .../CH2/EX2.30/Ex2_30.R | 24 ++++ .../CH2/EX2.36/Ex2_36.R | 12 ++ .../CH2/EX2.8/Ex2_8.R | 13 ++ .../CH3/EX3.10/Ex3_10.R | 55 ++++++++ .../CH3/EX3.13/Ex3_13.R | 26 ++++ .../CH3/EX3.15/Ex3_15.R | 16 +++ .../CH3/EX3.16/Ex3_16.R | 8 ++ .../CH3/EX3.17/Ex3_17.R | 8 ++ .../CH3/EX3.23/Ex3_23.R | 14 ++ .../CH3/EX3.24/Ex3_24.R | 17 +++ .../CH3/EX3.25/Ex3_25.R | 13 ++ .../CH3/EX3.26/Ex3_26.R | 23 ++++ .../CH3/EX3.29/Ex3_29.R | 25 ++++ .../CH3/EX3.30/Ex3_30.R | 14 ++ .../CH3/EX3.31/Ex3_31.R | 13 ++ .../CH3/EX3.32.1/Ex3_32_1.R | 13 ++ .../CH3/EX3.32.2/Ex3_32_2.R | 10 ++ .../CH3/EX3.32.3/Ex3_32_3.R | 15 +++ .../CH3/EX3.32.4/Ex3_32_4.R | 11 ++ .../CH3/EX3.33/Ex3_33.R | 11 ++ .../CH3/EX3.34/Ex3_34.R | 21 +++ .../CH3/EX3.35/Ex3_35.R | 11 ++ .../CH3/EX3.36/Ex3_36.R | 19 +++ .../CH3/EX3.37/Ex3_37.R | 21 +++ .../CH3/EX3.38/Ex3_38.R | 10 ++ .../CH3/EX3.39/Ex3_39.R | 12 ++ .../CH3/EX3.40/Ex3_40.R | 14 ++ .../CH3/EX3.41/Ex3_41.R | 7 + .../CH3/EX3.42/Ex3_42.R | 10 ++ .../CH3/EX3.7/Ex3_7.R | 22 ++++ .../CH3/EX3.8/Ex3_8.R | 41 ++++++ .../CH3/EX3.9/Ex3_9.R | 17 +++ .../CH4/EX4.10/Ex4_10.R | 9 ++ .../CH4/EX4.11/Ex4_11.R | 19 +++ .../CH4/EX4.12/Ex4_12.R | 17 +++ .../CH4/EX4.13.a/Ex4_13_a.R | 16 +++ .../CH4/EX4.13.b/Ex4_13_b.R | 19 +++ .../CH4/EX4.13.c/Ex4_13_c.R | 25 ++++ .../CH4/EX4.13.d/Ex4_13_d.R | 18 +++ .../CH4/EX4.14/Ex4_14.R | 25 ++++ .../CH4/EX4.15/Ex4_15.R | 25 ++++ .../CH4/EX4.16/Ex4_16.R | 26 ++++ .../CH4/EX4.17/Ex4_17.R | 14 ++ .../CH4/EX4.18/Ex4_18.R | 25 ++++ .../CH4/EX4.20/Ex4_20.R | 20 +++ .../CH4/EX4.21/Ex4_21.R | 14 ++ .../CH4/EX4.22/Ex4_22.R | 12 ++ .../CH4/EX4.23/Ex4_23.R | 12 ++ .../CH4/EX4.24/Ex4_24.R | 30 +++++ .../CH4/EX4.25/Ex4_25.R | 18 +++ .../CH4/EX4.26/Ex4_26.R | 14 ++ .../CH4/EX4.27/Ex4_27.R | 22 ++++ .../CH4/EX4.28/Ex4_28.R | 21 +++ .../CH4/EX4.29/Ex4_29.R | 21 +++ .../CH4/EX4.30/Ex4_30.R | 14 ++ .../CH4/EX4.31/Ex4_31.R | 13 ++ .../CH4/EX4.4/Ex4_4.R | 19 +++ .../CH4/EX4.5/Ex4_5.R | 15 +++ .../CH4/EX4.7/Ex4_7.R | 18 +++ .../CH5/EX5.1/Ex5_1.R | 10 ++ .../CH5/EX5.12/Ex5_12.R | 14 ++ .../CH5/EX5.14/Ex5_14.R | 16 +++ .../CH5/EX5.15/Ex5_15.R | 59 +++++++++ .../CH5/EX5.18/Ex5_18.R | 20 +++ .../CH5/EX5.19/Ex5_19.R | 31 +++++ .../CH5/EX5.2/Ex5_2.R | 32 +++++ .../CH5/EX5.24/Ex5_24.R | 39 ++++++ .../CH5/EX5.25/Ex5_25.R | 31 +++++ .../CH5/EX5.26/Ex5_26.R | 13 ++ .../CH5/EX5.27/Ex5_27.R | 13 ++ .../CH5/EX5.29/Ex5_29.R | 24 ++++ .../CH5/EX5.3/Ex5_3.R | 16 +++ .../CH5/EX5.30/Ex5_30.R | 19 +++ .../CH5/EX5.31/Ex5_31.R | 10 ++ .../CH5/EX5.4/Ex5_4.R | 11 ++ .../CH5/EX5.5/Ex5_5.R | 16 +++ .../CH5/EX5.8/Ex5_8.R | 17 +++ .../CH5/EX5.9/Ex5_9.R | 10 ++ .../CH6/EX6.1/Ex6_1.R | 6 + .../CH6/EX6.10/Ex6_10.R | 16 +++ .../CH6/EX6.11/Ex6_11.R | 13 ++ .../CH6/EX6.13/Ex6_13.R | 20 +++ .../CH6/EX6.14/Ex6_14.R | 22 ++++ .../CH6/EX6.2/Ex6_2.R | 21 +++ .../CH6/EX6.21/Ex6_21.R | 7 + .../CH6/EX6.3/Ex6_3.R | 27 ++++ .../CH6/EX6.9/Ex6_9.R | 16 +++ .../CH7/EX7.10/Ex7_10.R | 11 ++ .../CH7/EX7.11/Ex7_11.R | 32 +++++ .../CH7/EX7.12/Ex7_12.R | 29 +++++ .../CH7/EX7.13/Ex7_13.R | 20 +++ .../CH7/EX7.14/Ex7_14.R | 46 +++++++ .../CH7/EX7.15/Ex7_15.R | 15 +++ .../CH7/EX7.2/Ex7_2.R | 15 +++ .../CH7/EX7.3/Ex7_3.R | 19 +++ .../CH7/EX7.4/Ex7_4.R | 11 ++ .../CH7/EX7.6/Ex7_6.R | 36 +++++ .../CH7/EX7.7/Ex7_7.R | 15 +++ .../CH7/EX7.8/Ex7_8.R | 10 ++ .../CH8/EX8.1/Ex8_1.R | 33 +++++ .../CH8/EX8.11/Ex8_11.R | 27 ++++ .../CH8/EX8.12/Ex8_12.R | 26 ++++ .../CH8/EX8.13/Ex8_13.R | 15 +++ .../CH8/EX8.14/Ex8_14.R | 26 ++++ .../CH8/EX8.15/Ex8_15.R | 29 +++++ .../CH8/EX8.17/Ex8_17.R | 21 +++ .../CH8/EX8.18/Ex8_18.R | 28 ++++ .../CH8/EX8.19/Ex8_19.R | 27 ++++ .../CH8/EX8.2/Ex8_2.R | 33 +++++ .../CH8/EX8.3/Ex8_3.R | 21 +++ .../CH8/EX8.4/Ex8_4.R | 19 +++ .../CH8/EX8.5/Ex8_5.R | 20 +++ .../CH8/EX8.6/Ex8_6.R | 19 +++ .../CH8/EX8.7/Ex8_7.R | 28 ++++ .../CH8/EX8.8/Ex8_8.R | 23 ++++ .../CH8/EX8.9/Ex8_9.R | 26 ++++ .../CH9/EX9.1/Ex9_1.R | 22 ++++ .../CH9/EX9.10/Ex9_10.R | 22 ++++ .../CH9/EX9.11/Ex9_11.R | 32 +++++ .../CH9/EX9.12/Ex9_12.R | 27 ++++ .../CH9/EX9.13/Ex9_13.R | 26 ++++ .../CH9/EX9.14/Ex9_14.R | 20 +++ .../CH9/EX9.2/Ex9_2.R | 24 ++++ .../CH9/EX9.3/Ex9_3.R | 9 ++ .../CH9/EX9.4/Ex9_4.R | 25 ++++ .../CH9/EX9.5/Ex9_5.R | 22 ++++ .../CH9/EX9.6/Ex9_6.R | 38 ++++++ .../CH9/EX9.7/Ex9_7.R | 21 +++ .../CH9/EX9.9/Ex9_9.R | 26 ++++ .../README.txt | 18 +++ .../CH1/EX1.2/Ex1_2.R | 20 +++ .../CH1/EX1.3/Ex1_3.R | 19 +++ .../CH1/EX1.4/Ex1_4.R | 12 ++ .../CH1/EX1.5/Ex1_5.R | 19 +++ .../CH1/EX1.6/Ex1_6.zip | Bin 0 -> 7489 bytes .../CH10/EX10.10/Ex10_10.R | 18 +++ .../CH10/EX10.11/Ex10_11.R | 33 +++++ .../CH10/EX10.12/Ex10_12.R | 22 ++++ .../CH10/EX10.13/Ex10_13.R | 17 +++ .../CH10/EX10.14/Ex10_14.R | 32 +++++ .../CH10/EX10.15/Ex10_15.R | 18 +++ .../CH10/EX10.3/Ex10_3.R | 27 ++++ .../CH10/EX10.4/Ex10_4.R | 33 +++++ .../CH10/EX10.5/Ex10_5.R | 33 +++++ .../CH10/EX10.6/Ex10_6.R | 40 ++++++ .../CH10/EX10.7/Ex10_7.R | 28 ++++ .../CH10/EX10.9/Ex10_9.R | 26 ++++ .../CH11/EX11.1/Ex11_1.R | 18 +++ .../CH11/EX11.10/Ex11_10.R | 17 +++ .../CH11/EX11.11/Ex11_11.R | 21 +++ .../CH11/EX11.2/Ex11_2.R | 20 +++ .../CH11/EX11.3/Ex11_3.R | 37 ++++++ .../CH11/EX11.4/Ex11_4.R | 27 ++++ .../CH11/EX11.5/Ex11_5.R | 20 +++ .../CH11/EX11.6/Ex11_6.R | 26 ++++ .../CH11/EX11.7/Ex11_7.R | 26 ++++ .../CH11/EX11.8/Ex11_8.R | 25 ++++ .../CH11/EX11.9/Ex11_9.R | 22 ++++ .../CH12/EX12.1/Ex12_1.R | 27 ++++ .../CH12/EX12.10/Ex12_10.R | 38 ++++++ .../CH12/EX12.11/Ex12_11.R | 62 +++++++++ .../CH12/EX12.12/Ex12_12.R | 44 +++++++ .../CH12/EX12.13/Ex12_13.R | 23 ++++ .../CH12/EX12.2/Ex12_2.R | 19 +++ .../CH12/EX12.3/Ex12_3.R | 29 +++++ .../CH12/EX12.4/Ex12_4.R | 45 +++++++ .../CH12/EX12.5/Ex12_5.R | 59 +++++++++ .../CH12/EX12.6/Ex12_6.R | 28 ++++ .../CH12/EX12.7/Ex12_7.R | 24 ++++ .../CH12/EX12.8/Ex12_8.R | 27 ++++ .../CH12/EX12.9/Ex12_9.R | 22 ++++ .../CH13/EX13.1/Ex13_1.R | 20 +++ .../CH13/EX13.2/Ex13_2.R | 23 ++++ .../CH13/EX13.3/Ex13_3.R | 24 ++++ .../CH13/EX13.4/Ex13_4.R | 38 ++++++ .../CH13/EX13.5/Ex13_5.R | 26 ++++ .../CH13/EX13.6/Ex13_6.R | 36 +++++ .../CH13/EX13.7/Ex13_7.R | 32 +++++ .../CH14/EX14.1/Ex14_1.R | 40 ++++++ .../CH14/EX14.2/Ex14_2.R | 47 +++++++ .../CH14/EX14.3/Ex14_3.R | 28 ++++ .../CH14/EX14.4/Ex14_4.R | 31 +++++ .../CH14/EX14.5/Ex14_5.R | 37 ++++++ .../CH14/EX14.6/Ex14_6.R | 30 +++++ .../CH15/EX15.1/Ex15_1.R | 22 ++++ .../CH15/EX15.2/Ex15_2.R | 31 +++++ .../CH15/EX15.4/Ex15_4.R | 17 +++ .../CH15/EX15.6/Ex15_6.R | 31 +++++ .../CH15/EX15.7/Ex15_7.R | 14 ++ .../CH15/EX15.8/Ex15_8.R | 46 +++++++ .../CH16/EX16.1/Ex16_1.R | 26 ++++ .../CH16/EX16.2/Ex16_2.R | 28 ++++ .../CH16/EX16.3/Ex16_3.R | 18 +++ .../CH16/EX16.4/Ex16_4.R | 18 +++ .../CH16/EX16.5/Ex16_5.R | 15 +++ .../CH16/EX16.6/Ex16_6.R | 24 ++++ .../CH16/EX16.7/Ex16_7.R | 22 ++++ .../CH16/EX16.8.9/Ex16_8&9.R | 26 ++++ .../CH17/EX17.1/Ex17_1.R | 13 ++ .../CH17/EX17.2/Ex17_2.R | 54 ++++++++ .../CH17/EX17.3/Ex17_3.R | 24 ++++ .../CH17/EX17.4/Ex17_4.R | 17 +++ .../CH17/EX17.5/Ex17_5.R | 30 +++++ .../CH18/EX18.1/Ex18_1.R | 27 ++++ .../CH18/EX18.11/Ex18_11.R | 20 +++ .../CH18/EX18.4/Ex18_4.R | 31 +++++ .../CH18/EX18.6/Ex18_6.R | 25 ++++ .../CH18/EX18.7/Ex18_7.R | 22 ++++ .../CH18/EX18.8/Ex18_8.R | 30 +++++ .../CH18/EX18.9/Ex18_9.R | 31 +++++ .../CH2/EX2.10/Ex2_10.R | 10 ++ .../CH2/EX2.15/Ex2_15.R | 9 ++ .../CH2/EX2.18/Ex2_18.R | 10 ++ .../CH2/EX2.19.a/Ex2_19a.R | 14 ++ .../CH2/EX2.19.b/Ex2_19b.R | 19 +++ .../CH2/EX2.19.c/Ex2_19c.R | 20 +++ .../CH2/EX2.19.d/Ex2_19d.R | 17 +++ .../CH2/EX2.2/Ex2_2.R | 12 ++ .../CH2/EX2.21/Ex2_21.R | 14 ++ .../CH2/EX2.22/Ex2_22.R | 21 +++ .../CH2/EX2.24/Ex2_24.R | 32 +++++ .../CH2/EX2.25/Ex2_25.R | 15 +++ .../CH2/EX2.3/Ex2_3.R | 13 ++ .../CH2/EX2.30/Ex2_30.R | 21 +++ .../CH2/EX2.34/Ex2_34.R | 22 ++++ .../CH2/EX2.37/Ex2_37.R | 29 +++++ .../CH2/EX2.43/Ex2_43.R | 26 ++++ .../CH2/EX2.8/Ex2_8.R | 11 ++ .../CH3/EX3.10/Ex3_10.R | 25 ++++ .../CH3/EX3.11/Ex3_11.R | 29 +++++ .../CH3/EX3.12/Ex3_12.R | 17 +++ .../CH3/EX3.14/Ex3_14.R | 20 +++ .../CH3/EX3.15/Ex3_15.R | 50 +++++++ .../CH3/EX3.16/Ex3_16.R | 16 +++ .../CH3/EX3.18/Ex3_18.R | 50 +++++++ .../CH3/EX3.20/Ex3_20.R | 42 ++++++ .../CH3/EX3.22/Ex3_22.R | 30 +++++ .../CH3/EX3.8/Ex3_8.R | 26 ++++ .../CH3/EX3.9/Ex3_9.R | 21 +++ .../CH4/EX4.1/Ex4_1.R | 27 ++++ .../CH4/EX4.10/Ex4_10.R | 18 +++ .../CH4/EX4.11/Ex4_11.R | 18 +++ .../CH4/EX4.12/Ex4_12.R | 22 ++++ .../CH4/EX4.13/Ex4_13.R | 33 +++++ .../CH4/EX4.14/Ex4_14.R | 42 ++++++ .../CH4/EX4.15/Ex4_15.R | 40 ++++++ .../CH4/EX4.16/Ex4_16.R | 49 +++++++ .../CH4/EX4.17/Ex4_17.R | 14 ++ .../CH4/EX4.18/Ex4_18.R | 18 +++ .../CH4/EX4.19/Ex4_19.R | 24 ++++ .../CH4/EX4.2/Ex4_2.R | 21 +++ .../CH4/EX4.20/Ex4_20.R | 20 +++ .../CH4/EX4.21/Ex4_21.R | 28 ++++ .../CH4/EX4.3/Ex4_3.R | 21 +++ .../CH4/EX4.4/Ex4_4.R | 20 +++ .../CH4/EX4.5/Ex4_5.R | 15 +++ .../CH4/EX4.6/Ex4_6.R | 23 ++++ .../CH4/EX4.7/Ex4_7.R | 35 +++++ .../CH4/EX4.8/Ex4_8.R | 31 +++++ .../CH4/EX4.9/Ex4_9.R | 18 +++ .../CH5/EX5.1/Ex5_1.R | 14 ++ .../CH5/EX5.10/Ex5_10.R | 14 ++ .../CH5/EX5.11/Ex5_11.R | 18 +++ .../CH5/EX5.12/Ex5_12.R | 14 ++ .../CH5/EX5.13/Ex5_13.R | 16 +++ .../CH5/EX5.14/Ex5_14.R | 22 ++++ .../CH5/EX5.15/Ex5_15.R | 12 ++ .../CH5/EX5.16/Ex5_16.R | 14 ++ .../CH5/EX5.17/Ex5_17.R | 15 +++ .../CH5/EX5.18/Ex5_18.R | 16 +++ .../CH5/EX5.19/Ex5_19.R | 29 +++++ .../CH5/EX5.2.a/Ex5_2a.R | 12 ++ .../CH5/EX5.2.b.c/Ex5_2b_2c.R | 24 ++++ .../CH5/EX5.20/Ex5_20.R | 15 +++ .../CH5/EX5.3/Ex5_3.R | 15 +++ .../CH5/EX5.4/Ex5_4.R | 14 ++ .../CH5/EX5.6/Ex5_6.R | 15 +++ .../CH5/EX5.7/Ex5_7.R | 22 ++++ .../CH5/EX5.8/Ex5_8.R | 16 +++ .../CH5/EX5.9/Ex5_9.R | 14 ++ .../CH6/EX6.1/Ex6_1.R | 23 ++++ .../CH6/EX6.11/Ex6_11.R | 18 +++ .../CH6/EX6.12/Ex6_12.R | 13 ++ .../CH6/EX6.13/Ex6_13.R | 14 ++ .../CH6/EX6.14/Ex6_14.R | 12 ++ .../CH6/EX6.15/Ex6_15.R | 19 +++ .../CH6/EX6.16/Ex6_16.R | 24 ++++ .../CH6/EX6.17/Ex6_17.R | 25 ++++ .../CH6/EX6.18/Ex6_18.R | 14 ++ .../CH6/EX6.19/Ex6_19.R | 20 +++ .../CH6/EX6.2/Ex6_2.R | 16 +++ .../CH6/EX6.20/Ex6_20.R | 19 +++ .../CH6/EX6.21/Ex6_21.R | 18 +++ .../CH6/EX6.22/Ex6_22.R | 17 +++ .../CH6/EX6.23/Ex6_23.R | 10 ++ .../CH6/EX6.24/Ex6_24.R | 12 ++ .../CH6/EX6.3/Ex6_3.R | 11 ++ .../CH6/EX6.4/Ex6_4.R | 10 ++ .../CH6/EX6.5/Ex6_5.R | 12 ++ .../CH6/EX6.6/Ex6_6.R | 15 +++ .../CH6/EX6.7/Ex6_7.R | 18 +++ .../CH6/EX6.8/Ex6_8.R | 17 +++ .../CH6/EX6.9/Ex6_9.R | 14 ++ .../CH8/EX8.1/Ex8_1.R | 18 +++ .../CH8/EX8.10/Ex8_10.R | 11 ++ .../CH8/EX8.11/Ex8_11.R | 28 ++++ .../CH8/EX8.12/Ex8_12.R | 19 +++ .../CH8/EX8.2/Ex8_2.R | 11 ++ .../CH8/EX8.4/Ex8_4.R | 30 +++++ .../CH8/EX8.5/Ex8_5.R | 15 +++ .../CH8/EX8.6/Ex8_6.R | 25 ++++ .../CH8/EX8.7/Ex8_7.R | 27 ++++ .../CH8/EX8.8/Ex8_8.R | 10 ++ .../CH9/EX9.10/Ex9_10.R | 26 ++++ .../CH9/EX9.11/Ex9_11.R | 32 +++++ .../CH9/EX9.12/Ex9_12.R | 21 +++ .../CH9/EX9.13/Ex9_13.R | 16 +++ .../CH9/EX9.14/Ex9_14.R | 15 +++ .../CH9/EX9.15/Ex9_15.R | 20 +++ .../CH9/EX9.16/Ex9_16.R | 15 +++ .../CH9/EX9.18/Ex9_18.R | 15 +++ .../CH9/EX9.19/Ex9_19.R | 20 +++ .../CH9/EX9.2/Ex9_2.R | 35 +++++ .../CH9/EX9.22/Ex9_22.R | 23 ++++ .../CH9/EX9.3/Ex9_3.R | 15 +++ .../CH9/EX9.4/Ex9_4.R | 16 +++ .../CH9/EX9.5/Ex9_5.R | 18 +++ .../CH9/EX9.6/Ex9_6.R | 17 +++ .../CH9/EX9.7/Ex9_7.R | 17 +++ .../CH9/EX9.8/Ex9_8.R | 19 +++ .../README.txt | 18 +++ .../CH1/EX1.1/ex_1_1.R | 14 ++ .../CH1/EX1.10/ex_1_10.R | 4 + .../CH1/EX1.12/ex_1_12.R | 4 + .../CH1/EX1.13/ex_1_13.R | 17 +++ .../CH1/EX1.14/ex_1_14.R | 12 ++ .../CH1/EX1.16/ex_1_16.R | 9 ++ .../CH1/EX1.17/ex_1_17.R | 7 + .../CH1/EX1.2/ex_1_2.R | 28 ++++ .../CH1/EX1.3/ex_1_3.R | 23 ++++ .../CH1/EX1.4/ex_1_4.R | 36 +++++ .../CH1/EX1.8/ex_1_8.R | 3 + .../CH1/EX1.9/ex_1_9.R | 3 + .../CH10/EX10.10/ex_10_10.R | 10 ++ .../CH10/EX10.11/ex_10_11.R | 10 ++ .../CH10/EX10.12/ex_10_12.R | 17 +++ .../CH10/EX10.13/ex_10_13.R | 17 +++ .../CH10/EX10.14/ex_10_14.R | 6 + .../CH10/EX10.15/ex_10_15.R | 19 +++ .../CH10/EX10.16/ex_10_16.R | 19 +++ .../CH10/EX10.18/ex_10_18.R | 17 +++ .../CH10/EX10.19/ex_10_19.R | 18 +++ .../CH10/EX10.20/ex_10_20.R | 22 ++++ .../CH10/EX10.21/ex_10_21.R | 20 +++ .../CH10/EX10.22/ex_10_22.R | 13 ++ .../CH10/EX10.23/ex_10_23.R | 15 +++ .../CH10/EX10.24/ex_10_24.R | 17 +++ .../CH10/EX10.25/ex_10_25.R | 15 +++ .../CH10/EX10.26/ex_10_26.R | 33 +++++ .../CH10/EX10.27/ex_10_27.R | 18 +++ .../CH10/EX10.28/ex_10_28.R | 22 ++++ .../CH10/EX10.29/ex_10_29.R | 22 ++++ .../CH10/EX10.30/ex_10_30.R | 34 +++++ .../CH10/EX10.31/ex_10_31.R | 19 +++ .../CH10/EX10.32/ex_10_32.R | 6 + .../CH10/EX10.33/ex_10_33.R | 9 ++ .../CH10/EX10.8/ex_10_8.R | 20 +++ .../CH10/EX10.9/ex_10_9.R | 18 +++ .../CH11/EX11.10/ex_11_10.R | 7 + .../CH11/EX11.14/ex_11_14.R | 9 ++ .../CH11/EX11.15/ex_11_15.R | 12 ++ .../CH11/EX11.16/ex_11_16.R | 20 +++ .../CH11/EX11.17/ex_11_17.R | 22 ++++ .../CH11/EX11.18/ex_11_18.R | 25 ++++ .../CH11/EX11.19/ex_11_19.R | 22 ++++ .../CH11/EX11.2/ex_11_2.R | 9 ++ .../CH11/EX11.20/ex_11_20.R | 19 +++ .../CH11/EX11.21/ex_11_21.R | 24 ++++ .../CH11/EX11.22/ex_11_22.R | 17 +++ .../CH11/EX11.23.b/ex_11_23_b.R | 13 ++ .../CH11/EX11.25/ex_11_25.R | 30 +++++ .../CH11/EX11.26/ex_11_26.R | 19 +++ .../CH11/EX11.27/ex_11_27.R | 14 ++ .../CH11/EX11.28/ex_11_28.R | 11 ++ .../CH11/EX11.3/ex_11_3.R | 11 ++ .../CH11/EX11.4/ex_11_4.R | 13 ++ .../CH11/EX11.5/ex_11_5.R | 10 ++ .../CH11/EX11.6/ex_11_6.R | 12 ++ .../CH11/EX11.7/ex_11_7.R | 12 ++ .../CH11/EX11.8.a/ex_11_8_a.R | 17 +++ .../CH11/EX11.8.b/ex_11_8_b.R | 14 ++ .../CH11/EX11.9.a/ex_11_9_a.R | 10 ++ .../CH11/EX11.9.b/ex_11_9_b.R | 10 ++ .../CH12/EX12.10/ex_12_10.R | 50 +++++++ .../CH12/EX12.11/ex_12_11.R | 12 ++ .../CH12/EX12.12/ex_12_12.R | 25 ++++ .../CH12/EX12.13/ex_12_13.R | 40 ++++++ .../CH12/EX12.14/ex_12_14.R | 13 ++ .../CH12/EX12.15/ex_12_15.R | 24 ++++ .../CH12/EX12.16.a/ex_12_16_a.R | 15 +++ .../CH12/EX12.17/ex_12_17.R | 27 ++++ .../CH12/EX12.18/ex_12_18.R | 27 ++++ .../CH12/EX12.19/ex_12_19.R | 16 +++ .../CH12/EX12.2/ex_12_2.R | 21 +++ .../CH12/EX12.3/ex_12_3.R | 15 +++ .../CH12/EX12.4/ex_12_4.R | 20 +++ .../CH12/EX12.5/ex_12_5.R | 16 +++ .../CH12/EX12.6/ex_12_6.R | 7 + .../CH12/EX12.7/ex_12_7.R | 10 ++ .../CH12/EX12.8/ex_12_8.R | 27 ++++ .../CH12/EX12.9/ex_12_9.R | 34 +++++ .../CH2/EX2.1/ex_2_1.R | 17 +++ .../CH2/EX2.12/ex_2_12.R | 18 +++ .../CH2/EX2.13/ex_2_13.R | 6 + .../CH2/EX2.14/ex_2_14.R | 24 ++++ .../CH2/EX2.15/ex_2_15.R | 6 + .../CH2/EX2.16/ex_2_16.R | 9 ++ .../CH2/EX2.18/ex_2_18.R | 14 ++ .../CH2/EX2.19/ex_2_19.R | 23 ++++ .../CH2/EX2.20/ex_2_20.R | 51 ++++++++ .../CH2/EX2.3/ex_2_3.R | 7 + .../CH2/EX2.4/ex_2_4.R | 4 + .../CH2/EX2.5/ex_2_5.R | 21 +++ .../CH2/EX2.6/ex_2_6.R | 10 ++ .../CH2/EX2.7/ex_2_7.R | 4 + .../CH2/EX2.8/ex_2_8.R | 5 + .../CH2/EX2.9/ex_2_9.R | 6 + .../CH4/EX4.1/ex_4_1.R | 5 + .../CH4/EX4.12/ex_4_12.R | 4 + .../CH4/EX4.13/ex_4_13.R | 3 + .../CH4/EX4.16/ex_4_16.R | 1 + .../CH4/EX4.17/ex_4_17.R | 1 + .../CH4/EX4.18/ex_4_18.R | 2 + .../CH4/EX4.19.a/ex_4_19_a.R | 1 + .../CH4/EX4.19.b/ex_4_19_b.R | 8 ++ .../CH4/EX4.2/ex_4_2.R | 10 ++ .../CH4/EX4.20/ex_4_20.R | 7 + .../CH4/EX4.21.a/ex_4_21_a.R | 1 + .../CH4/EX4.21.b/ex_4_21_b.R | 5 + .../CH4/EX4.25/ex_4_25.R | 5 + .../CH4/EX4.28/ex_4_28.R | 13 ++ .../CH4/EX4.29/ex_4_29.R | 7 + .../CH4/EX4.31/ex_4_31.R | 8 ++ .../CH4/EX4.32/ex_4_32.R | 7 + .../CH4/EX4.33/ex_4_33.R | 9 ++ .../CH4/EX4.35/ex_4_35.R | 13 ++ .../CH4/EX4.37/ex_4_37.R | 6 + .../CH4/EX4.39/ex_4_39.R | 20 +++ .../CH4/EX4.40/ex_4_40.R | 4 + .../CH4/EX4.41/ex_4_41.R | 11 ++ .../CH4/EX4.42/ex_4_42.R | 19 +++ .../CH4/EX4.5/ex_4_5.R | 11 ++ .../CH4/EX4.6/ex_4_6.R | 6 + .../CH4/EX4.7/ex_4_7.R | 12 ++ .../CH5/EX5.1/ex_5_1.R | 11 ++ .../CH5/EX5.11/ex_5_11.R | 20 +++ .../CH5/EX5.12/ex_5_12.R | 10 ++ .../CH5/EX5.13/ex_5_13.R | 14 ++ .../CH5/EX5.15/ex_5_15.R | 14 ++ .../CH5/EX5.17/ex_5_17.R | 10 ++ .../CH5/EX5.18/ex_5_18.R | 8 ++ .../CH5/EX5.19/ex_5_19.R | 7 + .../CH5/EX5.2/ex_5_2.R | 15 +++ .../CH5/EX5.20/ex_5_20.R | 18 +++ .../CH5/EX5.22/ex_5_22.R | 5 + .../CH5/EX5.23.a/ex_5_23_a.R | 6 + .../CH5/EX5.3/ex_5_3.R | 18 +++ .../CH5/EX5.4/ex_5_4.R | 14 ++ .../CH5/EX5.5/ex_5_5.R | 9 ++ .../CH5/EX5.6/ex_5_6.R | 13 ++ .../CH5/EX5.7/ex_5_7.R | 10 ++ .../CH5/EX5.8.a/ex_5_8_a.R | 6 + .../CH5/EX5.8.b/ex_5_8_b.R | 5 + .../CH6/EX6.1/ex_6_1.R | 7 + .../CH6/EX6.10/ex_6_10.R | 11 ++ .../CH6/EX6.11/ex_6_11.R | 7 + .../CH6/EX6.12/ex_6_12.R | 1 + .../CH6/EX6.13/ex_6_13.R | 16 +++ .../CH6/EX6.14/ex_6_14.R | 7 + .../CH6/EX6.15/ex_6_15.R | 9 ++ .../CH6/EX6.16/ex_6_16.R | 18 +++ .../CH6/EX6.17.a/ex_6_17_a.R | 16 +++ .../CH6/EX6.17.b/ex_6_17_b.R | 5 + .../CH6/EX6.18/ex_6_18.R | 8 ++ .../CH6/EX6.2/ex_6_2.R | 12 ++ .../CH6/EX6.20/ex_6_20.R | 12 ++ .../CH6/EX6.22/ex_6_22.R | 6 + .../CH6/EX6.23/ex_6_23.R | 19 +++ .../CH6/EX6.24/ex_6_24.R | 12 ++ .../CH6/EX6.25/ex_6_25.R | 11 ++ .../CH6/EX6.26/ex_6_26.R | 11 ++ .../CH6/EX6.27/ex_6_27.R | 7 + .../CH6/EX6.4/ex_6_4.R | 13 ++ .../CH6/EX6.5/ex_6_5.R | 13 ++ .../CH6/EX6.6/ex_6_6.R | 15 +++ .../CH6/EX6.7/ex_6_7.R | 7 + .../CH6/EX6.8.a/ex_6_8_a.R | 10 ++ .../CH6/EX6.9.a/ex_6_9_a.R | 11 ++ .../CH6/EX6.9.b/ex_6_9_b.R | 10 ++ .../CH7/EX7.10/ex_7_10.R | 49 +++++++ .../CH7/EX7.12/ex_7_12.R | 37 ++++++ .../CH7/EX7.13/ex_7_13.R | 8 ++ .../CH7/EX7.15/ex_7_15.R | 13 ++ .../CH7/EX7.19/ex_7_19.R | 14 ++ .../CH7/EX7.2/ex_7_2.R | 39 ++++++ .../CH7/EX7.20/ex_7_20.R | 12 ++ .../CH7/EX7.3/ex_7_3.R | 19 +++ .../CH7/EX7.4/ex_7_4.R | 6 + .../CH7/EX7.5/ex_7_5.R | 10 ++ .../CH7/EX7.6/ex_7_6.R | 20 +++ .../CH7/EX7.7/ex_7_7.R | 23 ++++ .../CH8/EX8.10/ex_8_10.R | 17 +++ .../CH8/EX8.11/ex_8_11.R | 13 ++ .../CH8/EX8.12/ex_8_12.R | 13 ++ .../CH8/EX8.13.a/ex_8_13_a.R | 16 +++ .../CH8/EX8.13.b/ex_8_13_b.R | 15 +++ .../CH8/EX8.14/ex_8_14.R | 33 +++++ .../CH8/EX8.15/ex_8_15.R | 36 +++++ .../CH8/EX8.16/ex_8_16.R | 21 +++ .../CH8/EX8.17/ex_8_17.R | 14 ++ .../CH8/EX8.18/ex_8_18.R | 23 ++++ .../CH8/EX8.19/ex_8_19.R | 20 +++ .../CH8/EX8.2/ex_8_2.R | 41 ++++++ .../CH8/EX8.3/ex_8_3.R | 17 +++ .../CH8/EX8.4/ex_8_4.R | 20 +++ .../CH8/EX8.5/ex_8_5.R | 19 +++ .../CH8/EX8.6/ex_8_6.R | 10 ++ .../CH8/EX8.7/ex_8_7.R | 10 ++ .../CH8/EX8.8/ex_8_8.R | 20 +++ .../CH8/EX8.9/ex_8_9.R | 14 ++ .../CH9/EX9.10/ex_9_10.R | 11 ++ .../CH9/EX9.11/ex_9_11.R | 14 ++ .../CH9/EX9.12/ex_9_12.R | 14 ++ .../CH9/EX9.13/ex_9_13.R | 20 +++ .../CH9/EX9.14/ex_9_14.R | 18 +++ .../CH9/EX9.15/ex_9_15.R | 26 ++++ .../CH9/EX9.16/ex_9_16.R | 9 ++ .../CH9/EX9.17/ex_9_17.R | 24 ++++ .../CH9/EX9.18/ex_9_18.R | 8 ++ .../CH9/EX9.19/ex_9_19.R | 9 ++ .../CH9/EX9.20/ex_9_20.R | 19 +++ .../CH9/EX9.21/ex_9_21.R | 16 +++ .../CH9/EX9.22/ex_9_22.R | 11 ++ .../CH9/EX9.23/ex_9_23.R | 10 ++ .../CH9/EX9.24/ex_9_24.R | 9 ++ .../CH9/EX9.25/ex_9_25.R | 7 + .../CH9/EX9.29/ex_9_29.R | 13 ++ .../CH9/EX9.30/ex_9_30.R | 11 ++ .../CH9/EX9.4/ex_9_4.R | 13 ++ .../CH9/EX9.6/ex_9_6.R | 6 + .../CH9/EX9.7/ex_9_7.R | 12 ++ .../CH9/EX9.8/ex_9_8.R | 13 ++ .../CH9/EX9.9/ex_9_9.R | 9 ++ .../README.txt | 18 +++ README.txt | 18 +++ R_Book_by_R_Author/CH4/EX4.1.a/Ex4_1a.R | 30 +++++ R_Book_by_R_Author/CH4/EX4.1.c/Ex4_1c.R | 10 ++ R_Book_by_R_Author/README.txt | 18 +++ .../CH1/EX1.1/Ex1_1.R | 7 + .../CH1/EX1.10/Ex1_10.R | 6 + .../CH1/EX1.11/Ex1_11.R | 6 + .../CH1/EX1.12/Ex1_12.R | 10 ++ .../CH1/EX1.13/Ex1_13.R | 6 + .../CH1/EX1.15/Ex1_15.R | 7 + .../CH1/EX1.2/Ex1_2.R | 10 ++ .../CH1/EX1.24/Ex1_24.R | 10 ++ .../CH1/EX1.27/Ex1_27.R | 5 + .../CH1/EX1.29/Ex1_29.R | 6 + .../CH1/EX1.3/Ex1_3.R | 9 ++ .../CH1/EX1.31/Ex1_31.R | 5 + .../CH1/EX1.34/Ex1_34.R | 8 ++ .../CH1/EX1.5/Ex1_5.R | 21 +++ .../CH1/EX1.52/Ex1_52.R | 9 ++ .../CH1/EX1.54/Ex1_54.R | 14 ++ .../CH1/EX1.55/Ex1_55.R | 10 ++ .../CH1/EX1.6/Ex1_6.R | 11 ++ .../CH1/EX1.7/Ex1_7.R | 9 ++ .../CH1/EX1.8/Ex1_8.R | 18 +++ .../CH2/EX2.11/Ex2_11.R | 6 + .../CH2/EX2.13/Ex2_13.R | 10 ++ .../CH2/EX2.14/Ex2_14.R | 24 ++++ .../CH2/EX2.16/Ex2_16.R | 6 + .../CH2/EX2.17/Ex2_17.R | 6 + .../CH2/EX2.18/Ex2_18.R | 8 ++ .../CH2/EX2.19/Ex2_19.R | 7 + .../CH2/EX2.20/Ex2_20.R | 6 + .../CH2/EX2.25/Ex2_25.R | 13 ++ .../CH2/EX2.26/Ex2_26.R | 14 ++ .../CH3/EX3.1/Ex3_1.R | 4 + .../CH3/EX3.11/Ex3_11.R | 4 + .../CH3/EX3.15/Ex3_15.R | 6 + .../CH3/EX3.17/Ex3_17.R | 11 ++ .../CH3/EX3.18/Ex3_18.R | 6 + .../CH3/EX3.2/Ex3_2.R | 4 + .../CH3/EX3.3/Ex3_3.R | 15 +++ .../CH3/EX3.4/Ex3_4.R | 9 ++ .../CH3/EX3.40/Ex3_40.R | 7 + .../CH3/EX3.7/Ex3_7.R | 6 + .../CH3/EX3.8/Ex3_8.R | 5 + .../CH4/EX4.1/Ex4_1.R | 9 ++ .../CH4/EX4.13/Ex4_13.R | 7 + .../CH4/EX4.16/Ex4_16.R | 4 + .../CH4/EX4.17/Ex4_17.R | 4 + .../CH4/EX4.18/Ex4_18.R | 5 + .../CH4/EX4.19/Ex4_19.R | 5 + .../CH4/EX4.2/Ex4_2.R | 9 ++ .../CH4/EX4.20/Ex4_20.R | 4 + .../CH4/EX4.22/Ex4_22.R | 13 ++ .../CH4/EX4.27/Ex4_27.R | 9 ++ .../CH4/EX4.28/Ex4_28.R | 9 ++ .../CH4/EX4.4/Ex4_4.R | 8 ++ .../CH4/EX4.5/Ex4_5.R | 6 + .../CH4/EX4.6/Ex4_6.R | 6 + .../CH4/EX4.7/Ex4_7.R | 8 ++ .../CH4/EX4.8/Ex4_8.R | 7 + .../CH5/EX5.10/Ex5_10.R | 11 ++ .../CH5/EX5.11/Ex5_11.R | 13 ++ .../CH5/EX5.12/Ex5_12.R | 9 ++ .../CH5/EX5.13/Ex5_13.R | 7 + .../CH5/EX5.14/Ex5_14.R | 7 + .../CH5/EX5.17/Ex5_17.R | 6 + .../CH5/EX5.19/Ex5_19.R | 9 ++ .../CH5/EX5.3/Ex5_3.R | 11 ++ .../CH5/EX5.5/Ex5_5.R | 7 + .../CH5/EX5.6/Ex5_6.R | 7 + .../CH5/EX5.7/Ex5_7.R | 11 ++ .../CH5/EX5.8/Ex5_8.R | 7 + .../CH5/EX5.9/Ex5_9.R | 10 ++ .../CH6/EX6.10/Ex6_10.R | 6 + .../CH6/EX6.13/Ex6_13.R | 8 ++ .../CH6/EX6.14/Ex6_14.R | 9 ++ .../CH6/EX6.15/Ex6_15.R | 8 ++ .../CH6/EX6.16/Ex6_16.R | 10 ++ .../CH6/EX6.17/Ex6_17.R | 10 ++ .../CH6/EX6.18/Ex6_18.R | 7 + .../CH6/EX6.2/Ex6_2.R | 4 + .../CH6/EX6.22/Ex6_22.R | 10 ++ .../CH6/EX6.27/Ex6_27.R | 6 + .../CH6/EX6.28/Ex6_28.R | 8 ++ .../CH6/EX6.3/Ex6_3.R | 4 + .../CH6/EX6.4/Ex6_4.R | 13 ++ .../CH6/EX6.5/Ex6_5.R | 4 + .../CH6/EX6.7/Ex6_7.R | 4 + .../CH6/EX6.8/Ex6_8.R | 6 + .../CH6/EX6.9/Ex6_9.R | 11 ++ .../CH7/EX7.1/Ex7_1.R | 12 ++ .../CH7/EX7.10/Ex7_10.R | 18 +++ .../CH7/EX7.13/Ex7_13.R | 20 +++ .../CH7/EX7.15/Ex7_15.R | 12 ++ .../CH7/EX7.16/Ex7_16.R | 15 +++ .../CH7/EX7.2/Ex7_2.R | 9 ++ .../CH7/EX7.3/Ex7_3.R | 13 ++ .../CH7/EX7.4/Ex7_4.R | 7 + .../CH7/EX7.6/Ex7_6.R | 8 ++ .../CH7/EX7.7/Ex7_7.R | 12 ++ .../CH7/EX7.9/Ex7_9.R | 10 ++ .../CH8/EX8.1/Ex8_1.R | 14 ++ .../CH8/EX8.10/Ex8_10.R | 8 ++ .../CH8/EX8.12/Ex8_12.R | 7 + .../CH8/EX8.14/Ex8_14.R | 14 ++ .../CH8/EX8.15/Ex8_15.R | 10 ++ .../CH8/EX8.16/Ex8_16.R | 7 + .../CH8/EX8.17/Ex8_17.R | 12 ++ .../CH8/EX8.18/Ex8_18.R | 5 + .../CH8/EX8.2/Ex8_2.R | 14 ++ .../CH8/EX8.3/Ex8_3.R | 7 + .../CH8/EX8.4/Ex8_4.R | 4 + .../CH8/EX8.9/Ex8_9.R | 8 ++ .../README.txt | 18 +++ .../CH10/EX10.1a/Ex10_1a.R | 22 ++++ .../CH10/EX10.1b/Ex10_1b.R | 43 ++++++ .../CH10/EX10.2a/Ex10_2a.R | 27 ++++ .../CH10/EX10.2b/Ex10_2b.R | 21 +++ .../CH10/EX10.3a/Ex10_3a.R | 31 +++++ .../CH10/EX10.4a/Ex10_4a.R | 28 ++++ .../CH10/EX10.4b/Ex10_4b.R | 24 ++++ .../CH11/EX11.1a/Ex11_1a.R | 18 +++ .../CH11/EX11.1b/Ex11_1b.R | 63 +++++++++ .../CH11/EX11.2a/Ex11_2a.R | 80 ++++++++++++ .../CH12/EX12.1a/Ex12_1a.R | 45 +++++++ .../CH12/EX12.2a/Ex12_2a.R | 27 ++++ .../CH12/EX12.3a/Ex12_3a.R | 46 +++++++ .../CH12/EX12.3b/Ex12_3b.R | 55 ++++++++ .../CH13/EX13.1a/Ex13_1a.R | 36 +++++ .../CH13/EX13.2a/Ex13_2a.R | 54 ++++++++ .../CH13/EX13.3a/Ex13_3a.R | 98 ++++++++++++++ .../CH13/EX13.4a/Ex13_4a.R | 38 ++++++ .../CH13/EX13.5a/Ex13_5a.R | 60 +++++++++ .../CH14/EX14.1a/Ex14_1a.R | 40 ++++++ .../CH14/EX14.2a/Ex14_2a.R | 35 +++++ .../CH14/EX14.3a/Ex14_3a.R | 61 +++++++++ .../CH14/EX14.4a/Ex14_4a.R | 28 ++++ .../CH14/EX14.5a/Ex14_5a.R | 28 ++++ .../CH14/EX14.5b/Ex14_5b.R | 49 +++++++ .../CH14/EX14.6a/Ex14_6a.R | 11 ++ .../CH14/EX14.6b/Ex14_6b.R | 25 ++++ .../CH15/EX15.1a/Ex15_1a.R | 52 ++++++++ .../CH15/EX15.2a/Ex15_2a.R | 19 +++ .../CH15/EX15.3a/Ex15_3a.R | 39 ++++++ .../CH15/EX15.4a/Ex15_4a.R | 84 ++++++++++++ .../CH15/EX15.5a/Ex15_5a.R | 50 +++++++ .../CH15/EX15.6a/Ex15_6a.R | 40 ++++++ .../CH15/EX15.6b/Ex15_6b.R | 44 +++++++ .../CH15/EX15.7a/Ex15_7a.R | 15 +++ .../CH16/EX16.1a/Ex16_1a.R | 74 +++++++++++ .../CH16/EX16.1b/Ex16_1b.R | 32 +++++ .../CH16/EX16.1c/Ex16_1c.R | 79 +++++++++++ .../CH16/EX16.2a/Ex16_2a.R | 56 ++++++++ .../CH16/EX16.3a/Ex16_3a.R | 21 +++ .../CH17/EX17.1a/Ex17_1a.R | 18 +++ .../CH17/EX17.2a/Ex17_2a.R | 29 +++++ .../CH17/EX17.3a/Ex17_3a.R | 24 ++++ .../CH17/EX17.4a/Ex17_4a.R | 29 +++++ .../CH18/EX18.1a/Ex18_1a.R | 19 +++ .../CH18/EX18.1b/Ex18_1b.R | 19 +++ .../CH18/EX18.1c/Ex18_1c.R | 19 +++ .../CH18/EX18.1d/Ex18_1d.R | 19 +++ .../CH18/EX18.1e/Ex18_1e.R | 22 ++++ .../CH18/EX18.1f/Ex18_1f.R | 21 +++ .../CH18/EX18.2a/Ex18_2a.R | 93 +++++++++++++ .../CH18/EX18.3a/Ex18_3a.R | 39 ++++++ .../CH18/EX18.3b/Ex18_3b.R | 28 ++++ .../CH18/EX18.4a/Ex18_4a.R | 24 ++++ .../CH18/EX18.4b/Ex18_4b.R | 35 +++++ .../CH18/EX18.4c/Ex18_4c.R | 28 ++++ .../CH18/EX18.5a/Ex18_5a.R | 39 ++++++ .../CH18/EX18.5b/Ex18_5b.R | 39 ++++++ .../CH18/EX18.6a/Ex18_6a.R | 30 +++++ .../CH18/EX18.6b/Ex18_6b.R | 36 +++++ .../CH19/EX19.1a/Ex19_1a.R | 43 ++++++ .../CH19/EX19.2a/Ex19_2a.R | 59 +++++++++ .../CH19/EX19.3a/Ex19_3a.R | 22 ++++ .../CH19/EX19.4a/Ex19_4a.R | 20 +++ .../CH19/EX19.4b/Ex19_4b.R | 20 +++ .../CH19/EX19.5a/Ex19_5a.R | 20 +++ .../CH2/EX2.1a/Ex2_1a.R | 49 +++++++ .../CH2/EX2.1b/Ex2_1b.R | 42 ++++++ .../CH2/EX2.2a/Ex2_2a.R | 63 +++++++++ .../CH2/EX2.3a/Ex2_3a.R | 23 ++++ .../CH2/EX2.4a/Ex2_4a.R | 34 +++++ .../CH2/EX2.5a/Ex2_5a.R | 15 +++ .../CH20/EX20.1a/Ex20_1a.R | 71 ++++++++++ .../CH21/EX21.1a/Ex21_1a.R | 26 ++++ .../CH3/EX3.1a/Ex3_1a.R | 9 ++ .../CH3/EX3.1b/Ex3_1b.R | 17 +++ .../CH3/EX3.1c/Ex3_1c.R | 9 ++ .../CH3/EX3.1d/Ex3_1d.R | 9 ++ .../CH3/EX3.1e/Ex3_1e.R | 20 +++ .../CH3/EX3.2a/Ex3_2a.R | 18 +++ .../CH3/EX3.2b/Ex3_2b.R | 9 ++ .../CH3/EX3.2c/Ex3_2c.R | 15 +++ .../CH3/EX3.3a/Ex3_3a.R | 21 +++ .../CH3/EX3.4a/Ex3_4a.R | 16 +++ .../CH3/EX3.5a/Ex3_5a.R | 20 +++ .../CH3/EX3.5b/Ex3_5b.R | 12 ++ .../CH3/EX3.6a/Ex3_6a.R | 15 +++ .../CH3/EX3.6b/Ex3_6b.R | 23 ++++ .../CH4/EX4.1a/Ex4_1a.R | 21 +++ .../CH4/EX4.1b/Ex4_1b.R | 10 ++ .../CH4/EX4.1c/Ex4_1c.R | 16 +++ .../CH4/EX4.1d/Ex4_1d.R | 29 +++++ .../CH4/EX4.2a/Ex4_2a.R | 42 ++++++ .../CH4/EX4.3a/Ex4_3a.R | 9 ++ .../CH4/EX4.3b/Ex4_3b.R | 22 ++++ .../CH4/EX4.3c/Ex4_3c.R | 11 ++ .../CH4/EX4.4a/Ex4_4a.R | 40 ++++++ .../CH4/EX4.4b/Ex4_4b.R | 25 ++++ .../CH4/EX4.5a/Ex4_5a.R | 21 +++ .../CH5/EX5.1a/Ex5_1a.R | 44 +++++++ .../CH5/EX5.2a/Ex5_2a.R | 13 ++ .../CH5/EX5.2b/Ex5_2b.R | 98 ++++++++++++++ .../CH5/EX5.3a/Ex5_3a.R | 12 ++ .../CH5/EX5.4a/Ex5_4a.R | 31 +++++ .../CH5/EX5.5a/Ex5_5a.R | 28 ++++ .../CH6/EX6.1a/Ex6_1a.R | 31 +++++ .../CH6/EX6.2a/Ex6_2a.R | 18 +++ .../CH6/EX6.3a/Ex6_3a.R | 32 +++++ .../CH6/EX6.4a/Ex6_4a.R | 24 ++++ .../CH7/EX7.1a/Ex7_1a.R | 30 +++++ .../CH7/EX7.2a/Ex7_2a.R | 17 +++ .../CH7/EX7.3a/Ex7_3a.R | 35 +++++ .../CH7/EX7.3b/Ex7_3b.R | 22 ++++ .../CH7/EX7.4a/Ex7_4a.R | 19 +++ .../CH7/EX7.4b/Ex7_4b.R | 22 ++++ .../CH7/EX7.4c/Ex7_4c.R | 25 ++++ .../CH8/EX8.1a/Ex8_1a.R | 35 +++++ .../CH8/EX8.2a/Ex8_2a.R | 17 +++ .../CH8/EX8.2b/Ex8_2b.R | 15 +++ .../CH8/EX8.3a/Ex8_3a.R | 13 ++ .../CH8/EX8.4a/Ex8_4a.R | 20 +++ .../CH8/EX8.4b/Ex8_4b.R | 27 ++++ .../CH9/EX9.1a/Ex9_1a.R | 38 ++++++ .../CH9/EX9.1b/Ex9_1b.R | 42 ++++++ .../CH9/EX9.1c/Ex9_1c.R | 26 ++++ .../CH9/EX9.2a/Ex9_2a.R | 25 ++++ .../CH9/EX9.2b/Ex9_2b.R | 41 ++++++ .../CH9/EX9.3a/Ex9_3a.R | 38 ++++++ .../CH9/EX9.4a/Ex9_4a.R | 35 +++++ .../CH9/EX9.5a/Ex9_5a.R | 15 +++ .../README.txt | 18 +++ .../CH10/EX10.1/Ex10_1.R | 22 ++++ .../CH11/EX11.1/Ex11_1.zip | Bin 0 -> 2223 bytes .../CH11/EX11.2/Ex11_2.zip | Bin 0 -> 1229 bytes .../CH12/EX12.1/Ex12_1.zip | Bin 0 -> 1226 bytes .../CH12/EX12.2/Ex12_2.zip | Bin 0 -> 1755 bytes .../CH12/EX12.3/Ex12_3.R | 51 ++++++++ .../CH12/EX12.4/Ex12_4.R | 33 +++++ .../CH12/EX12.5/Ex12_5.zip | Bin 0 -> 1553 bytes .../CH12/EX12.6/Ex12_6.zip | Bin 0 -> 4807 bytes .../CH13/EX13.1/Ex13_1.zip | Bin 0 -> 1683 bytes .../CH13/EX13.10/Ex13_10.zip | Bin 0 -> 2548 bytes .../CH13/EX13.11/Ex13_11.zip | Bin 0 -> 2415 bytes .../CH13/EX13.2/Ex13_2.zip | Bin 0 -> 1552 bytes .../CH13/EX13.3/Ex13_3.zip | Bin 0 -> 1337 bytes .../CH13/EX13.4/Ex13_4.zip | Bin 0 -> 1158 bytes .../CH13/EX13.5/Ex13_5.zip | Bin 0 -> 1203 bytes .../CH13/EX13.6/Ex13_6.zip | Bin 0 -> 1087 bytes .../CH13/EX13.7/Ex13_7.zip | Bin 0 -> 1040 bytes .../CH13/EX13.8/Ex13_8.zip | Bin 0 -> 1004 bytes .../CH13/EX13.9/Ex13_9.zip | Bin 0 -> 2566 bytes .../CH14/EX14.1/Ex14_1.zip | Bin 0 -> 1779 bytes .../CH14/EX14.2.a/Ex14_2a.zip | Bin 0 -> 1022 bytes .../CH14/EX14.2b/Ex14_2b.zip | Bin 0 -> 1555 bytes .../CH14/EX14.3/Ex14_3.zip | Bin 0 -> 1380 bytes .../CH14/EX14.4/Ex14_4.zip | Bin 0 -> 1661 bytes .../CH14/EX14.5/Ex14_5.zip | Bin 0 -> 1134 bytes .../CH15/EX15.1/Ex15_1.R | 24 ++++ .../CH15/EX15.2/Ex15_2.zip | Bin 0 -> 1141 bytes .../CH16/EX16.1/Ex16_1.R | 25 ++++ .../CH16/EX16.2/Ex16_2.zip | Bin 0 -> 1382 bytes .../CH16/EX16.3/Ex16_3.zip | Bin 0 -> 1327 bytes .../CH16/EX16.4/Ex16_4.zip | Bin 0 -> 1478 bytes .../CH16/EX16.5/Ex16_5.zip | Bin 0 -> 1424 bytes .../CH16/EX16.6/Ex16_6.zip | Bin 0 -> 1364 bytes .../CH16/EX16.7.a/Ex16_7a.zip | Bin 0 -> 1414 bytes .../CH16/EX16.7.b/Ex16_7b.zip | Bin 0 -> 1415 bytes .../CH17/EX17.1/Ex17_1.zip | Bin 0 -> 1848 bytes .../CH2/EX2.1/Ex2_1.R | 38 ++++++ .../CH2/EX2.2/Ex2_2.R | 23 ++++ .../CH2/EX2.3/Ex2_3.R | 21 +++ .../CH2/EX2.4/Ex2_4.zip | Bin 0 -> 1926 bytes .../CH3/EX3.1/Ex3_1.zip | Bin 0 -> 1453 bytes .../CH3/EX3.2/Ex3_2.zip | Bin 0 -> 1178 bytes .../CH3/EX3.3/Ex3_3.zip | Bin 0 -> 1102 bytes .../CH3/EX3.4/Ex3_4.zip | Bin 0 -> 1161 bytes .../CH3/EX3.5/Ex3_5.zip | Bin 0 -> 3678 bytes .../CH3/EX3.6/Ex3_6.zip | Bin 0 -> 4841 bytes .../CH3/EX3.7/Ex3_7.zip | Bin 0 -> 882 bytes .../CH4/EX4.1/Ex4_1.R | 16 +++ .../CH4/EX4.10/Ex4_10.R | 33 +++++ .../CH4/EX4.11/Ex4_11.R | 13 ++ .../CH4/EX4.12/Ex4_12.zip | Bin 0 -> 1347 bytes .../CH4/EX4.13/Ex4_13.zip | Bin 0 -> 1321 bytes .../CH4/EX4.14/Ex4_14.zip | Bin 0 -> 1377 bytes .../CH4/EX4.15/Ex4_15.zip | Bin 0 -> 1810 bytes .../CH4/EX4.16/Ex4_16.R | 24 ++++ .../CH4/EX4.17/Ex4_17.zip | Bin 0 -> 1207 bytes .../CH4/EX4.18/Ex4_18.zip | Bin 0 -> 949 bytes .../CH4/EX4.19/Ex4_19.zip | Bin 0 -> 1706 bytes .../CH4/EX4.2/Ex4_2.zip | Bin 0 -> 1248 bytes .../CH4/EX4.3/Ex4_3.R | 13 ++ .../CH4/EX4.4/Ex4_4.zip | Bin 0 -> 1289 bytes .../CH4/EX4.5/Ex4_5.R | 25 ++++ .../CH4/EX4.6/Ex4_6.zip | Bin 0 -> 1475 bytes .../CH4/EX4.7/Ex4_7.R | 18 +++ .../CH4/EX4.8/Ex4_8.zip | Bin 0 -> 1050 bytes .../CH4/EX4.9/Ex4_9.R | 44 +++++++ .../CH5/EX5.1/Ex5_1.R | 9 ++ .../CH6/EX6.1/Ex6_1.R | 41 ++++++ .../CH6/EX6.10/Ex6_10.R | 130 ++++++++++++++++++ .../CH6/EX6.2/Ex6_2.R | 30 +++++ .../CH6/EX6.3/Ex6_3.R | 36 +++++ .../CH6/EX6.4/Ex6_4.R | 33 +++++ .../CH6/EX6.5/Ex6_5.R | 23 ++++ .../CH6/EX6.6/Ex6_6.R | 23 ++++ .../CH6/EX6.7/Ex6_7.R | 22 ++++ .../CH6/EX6.8/Ex6_8.R | 26 ++++ .../CH6/EX6.9/Ex6_9.R | 28 ++++ .../CH7/EX7.1/Ex7_1.R | 18 +++ .../CH7/EX7.10/Ex7_10.R | 21 +++ .../CH7/EX7.11/Ex7_11.R | 27 ++++ .../CH7/EX7.12/Ex7_12.R | 17 +++ .../CH7/EX7.13.a/Ex7_13a.R | 18 +++ .../CH7/EX7.13.b/Ex7_13b.R | 23 ++++ .../CH7/EX7.2/Ex7_2.R | 33 +++++ .../CH7/EX7.3/Ex7_3.R | 25 ++++ .../CH7/EX7.4/Ex7_4.R | 26 ++++ .../CH7/EX7.5/Ex7_5.R | 64 +++++++++ .../CH7/EX7.6/Ex7_6.R | 78 +++++++++++ .../CH7/EX7.7/Ex7_7.R | 82 ++++++++++++ .../CH7/EX7.8.a/Ex7_8a.R | 15 +++ .../CH7/EX7.8b/Ex7_8b.R | 30 +++++ .../CH7/EX7.9.a/Ex7_9a.R | 18 +++ .../CH7/EX7.9.b/Ex7_9b.R | 17 +++ .../CH8/EX8.1.a/Ex8_1a.R | 20 +++ .../CH8/EX8.1.b/Ex8_1b.R | 17 +++ .../CH8/EX8.1.c/Ex8_1c.R | 15 +++ .../CH8/EX8.2/Ex8_2.R | 17 +++ .../CH8/EX8.3.a/Ex8_3a.R | 15 +++ .../CH8/EX8.3.b/Ex8_3b.R | 15 +++ .../CH8/EX8.4/Ex8_4.R | 15 +++ .../CH8/EX8.5/Ex8_5.R | 15 +++ .../CH8/EX8.6/Ex8_6.R | 14 ++ .../CH8/EX8.7.a/Ex8_7a.R | 15 +++ .../CH8/EX8.7.b/Ex8_7b.R | 15 +++ .../CH8/EX8.7.c/Ex8_7c.R | 19 +++ .../CH8/EX8.8.a/Ex8_8a.R | 18 +++ .../CH8/EX8.8.b/Ex8_8b.R | 19 +++ .../CH8/EX8.8.c/Ex8_8c.R | 19 +++ .../CH9/EX9.1.a/Ex9_1a.R | 21 +++ .../CH9/EX9.1.b/Ex9_1b.R | 24 ++++ .../CH9/EX9.2/Ex9_2.R | 24 ++++ .../CH9/EX9.3/Ex9_3.R | 26 ++++ .../README.txt | 18 +++ .../CH1/EX1.1a/Ex1_1a.R | 16 +++ .../CH1/EX1.1c/Ex1_1c.R | 21 +++ .../CH1/EX1.1d/Ex1_1d.R | 18 +++ .../CH1/EX1.1e/Ex1_1e.R | 22 ++++ .../CH1/EX1.2a/Ex1_2a.R | 21 +++ .../CH1/EX1.2b/Ex1_2b.R | 24 ++++ .../CH1/EX1.2c/Ex1_2c.R | 35 +++++ .../CH1/EX1.2d/Ex1_2d.R | 23 ++++ .../CH1/EX1.2e/Ex1_2e.R | 26 ++++ .../CH1/EX1.4a/Ex1_4a.R | 25 ++++ .../CH10/EX10.1a/Ex10_1a.R | 76 +++++++++++ .../CH10/EX10.1b/Ex10_1b.R | 69 ++++++++++ .../CH10/EX10.2a/Ex10_2a.R | 33 +++++ .../CH10/EX10.2b/Ex10_2b.R | 16 +++ .../CH10/EX10.3a/Ex10_3a.R | 76 +++++++++++ .../CH11/EX11.1a/Ex11_1a.R | 22 ++++ .../CH11/EX11.1b/Ex11_1b.R | 24 ++++ .../CH11/EX11.2a/Ex11_2a.R | 38 ++++++ .../CH11/EX11.2b/Ex11_2b.R | 11 ++ .../CH11/EX11.2c/Ex11_2c.R | 15 +++ .../CH11/EX11.3a/Ex11_3a.R | 10 ++ .../CH11/EX11.3b/Ex11_3b.R | 26 ++++ .../CH11/EX11.3c/Ex11_3c.R | 28 ++++ .../CH11/EX11.4a/Ex11_4a.R | 22 ++++ .../CH11/EX11.4b/Ex11_4b.R | 12 ++ .../CH11/EX11.4c/Ex11_4c.R | 26 ++++ .../CH12/EX12.1a/Ex12_1a.R | 21 +++ .../CH12/EX12.1b/Ex12_1b.R | 32 +++++ .../CH12/EX12.2a/Ex12_2a.R | 25 ++++ .../CH12/EX12.3a/Ex12_3a.R | 30 +++++ .../CH12/EX12.3b/Ex12_3b.R | 62 +++++++++ .../CH12/EX12.3c/Ex12_3c.R | 22 ++++ .../CH12/EX12.3d/Ex12_3d.R | 50 +++++++ .../CH12/EX12.4a/Ex12_4a.R | 11 ++ .../CH12/EX12.4b/Ex12_4b.R | 13 ++ .../CH12/EX12.5a/Ex12_5a.R | 18 +++ .../CH12/EX12.5b/Ex12_5b.R | 29 +++++ .../CH12/EX12.6a/Ex12_6a.R | 20 +++ .../CH12/EX12.6b/Ex12_6b.R | 31 +++++ .../CH12/EX12.7a/Ex12_7a.R | 41 ++++++ .../CH12/EX12.7b/Ex12_7b.R | 24 ++++ .../CH12/EX12.7c/Ex12_7c.R | 11 ++ .../CH12/EX12.7d/Ex12_7d.R | 18 +++ .../CH12/EX12.7e/Ex12_7e.R | 21 +++ .../CH13/EX13.1a/Ex13_1a.R | 15 +++ .../CH13/EX13.1b/Ex13_1b.R | 14 ++ .../CH13/EX13.1c/Ex13_1c.R | 34 +++++ .../CH13/EX13.1d/Ex13_1d.R | 32 +++++ .../CH13/EX13.2a/Ex13_2a.R | 48 +++++++ .../CH13/EX13.2b/Ex13_2b.R | 49 +++++++ .../CH13/EX13.2c/Ex13_2c.R | 49 +++++++ .../CH13/EX13.3a/Ex13_3a.R | 20 +++ .../CH13/EX13.3b/Ex13_3b.R | 22 ++++ .../CH13/EX13.4a/Ex13_4a.R | 31 +++++ .../CH13/EX13.4b/Ex13_4b.R | 49 +++++++ .../CH13/EX13.4c/Ex13_4c.R | 18 +++ .../CH14/EX14.1a/Ex14_1a.R | 54 ++++++++ .../CH14/EX14.2a/Ex14_2a.R | 31 +++++ .../CH14/EX14.2b/Ex14_2b.R | 42 ++++++ .../CH14/EX14.2c/Ex14_2c.R | 13 ++ .../CH14/EX14.3a/Ex14_3a.R | 23 ++++ .../CH2/EX2.1a/Ex2_1a.R | 9 ++ .../CH2/EX2.1b/Ex2_1b.R | 26 ++++ .../CH2/EX2.1c/Ex2_1c.R | 28 ++++ .../CH2/EX2.1d/Ex2_1d.R | 38 ++++++ .../CH2/EX2.2a/Ex2_2a.R | 21 +++ .../CH2/EX2.2b/Ex2_2b.R | 24 ++++ .../CH2/EX2.2c/Ex2_2c.R | 22 ++++ .../CH2/EX2.3a/Ex2_3a.R | 43 ++++++ .../CH3/EX3.1a/Ex3_1a.R | 21 +++ .../CH3/EX3.1b/Ex3_1b.R | 21 +++ .../CH3/EX3.1c/Ex3_1c.R | 21 +++ .../CH3/EX3.1d/Ex3_1d.R | 40 ++++++ .../CH3/EX3.1e/Ex3_1e.R | 41 ++++++ .../CH3/EX3.2a/Ex3_2a.R | 34 +++++ .../CH3/EX3.2b/Ex3_2b.R | 42 ++++++ .../CH3/EX3.3a/Ex3_3a.R | 23 ++++ .../CH3/EX3.3b/Ex3_3b.R | 36 +++++ .../CH3/EX3.3c/Ex3_3c.R | 19 +++ .../CH4/EX4.1a/Ex4_1a.R | 25 ++++ .../CH4/EX4.1b/Ex4_1b.R | 22 ++++ .../CH4/EX4.1c/Ex4_1c.R | 28 ++++ .../CH4/EX4.2a/Ex4_2a.R | 28 ++++ .../CH4/EX4.2b/Ex4_2b.R | 30 +++++ .../CH4/EX4.3a/Ex4_3a.R | 28 ++++ .../CH5/EX5.1a/Ex5_1a.R | 21 +++ .../CH5/EX5.1b/Ex5_1b.R | 17 +++ .../CH5/EX5.1c/Ex5_1c.R | 17 +++ .../CH5/EX5.2a/Ex5_2a.R | 11 ++ .../CH5/EX5.2b/Ex5_2b.R | 25 ++++ .../CH5/EX5.2c/Ex5_2c.R | 29 +++++ .../CH5/EX5.2d/Ex5_2d.R | 31 +++++ .../CH5/EX5.3a/Ex5_3a.R | 26 ++++ .../CH5/EX5.3b/Ex5_3b.R | 25 ++++ .../CH5/EX5.4a/Ex5_4a.R | 11 ++ .../CH5/EX5.4b/Ex5_4b.R | 29 +++++ .../CH5/EX5.4c/Ex5_4c.R | 26 ++++ .../CH6/EX6.1a/Ex6_1a.R | 23 ++++ .../CH6/EX6.1b/Ex6_1b.R | 13 ++ .../CH6/EX6.2a/Ex6_2a.R | 17 +++ .../CH6/EX6.2b/Ex6_2b.R | 13 ++ .../CH6/EX6.3a/Ex6_3a.R | 25 ++++ .../CH6/EX6.3b/Ex6_3b.R | 23 ++++ .../CH6/EX6.4a/Ex6_4a.R | 11 ++ .../CH6/EX6.4b/Ex6_4b.R | 11 ++ .../CH6/EX6.4c/Ex6_4c.R | 21 +++ .../CH7/EX7.1a/Ex7_1a.R | 10 ++ .../CH7/EX7.1b/Ex7_1b.R | 14 ++ .../CH7/EX7.1c/Ex7_1c.R | 11 ++ .../CH7/EX7.1d/Ex7_1d.R | 51 ++++++++ .../CH7/EX7.1e/Ex7_1e.R | 44 +++++++ .../CH7/EX7.2a/Ex7_2a.R | 55 ++++++++ .../CH7/EX7.2b/Ex7_2b.R | 53 ++++++++ .../CH7/EX7.2c/Ex7_2c.R | 51 ++++++++ .../CH7/EX7.3a/Ex7_3a.R | 19 +++ .../CH7/EX7.3b/Ex7_3b.R | 14 ++ .../CH7/EX7.4a/Ex7_4a.R | 38 ++++++ .../CH7/EX7.4b/Ex7_4b.R | 48 +++++++ .../CH8/EX8.1a/Ex8_1a.R | 17 +++ .../CH8/EX8.1b/Ex8_1b.R | 15 +++ .../CH8/EX8.1c/Ex8_1c.R | 14 ++ .../CH8/EX8.1d/Ex8_1d.R | 12 ++ .../CH8/EX8.1e/Ex8_1e.R | 35 +++++ .../CH8/EX8.2a/Ex8_2a.R | 71 ++++++++++ .../CH8/EX8.2b/Ex8_2b.R | 71 ++++++++++ .../CH8/EX8.2c/Ex8_2c.R | 55 ++++++++ .../CH8/EX8.3a/Ex8_3a.R | 19 +++ .../CH8/EX8.4a/Ex8_4a.R | 25 ++++ .../CH8/EX8.5a/Ex8_5a.R | 33 +++++ .../CH8/EX8.5b/Ex8_5b.R | 67 ++++++++++ .../CH8/EX8.5c/Ex8_5c.R | 12 ++ .../CH9/EX9.1a/Ex9_1a.R | 112 ++++++++++++++++ .../CH9/EX9.1b/Ex9_1b.R | 62 +++++++++ .../CH9/EX9.1c/Ex9_1c.R | 66 ++++++++++ .../CH9/EX9.1d/Ex9_1d.R | 62 +++++++++ .../CH9/EX9.2a/Ex9_2a.R | 41 ++++++ .../CH9/EX9.2b/Ex9_2b.R | 41 ++++++ .../CH9/EX9.2c/Ex9_2c.R | 44 +++++++ .../CH9/EX9.3a/Ex9_3a.R | 52 ++++++++ .../CH9/EX9.4a/Ex9_4a.R | 23 ++++ .../CH9/EX9.4b/Ex9_4b.R | 30 +++++ .../CH9/EX9.5a/Ex9_5a.R | 66 ++++++++++ .../CH9/EX9.6a/Ex9_6a.R | 51 ++++++++ .../CH9/EX9.6b/Ex9_6b.R | 45 +++++++ .../CH9/EX9.6c/Ex9_6c.R | 35 +++++ .../CH9/EX9.6d/Ex9_6d.R | 27 ++++ .../CH9/EX9.6e/Ex9_6e.R | 17 +++ .../CH9/EX9.6f/Ex9_6f.R | 66 ++++++++++ .../README.txt | 18 +++ .../CH10/EX10.5.1/Ex10.5_1.R | 9 ++ .../CH10/EX10.5.2/Ex10.5_2.R | 9 ++ .../CH10/EX10.5.3/Ex10.5_3.R | 15 +++ .../CH10/EX10.6.1/Ex10.6_1.R | 15 +++ .../CH10/EX10.7.1/Ex10.7_1.R | 13 ++ .../CH11/EX11.4.1/Ex11.4_1.R | 32 +++++ .../CH11/EX11.4.2/Ex11.4_2.R | 34 +++++ .../CH11/EX11.4.3/Ex11.4_3.R | 33 +++++ .../CH11/EX11.4.4/Ex11.4_4.R | 33 +++++ .../CH11/EX11.4.7/Ex11.4_7.R | 35 +++++ .../CH11/EX11.4.8/Ex11.4_8.R | 37 ++++++ .../CH12/EX12.9.3.1/Ex12.9.3_1.R | 33 +++++ .../CH12/EX12.9.3.2/Ex12.9.3_2.R | 33 +++++ .../CH12/EX12.9.3.3/Ex12.9.3_3.R | 27 ++++ .../CH12/EX12.9.3.4/Ex12.9.3_4.R | 26 ++++ .../CH12/EX12.9.3.5/Ex12.9.3_5.R | 43 ++++++ .../CH12/EX12.9.3.6/Ex12.9.3_6.R | 46 +++++++ .../CH12/EX12.9.3.7/Ex12.9.3_7.R | 32 +++++ .../CH12/EX12.9.3.8/Ex12.9.3_8.R | 29 +++++ .../CH12/EX12.9.3.9/Ex12.9.3_9.R | 29 +++++ .../CH13/EX13.8.1/Ex13.8_1.R | 12 ++ .../CH13/EX13.8.2/Ex13.8_2.R | 12 ++ .../CH13/EX13.8.3/Ex13.8_3.R | 22 ++++ .../CH13/EX13.8.4/Ex13.8_4.R | 88 +++++++++++++ .../CH14/EX14.4.1/Ex14.4_1.R | 142 ++++++++++++++++++++ .../CH2/EX2.6.1/Ex2.6_1.R | 16 +++ .../CH3/EX3.3.1/Ex3.3_1.R | 31 +++++ .../CH4/EX4.10.1/Ex4.10_1.R | 6 + .../CH4/EX4.7.1/Ex4.7_1.R | 19 +++ .../CH4/EX4.8.1/Ex4.8_1.R | 20 +++ .../CH4/EX4.9.1/Ex4.9_1.R | 7 + .../CH5/EX5.3.1/Ex5.3_1.R | 7 + .../CH5/EX5.3.10/Ex5.3_10.R | 5 + .../CH5/EX5.3.11/Ex5.3_11.R | 8 ++ .../CH5/EX5.3.12/Ex5.3_12.R | 17 +++ .../CH5/EX5.3.2/Ex5.3_2.R | 5 + .../CH5/EX5.3.3/Ex5.3_3.R | 5 + .../CH5/EX5.3.4/Ex5.3_4.R | 18 +++ .../CH5/EX5.3.5/Ex5.3_5.R | 8 ++ .../CH5/EX5.3.6/Ex5.3_6.R | 8 ++ .../CH5/EX5.3.7/Ex5.3_7.R | 6 + .../CH5/EX5.3.8/Ex5.3_8.R | 5 + .../CH5/EX5.3.9/Ex5.3_9.R | 6 + .../CH5/EX5.4.1/Ex5.4_1.R | 5 + .../CH5/EX5.4.2/EX5.4_2.R | 5 + .../CH5/EX5.4.3/Ex5.4_3.R | 17 +++ .../CH5/EX5.4.7/Ex5.4_7.R | 8 ++ .../CH5/EX5.4.8/Ex5.4_8.R | 8 ++ .../CH5/EX5.4.9/Ex5.4_9.R | 11 ++ .../CH5/EX5.5.1/Ex5.5_1.R | 23 ++++ .../CH5/EX5.5.10/Ex5.5_10.R | 57 ++++++++ .../CH5/EX5.5.11/Ex5.5_11.R | 50 +++++++ .../CH5/EX5.5.2/Ex5.5_2.R | 16 +++ .../CH5/EX5.5.3/Ex5.5_3.R | 14 ++ .../CH5/EX5.5.4/Ex5.5_4.R | 14 ++ .../CH5/EX5.5.6/Ex5.5_6.R | 21 +++ .../CH5/EX5.5.7/Ex5.5_7.R | 24 ++++ .../CH5/EX5.5.8/Ex5.5_8.R | 26 ++++ .../CH5/EX5.5.9/Ex5.5_9.R | 19 +++ .../CH5/EX5.7.1/Ex5.7_1.R | 65 +++++++++ .../CH5/EX5.7.2/Ex5.7_2.R | 45 +++++++ .../CH6/EX6.2.1/Ex6.2_1.R | 40 ++++++ .../CH6/EX6.3.1/Ex6.3_1.R | 18 +++ .../CH6/EX6.3.2/Ex6.3_2.R | 16 +++ .../CH6/EX6.3.3/Ex6.3_3.R | 38 ++++++ .../CH6/EX6.3.4/Ex6.3_4.R | 45 +++++++ .../CH6/EX6.4.1/Ex6.4_1.R | 50 +++++++ .../CH6/EX6.5.1/Ex6.5_1.R | 19 +++ .../CH7/EX7.5.1/Ex7.5_1.R | 5 + .../CH7/EX7.5.2/Ex7.5_2.R | 5 + .../CH7/EX7.5.3/Ex7.5_3.R | 7 + .../CH7/EX7.5.4/Ex7.5_4.R | 10 ++ .../CH7/EX7.5.5/Ex7.5_5.R | 10 ++ .../CH7/EX7.5.6/Ex7.5_6.R | 10 ++ .../CH7/EX7.6.1/Ex7.6_1.R | 20 +++ .../CH7/EX7.6.2/Ex7.6_2.R | 18 +++ .../CH7/EX7.6.3/Ex7.6_3.R | 17 +++ .../CH7/EX7.7.2/Ex7.7_2.R | 9 ++ .../CH7/EX7.7.3/Ex7.7_3.R | 6 + .../CH7/EX7.7.5/Ex7.7_5.R | 15 +++ .../CH7/EX7.7.6/Ex7.7_6.R | 15 +++ .../CH7/EX7.7.7/Ex7.7_7.R | 15 +++ .../CH7/EX7.8.1/Ex7.8_1.R | 13 ++ .../CH7/EX7.8.10/Ex7.8_10.R | 17 +++ .../CH7/EX7.8.2/Ex7.8_2.R | 11 ++ .../CH7/EX7.8.5/Ex7.8_5.R | 18 +++ .../CH7/EX7.8.6/Ex7.8_6.R | 17 +++ .../CH7/EX7.8.9/Ex7.8_9.R | 62 +++++++++ .../CH8/EX8.10.1/Ex8.10_1.R | 57 ++++++++ .../CH8/EX8.10.2/Ex8.10_2.R | 9 ++ .../CH8/EX8.10.3/Ex8.10_3.R | 8 ++ .../CH8/EX8.10.4/Ex8.10_4.R | 8 ++ .../CH8/EX8.11.1/Ex8.11_1.R | 49 +++++++ .../CH8/EX8.11.2/Ex8.11_2.R | 35 +++++ .../CH8/EX8.11.3/Ex8.11_3.R | 40 ++++++ .../CH8/EX8.12.1/Ex8.12_1.R | 11 ++ .../CH8/EX8.12.2/Ex8.12_2.R | 10 ++ .../CH8/EX8.13.1/Ex8.13_1.R | 18 +++ .../CH8/EX8.13.2/Ex8.13_2.R | 18 +++ .../CH8/EX8.14.1/Ex8.14_1.R | 15 +++ .../CH8/EX8.14.2/Ex8.14_2.R | 15 +++ .../CH8/EX8.15.1/Ex8.15_1.R | 9 ++ .../CH8/EX8.15.2/Ex8.15_2.R | 9 ++ .../CH8/EX8.8.1/Ex8.8_1.R | 14 ++ .../CH8/EX8.8.10/Ex8.8_10.R | 13 ++ .../CH8/EX8.8.11/Ex8.8_11.R | 12 ++ .../CH8/EX8.8.2/Ex8.8_2.R | 9 ++ .../CH8/EX8.8.3/Ex8.8_3.R | 9 ++ .../CH8/EX8.8.4/Ex8.8_4.R | 13 ++ .../CH8/EX8.8.5/Ex8.8_5.R | 13 ++ .../CH8/EX8.8.6/Ex8.8_6.R | 13 ++ .../CH8/EX8.8.7/Ex8.8_7.R | 13 ++ .../CH8/EX8.8.8/Ex8.8_8.R | 14 ++ .../CH8/EX8.8.9/Ex8.8_9.R | 11 ++ .../CH8/EX8.9.1/Ex8.9_1.R | 20 +++ .../CH8/EX8.9.2/Ex8.9_2.R | 8 ++ .../CH8/EX8.9.3/Ex8.9_3.R | 10 ++ .../CH8/EX8.9.4/Ex8.9_4.R | 10 ++ .../CH9/EX9.7.1/Ex9.7_1.R | 8 ++ .../CH9/EX9.7.2/Ex9.7_2.R | 9 ++ .../CH9/EX9.7.3/Ex9.7_3.R | 11 ++ .../CH9/EX9.7.4/Ex9.7_4.R | 10 ++ .../CH9/EX9.7.5/Ex9.7_5.R | 11 ++ .../CH9/EX9.7.6/Ex9.7_6.R | 9 ++ .../CH9/EX9.7.7/Ex9.7_7.R | 22 ++++ .../CH9/EX9.7.8/Ex9.7_8.R | 6 + .../README.txt | 18 +++ .../CH1/EX1.16/Ex1_16.R | 3 + .../CH1/EX1.20/Ex1_20.R | 3 + .../CH1/EX1.21/Ex1_21.R | 3 + .../CH1/EX1.22/Ex1_22.R | 3 + .../CH1/EX1.23/Ex1_23.R | 7 + .../CH1/EX1.24/Ex1_24.R | 3 + .../CH1/EX1.26/Ex1_26.R | 5 + .../CH1/EX1.32/Ex1_32.R | 9 ++ .../CH1/EX1.33/Ex1_33.R | 7 + .../CH1/EX1.34/Ex1_34.R | 7 + .../CH2/EX2.12/Ex2_12.R | 6 + .../CH2/EX2.12/worldmarket.csv | 16 +++ .../CH2/EX2.16/Ex2_16.R | 4 + .../CH2/EX2.16/worldmarket.csv | 16 +++ .../CH2/EX2.20/Ex2_20.R | 4 + .../CH2/EX2.20/spam_botnets.csv | 11 ++ .../CH2/EX2.21/Ex2_21.R | 6 + .../CH2/EX2.21/spam_botnets.csv | 11 ++ .../CH2/EX2.22/Ex2_22.R | 8 ++ .../CH2/EX2.22/spam_botnets.csv | 11 ++ .../CH2/EX2.23/Ex2_23.R | 7 + .../CH2/EX2.23/spam_botnets.csv | 11 ++ .../CH2/EX2.24/Ex2_24.R | 6 + .../CH2/EX2.24/target.csv | 6 + .../CH2/EX2.3/Ex2_3.R | 3 + .../CH2/EX2.3/spam_botnets.csv | 11 ++ .../CH2/EX2.4/Ex2_4.R | 4 + .../CH2/EX2.4/spam_botnets.csv | 11 ++ .../CH2/EX2.5/Ex2_5.R | 3 + .../CH2/EX2.5/govtdebt.csv | 25 ++++ .../CH2/EX2.6/Ex2_6.R | 5 + .../CH2/EX2.6/govtdebt.csv | 25 ++++ .../CH2/EX2.7/Ex2_7.R | 4 + .../CH2/EX2.7/govtdebt.csv | 25 ++++ 4408 files changed, 79060 insertions(+) create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.a/Ex1_2a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.b/Ex1_2b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.c/Ex1_2c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.e/Ex1_2e.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.a/Ex1_3a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.b.a/Ex1_3ba.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.b.b/Ex1_3bb.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.c/Ex1_3c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.d/Ex1_3d.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.e/Ex1_3e.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.f/Ex1_3f.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX4.a/Ex1_4a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX4.b/Ex1_4b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.a/Ex1_5a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.b/Ex1_5b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.c/Ex1_5c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.d/Ex1_5d.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX6.a/Ex1_6a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX6.b/Ex1_6b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX3.b/Ex2_3b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX4.a/Ex2_4a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.a/Ex2_5a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.b/Ex2_5b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.c/Ex2_5c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.f/Ex2_5f.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.g/Ex2_5g.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.h.a/Ex2_5ha.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.h.b/Ex2_5hb.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.i/Ex2_5i.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.k/Ex2_5k.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.l/Ex2_5l.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.n/Ex2_5n.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX7.a/Ex2_7a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.a/Ex3_2a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.b.a/Ex3_2ba.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.b.b/Ex3_2bb.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.c/Ex3_2c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.e/Ex3_2e.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.f.a/Ex3_2fa.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.h/Ex3_2h.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.a.1/Ex3_3a1.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.a.2/Ex3_3a2.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.d/Ex3_3d.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.e/Ex3_3e.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.f/Ex3_3f.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.i/Ex3_3i.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.l/Ex3_3l.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.n.a/Ex3_3na.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.n.b/Ex3_3nb.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.o/Ex3_3o.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX4.h/Ex3_4h.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX5.a/Ex3_5a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX1.b/Ex4_1b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX1.d/Ex4_1d.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX10.a/Ex4_10a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX3.a/Ex4_3a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX3.d/Ex4_3d.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX4.a/Ex4_4a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX5.a/Ex4_5a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.a/Ex4_6a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.b/Ex4_6b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.c/Ex4_6c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.d/Ex4_6d.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.h/Ex4_6h.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.i/Ex4_6i.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.a/Ex4_7a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.b/Ex4_7b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.c/Ex4_7c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.e.a/Ex4_7ea.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.f/Ex4_7f.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX8.g/Ex4_8g.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX8.i/Ex4_8i.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.a.a/Ex5_1aa.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.a.b/Ex5_1ab.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.b.a/Ex5_1ba.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.b.b/Ex5_1bb.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.c/Ex5_1c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX2.a/Ex5_2a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX2.e/Ex5_2e.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX3.b/Ex5_3b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX3.c/Ex5_3c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.b/Ex5_4b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.c/Ex5_4c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.d/Ex5_4d.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.e/Ex5_4e.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.f/Ex5_4f.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.g/Ex5_4g.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.h/Ex5_4h.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.i/Ex5_4i.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX5.b/Ex5_5b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX5.e/Ex5_5e.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.a/Ex6_1a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.b/Ex6_1b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.c.a/Ex6_1ca.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.c.b/Ex6_1cb.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX2.c/Ex6_2c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.c.a/Ex6_3ca.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.c.b/Ex6_3cb.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.d.a/Ex6_3da.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.d.b/Ex6_3db.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX4.a/Ex6_4a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX6.b/Ex6_6b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX2.r/Ex7_2r.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.a/Ex7_5ea.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.b/Ex7_5eb.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.c/Ex7_5ec.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX2.b/Ex8_2b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.a/Ex8_3a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.b/Ex8_3b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.c/Ex8_3c.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.d/Ex8_3d.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.e/Ex8_3e.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX5.a/Ex8_5a.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX5.b/Ex8_5b.R create mode 100644 A_First_Course_In_Probability_by_Sheldon_Ross/README.txt create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.1/Ex10_1.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.10/Ex10_10.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.11/Ex10_11.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.12/Ex10_12.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.13/Ex10_13.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.14/Ex10_14.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.15/Ex10_15.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.16/Ex10_16.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.17/Ex10_17.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.2/Ex10_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.3/Ex10_3.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.4/Ex10_4.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.5/Ex10_5.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.6/Ex10_6.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.7/Ex10_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.8/Ex10_8.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.9/Ex10_9.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.10/Ex11_10.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.11/Ex11_11.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.12/Ex11_12.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.13/Ex11_13.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.14/Ex11_14.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.15/Ex11_15.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.16/Ex11_16.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.17/Ex11_17.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.2/Ex11_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.3/Ex11_3.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.4/Ex11_4.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.7/Ex11_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.8/Ex11_8.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.11/Ex12_11.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.12/Ex12_12.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.13/Ex12_13.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.14/Ex12_14.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.15/Ex12_15.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.16/Ex12_16.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.17/Ex12_17.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.2/Ex12_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.21/Ex12_21.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.22/Ex12_22.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.26/Ex12_26.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.27/Ex12_27.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.28/Ex12_28.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.29/Ex12_29.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.3/Ex12_3.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.30/Ex12_30.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.31/Ex12_31.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.5/Ex12_5.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.6/Ex12_6.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.8/Ex12_8.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.9/Ex12_9.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.10/Ex13_10.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.12/Ex13_12.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.14/Ex13_14.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.15/Ex13_15.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.19/Ex13_19.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.3/Ex13_3.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.7/Ex13_7.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.9/Ex13_9.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.1/Ex14_1.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.10/Ex14_10.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.11/Ex14_11.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.12/Ex14_12.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.13/Ex14_13.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.2/Ex14_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.6/Ex14_6.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.7/Ex14_7.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.1/Ex15_1.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.11/Ex15_11.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.12/Ex15_12.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.5/Ex15_5.zip create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.7/Ex15_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.1/Ex3_1.R create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.10/Ex3_10.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.12/Ex3_12.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.13/Ex3_13.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.14/Ex3_14.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.15/Ex3_15.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.16/Ex3_16.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.2/Ex3_2.R create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.3/Ex3_3.R create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.4/Ex3_4.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.5/Ex3_5.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.6/Ex3_6.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.7/Ex3_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.8/Ex3_8.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.9/Ex3_9.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.1/Ex4_1.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.10/Ex4_10.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.11/Ex4_11.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.12/Ex4_12.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.13/Ex4_13.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.15/Ex4_15.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.16/Ex4_16.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.17/Ex4_17.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.18/Ex4_18.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.19/Ex4_19.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.2/Ex4_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.20/Ex4_20.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.21/Ex4_21.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.22/Ex4_22.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.24/Ex4_24.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.25/Ex4_25.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.26/Ex4_26.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.27/Ex4_27.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.28/Ex4_28.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.3/Ex4_3.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.4/Ex4_4.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.7/Ex4_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.8/Ex4_8.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.9/Ex4_9.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.1/Ex5_1.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.10/Ex5_10.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.11/Ex5_11.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.12/Ex5_12.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.13/Ex5_13.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.14/Ex5_14.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.15/Ex5_15.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.17/Ex5_17.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.18/Ex5_18.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.19/Ex5_19.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.2/Ex5_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.20/Ex5_20.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.21/Ex5_21.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.23/Ex5_23.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.3/Ex5_3.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.4/Ex5_4.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.5/Ex5_5.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.6/Ex5_6.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.7/Ex5_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.8/Ex5_8.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.9/Ex5_9.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.1/Ex6_1.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.10/Ex6_10.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.11/Ex6_11.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.2/Ex6_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.3/Ex6_3.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.4/Ex6_4.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.5/Ex6_5.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.6/Ex6_6.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.7/Ex6_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.8/Ex6_8.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.9/Ex6_9.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.1/Ex7_1.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.2/Ex7_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.4/Ex7_4.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.5/Ex7_5.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.6/Ex7_6.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.7/Ex7_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.8/Ex7_8.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.9/Ex7_9.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.1/Ex8_1.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.2/Ex8_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.3/Ex8_3.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.4/Ex8_4.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.7/Ex8_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.1/Ex9_1.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.11/Ex9_11.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.13/Ex9_13.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.14/Ex9_14.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.2/Ex9_2.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.3/Ex9_3.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.5/Ex9_5.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.6/Ex9_6.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.7/Ex9_7.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.9/Ex9_9.r create mode 100644 An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/README.txt create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.1/EX10_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.10/EX10_10.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.11/EX10_11.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.12/EX10_12.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.13/EX10_13.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.15/EX10_15.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.16/EX10_16.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.17/EX10_17.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.2/EX10_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.3/EX10_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.4/EX10_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.5/EX10_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.6/EX10_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.8/EX10_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.9/EX10_9.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH11/EX11.1/EX11_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH11/EX11.2/EX11_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH11/EX11.3/EX11_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH11/EX11.4/EX11_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH11/EX11.5/EX11_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH11/EX11.6/EX11_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH11/EX11.8/EX11_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.1/EX12_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.11/EX12_11.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.12/EX12_12.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.13/EX12_13.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.2/EX12_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.3/EX12_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.4/EX12_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.5/EX12_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.6/EX12_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.7/EX12_7.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.8/EX12_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.9/EX12_9.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.1/EX13_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.2/EX13_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.4/EX13_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.5/EX13_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH14/EX14.1/EX14_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH14/EX14.3/EX14_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH14/EX14.4/EX14_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH14/EX14.5/EX14_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH14/EX14.6/EX14_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH14/EX14.8/EX14_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH15/EX15.1/EX15_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH15/EX15.2/EX15_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH15/EX15.3/EX15_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH15/EX15.4/EX15_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH15/EX15.5/EX15_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH15/EX15.6/EX15_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH15/EX15.7/EX15_7.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.1/EX2_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.10/EX2_10.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.11/EX2_11.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.12/EX2_12.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.13/EX2_13.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.14/EX2_14.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.15/EX2_15.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.16/Ex2_16.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.17/EX2_17.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.18/EX2_18.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.19/EX2_19.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.20/EX2_20.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.22/EX2_22.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.23/EX2_23.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.24/EX2_24.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.25/EX2_25.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.26/EX2_26.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.27/EX2_27.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.28/EX2_28.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.29/EX2_29.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.30/EX2_30.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.31/EX2_31.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.32/EX2_32.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.33/EX2_33.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.34/EX2_34.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.35/EX2_35.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.37/EX2_37.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.4/EX2_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.5/EX2_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.8/EX2_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.9/EX2_9.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.10/EX3_10.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.11/EX3_11.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.12/EX3_12.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.14/EX3_14.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.15/EX3_15.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.16/EX3_16.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.17/EX3_17.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.18/EX3_18.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.19/EX3_19.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.2/EX3_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.20/EX3_20.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.21/EX3_21.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.22/EX3_22.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.24/EX3_24.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.25/EX3_25.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.26/EX3_26.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.27/EX3_27.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.28/EX3_28.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.29/EX3_29.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.31/EX3_31.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.32/EX3_32.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.5/EX3_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.6/EX3_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.7/EX3_7.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.8/EX3_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.9/EX3_9.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.1/EX4_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.12/EX4_12.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.13/EX4_13.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.14/EX4_14.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.15/EX4_15.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.16/EX4_16.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.18/EX4_18.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.19/EX4_19.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.2/EX4_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.20/EX4_20.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.21/EX4_21.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.22/EX4_22.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.23/EX4_23.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.24/EX4_24.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.25/EX4_25.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.26/EX4_26.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.27/EX4_27.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.28/EX4_28.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.5/EX4_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.6/EX4_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.7/EX4_7.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.8/EX4_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.9/EX4_9.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.12/EX5_12.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.14/EX5_14.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.15/EX5_15.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.16/EX5_16.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.18/EX5_18.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.19/EX5_19.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.2/EX5_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.21/EX5_21.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.23/EX5_23.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.24/EX5_24.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.25/EX5_25.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.3/EX5_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.31/EX5_31.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.32/EX5_32.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.33/EX5_33.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.4/EX5_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.5/EX5_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.6/EX5_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.8/EX5_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.9/EX5_9.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.1/EX6_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.2/EX6_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.3/EX6_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.1/EX7_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.17/EX7_17.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.3/EX7_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.5/EX7_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.9/EX7_9.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.1/EX8_1.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.10/EX8_10.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.11/EX8_11.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.12/EX8_12.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.2/EX8_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.3/EX8_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.4/EX8_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.5/EX8_5.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.6/EX8_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.7/EX8_7.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.8/EX8_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.9/EX8_9.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.10/EX9_10.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.11/EX9_11.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.12/EX9_12.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.13/EX9_13.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.14/EX9_14.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.15/EX9_15.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.16/EX9_16.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.17/EX9_17.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.2/EX9_2.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.3/EX9_3.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.4/EX9_4.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.6/EX9_6.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.7/EX9_7.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.8/EX9_8.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.9/EX9_9.R create mode 100644 Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/README.txt create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.18/Ex11_18.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.19/Ex11_19.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.22/Ex11_22.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.24/Ex11_24.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.28/Ex11_28.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.17/Ex13_17.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.18/Ex13_18.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.4/Ex13_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.18/Ex14_18.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.19/Ex14_19.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.22/Ex14_22.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.26/Ex14_26.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.5/Ex14_5.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.7/Ex14_7.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.1/Ex15_1.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.2/Ex15_2.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.3/Ex15_3.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.4/Ex15_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.6/Ex15_6.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.1/Ex16_1.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.15/Ex16_15.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.18/Ex16_18.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.19/Ex16_19.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.2/Ex16_2.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.3/Ex16_3.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.4/Ex16_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.5/Ex16_5.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.1/Ex22_1.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.10/Ex22_10.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.11/Ex22_11.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.2/Ex22_2.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.3/Ex22_3.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.4/Ex22_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.5/Ex22_5.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.6/Ex22_6.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.8/Ex22_8.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.9/Ex22_9.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.10/Ex26_10.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.11/Ex26_11.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.12/Ex26_12.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.13/Ex26_13.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.14/Ex26_14.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.15/Ex26_15.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.16/Ex26_16.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.17/Ex26_17.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.18/Ex26_18.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.2/Ex26_2.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.3/Ex26_3.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.4/Ex26_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.5/Ex26_5.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.6/Ex26_6.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.7/Ex26_7.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.8/Ex26_8.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.1/Ex27_1.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.10/Ex27_10.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.11/Ex27_11.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.12/Ex27_12.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.13/Ex27_13.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.15/Ex27_15.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.16/Ex27_16.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.2/Ex27_2.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.3/Ex27_3.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.4/Ex27_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.5/Ex27_5.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.6/Ex27_6.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.8/Ex27_8.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.9/Ex27_9.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.1/Ex28_1.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.11/Ex28_11.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.12/Ex28_12.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.13/Ex28_13.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.15/Ex28_15.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.18/Ex28_18.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.23/Ex28_23.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.24/Ex28_24.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.29/Ex28_29.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.4/Ex28_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.5/Ex28_5.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.9/Ex28_9.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.1/Ex33_1.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.2/Ex33_2.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.3/Ex33_3.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.4/Ex33_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.5/Ex33_5.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.6/Ex33_6.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.1/Ex34_1.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.2/Ex34_2.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.3/Ex34_3.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.4/Ex34_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.5/Ex34_5.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.6/Ex34_6.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.7/Ex34_7.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.8/Ex34_8.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.9/Ex34_9.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.11/Ex35_11.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.12/Ex35_12.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.16/Ex35_16.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.25/Ex35_25.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.6/Ex35_6.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.9/Ex35_9.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.18/Ex36_18.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.20/Ex36_20.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.22/Ex36_22.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.24/Ex36_24.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.10/Ex37_10.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.12/Ex37_12.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.14/Ex37_14.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.16/Ex37_16.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.20/Ex37_20.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.22/Ex37_22.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.23/Ex37_23.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.4/Ex37_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.1/Ex5_1.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.10/Ex5_10.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.12/Ex5_12.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.14/Ex5_14.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.15/Ex5_15.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.18/Ex5_18.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.21/Ex5_21.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.23/Ex5_23.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.4/Ex5_4.R create mode 100644 Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.7/Ex5_7.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH1/EX1.4.1/Ex1_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH1/EX1.4.2/Ex1_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.3.1/Ex10_3_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.1/Ex10_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.2/Ex10_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.3/Ex10_4_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.5.1/Ex10_5_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.6.1/Ex10_6_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.6.2/Ex10_6_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.1.1/Ex11_1_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.1.2/Ex11_1_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.2.1/Ex11_2_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.2.2/Ex11_2_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.3.1/Ex11_3_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.4.1/Ex11_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.4.2/Ex11_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.2/Ex12_3_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.3/Ex12_3_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.4/Ex12_3_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.5/Ex12_3_5.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.4.1/Ex12_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.4.2/Ex12_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.5.1/Ex12_5_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.6.1/Ex12_6_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.7.1/Ex12_7_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.7.2/Ex12_7_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.10.1/Ex13_10_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.10.2/Ex13_10_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.3.1/Ex13_3_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.3.2/Ex13_3_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.4.1/Ex13_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.5.1/Ex13_5_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.6.1/Ex13_6_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.7.1/Ex13_7_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.8.1/Ex13_8_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.8.2/Ex13_8_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.9.1/Ex13_9_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.9.2/Ex13_9_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.2.1/Ex2_2_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.3.1/Ex2_3_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.3.2/Ex2_3_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.1/Ex2_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.2/Ex2_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.3/Ex2_4_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.4/Ex2_4_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.5/Ex2_4_5.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.6/Ex2_4_6.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.1/Ex2_5_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.2/Ex2_5_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.3/Ex2_5_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.4/Ex2_5_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.5/Ex2_5_5.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.1/Ex3_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.2/Ex3_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.3/Ex3_4_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.4/Ex3_4_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.5/Ex3_4_5.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.6/Ex3_4_6.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.7/Ex3_4_7.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.8/Ex3_4_8.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.9/Ex3_4_9.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.5.1/Ex3_5_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.1/Ex4_2_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.2/Ex4_2_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.3/Ex4_2_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.4/Ex4_2_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.5/Ex4_2_5.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.6/Ex4_2_6.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.7/Ex4_2_7.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.8/Ex4_2_8.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.1/Ex4_3_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.2/Ex4_3_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.3/Ex4_3_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.4/Ex4_3_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.1/Ex4_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.2/Ex4_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.3/Ex4_4_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.4/Ex4_4_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.5/Ex4_4_5.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.1/Ex4_6_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.2/Ex4_6_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.3/Ex4_6_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.4/Ex4_6_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.5/Ex4_6_5.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.7.1/Ex4_7_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.7.2/Ex4_7_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.7.3/Ex4_7_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.3.2/Ex5_3_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.3.3/Ex5_3_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.4.1/Ex5_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.4.2/Ex5_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.5.2/Ex5_5_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.6.1/Ex5_6_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.6.2/Ex5_6_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.10.1/Ex6_10_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.2.1/Ex6_2_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.2.2/Ex6_2_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.2.3/Ex6_2_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.2.4/Ex6_2_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.3.1/Ex6_3_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.4.1/Ex6_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.4.2/Ex6_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.4.3/Ex6_4_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.4.4/Ex6_4_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.5.1/Ex6_5_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.6.1/Ex6_6_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.7.1/Ex6_7_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.8.1/Ex6_8_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH6/EX6.9.1/Ex6_9_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.1/Ex7_2_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.2/Ex7_2_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.3/Ex7_2_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.4/Ex7_2_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.5/Ex7_2_5.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.1/Ex7_3_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.2/Ex7_3_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.3/Ex7_3_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.4/Ex7_3_4.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.4.1/Ex7_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.5.1/Ex7_5_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.6.1/Ex7_6_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.7.1/Ex7_7_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.8.1/Ex7_8_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.8.2/Ex7_8_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH8/EX8.2.1/Ex8_2_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH8/EX8.2.2/Ex8_2_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH8/EX8.3.1/Ex8_3_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH9/EX9.3.1/Ex9_3_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH9/EX9.4.1/Ex9_4_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH9/EX9.4.2/Ex9_4_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH9/EX9.4.3/Ex9_4_3.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH9/EX9.7.1/Ex9_7_1.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH9/EX9.7.2/Ex9_7_2.R create mode 100644 Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/README.txt create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH10/EX10.1/Ex10_1.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH2/EX2.6/Ex2_6.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.1/Ex3_1.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.10/Ex3_10.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.2/Ex3_2.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.3/Ex3_3.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.7/Ex3_7.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.8/Ex3_8.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.9/Ex3_9.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.10/Ex4_10.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.11/Ex4_11.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.12/Ex4_12.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.13/Ex4_13.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.14/Ex4_14.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.15/Ex4_15.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.3/Ex4_3.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.4/Ex4_4.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.5/Ex4_5.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.8/Ex4_8.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.1/Ex5_1.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.2/Ex5_2.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.3/Ex5_3.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.4.a/Ex5_4_a.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.4.b/Ex5_4_b.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.5/Ex5_5.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.1/7_1.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.2/7_2.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.3/7_3.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.4/7_4.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.1/8_1.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.2/8_2.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.3/8_3.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.4/Ex8_4.R create mode 100644 Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH9/EX9.6/Ex9_6.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.1/Ex10_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.2/10_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.3/Ex10_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.4/Ex10_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.5/10_5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.6/10_6.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.7/Ex10_7.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.1/Ex11_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.2/Ex11_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.3/Ex11_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.4/Ex11_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.1/Ex12_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.2/12_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.3/12_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.4/12_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.5/Ex12_5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.6/Ex12_6.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.7/Ex12_7.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH13/EX13.1/Ex13_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH13/EX13.2/Ex13_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH14/EX14.1/Ex14_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.1.a/15_1_a.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.1.b/15_1_b.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.2/Ex15_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.3/Ex15_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.4/Ex15_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.5/Ex15_5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.1/Ex16_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.2/Ex16_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.3/Ex16_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.4/Ex16_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.1/Ex17_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.2/Ex17_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.3/Ex17_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.4/Ex17_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.5/Ex17_5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.6/Ex17_6.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.a/Ex2_1a.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.b/Ex2_1b.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.c/Ex2_1c.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.2/2_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.3.a/2_3_a.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.3.b/2_3_b.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.4/2_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.a/3_1_a.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.b/Ex3_1b.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.c/Ex3_1c.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.2/Ex3_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.3/Ex3_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.5/3_5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.6.a/3_6_a.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.6.b/Ex3_6b.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.7/Ex3_7.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.1/4_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.11/4_11.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.12/4_12.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.3/4_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.5/4_5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.6/Ex4_6.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.8/4_8.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.9/4_9.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.1/5_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.10/Ex5_10.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.11/Ex5_11.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.2/5_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.3/Ex5_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.5/Ex5_5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.6/Ex5_6.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.7/5_7.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.8/Ex5_8.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.9/Ex5_9.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.1/6_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.10/Ex6_10.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.11/6_11.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.2/Ex6_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.3/Ex6_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.4/Ex6_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.5/Ex6_5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.6/Ex6_6.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.7/Ex6_7.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.8/Ex6_8.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.9/6_9.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.1/Ex7_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.2/Ex7_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.3/Ex7_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.1/Ex8_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.2/8_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.3/Ex8_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.4/8_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.5/Ex8_5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.6/Ex8_6.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.7/8_7.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.8/8_8.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.1/Ex9_1.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.2/Ex9_2.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.3/Ex9_3.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.4/Ex9_4.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.5/9-5.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.6/Ex9_6.R create mode 100644 Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/README.txt create mode 100644 Chemical_Simulation_by_Prof_Kannan/CH8/EX1.1/Ex8_1.R create mode 100644 Chemical_Simulation_by_Prof_Kannan/README.txt create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.1/Ex10_1.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.2/Ex10_2.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.3/Ex10_3.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.4/Ex10_4.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.7/Ex10_7.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.8/Ex10_8.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.14/Ex11_14.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.16/Ex11_16.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.19/Ex11_19.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.21/Ex11_21.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.23/Ex11_23.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.3/Ex11_3.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.5/Ex11_5.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.7/Ex11_7.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.1/Ex12_1.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.10/Ex12_10.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.12/Ex12_12.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.13/Ex12_13.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.14/Ex12_14.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.15/Ex12_15.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.16/Ex12_16.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.18/Ex12_18.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.20/Ex12_20.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.24/Ex12_24.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.25/Ex12_25.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.7/Ex12_7.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.8/Ex12_8.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.9/Ex12_9.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.10/Ex2_10.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.11/Ex2_11.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.12/Ex2_12.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.13/Ex2_13.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.15/Ex2_15.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.18/Ex2_18.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.19/Ex2_19.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.20/Ex2_20.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.21/Ex2_21.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.23/Ex2_23.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.6.1/Ex2_6.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.7/Ex2_7.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.8/Ex2_8.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.9/Ex2_9.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.1/Ex3_1.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.2/Ex3_2.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.3/Ex3_3.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.4/Ex3_4.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.5/Ex3_5.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.6/Ex3_6.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.10/Ex4_10.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.11/Ex4_11.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.13/Ex4_13.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.3/Ex4_3.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.4/Ex4_4.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.6/Ex4_6.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.8/Ex4_8.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.9/Ex4_9.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.10/EX5_10.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.11/EX5_11.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.14/Ex5_14.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.15/Ex5_15.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.16/Ex5_16.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.9/EX5_9.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.2/Ex6_2.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.3/Ex6_3.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.4/Ex6_4.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.8/Ex6_8.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.9/EX6_9.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.1/EX7_1.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.12/EX7_12.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.13/EX7_13.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.15/EX7_15.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.2/EX7_2.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.3/EX7_3.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.6/EX7_6.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.1/Ex8_1.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.10/Ex8_10.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.11/Ex8_11.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.2/Ex8_2.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.3/Ex8_3.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.4/Ex8_4.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.6/Ex8_6.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.7/Ex8_7.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.8/Ex8_8.zip create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.9/Ex8_9.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH9/EX9.1/Ex9_1.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH9/EX9.3/Ex9_3.R create mode 100644 Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/README.txt create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.1/ex10_1.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.10/ex10_10.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.12/ex10_12.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.13/ex10_13.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.14/ex10_14.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.15/ex10_15.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.16/ex10_16.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.17/ex10_17.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.2/ex10_2.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.3/ex10_3.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.4/ex10_4.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.5/ex10_5.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.6/ex10_6.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.7/ex10_7.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.8/ex10_8.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.9/ex10_9.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.1/ex11_1.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.2/ex11_2.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.3/ex11_3.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.4/ex11_4.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.5/ex11_5.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.6/ex11_6.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.7/ex11_7.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.1/ex12_1.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.2/ex12_2.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.3/ex12_3.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.4/ex12_4.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.5/ex12_5.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.1/ex13_1.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.10/ex13_10.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.2/ex13_2.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.3/ex13_3.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.4/ex13_4.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.5/ex13_5.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.6/ex13_6.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.7/ex13_7.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.1/ex2_1.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.10/ex2_10.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.11/ex2_11.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.12/ex2_12.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.13/ex2_13.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.14/ex2_14.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.15/ex2_15.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.2/ex2_2.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.3/ex2_3.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.4/ex2_4.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.5/ex2_5.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.6/ex2_6.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.7/ex2_7.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.8/ex2_8.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.9/ex2_9.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.1/ex3_1.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.10/ex3_10.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.11/ex3_11.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.12/ex3_12.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.13/ex3_13.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.14/ex3_14.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.15/ex3_15.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.16/ex3_16.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.17/ex3_17.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.18/ex3_18.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.19/ex3_19.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.2/ex3_2.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.20/ex3_20.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.21/ex3_21.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.22/ex3_22.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.23/ex3_23.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.24/ex3_24.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.25/ex3_25.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.26/ex3_26.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.27/ex3_27.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.28/ex3_28.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.29/ex3_29.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.3/ex3_3.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.30/ex3_30.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.31/ex3_31.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.32/ex3_32.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.33/ex3_33.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.34/ex3_34.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.35/ex3_35.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.36/ex3_36.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.37/ex3_37.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.38/ex3_38.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.39/ex3_39.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.4/ex3_4.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.5/ex3_5.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.6/ex3_6.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.7/ex3_7.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.8/ex3_8.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.9/ex3_9.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.11/ex4_11.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.12/ex4_12.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.13/ex4_13.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.14/ex4_14.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.17/ex4_17.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.18/ex4_18.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.19/ex4_19.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.20/ex4_20.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.21/ex4_21.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.22/ex4_22.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.23/ex4_23.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.24/ex4_24.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.25/ex4_25.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.26/ex4_26.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.27/ex4_27.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.28/ex4_28.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.29/ex4_29.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.30/ex4_30.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.42/ex4_42.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.43/ex4_43.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.44/ex4_44.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.45/ex4_45.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.47/ex4_47.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.48/ex4_48.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.49/ex4_49.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.5/ex4_5.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.50/ex4_50.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.a/ex4_51a.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.b/ex4_51b.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.c/ex4_51c.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.d/ex4_51d.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.52/ex4_52.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.6/ex4_6.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.7/ex4_7.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.8/ex4_8.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.9/ex4_9.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.1/ex5_1.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.10/ex5_10.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.11/ex5_11.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.12/ex5_12.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.13/ex5_13.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.14/ex5_14.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.15/ex5_15.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.16/ex5_16.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.17/ex5_17.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.19.a/ex5_19a.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.19.b/ex5_19b.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.19.c/ex5_19c.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.2/ex5_2.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.20/ex5_20.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.21/ex5_21.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.22/ex5_22.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.23/ex5_23.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.24/ex5_24.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.25/ex5_25.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.26/ex5_26.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.27/ex5_27.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.28.a/ex5_28a.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.28.b/ex5_28b.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.28.c/ex5_28c.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.29/ex5_29.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.30/ex5_30.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.31/ex5_31.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.32/ex5_32.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.5/ex5_5.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.6/ex5_6.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.7/ex5_7.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.8/ex5_8.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.9/ex5_9.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.1/ex6_1.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.10/ex6_10.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.11/ex6_11.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.12/ex6_12.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.13/ex6_13.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.14/ex6_14.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.15/ex6_15.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.16/ex6_16.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.17/ex6_17.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.18/ex6_18.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.19/ex6_19.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.2/ex6_2.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.3/ex6_3.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.a/ex6_4a.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.b/ex6_4b.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.c/ex6_4c.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.6/ex6_6.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.7/ex6_7.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.8/ex6_8.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.1/ex7_1.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.10/ex7_10.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.11/ex7_11.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.12/ex7_12.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.13/ex7_13.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.14/ex7_14.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.15/ex7_15.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.2/ex7_2.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.3/ex7_3.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.4/ex7_4.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.5/ex7_5.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.6/ex7_6.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.7/ex7_7.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.8/ex7_8.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.9/ex7_9.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.10/ex8_10.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.11/ex8_11.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.12/ex8_12.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.13/ex8_13.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.14/ex8_14.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.15/ex8_15.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.16/ex8_16.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.17/ex8_17.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.18/ex8_18.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.19/ex8_19.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.2.a/ex8_2a.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.2.b/ex8_2b.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.2.c/ex8_2c.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.20/ex8_20.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.21/ex8_21.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.22/ex8_22.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.23/ex8_23.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.24/ex8_24.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.25/ex8_25.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.26/ex8_26.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.27/ex8_27.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.28/ex8_28.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.29/ex8_29.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.3/ex8_3.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.30/ex8_30.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.31/ex8_31.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.4/ex8_4.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.5/ex8_5.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.6/ex8_6.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.7/ex8_7.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.8/ex8_8.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.9/ex8_9.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.1/ex9_1.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.10/ex9_10.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.11/ex9_11.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.12/ex9_12.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.13/ex9_13.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.14/ex9_14.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.15/ex9_15.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.16/ex9_16.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.2/ex9_2.R.zip create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.3/ex9_3.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.4/ex9_4.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.5/ex9_5.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.6/ex9_6.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.7/ex9_7.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.8/ex9_8.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.9/ex9_9.R create mode 100644 Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/README.txt create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH10/EX10.1/EX10_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH10/EX10.14/EX10_14.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH10/EX10.15/EX10_15.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH10/EX10.17/EX10_17.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH10/EX10.18/EX10_18.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH10/EX10.19/EX10_19.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH10/EX10.2/EX10_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.1/EX11_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.2/EX11_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.3/EX11_3.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.6/EX11_6.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.7/EX11_7.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.7/EX12_7.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.8/EX12_8.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.9/EX12_9.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.11/EX13_11.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.12/EX13_12.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.14/EX13_14.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.15/EX13_15.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.2/EX13_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.1/EX14_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.10/EX14_10.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.15/EX14_15.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.18/EX14_18.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.2/EX14_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.26/EX14_26.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.28/EX14_28.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.30/EX14_30.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.4/EX14_4.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.6/EX14_6.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.7/EX14_7.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.12/EX15_12.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.14/EX15_14.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.15/EX15_15.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.18/EX15_18.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.20/EX15_20.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.9/EX15_9.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.10/EX16_10.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.12/EX16_12.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.15/EX16_15.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.18/EX16_18.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.26/EX16_26.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.27/EX16_27.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.6/EX16_6.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.7/EX16_7.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.1/EX2_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.12/EX2_12.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.15/EX2_15.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.17/EX2_17.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.18/EX2_18.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.19/EX2_19.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.2/EX2_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.20/EX2_20.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.21/EX2_21.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.23/EX2_23.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.24/EX2_24.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.26/EX2_26.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.27/EX2_27.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.28/EX2_28.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.29/EX2_29.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.3/EX2_3.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.34/EX2_34.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.35/EX2_35.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.36/EX2_36.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.4/EX2_4.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.40/EX2_40.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.42/EX2_42.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.43/EX2_43.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.6/EX2_6.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.7/EX2_7.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.8/EX2_8.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.9/EX2_9.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH20/EX20.1/EX20_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH20/EX20.2/EX20_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.2/EX3_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.24/EX3_24.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.29/EX3_29.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.3/EX3_3.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.30/EX3_30.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.37/EX3_37.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.4/EX3_4.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.1/EX4_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.10/EX4_10.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.16/EX4_16.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.18/EX4_18.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.2/EX4_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.20/EX4_20.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.3/EX-4_3.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.4/EX4_4.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.9/EX4_9.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.1/EX5_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.12/EX5_12.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.13/EX5_13.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.19/EX5_19.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.2/EX5_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.22/EX5_22.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.24/EX5_24.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.3/EX5_3.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.4/EX5_4.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.5/EX5_5.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.1/EX6_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.2/EX6_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.29/EX6_29.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.3/EX6_3.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.30/EX6_30.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.4/EX6_4.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.5/EX6_5.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.12/EX7_12.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.13/EX7_13.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.14/EX7_14.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.17/EX7_17.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.18/EX7_18.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.19/EX7_19.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.1/EX8_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.10/EX8_10.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.12/EX8_12.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.2/EX8_2.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.21/EX8_21.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.22/EX8_22.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.3/EX8_3.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.33/EX8_33.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.34/EX8_34.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.37/EX8_37.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.4/EX8_4.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.41/EX8_41.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.55/EX8_55.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.56/EX8_56.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.57/EX8_57.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.6/EX8_6.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.63/EX8_63.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.7/EX8_7.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.9/EX8_9.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.1/EX9_1.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.12/EX9_12.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.13/EX9_13.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.14/EX9_14.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.15/EX9_15.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.21/EX9_21.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.22/EX9_22.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.3/EX9_3.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.4/EX9_4.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.5/EX9_5.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.7/EX9_7.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.8/EX9_8.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.9/EX9_9.R create mode 100644 Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/README.txt create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX1.1/Ex1_1_1.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX2.2/Ex1_2_2.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX3.3/Ex1_3_3.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX3.4/Ex1_3_4.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX3.5/Ex1_3_5.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX3.6/Ex1_3_6.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX3.7/Ex1_3_7.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX4.10/Ex1_4_10.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX4.11/Ex1_4_11.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX4.12/Ex1_4_12.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX4.13/Ex1_4_13.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX4.14/Ex1_4_14.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX4.15/Ex1_4_15.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX4.8/Ex1_4_8.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX4.9/Ex1_4_9.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX5.16/Ex1_5_16.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX5.17/Ex1_5_17.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX5.18/Ex1_5_18.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX5.19/Ex1_5_19.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX5.20/Ex1_5_20.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH1/EX5.21/Ex1_5_21.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX1.22/Ex2_1_22.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX1.23/Ex2_1_23.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX2.24/Ex2_2_24.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX2.25/Ex2_2_25.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX2.26/Ex2_2_26.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX2.27/Ex2_2_27.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX2.28/Ex2_2_28.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX2.29/Ex2_2_29.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX2.30/Ex2_2_30.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.31/Ex2_3_31.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.32/Ex2_3_32.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.33/Ex2_3_33.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.34/Ex2_3_34.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.35/Ex2_3_35.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.36/Ex2_3_36.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.37/Ex2_3_37.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.38/Ex2_3_38.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.39/Ex2_3_39.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.40/Ex2_3_40.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.41/Ex2_3_41.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX3.42/Ex2_3_42.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX4.43/Ex2_4_43.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX4.44/Ex2_4_44.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX4.45/Ex2_4_45.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX4.46/Ex2_4_46.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX4.47/Ex2_4_47.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX4.48/Ex2_4_48.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX4.49/Ex2_4_49.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX4.50/Ex2_4_50.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX5.51/Ex2_5_51.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX5.52/Ex2_5_52.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX6.53/Ex2_6_53.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX6.54/Ex2_6_54.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX6.55/Ex2_6_55.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX6.56/Ex2_6_56.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX6.57/Ex2_6_57.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX7.58/Ex2_7_58.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH2/EX7.59/Ex2_7_59.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX1.60/Ex3_1_60.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX1.61/Ex3_1_61.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX1.62/Ex3_1_62.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX1.63/Ex3_1_63.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX1.64/Ex3_1_64.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX1.65/Ex3_1_65.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX1.66/Ex3_1_66.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX2.67/Ex3_2_67.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX3.68/Ex3_3_68.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX3.69/Ex3_3_69.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX3.70/Ex3_3_70.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX3.71/Ex3_3_71.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX3.72/Ex3_3_72.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX3.73/Ex3_3_73.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX4.74/Ex3_4_74.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX4.75/Ex3_4_75.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX4.76/Ex3_4_76.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX4.77/Ex3_4_77.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX4.78/Ex3_4_78.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX4.79/Ex3_4_79.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX4.80/Ex3_4_80.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX4.81/Ex3_4_81.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX5.82/Ex3_5_82.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH3/EX5.83/Ex3_5_83.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH4/EX1.84/Ex4_1_84.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH4/EX1.85/Ex4_1_85.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH4/EX1.86/Ex4_1_86.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH4/EX1.87/Ex4_1_87.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH4/EX1.88/Ex4_1_88.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH4/EX1.89/Ex4_1_89.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH4/EX2.90/Ex4_2_90.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH4/EX2.91/Ex4_2_91.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH4/EX2.92/Ex4_2_92.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX1.93/Ex5_1_93.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX1.94/Ex5_1_94.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX1.95/Ex5_1_95.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX1.96/Ex5_1_96.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX1.97/Ex5_1_97.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX2.100/Ex5_2_100.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX2.101/Ex5_2_101.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX2.102/Ex5_2_102.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX2.98/Ex5_2_98.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX2.99/Ex5_2_99.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX3.103/Ex5_3_103.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX3.104/Ex5_3_104.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX3.105/Ex5_3_105.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX3.106/Ex5_3_106.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX3.107/Ex5_3_107.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX3.108/Ex5_3_108.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX3.109/Ex5_3_109.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/CH5/EX3.110/Ex5_3_110.zip create mode 100644 Fundamentals_Of_Matrix_Algebra,_Third_Edition_by_Gregory_Hartman/README.txt create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.1/Ex1_1.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.1/Ex1.2_1.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.2/Ex1.2_2.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.5/Ex1.2_5.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.a/Ex1_1.2A.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.b/Ex1_1.2B.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.c/Ex1_1.2C.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.3.a/Ex1_1.3A.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH10/EX10.1.1/Ex10.1_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH10/EX10.2.1/EX10.2_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.1.1/Ex2.1_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.1.a/Ex2_2.1a.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.2.a/Ex2_2.2a.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.3.1/Ex2.3_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.3.2/Ex2.3_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.3.b/Ex2_2.3b.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.3.c/Ex2_2.3C.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.4.1/Ex2.4_1.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.4.2/Ex2.4_2.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.4.a/Ex2_2.4A.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.4.b/Ex2_2.4B.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.4.c/Ex2_2.4C.R create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.5.2/Ex2.5_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.5.3/Ex2.5_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.5.4/Ex2.5_4.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.5.5/Ex2.5_5.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.5.a/Ex2_2.5A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.5.b/Ex2_2.5B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.5.c/Ex2_2.5C.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.6.1/Ex2.6_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.6.2/Ex2.6_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.6.3/Ex2.6_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.6.a/Ex2_2.6A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.6.b/Ex2_2.6B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.7.1/Ex2.7_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.7.4/Ex2.7_4.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.7.a/Ex2_2.7A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH2/EX2.7.b/Ex2_2.7B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.2.2/Ex3.2_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.2.3/Ex3.2_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.2.4/Ex3.2_4.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.2.a/Ex3_3.2A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.2.b/Ex3_3.2b.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.3.a/Ex3_3.3A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.3.c/Ex3_3.3C.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.4.2/Ex3.4_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.4.a/Ex3_3.4A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.4.c/Ex3_3.4C.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.5.1/Ex3.5_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.6.1/Ex3.6_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.6.2/Ex3.6_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH3/EX3.6.a/Ex3_3.6A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.1.3/Ex4.1_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.1.a/Ex4_4.1A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.1.b/Ex4_4.1B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.2.1/Ex4.2_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.2.2/Ex4.2_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.2.3/Ex4.2_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.2.a/Ex4_4.2A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.2.b/Ex4_4.2B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.3.1/Ex4.3_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.3.2/Ex4.3_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.3.3/Ex4.3_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.3.a/Ex4_4.3A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.3.b/Ex4_4.3B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.4.4/Ex4.4_4.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH4/EX4.4.5/Ex4.4_5.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.2.1/Ex5.2_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.2.5/Ex5.2_5.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.2.7/Ex5.2_7.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.3.1/Ex5.3_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.3.3/Ex5.3_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.3.7/Ex5.3_7.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.3.8/Ex5.3_8.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.3.9/Ex5.3_9.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.3.a/Ex5_5.3A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH5/EX5.3.b/Ex5_5.3B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.1.1/Ex6.1_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.1.2/Ex6.1_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.1.3/Ex6.1_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.1.4/Ex6.1_4.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.1.a/Ex6_6.1A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.1.b/Ex6_6.1B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.2.1/Ex6.2_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.2.2/Ex6.2_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.2.b/Ex6_6.2B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.3.1/Ex6.3_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.3.2/Ex6.3_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.3.6/Ex6.3_6.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.3.b/Ex6_6.3B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.4.1/Ex6.4_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.4.4/Ex6.4_4.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.4.b/Ex6_6.4B.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.5.1/Ex6.5_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.6.1/Ex6.6_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.6.2/Ex6.6_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.6.3/Ex6.6_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.6.a/Ex6_6.6A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.7.3/Ex6.7_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH6/EX6.7.4/Ex6.7_4.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH7/EX7.3.1/Ex7.3_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH7/EX7.3.2/Ex7.3_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH7/EX7.3.3/Ex7.3_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH7/EX7.3.4/Ex7.3_4.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH7/EX7.3.a/Ex7_7.3A.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH8/EX8.1.1/Ex8.1_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH8/EX8.1.2/Ex8.1_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH8/EX8.2.1/Ex8.2_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH8/EX8.3.1/Ex8.3_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH8/EX8.3.3/Ex8.3_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH8/EX8.3.4/Ex8.3_4.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH8/EX8.3.5/Ex8.3_5.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH8/EX8.5.2/Ex8.5_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH8/EX8.6.2/Ex8.6_6.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH9/EX9.2.2/Ex9.2_2.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH9/EX9.2.3/Ex9.2_3.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH9/EX9.3.1/Ex9.3_1.r create mode 100644 Introduction_To_Linear_Algebra_by_Gilbert_Strang/README.txt create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.3.a/Ex10_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.3.b/Ex10_3b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.3.c/Ex10_3c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.4.b/Ex10_4b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.5.a/Ex10_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.a/Ex11_2a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.b/Ex11_2b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.d/Ex11_2d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.3.a/Ex11_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.4.a/Ex11_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.4.b/Ex11_4b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.5.a/Ex11_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.5.b/Ex11_5b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.6.a/Ex11_6a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.2.a/Ex12_2a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.2.b/Ex12_2b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.3.b/Ex12_3b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.3.c/Ex12_3c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.a/Ex12_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.b/Ex12_4b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.c/Ex12_4c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.d/Ex12_4d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.e/Ex12_4e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.5.a/Ex12_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.5.c/Ex12_5c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.2.a/Ex13_2a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.2.b/Ex13_2b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.3.a/Ex13_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.4.a/Ex13_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.5.a/Ex13_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.b/Ex13_6b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.c/Ex13_6c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.d/Ex13_6d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.a/Ex14_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.b/Ex14_3b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.c/Ex14_3c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.d/Ex14_3d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.e/Ex14_3e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.4.a/Ex14_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.2.a/Ex2_2a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.2.b/Ex2_2b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.a/Ex2_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.b/Ex2_3b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.c/Ex2_3c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.d/Ex2_3d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.e/Ex2_3e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.f/Ex2_3f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.g/Ex2_3g.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.h/Ex2_3h.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.i/Ex2_3i.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.4.a/Ex2_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.5.a/Ex2_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.6.a/Ex2_6a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.6.b/Ex2_6b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.4.a/Ex3_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.a/Ex3_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.b/Ex3_5b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.c/Ex3_5c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.d/Ex3_5d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.f/Ex3_5f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.a/Ex3_6a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.b/Ex3_6b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.c/Ex3_6c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.a/Ex3_7a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.b/Ex3_7b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.c/Ex3_7c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.d/Ex3_7d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.e/Ex3_7e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.f/Ex3_7f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.8.a/Ex3_8a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.1.a/Ex4_1a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.1.c/Ex4_1c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.2.a/Ex4_2a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.2.b/Ex4_2b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.a/Ex4_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.b/Ex4_3b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.c/Ex4_3c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.d/Ex4_3d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.e/Ex4_3e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.f/Ex4_3f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.g/Ex4_3g.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.4.a/Ex4_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.4.d/Ex4_4d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.a/Ex4_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.b/Ex4_5b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.c/Ex4_5c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.d/Ex4_5d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.e/Ex4_5e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.g/Ex4_5g.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.6.a/Ex4_6a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.7.a/Ex4_7a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.7.b/Ex4_7b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.9.a/Ex4_9a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.a/Ex5_1a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.b/Ex5_1b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.e/Ex5_1e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.f/Ex5_1f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.a/Ex5_2a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.b/Ex5_2b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.c/Ex5_2c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.d/Ex5_2d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.f/Ex5_2f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.a/Ex5_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.b/Ex5_3b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.c/Ex5_3c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.a/Ex5_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.b/Ex5_4b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.c/Ex5_4c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.a/Ex5_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.b/Ex5_5b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.c/Ex5_5c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.d/Ex5_5d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.a/Ex5_6a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.b/Ex5_6b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.c/Ex5_6c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.a/Ex5_8a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.b/Ex5_8b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.c/Ex5_8c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.d/Ex5_8d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.e/Ex5_8e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.f/Ex5_8f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.a/Ex6_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.c/Ex6_3c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.d/Ex6_3d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.e/Ex6_3e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.5.a/Ex6_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.6.a/Ex6_6a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.6.b/Ex6_6b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.a/Ex7_2a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.b/Ex7_2b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.c/Ex7_2c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.d/Ex7_2d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.e/Ex7_2e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.f/Ex7_2f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.g/Ex7_2g.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.a/Ex7_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.b/Ex7_3b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.c/Ex7_3c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.d/Ex7_3d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.e/Ex7_3e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.f/Ex7_3f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.g/Ex7_3g.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.h/Ex7_3h.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.4.a/Ex7_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.4.b/Ex7_4b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.a/Ex7_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.b/Ex7_5b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.c/Ex7_5c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.6.a/Ex7_6a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.a/Ex7_7a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.b/Ex7_7b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.c/Ex7_7c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.a/Ex7_8a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.b/Ex7_8b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.d/Ex7_8d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.a/Ex8_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.b/Ex8_3b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.c/Ex8_3c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.d/Ex8_3d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.e/Ex8_3e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.f/Ex8_3f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.g/Ex8_3g.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.h/Ex8_3h.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.i/Ex8_3i.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.j/Ex8_3j.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.4.a/Ex8_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.4.b/Ex8_4b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.4.c/Ex8_4c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.4.d/Ex8_4d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.5.a/Ex8_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.5.b/Ex8_5b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.6.a/Ex8_6a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.6.b/Ex8_6b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.6.c/Ex8_6c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.a/Ex8_7a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.b/Ex8_7b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.c/Ex8_7c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.1.a/Ex9_1a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.a/Ex9_10a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.b/Ex9_10b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.c/Ex9_10c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.d/Ex9_10d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.11.a/Ex9_11a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.2.a/Ex9_2a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.3.a/Ex9_3a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.a/Ex9_4a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.b/Ex9_4b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.c/Ex9_4c.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.d/Ex9_4d.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.e/Ex9_4e.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.f/Ex9_4f.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.5.a/Ex9_5a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.7.a/Ex9_7a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.8.b/Ex9_8b.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.9.a/Ex9_9a.R create mode 100644 Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/README.txt create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.10/Ex1_10.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.11/Ex1_11.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.3/Ex1_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.4/Ex1_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.5/Ex1_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.6/Ex1_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.7/Ex1_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.8/Ex1_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.11/Ex10_11.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.12/Ex10_12.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.13/Ex10_13.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.14/Ex10_14.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.15/Ex10_15.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.16/Ex10_16.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.2/Ex10_2.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.3/Ex10_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.4/Ex10_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.5/Ex10_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.6/Ex10_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.7/Ex10_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.8/Ex10_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.9/Ex10_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.10/Ex11_10.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.12/Ex11_12.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.4/Ex11_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.5/Ex11_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.6/Ex11_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.7/Ex11_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.8/Ex11_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.9/Ex11_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.1/Ex12_1.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.2/Ex12_2.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.3/Ex12_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.4/Ex12_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.5/Ex12_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.6/Ex12_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.7/Ex12_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.8/Ex12_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.2/Ex13_2.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.3/Ex13_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.4/Ex13_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.6/Ex13_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.7/Ex13_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.8/Ex13_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.1/Ex14_1.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.2/Ex14_2.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.4/Ex14_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.5/Ex14_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.7/Ex14_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.1/Ex15_1.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.10/Ex15_10.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.11/Ex15_11.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.2/Ex15_2.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.3/Ex15_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.4/Ex15_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.5/Ex15_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.6/Ex15_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.8/Ex15_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.9/Ex15_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.1/Ex2_1.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.10/Ex2_10.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.11/Ex2_11.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.13/Ex2_13.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.14/Ex2_14.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.2/Ex2_2.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.3/Ex2_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.5/Ex2_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.6/Ex2_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.7/Ex2_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.9/Ex2_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.1/Ex3_1.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.2/Ex3_2.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.3/Ex3_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.4/Ex3_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.5/Ex3_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.6/Ex3_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.7/Ex3_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.10/Ex4_10.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.11/Ex4_11.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.12/Ex4_12.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.13/Ex4_13.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.14/Ex4_14.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.15/Ex4_15.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.17/Ex4_17.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.18/Ex4_18.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.19/Ex4_19.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.20/Ex4_20.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.21/Ex4_21.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.22/Ex4_22.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.23/Ex4_23.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.24/Ex4_24.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.26/Ex4_26.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.27/Ex4_27.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.5/Ex4_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.6/Ex4_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.7/Ex4_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.8/Ex4_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.9/Ex4_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.10/Ex5_10.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.11/Ex5_11.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.12/Ex5_12.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.3/Ex5_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.4/Ex5_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.5/Ex5_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.6/Ex5_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.7/Ex5_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.8/Ex5_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.9/Ex5_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.1/Ex6_1.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.10/Ex6_10.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.11/Ex6_11.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.12/Ex6_12.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.13/Ex6_13.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.2/Ex6_2.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.3/Ex6_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.4/Ex6_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.5/Ex6_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.6/Ex6_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.7/Ex6_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.8/Ex6_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.9/Ex6_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.1/Ex7_1.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.4/Ex7_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.5/Ex7_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.6/Ex7_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.7/Ex7_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.8/Ex7_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.9/Ex7_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.10/Ex8_10.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.11/Ex8_11.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.12/Ex8_12.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.13/Ex8_13.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.14/Ex8_14.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.4/Ex8_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.5/Ex8_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.6/Ex8_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.7/Ex8_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.8/Ex8_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.9/Ex8_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.10/Ex9_10.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.11/Ex9_11.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.12/Ex9_12.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.3/Ex9_3.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.4/Ex9_4.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.5/Ex9_5.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.6/Ex9_6.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.7/Ex9_7.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.8/Ex9_8.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.9/Ex9_9.R create mode 100644 Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/README.txt create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.10/EX1_10.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.11/EX1_11.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.12/EX1_12.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.18/EX1_18.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.2/EX1_2.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.28/EX1_28.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.29/EX1_29.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.3/EX1_3.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.30/EX1_30.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.6/EX1_6.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.8/EX1_8.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.9/EX1_9.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.1/EX_2_1.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.11/EX_2_11.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.13/EX_2_13.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.14/EX_2_14.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.16/EX_2_16.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.18/EX_2_18.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.2/EX_2_2.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.3/EX_2_3.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.4/EX_2_4.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.5/EX_2_5.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.7/EX_2_7.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.8/EX_2_8.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.9/EX_2_9.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.11/EX_3_11.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.12/EX_3_12.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.2/EX_3_2.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.22/EX_3_22.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.3/EX_3_3.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.4/EX_3_4.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.5/EX_3_5.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.7/EX_3_7.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.8/EX_3_8.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.9/EX_3_9.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.1/EX_4_1.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.13/EX_4_13.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.16/EX_4_16.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.20/EX_4_20.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.21/EX_4_21.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.4/EX_4_4.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.5/EX_4_5.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.6/EX_4_6.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.7/EX_4_7.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.9/EX_4_9.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.12/EX_5_12.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.17/EX_5_17.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.5/EX_5_5.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.6/EX_5_6.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.7/EX_5_7.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.9/EX_5_9.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.1/EX_6_1.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.11/EX_6_11.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.13/EX_6_13.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.14/EX_6_14.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.2/EX_6_2.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.4/EX_6_4.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.1/EX_7_1.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.10/EX_7_10.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.11/EX_7_11.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.4/EX_7_4.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.8/EX_7_8.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.9/EX_7_9.R create mode 100644 Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/README.txt create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.1/example1_sect1_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.3/example3_sec1_1.R create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.4/example4_sec1_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.5/example5_sec1_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.6/example6_sec1_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.10/example10_sec1_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.12/example12_sec1_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.14/example14_sec1_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.15/example15_sec1_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.3/example3_sec1_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.1/example1_sec1_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.10/example10_sec1_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.21/example21_sec1_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.23/example23_sec1_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.4/example4_sec1_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.5/example5_sec1_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.10/example10_sec1_4.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.11/example11_sec1_4.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.2/example2_sec_1_4.R create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.5/example5_sec1_4.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.5.3/example3_sec1_5.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.6.4/example4_sec1_6.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.6.5/example5_sec1_6.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.4/example4_sec1_7.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.5/example5_sec1_7.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.6/example6_sec1_7.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.1.2/example2_sec10_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.2.12/example12_sec10_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.2.3/example3_sec10_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.12/example12_sec2_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.14/2.2.14.R create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.5/example5_sec2_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.6/example6_sec2_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.4.1/example1_sec2_4.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.1/example1_sec2_5.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.3/example3_sec2_5.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.7/example7_sec2_5.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX7.2.2/example2_sec7_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.10/example10_sec3_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.11/example11_sec3_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.18/example18_sec3_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.19/example19_sec3_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.5/example5_sec3_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.7/example7_sec3_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.9/example9_sec3_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.1/example1_sec3_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.2/example2_sec3_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.5/example5_sec3_2.R create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.7/example7_sec3_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.9/example9_sec3_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.3.14/example14_sec3_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.14/example14_sec4_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.15/example15_sec4_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.16/example16_sec4_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.3/4.1.3.R create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.6/example6_sec4_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.7/example7_sec4_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.8/example8_sec4_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.9/example9_sec4_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.10/example10_sec4_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.13/example13_sec4_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.2/example2_sec4_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.3/example3_sec4_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.3.2/example2_sec4_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.3.5/example5_sec4_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.1/example1_sec5_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.4/example4_sec5_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.6/example6_sec5_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.1.7/example7_sec6_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.11/example11_sec6_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.12/example12_sec6_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.3/example3_sec6_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.3.2/example2_sec6_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.3.8/example8_sec6_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.4.2/example2_sec6_4.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.4.5/6.4.5.R create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.5.3/example3_sec6_5.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.6.5/example5_sec6_6.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.6.8/example8_sec6_6.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.7.1/example1_sec6_7.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.8.4/example4_sec6_8.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.1/example1_sec7_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.2/example2_sec7_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.4/example4_sec7_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.2/example2_sec8_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.3/example3_sec8_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.5/example5_sec8_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.6/example6_sec8_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.8/example8_sec8_1.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.2.1/example1_sec8_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.2.3/example3_sec8_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.3.1/example1_sec8_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.3.5/example5_sec8_3.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.2.5/example5_sec9_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.2.6/example6_sec9_2.zip create mode 100644 Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.4.7/example7_sec9_4.zip create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.1/Ex1.1.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.10/Ex1.10.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.11/Ex1.11.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.12/Ex1.12.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.13/Ex1.13.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.14/Ex1.14.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.15/Ex1.15.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.16/Ex1.16.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.17/Ex1.17.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.18/Ex1.18.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.19/Ex1.19.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.2/Ex1.2.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.20/Ex1.20.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.21/Ex1.21.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.22/Ex1.22.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.23/Ex1.23.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.24/Ex1.24.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.25/Ex1.25.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.26/Ex1.26.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.27/Ex1.27.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.28/Ex1.28.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.29/Ex1.29.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.3/Ex1.3.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.30/Ex1.30.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.31/Ex1.31.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.32/Ex1.32.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.4/Ex1.4.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.5/Ex1.5.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.6/Ex1.6.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.7/Ex1.7.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.8/Ex1.8.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.9/Ex1.9.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.1/Ex2.1.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.10/Ex2.10.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.11/Ex2.11.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.12/Ex2.12.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.13/Ex2.13.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.14/Ex2.14.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.15/Ex2.15.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.16/Ex2.16.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.17/Ex2.17.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.18/Ex2.18.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.19/Ex2.19.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.2/Ex2.2.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.20/Ex2.20.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.21/Ex2.21.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.22/Ex2.22.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.23/Ex2.23.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.3/Ex2.3.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.4/Ex2.4.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.5/Ex2.5.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.6/Ex2.6.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.7/Ex2.7.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.8/Ex2.8.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.9/Ex2.9.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.1/Ex3.1.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.10/Ex3.10.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.11/Ex3.11.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.12/Ex3.12.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.2/Ex3.2.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.3/Ex3.3.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.4/Ex3.4.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.5/Ex3.5.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.6/Ex3.6.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.7/Ex3.7.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.8/Ex3.8.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.9/Ex3.9.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.1/Ex4.1.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.10/Ex4.10.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.11/Ex4.11.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.12/Ex4.12.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.13/Ex4.13.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.14/Ex4.14.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.15/Ex4.15.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.16/Ex4.16.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.17/Ex4.17.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.18/Ex4.18.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.19/Ex4.19.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.2/Ex4.2.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.20/Ex4.20.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.21/Ex4.21.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.3/Ex4.3.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.4/Ex4.4.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.5/Ex4.5.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.6/Ex4.6.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.7/Ex4.7.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.8/Ex4.8.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.9/Ex4.9.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.1/Ex5.1.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.10/Ex5.10.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.11/Ex5.11.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.12/Ex5.12.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.13/Ex5.13.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.14/Ex5.14.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.15/Ex5.15.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.16/Ex5.16.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.17/Ex5.17.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.18/Ex5.18.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.19/Ex5.19.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.2/Ex5.2.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.20/Ex5.20.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.21/Ex5.21.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.22/Ex5.22.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.23/Ex5.23.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.24/Ex5.24.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.3/Ex5.3.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.4/Ex5.4.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.5/Ex5.5.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.6/Ex5.6.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.7/Ex5.7.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.8/Ex5.8.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.9/Ex5.9.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.1/Ex6.1.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.10/Ex6.10.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.11/Ex6.11.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.12/Ex6.12.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.13/Ex6.13.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.14/Ex6.14.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.15/Ex6.15.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.16/Ex6.16.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.17/Ex6.17.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.18/Ex6.18.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.19/Ex6.19.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.2/Ex6.2.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.20/Ex6.20.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.21/Ex6.21.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.22/Ex6.22.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.23/Ex6.23.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.3/Ex6.3.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.4/Ex6.4.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.5/Ex6.5.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.6/Ex6.6.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.7/Ex6.7.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.8/Ex6.8.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.9/Ex6.9.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.1/Ex7.1.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.10/Ex7.10.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.11/Ex7.11.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.12/Ex7.12.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.13/Ex7.13.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.14/Ex7.14.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.2/Ex7.2.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.3/Ex7.3.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.4/Ex7.4.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.5/Ex7.5.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.6/Ex7.6.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.7/Ex7.7.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.8/Ex7.8.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.9/Ex7.9.R create mode 100644 Linear_Algebra_And_Its_Applications_by_David_C._Lay/README.txt create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX1.11/Ex1_11.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX1.12/Ex1_12.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX1.13/Ex1_13.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX1.3/Ex1_3.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX1.4/Ex1_4.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX1.7/Ex1_7.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX1.8/Ex1_8.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX1.9/Ex1_9.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX2.1/Ex1_2_1.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX2.12/Ex1_2_12.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX2.3/Ex1_2_3.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX2.5/Ex1_2_5.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX2.7/Ex1_2_7.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX3.3/Ex1_3_3.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH1/EX3.5/Ex1_3_5.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH2/EX1.16/Ex2_1_16.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH2/EX1.6/Ex2_1_6.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH2/EX1.9/Ex2_1_9.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH2/EX3.10/Ex2_3_10.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH2/EX3.2/Ex2_3_2.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH2/EX3.5/Ex2_3_5.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH2/EX3.7/Ex2_3_7.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH2/EX3.9/Ex2_3_9.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX1.1/Ex3_1_1.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX1.11/Ex3_1_11.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX1.9/Ex3_1_9.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX2.10/Ex3_2_10.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX2.11/Ex3_2_11.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX2.5/Ex3_2_5.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX3.1.11/Ex3_3_1_11.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX4.1.1/Ex3_4_1_1.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX4.1.2/Ex3_4_1_2.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.4/Ex3_4_2_4.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.5/Ex3_4_2_5.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.6/Ex3_4_2_6.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX4.3.15/Ex3_4_3_15.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH3/EX4.4.9/Ex3_4_4_9.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH4/EX1.10/Ex4_1_10.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH4/EX1.4/Ex4_1_4.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH4/EX1.6/Ex4_1_6.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH4/EX1.7/Ex4_1_7.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH4/EX2.5/Ex4_2_5.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH4/EX2.6/Ex4_2_6.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH4/EX3.1/Ex4_3_1.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH4/EX3.4/Ex4_3_4.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH5/EX1.3/Ex5_1_3.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH5/EX2.10/Ex5_2_10.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH5/EX2.17/Ex5_2_17.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH5/EX2.18/Ex5_2_18.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2.2/Ex5_2_2_2.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2/Ex5_2_2.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH5/EX2.4/Ex5_2_4.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH5/EX3.19/Ex5_3_19.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/CH5/EX3.6/Ex5_3_6.R create mode 100644 Linear_Algebra_by_Jim_Hefferon/README.txt create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.1/EX1_1.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.12/EX1_12.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.13/EX1_13.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.16/EX1_16.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.2/EX1_2.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.20/EX1_20.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.22/EX1_22.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.30/EX1_30.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.31/EX1_31.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.32/EX1_32.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.4/EX1_4.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.1/EX2_1.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.18/EX2_18.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.20/EX2_20.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.21/EX2_21.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.24/EX2_24.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.26/EX2_26.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.3/EX2_3.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.36/EX2_36.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.4/EX2_4.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.5/EX2_5.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.1/EX3_1.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.10.a/EX3_10_(a).zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.10.c/EX3_10_(c).zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.13/EX3_13.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.14/EX3_14.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.2/EX3_2.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.3/EX3_3.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.4/EX3_4.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.8/EX3_8.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.1/EX4_1.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.2/EX4_2.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.3/EX4_3.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.4/EX4_4.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.6/EX4_6.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.7/EX4_7.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.8/EX4_8.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.9/EX4_9.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.1/EX5_1.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.10/EX5_10.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.12/EX5_12.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.4/EX5_4.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.5/EX5_5.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.6/EX5_6.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.8/EX5_8.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.9/EX5_9.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.23/EX6_23.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.24/EX6_24.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.25/EX6_25.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.27/EX6_27.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.31/EX6_31.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.34/EX6_34.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.37/EX6_37.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.38/EX6_38.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.4/EX6_4.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.40/EX6_40.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.41/EX6_41.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.8/EX6_8.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.10/EX7_10.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.8/EX7_8.zip create mode 100644 Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.9/EX7_9.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.1/Ex1_1.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.10/Ex1_10.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.11/Ex1_11.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.12/Ex1_12.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.13/Ex1_13.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.14/Ex1_14.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.15/Ex1_15.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.2/Ex1_2.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.3/Ex1_3.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.4/Ex1_4.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.5/Ex1_5.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.6/Ex1_6.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.7/Ex1_7.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.8/Ex1_8.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.9/Ex1_9.zip create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.1/Ex2_1.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.2/Ex2_2.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.3/Ex2_3.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.4/Ex2_4.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.5/Ex2_5.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.6/Ex2_6.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.7/Ex2_7.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.1/Ex3_1.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.2/Ex3_2.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.3/Ex3_3.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.4/Ex3_4.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.5/Ex3_5.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.6/Ex3_6.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.7/Ex3_7.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.1/Ex4_1.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.2/Ex4_2.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.3/Ex4_3.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.4/Ex4_4.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.5/Ex4_5.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.6/Ex4_6.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH5/EX5.1/Ex5_1.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH5/EX5.2/Ex5_2.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH6/EX6.1/Ex6_1.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH8/EX8.1/Ex8_1.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.1/Ex9_1.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.2/Ex9_2.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.3/Ex9_3.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.4/Ex9_4.R create mode 100644 Matrices_And_Linear_Transformations_by_Charles_G._Cullen/README.txt create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.1/EX10_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.10/EX10_10.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.11/EX10_11.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.12/EX10_12.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.13/EX10_13.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.15/EX10_15.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.2/EX10_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.3/EX10_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.4/EX10_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.5/EX10_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.6/EX10_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.7/EX10_7.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.8/EX10_8.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.9/EX10_9.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.1/EX11_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.10/EX11_10.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.11/EX11_11.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.12/EX11_12.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.14/EX11_14.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.15/EX11_15.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.17/EX11_17.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.18/EX11_18.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.19/EX11_19.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.2/EX11_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.20/EX11_20.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.21/EX11_21.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.3/EX11_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.5/EX11_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.6/EX11_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.7/EX11_7.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.8/EX11_8.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.9/EX11_9.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.1/EX12_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.10/EX12_10.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.11/12_11.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.2/EX12_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.3/EX12_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.4/EX12_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.5/EX12_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.6/EX12_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.7/EX12_7.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.8/EX12_8.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.9/EX12_9.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.1/EX13_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.2/EX13_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.3/EX13_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.4/EX13_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.1/EX14_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.2/EX14_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.3/EX14_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.4/EX14_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.5/EX14_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.6/EX14_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.7/EX14_7.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.8/EX14_8.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.9/EX14_9.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH15/EX15.2/EX15_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH15/EX15.3/EX15_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH15/EX15.4/EX15_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH16/EX16.1/EX16_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH16/EX16.2/EX16_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH16/EX16.3/EX16_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH16/EX16.4/EX16_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.1/EX2_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.11/EX2_11.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.12/EX2_12.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.13/EX2_13.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.14/EX2_14.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.15/EX2_15.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.16/EX2_16.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.18/EX2_18.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.19/EX2_19.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.2/EX2_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.3/EX2_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.4/EX2_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.6/EX2_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.7/EX2_7.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.8/EX2_8.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.9/EX2_9.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.1/EX3_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.11/EX3_11.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.13/EX3_13.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.14/EX3_14.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.15/EX3_15.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.16/EX3_16.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.17/EX3_17.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.18/EX3_18.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.19/EX3_19.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.20/EX3_20.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.21/EX3_21.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.22/EX3_22.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.24/EX3_24.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.25/EX3_25.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.26/EX3_26.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.28/EX3_28.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.29/EX3_29.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.30/EX3_30.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.31/EX3_31.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.5/EX3_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.6/EX3_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.1/EX4_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.10/EX4_10.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.11/EX4_11.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.12/EX4_12.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.13/EX4_13.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.14/EX4_14.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.15/EX4_15.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.16/EX4_16.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.17/EX4_17.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.18/EX4_18.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.19/EX4_19.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.20/EX4_20.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.21/EX4_21.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.22/EX4_22.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.24/EX4_24.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.25/EX4_25.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.26/EX4_26.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.27/EX4_27.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.3/EX4_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.4/EX4_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.5/EX4_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.6/EX4_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.7/EX4_7.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.8/EX4_8.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.9/EX4_9.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.1/EX5_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.10/EX5_10.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.11/EX5_11.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.12/EX5_12.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.13/EX5_13.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.14/EX5_14.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.15/EX5_15.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.16/EX5_16.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.17/EX5_17.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.18/EX5_18.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.19/EX5_19.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.2/EX5_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.20/EX5_20.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.21/EX5_21.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.22/EX5_22.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.23/EX5_23.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.3/EX5_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.31/EX5_31.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.4/EX5_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.42/EX5_42.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.43/EX5_43.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.44/EX5_44.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.45/EX5_45.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.5/EX5_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.6/EX5_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.7/EX5_7.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.8/EX5_8.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.9/EX5_9.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX5.54/EX6_54.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.49/EX6_49.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.51/EX6_51.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.52/EX6_52.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.53/EX6_53.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.55/EX6_55.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.13/EX7_13.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.15/EX7_15.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.18/EX7_18.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.19/EX7_19.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.2/EX7_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.20/EX7_20.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.22/EX7_22.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.23/EX7_23.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.24/EX7_24.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.3/EX7_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.4/EX7_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.5/EX7_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.6/EX7_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.7/EX7_7.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.8/EX7_8.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.10/EX8_10.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.11/EX8_11.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.12/EX8_12.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.13/EX8_13.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.14/EX8_14.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.3/EX8_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.4/EX8_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.5/EX8_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.6/EX8_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.7/EX8_7.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.8/EX8_8.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.9/EX8_9.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.1/EX9_1.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.2/EX9_2.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.3/EX9_3.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.4/EX9_4.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.5/EX9_5.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.6/EX9_6.R create mode 100644 Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/README.txt create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH1/EX1.1/Ex1_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.1/Ex14_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.2/Ex14_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.3/Ex14_3.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.4/Ex14_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.1/Ex15_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.2/Ex15_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.3/Ex15_3.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.4/Ex15_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.5/Ex15_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.6/Ex15_6.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.7/Ex15_7.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH17/EX17.3.a/Ex17_3_a.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH17/EX17.3.b/Ex17_3_b.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH18/EX18.5/Ex18_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.1/Ex19_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.2/Ex19_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.4/Ex19_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.5/Ex19_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.6/Ex19_6.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.1/Ex21_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.2/Ex21_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.3/Ex21_3.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.4/Ex21_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.5/Ex21_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.6/Ex21_6.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.7/Ex21_7.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.8/Ex21_8.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.9/Ex21_9.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH23/EX23.4/Ex23_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH23/EX23.5/Ex23_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH25/EX25.11/Ex25_11.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH25/EX25.14/Ex25_14.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH25/EX25.4/Ex25_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH26/EX26.1/Ex26_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.11/Ex27_11.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.3/Ex27_3.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.4/Ex27_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.5/Ex27_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.6/Ex27_6.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.7/Ex27_7.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.8/Ex27_8.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.9/Ex27_9.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.1/Ex3_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.2/Ex3_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.3/Ex3_3.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.4/Ex3_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.5/Ex3_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.6/Ex3_6.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.7/Ex3_7.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.8/Ex3_8.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH31/EX31.1/Ex31_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH31/EX31.2/Ex31_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.1/Ex4_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.2/Ex4_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.4/Ex4_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.5/Ex4_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.6/Ex4_6.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.7/Ex4_7.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.1/Ex5_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.2/Ex5_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.3/Ex5_3.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.4/Ex5_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.5/Ex5_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.6/Ex5_6.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH6/EX6.11/Ex6_11.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.1/Ex7_1.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.2/Ex7_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.3/Ex7_3.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.4/Ex7_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.5/Ex7_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.6/Ex7_6.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.7/Ex7_7.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.8/Ex7_8.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.11/Ex9_11.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.2/Ex9_2.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.3/Ex9_3.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.4/Ex9_4.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.5/Ex9_5.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.6/Ex9_6.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.7/Ex9_7.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.8/Ex9_8.R create mode 100644 Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/README.txt create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH10/EX10.4/Ex10_4.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.10/Ex2_10.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.24/Ex2_24.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.7/Ex2_7.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.8/Ex2_8.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.9/Ex2_9.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.11/Ex3_11.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.12/Ex3_12.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.13/Ex3_13.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.14/Ex3_14.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.15/Ex3_15.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.16/Ex3_16.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.17/Ex3_17.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.18/Ex3_18.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.2/Ex3_2.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.22/Ex3_22.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.23/Ex3_23.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.24/Ex3_24.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.4/Ex3_4.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.6/Ex3_6.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.7/Ex3_7.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.8/Ex3_8.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.1/Ex4_1.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.10/Ex4_10.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.11/Ex4_11.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.12/Ex4_12.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.14/Ex4_14.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.15/Ex4_15.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.16/Ex4_16.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.17/Ex4_17.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.18/Ex4_18.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.19/Ex4_19.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.2/Ex4_2.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.20/Ex4_20.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.3/Ex4_3.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.4/Ex4_4.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.5/Ex4_5.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.6/Ex4_6.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.8/Ex4_8.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.9/Ex4_9.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.1/Ex5_1.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.3/Ex5_3.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.4/Ex5_4.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.1/Ex6_1.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.12/Ex6_12.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.3/Ex6_3.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.5/Ex6_5.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.8/Ex6_8.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.1/Ex7_1.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.2/Page_409_CompLatticeBLS.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.3/Page_411_Luenberger_Investment Science_Ex13_11.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.4/Page_413_SmartEurLattice.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.5/Page_416_AmPutLattice.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.6/Page_420_AmSpreadLattice.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.7/Page_424_EuCallTrinomial.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.1/Page_433_AssetPaths.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.10/Page_449_D0PutMCCond.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.11/Page_453_DOPutMCCondIS.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.12/Page_455_AsianMC.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.13/Page_456_AsianMCCV.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.14/Page_459_AsianMCGeoCV.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.15/Page_460_AsianHalton.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.16/Page_464_GBMHaltonBridge.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.17/Page_470_BlsDeltaMCNaive.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.18/Page_472_BlsDeltaMCPath.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.2/Page_434_AssetPathsV.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.3/Page_436_StopLoss.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.4/Page_437_StopLossV.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.5/Page_438_DeltaHedging.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.6/Page_442_WienerBridge.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.7/Page_444_Exchange.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.8/Page_445_ExchangeMC.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.9/Page_446_DOPutMC.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.3/Page_479_EuPutExpl.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.4/Page_484_EuPutImpl.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.5/Page_487_DOPutCK.R create mode 100644 Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/README.txt create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH10/EX10.1/Ex10_1.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.5/Ex11_5.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.6/Ex11_6.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8/Ex11_8.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.3/Ex12_3.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.5/Ex12_5.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.6/Ex12_6.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.7/Ex12_7.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.8/Ex12_8.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.9/Ex12_9.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.10/Ex13_10.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.6/Ex13_6.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.7/Ex13_7.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.8/Ex13_8.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6/Ex14_6.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.1/Ex3_1.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.10/Ex3_10.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.11/Ex3_11.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.12/Ex3_12.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.2/Ex3_2.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.4/Ex3_4.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.8/Ex3_8.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.9/Ex3_9.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.10/Ex4_10.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.3/Ex4_3.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.4/Ex4_4.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.5/Ex4_5.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.6/Ex4_6.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.7/Ex4_7.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.9/Ex4_9.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.1/Ex6_1.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.11/Ex6_11.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.14/Ex6_14.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.15/Ex6_15.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.16/Ex6_16.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.17/Ex6_17.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.4/Ex6_4.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.5/Ex6_5.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.7/Ex6_7.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH7/EX7.1/Ex7_1.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH7/EX7.5/Ex7_5.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.1/Ex8_1.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.2/Ex8_2.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.3/Ex8_3.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.1/Ex9_1.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.11/Ex9_11.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.12/Ex9_12.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.2/Ex9_2.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.3/Ex9_3.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.4/Ex9_4.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.5/Ex9_5.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.8/Ex9_8.R create mode 100644 Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.9/Ex9_9.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.3.1/10.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.3.2/10.3.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.4.1/10.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH11/EX11.1.1/11.1.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.2.1/12.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.3.1/12.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.3.2/12.3.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.4.1/12.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.1/13.1.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.2/13.1.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.3/13.1.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.2.1/13.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.2.2/13.2.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.3.1/13.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.4.1/13.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.4.3/13.4.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH14/EX14.1.1/14.1.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH14/EX14.2.1/14.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.2.1/15.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.3.1/15.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.3.2/15.3.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.4.1/15.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.4.2/15.4.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.5.1/15.5.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.6.1/15.6.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.4.1/16.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.4.2/16.4.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.1/16.6.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.2/16.6.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.4/16.6.4.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.5/16.6.5.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.6/16.6.6.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.7/16.6.7.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.8/16.6.8.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.7.1/16.7.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.1/16.9.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.2/16.9.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.3/16.9.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.1.1/17.1.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.3.3/17.3.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.4.1/17.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH18/EX18.1.1/18.1.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH18/EX18.1.3/18.1.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.2.1/2.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.2.2/2.2.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.1/2.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.2/2.4.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.3/2.4.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.4/2.4.4.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.5/2.4.5.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.6/2.4.6.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.7/2.4.7.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.2.1/3.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.3.1/3.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.4.1/3.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.4.2/3.4.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.1/3.5.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.2/3.5.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.3/3.5.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.4/3.5.4.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.1/3.6.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.2/3.6.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.3/3.6.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.1/4.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.2/4.2.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.3/4.2.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.3.1/4.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.3.2/4.3.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.4.1/4.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.1/4.5.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.2/4.5.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.3/4.5.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.4/4.5.4.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.1.1/5.1.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.1.2/5.1.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.2.1/5.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.2.2/5.2.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.1/5.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.2/5.3.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.3/5.3.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.5/5.3.5.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.4.1/5.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.4.2/5.4.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.2.1/6.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.1/6.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.2/6.3.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.3/6.3.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.4/6.3.4.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.5/6.3.5.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.6/6.3.6.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.4.2/6.4.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.4.3/6.4.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.1/6.5.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.2/6.5.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.3/6.5.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.4/6.5.4.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.5/6.5.5.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.1.2/7.1.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.1.3/7.1.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.2.1/7.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.3.1/7.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.4.1/7.4.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.1/8.1.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.2/8.1.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.3/8.1.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.4/8.1.4.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.2.1/8.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.2.2/8.2.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH9/EX9.2.1/9.2.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH9/EX9.2.2/9.2.2.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH9/EX9.2.3/9.2.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH9/EX9.3.1/9.3.1.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH9/EX9.3.3/9.3.3.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH9/EX9.3.4/9.3.4.R create mode 100644 Operations_Research:_An_Introduction_by_Hamdy_A_Taha/README.txt create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH1/EX1.2/Ex1_2.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH1/EX1.3/Ex1_3.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH1/EX1.4/Ex1_4.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH14/EX14.1/Ex14_1.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH14/EX14.2/Ex14_2.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH14/EX14.4/Ex14_4.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH14/EX14.7/Ex14_7.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH14/EX14.8/Ex14_8.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.1/Ex2_1.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.10/Ex2_10.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.11/Ex2_11.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.12/Ex2_12.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.13/Ex2_13.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.15/Ex2_15.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.16/Ex2_16.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.18/Ex2_18.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.2/Ex2_2.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.20/Ex2_20.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH2/EX2.5/Ex2_5.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH3/EX3.12/Ex3_12.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH3/EX3.13/Ex3_13.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH3/EX3.14/Ex3_14.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH3/EX3.16/Ex3_16.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH3/EX3.17/Ex3_17.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH3/EX3.3/Ex3_3.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH3/EX3.7/Ex3_7.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH3/EX3.8/Ex3_8.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.1/Ex4_1.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.10/Ex4_10.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.11/Ex4_11.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.13/Ex4_13.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.14/Ex4_14.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.19/Ex4_19.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.20/Ex4_20.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.21/Ex4_21.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.22/Ex4_22.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.23/Ex4_23.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.24/Ex4_24.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.26/Ex4_26.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.27/Ex4_27.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.28/Ex4_28.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.29/Ex4_29.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.30/Ex4_30.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.31/Ex4_31.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.32/Ex4_32.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.4/Ex4_4.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.9/Ex4_9.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.1/Ex5_1.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.10/Ex5_10.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.17/Ex5_17.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.2/Ex5_2.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.27/Ex5_27.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.5/Ex5_5.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.9/Ex5_9.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH7/EX7.16/Ex7_16.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH7/EX7.4/Ex7_4.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.1/Ex8_1.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.2/Ex8_2.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.21/Ex8_21.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.22/Ex8_22.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.24/Ex8_24.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.25/Ex8_25.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.26/Ex8_26.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.3/Ex8_3.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.4/Ex8_4.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.5/Ex8_5.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.6/Ex8_6.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.7/Ex8_7.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.8/Ex8_8.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH9/EX9.10/Ex9_10.R create mode 100644 Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/README.txt create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.10.1/Ex1_10_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.1/Ex1_4_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.2/Ex1_4_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.3/Ex1_4_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.4/Ex1_4_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.5/Ex1_4_5.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.2/Ex1_5_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.3/Ex1_5_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.4/Ex1_5_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.2/Ex1_6_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.3/Ex1_6_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.4/Ex1_6_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.5/Ex1_6_5.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.1/Ex1_7_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.12/Ex1_7_12.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.3/Ex1_7_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.4/Ex1_7_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.5/Ex1_7_5.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.7/Ex1_7_7.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.8/Ex1_7_8.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.9/Ex1_7_9.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.1/Ex1_8_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.10/Ex1_8_10.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.11/Ex1_8_11.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.12/Ex1_8_12.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.2/Ex1_8_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.3/Ex1_8_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.4/Ex1_8_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.5/Ex1_8_5.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.6/Ex1_8_6.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.7/Ex1_8_7.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.8/Ex1_8_8.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.9/Ex1_8_9.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.1/Ex1_9_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.2/Ex1_9_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.3/Ex1_9_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.4/Ex1_9_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.10/Ex2_1_10.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.11/Ex2_1_11.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.12/Ex2_1_12.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.2/Ex2_1_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.3/Ex2_1_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.4/Ex2_1_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.5/Ex2_1_5.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.9/Ex2_1_9.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.1/Ex2_2_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.10/Ex2_2_10.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.2/Ex2_2_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.3/Ex2_2_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.4/Ex2_2_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.7/Ex2_2_7.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.9/Ex2_2_9.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.2/Ex2_3_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.3/Ex2_3_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.4/Ex2_3_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.5/Ex2_3_5.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.6/Ex2_3_6.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.7/Ex2_3_7.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.8/Ex2_3_8.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.4.1/Ex2_4_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.4.2/Ex2_4_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.1/Ex3_1_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.3/Ex3_1_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.5/Ex3_1_5.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.6/Ex3_1_6.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.8/Ex3_1_8.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.11/Ex3_10_11.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.12/Ex3_10_12.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.14/Ex3_10_14.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.15/Ex3_10_15.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.2/Ex3_10_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.4/Ex3_10_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.5/Ex3_10_5.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.7/Ex3_10_7.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.8/Ex3_10_8.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.3/Ex3_2_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.4/Ex3_2_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.7/Ex3_2_7.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.3.1/Ex3_3_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.3.3/Ex3_3_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.3.9/Ex3_3_9.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.11/Ex3_4_11.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.12/Ex3_4_12.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.3/Ex3_4_3.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.7/Ex3_4_7.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.8/Ex3_4_8.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.9/Ex3_4_9.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.2/Ex3_5_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.4/Ex3_5_4.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.7/Ex3_5_7.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.8/Ex3_5_8.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.9/Ex3_5_9.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.1/Ex3_6_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.2/Ex3_6_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.5/Ex3_6_5.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.9/Ex3_6_9.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.15/Ex3_7_15.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.16/Ex3_7_16.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.7/Ex3_7_7.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.8/Ex3_7_8.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.9/Ex3_7_9.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.1/Ex3_8_1.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.2/Ex3_8_2.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.6/Ex3_8_6.R create mode 100644 Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.9.2/Ex3_9_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.1/Ex1_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.10/Ex1_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.11/Ex1_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.13/Ex1_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.14/Ex1_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.15/Ex1_15.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.17/Ex1_17.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.18/Ex1_18.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.19/Ex1_19.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.20/Ex1_20.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.5/Ex1_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.8/Ex1_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.9/Ex1_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.1/Ex10_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.10/Ex10_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.11/Ex10_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.2/Ex10_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.3/Ex10_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.4/Ex10_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.6/Ex10_6.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.9/Ex10_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.1/Ex11_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.10/Ex11_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.11/Ex11_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.12/Ex11_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.13/Ex11_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.3/Ex11_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.5/Ex11_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.6/Ex11_6.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.7/Ex11_7.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.9/Ex11_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.1/Ex12_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.11/Ex12_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.12/Ex12_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.13/Ex12_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.14/Ex12_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.15/Ex12_15.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.16/Ex12_16.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.17/Ex12_17.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.18/Ex12_18.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.19/Ex12_19.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.2/Ex12_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.3/Ex12_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.4/Ex12_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.5/Ex12_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.6/Ex12_6.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.7/Ex12_7.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.8/Ex12_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.9/Ex12_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.10/Ex13_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.12/Ex13_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.13/Ex13_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.14/Ex13_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.15/Ex13_15.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.16/Ex13_16.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.18/Ex13_18.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.2/Ex13_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.4/Ex13_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.7/Ex13_7.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.8/Ex13_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.9/Ex13_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.1/Ex14_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.10/Ex14_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.12/Ex14_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.13/Ex14_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.14/Ex14_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.2/Ex14_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.3/Ex14_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.4/Ex14_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.5/Ex14_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.6/Ex14_6.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.9/Ex14_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.1/Ex15_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.10/Ex15_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.2/Ex15_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.3/Ex15_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.4/Ex15_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.5/Ex15_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.6/Ex15_6.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.8/Ex15_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.9/Ex15_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.1/Ex16_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.10/Ex16_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.11/Ex16_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.12/Ex16_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.2/Ex16_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.3/Ex16_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.4/Ex16_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.5/Ex16_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.6/Ex16_6.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.7/Ex16_7.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.8/Ex16_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.9/Ex16_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.11/Ex2_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.13/Ex2_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.14/Ex2_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.19/Ex2_19.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.21/Ex2_21.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.22/Ex2_22.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.23/Ex2_23.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.25/Ex2_25.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.26/Ex2_26.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.30/Ex2_30.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.36/Ex2_36.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.8/Ex2_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.10/Ex3_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.13/Ex3_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.15/Ex3_15.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.16/Ex3_16.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.17/Ex3_17.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.23/Ex3_23.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.24/Ex3_24.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.25/Ex3_25.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.26/Ex3_26.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.29/Ex3_29.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.30/Ex3_30.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.31/Ex3_31.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.1/Ex3_32_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.2/Ex3_32_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.3/Ex3_32_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.4/Ex3_32_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.33/Ex3_33.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.34/Ex3_34.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.35/Ex3_35.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.36/Ex3_36.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.37/Ex3_37.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.38/Ex3_38.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.39/Ex3_39.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.40/Ex3_40.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.41/Ex3_41.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.42/Ex3_42.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.7/Ex3_7.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.8/Ex3_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.9/Ex3_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.10/Ex4_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.11/Ex4_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.12/Ex4_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.a/Ex4_13_a.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.b/Ex4_13_b.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.c/Ex4_13_c.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.d/Ex4_13_d.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.14/Ex4_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.15/Ex4_15.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.16/Ex4_16.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.17/Ex4_17.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.18/Ex4_18.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.20/Ex4_20.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.21/Ex4_21.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.22/Ex4_22.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.23/Ex4_23.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.24/Ex4_24.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.25/Ex4_25.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.26/Ex4_26.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.27/Ex4_27.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.28/Ex4_28.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.29/Ex4_29.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.30/Ex4_30.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.31/Ex4_31.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.4/Ex4_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.5/Ex4_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.7/Ex4_7.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.1/Ex5_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.12/Ex5_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.14/Ex5_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.15/Ex5_15.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.18/Ex5_18.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.19/Ex5_19.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.2/Ex5_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.24/Ex5_24.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.25/Ex5_25.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.26/Ex5_26.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.27/Ex5_27.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.29/Ex5_29.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.3/Ex5_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.30/Ex5_30.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.31/Ex5_31.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.4/Ex5_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.5/Ex5_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.8/Ex5_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.9/Ex5_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.1/Ex6_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.10/Ex6_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.11/Ex6_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.13/Ex6_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.14/Ex6_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.2/Ex6_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.21/Ex6_21.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.3/Ex6_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.9/Ex6_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.10/Ex7_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.11/Ex7_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.12/Ex7_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.13/Ex7_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.14/Ex7_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.15/Ex7_15.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.2/Ex7_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.3/Ex7_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.4/Ex7_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.6/Ex7_6.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.7/Ex7_7.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.8/Ex7_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.1/Ex8_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.11/Ex8_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.12/Ex8_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.13/Ex8_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.14/Ex8_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.15/Ex8_15.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.17/Ex8_17.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.18/Ex8_18.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.19/Ex8_19.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.2/Ex8_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.3/Ex8_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.4/Ex8_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.5/Ex8_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.6/Ex8_6.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.7/Ex8_7.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.8/Ex8_8.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.9/Ex8_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.1/Ex9_1.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.10/Ex9_10.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.11/Ex9_11.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.12/Ex9_12.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.13/Ex9_13.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.14/Ex9_14.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.2/Ex9_2.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.3/Ex9_3.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.4/Ex9_4.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.5/Ex9_5.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.6/Ex9_6.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.7/Ex9_7.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.9/Ex9_9.R create mode 100644 Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/README.txt create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH1/EX1.2/Ex1_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH1/EX1.3/Ex1_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH1/EX1.4/Ex1_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH1/EX1.5/Ex1_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH1/EX1.6/Ex1_6.zip create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.10/Ex10_10.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.11/Ex10_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.12/Ex10_12.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.13/Ex10_13.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.14/Ex10_14.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.15/Ex10_15.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.3/Ex10_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.4/Ex10_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.5/Ex10_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.6/Ex10_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.7/Ex10_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.9/Ex10_9.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.1/Ex11_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.10/Ex11_10.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.11/Ex11_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.2/Ex11_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.3/Ex11_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.4/Ex11_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.5/Ex11_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.6/Ex11_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.7/Ex11_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.8/Ex11_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.9/Ex11_9.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.1/Ex12_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.10/Ex12_10.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.11/Ex12_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.12/Ex12_12.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.13/Ex12_13.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.2/Ex12_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.3/Ex12_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.4/Ex12_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.5/Ex12_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.6/Ex12_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.7/Ex12_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.8/Ex12_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.9/Ex12_9.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.1/Ex13_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.2/Ex13_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.3/Ex13_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.4/Ex13_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.5/Ex13_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.6/Ex13_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.7/Ex13_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.1/Ex14_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.2/Ex14_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.3/Ex14_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.4/Ex14_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.5/Ex14_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.6/Ex14_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.1/Ex15_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.2/Ex15_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.4/Ex15_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.6/Ex15_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.7/Ex15_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.8/Ex15_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.1/Ex16_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.2/Ex16_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.3/Ex16_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.4/Ex16_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.5/Ex16_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.6/Ex16_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.7/Ex16_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.8.9/Ex16_8&9.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.1/Ex17_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.2/Ex17_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.3/Ex17_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.4/Ex17_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.5/Ex17_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.1/Ex18_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.11/Ex18_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.4/Ex18_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.6/Ex18_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.7/Ex18_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.8/Ex18_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.9/Ex18_9.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.10/Ex2_10.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.15/Ex2_15.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.18/Ex2_18.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.19.a/Ex2_19a.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.19.b/Ex2_19b.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.19.c/Ex2_19c.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.19.d/Ex2_19d.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.2/Ex2_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.21/Ex2_21.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.22/Ex2_22.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.24/Ex2_24.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.25/Ex2_25.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.3/Ex2_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.30/Ex2_30.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.34/Ex2_34.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.37/Ex2_37.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.43/Ex2_43.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.8/Ex2_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.10/Ex3_10.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.11/Ex3_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.12/Ex3_12.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.14/Ex3_14.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.15/Ex3_15.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.16/Ex3_16.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.18/Ex3_18.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.20/Ex3_20.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.22/Ex3_22.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.8/Ex3_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.9/Ex3_9.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.1/Ex4_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.10/Ex4_10.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.11/Ex4_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.12/Ex4_12.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.13/Ex4_13.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.14/Ex4_14.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.15/Ex4_15.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.16/Ex4_16.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.17/Ex4_17.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.18/Ex4_18.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.19/Ex4_19.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.2/Ex4_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.20/Ex4_20.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.21/Ex4_21.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.3/Ex4_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.4/Ex4_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.5/Ex4_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.6/Ex4_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.7/Ex4_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.8/Ex4_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.9/Ex4_9.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.1/Ex5_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.10/Ex5_10.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.11/Ex5_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.12/Ex5_12.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.13/Ex5_13.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.14/Ex5_14.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.15/Ex5_15.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.16/Ex5_16.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.17/Ex5_17.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.18/Ex5_18.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.19/Ex5_19.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.2.a/Ex5_2a.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.2.b.c/Ex5_2b_2c.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.20/Ex5_20.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.3/Ex5_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.4/Ex5_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.6/Ex5_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.7/Ex5_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.8/Ex5_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.9/Ex5_9.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.1/Ex6_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.11/Ex6_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.12/Ex6_12.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.13/Ex6_13.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.14/Ex6_14.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.15/Ex6_15.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.16/Ex6_16.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.17/Ex6_17.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.18/Ex6_18.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.19/Ex6_19.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.2/Ex6_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.20/Ex6_20.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.21/Ex6_21.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.22/Ex6_22.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.23/Ex6_23.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.24/Ex6_24.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.3/Ex6_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.4/Ex6_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.5/Ex6_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.6/Ex6_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.7/Ex6_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.8/Ex6_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.9/Ex6_9.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.1/Ex8_1.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.10/Ex8_10.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.11/Ex8_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.12/Ex8_12.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.2/Ex8_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.4/Ex8_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.5/Ex8_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.6/Ex8_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.7/Ex8_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.8/Ex8_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.10/Ex9_10.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.11/Ex9_11.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.12/Ex9_12.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.13/Ex9_13.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.14/Ex9_14.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.15/Ex9_15.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.16/Ex9_16.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.18/Ex9_18.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.19/Ex9_19.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.2/Ex9_2.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.22/Ex9_22.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.3/Ex9_3.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.4/Ex9_4.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.5/Ex9_5.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.6/Ex9_6.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.7/Ex9_7.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.8/Ex9_8.R create mode 100644 Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/README.txt create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.1/ex_1_1.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.10/ex_1_10.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.12/ex_1_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.13/ex_1_13.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.14/ex_1_14.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.16/ex_1_16.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.17/ex_1_17.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.2/ex_1_2.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.3/ex_1_3.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.4/ex_1_4.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.8/ex_1_8.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.9/ex_1_9.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.10/ex_10_10.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.11/ex_10_11.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.12/ex_10_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.13/ex_10_13.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.14/ex_10_14.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.15/ex_10_15.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.16/ex_10_16.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.18/ex_10_18.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.19/ex_10_19.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.20/ex_10_20.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.21/ex_10_21.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.22/ex_10_22.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.23/ex_10_23.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.24/ex_10_24.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.25/ex_10_25.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.26/ex_10_26.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.27/ex_10_27.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.28/ex_10_28.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.29/ex_10_29.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.30/ex_10_30.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.31/ex_10_31.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.32/ex_10_32.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.33/ex_10_33.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.8/ex_10_8.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.9/ex_10_9.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.10/ex_11_10.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.14/ex_11_14.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.15/ex_11_15.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.16/ex_11_16.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.17/ex_11_17.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.18/ex_11_18.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.19/ex_11_19.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.2/ex_11_2.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.20/ex_11_20.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.21/ex_11_21.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.22/ex_11_22.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.23.b/ex_11_23_b.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.25/ex_11_25.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.26/ex_11_26.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.27/ex_11_27.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.28/ex_11_28.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.3/ex_11_3.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.4/ex_11_4.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.5/ex_11_5.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.6/ex_11_6.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.7/ex_11_7.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.8.a/ex_11_8_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.8.b/ex_11_8_b.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.9.a/ex_11_9_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.9.b/ex_11_9_b.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.10/ex_12_10.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.11/ex_12_11.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.12/ex_12_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.13/ex_12_13.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.14/ex_12_14.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.15/ex_12_15.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.16.a/ex_12_16_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.17/ex_12_17.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.18/ex_12_18.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.19/ex_12_19.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.2/ex_12_2.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.3/ex_12_3.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.4/ex_12_4.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.5/ex_12_5.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.6/ex_12_6.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.7/ex_12_7.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.8/ex_12_8.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH12/EX12.9/ex_12_9.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.1/ex_2_1.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.12/ex_2_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.13/ex_2_13.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.14/ex_2_14.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.15/ex_2_15.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.16/ex_2_16.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.18/ex_2_18.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.19/ex_2_19.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.20/ex_2_20.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.3/ex_2_3.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.4/ex_2_4.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.5/ex_2_5.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.6/ex_2_6.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.7/ex_2_7.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.8/ex_2_8.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH2/EX2.9/ex_2_9.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.1/ex_4_1.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.12/ex_4_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.13/ex_4_13.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.16/ex_4_16.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.17/ex_4_17.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.18/ex_4_18.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.19.a/ex_4_19_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.19.b/ex_4_19_b.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.2/ex_4_2.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.20/ex_4_20.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.21.a/ex_4_21_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.21.b/ex_4_21_b.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.25/ex_4_25.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.28/ex_4_28.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.29/ex_4_29.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.31/ex_4_31.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.32/ex_4_32.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.33/ex_4_33.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.35/ex_4_35.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.37/ex_4_37.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.39/ex_4_39.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.40/ex_4_40.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.41/ex_4_41.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.42/ex_4_42.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.5/ex_4_5.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.6/ex_4_6.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH4/EX4.7/ex_4_7.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.1/ex_5_1.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.11/ex_5_11.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.12/ex_5_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.13/ex_5_13.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.15/ex_5_15.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.17/ex_5_17.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.18/ex_5_18.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.19/ex_5_19.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.2/ex_5_2.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.20/ex_5_20.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.22/ex_5_22.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.23.a/ex_5_23_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.3/ex_5_3.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.4/ex_5_4.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.5/ex_5_5.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.6/ex_5_6.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.7/ex_5_7.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.8.a/ex_5_8_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.8.b/ex_5_8_b.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.1/ex_6_1.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.10/ex_6_10.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.11/ex_6_11.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.12/ex_6_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.13/ex_6_13.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.14/ex_6_14.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.15/ex_6_15.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.16/ex_6_16.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.17.a/ex_6_17_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.17.b/ex_6_17_b.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.18/ex_6_18.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.2/ex_6_2.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.20/ex_6_20.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.22/ex_6_22.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.23/ex_6_23.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.24/ex_6_24.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.25/ex_6_25.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.26/ex_6_26.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.27/ex_6_27.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.4/ex_6_4.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.5/ex_6_5.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.6/ex_6_6.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.7/ex_6_7.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.8.a/ex_6_8_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.9.a/ex_6_9_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.9.b/ex_6_9_b.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.10/ex_7_10.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.12/ex_7_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.13/ex_7_13.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.15/ex_7_15.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.19/ex_7_19.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.2/ex_7_2.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.20/ex_7_20.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.3/ex_7_3.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.4/ex_7_4.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.5/ex_7_5.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.6/ex_7_6.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.7/ex_7_7.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.10/ex_8_10.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.11/ex_8_11.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.12/ex_8_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.13.a/ex_8_13_a.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.13.b/ex_8_13_b.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.14/ex_8_14.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.15/ex_8_15.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.16/ex_8_16.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.17/ex_8_17.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.18/ex_8_18.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.19/ex_8_19.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.2/ex_8_2.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.3/ex_8_3.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.4/ex_8_4.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.5/ex_8_5.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.6/ex_8_6.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.7/ex_8_7.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.8/ex_8_8.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.9/ex_8_9.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.10/ex_9_10.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.11/ex_9_11.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.12/ex_9_12.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.13/ex_9_13.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.14/ex_9_14.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.15/ex_9_15.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.16/ex_9_16.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.17/ex_9_17.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.18/ex_9_18.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.19/ex_9_19.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.20/ex_9_20.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.21/ex_9_21.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.22/ex_9_22.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.23/ex_9_23.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.24/ex_9_24.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.25/ex_9_25.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.29/ex_9_29.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.30/ex_9_30.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.4/ex_9_4.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.6/ex_9_6.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.7/ex_9_7.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.8/ex_9_8.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.9/ex_9_9.R create mode 100644 Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/README.txt create mode 100644 README.txt create mode 100644 R_Book_by_R_Author/CH4/EX4.1.a/Ex4_1a.R create mode 100644 R_Book_by_R_Author/CH4/EX4.1.c/Ex4_1c.R create mode 100644 R_Book_by_R_Author/README.txt create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.1/Ex1_1.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.10/Ex1_10.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.11/Ex1_11.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.12/Ex1_12.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.13/Ex1_13.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.15/Ex1_15.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.2/Ex1_2.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.24/Ex1_24.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.27/Ex1_27.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.29/Ex1_29.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.3/Ex1_3.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.31/Ex1_31.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.34/Ex1_34.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.5/Ex1_5.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.52/Ex1_52.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.54/Ex1_54.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.55/Ex1_55.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.6/Ex1_6.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.7/Ex1_7.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.8/Ex1_8.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.11/Ex2_11.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.13/Ex2_13.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.14/Ex2_14.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.16/Ex2_16.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.17/Ex2_17.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.18/Ex2_18.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.19/Ex2_19.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.20/Ex2_20.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.25/Ex2_25.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.26/Ex2_26.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.1/Ex3_1.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.11/Ex3_11.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.15/Ex3_15.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.17/Ex3_17.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.18/Ex3_18.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.2/Ex3_2.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.3/Ex3_3.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.4/Ex3_4.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.40/Ex3_40.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.7/Ex3_7.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.8/Ex3_8.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.1/Ex4_1.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.13/Ex4_13.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.16/Ex4_16.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.17/Ex4_17.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.18/Ex4_18.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.19/Ex4_19.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.2/Ex4_2.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.20/Ex4_20.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.22/Ex4_22.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.27/Ex4_27.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.28/Ex4_28.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.4/Ex4_4.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.5/Ex4_5.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.6/Ex4_6.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.7/Ex4_7.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.8/Ex4_8.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.10/Ex5_10.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.11/Ex5_11.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.12/Ex5_12.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.13/Ex5_13.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.14/Ex5_14.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.17/Ex5_17.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.19/Ex5_19.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.3/Ex5_3.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.5/Ex5_5.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.6/Ex5_6.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.7/Ex5_7.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.8/Ex5_8.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.9/Ex5_9.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.10/Ex6_10.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.13/Ex6_13.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.14/Ex6_14.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.15/Ex6_15.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.16/Ex6_16.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.17/Ex6_17.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.18/Ex6_18.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.2/Ex6_2.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.22/Ex6_22.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.27/Ex6_27.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.28/Ex6_28.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.3/Ex6_3.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.4/Ex6_4.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.5/Ex6_5.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.7/Ex6_7.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.8/Ex6_8.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.9/Ex6_9.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.1/Ex7_1.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.10/Ex7_10.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.13/Ex7_13.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.15/Ex7_15.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.16/Ex7_16.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.2/Ex7_2.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.3/Ex7_3.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.4/Ex7_4.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.6/Ex7_6.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.7/Ex7_7.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.9/Ex7_9.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.1/Ex8_1.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.10/Ex8_10.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.12/Ex8_12.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.14/Ex8_14.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.15/Ex8_15.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.16/Ex8_16.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.17/Ex8_17.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.18/Ex8_18.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.2/Ex8_2.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.3/Ex8_3.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.4/Ex8_4.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.9/Ex8_9.R create mode 100644 Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/README.txt create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.1a/Ex10_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.1b/Ex10_1b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.2a/Ex10_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.2b/Ex10_2b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.3a/Ex10_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.4a/Ex10_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.4b/Ex10_4b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.1a/Ex11_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.1b/Ex11_1b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.2a/Ex11_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.1a/Ex12_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.2a/Ex12_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.3a/Ex12_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.3b/Ex12_3b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.1a/Ex13_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.2a/Ex13_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.3a/Ex13_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.4a/Ex13_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.5a/Ex13_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.1a/Ex14_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.2a/Ex14_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.3a/Ex14_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.4a/Ex14_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.5a/Ex14_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.5b/Ex14_5b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.6a/Ex14_6a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.6b/Ex14_6b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.1a/Ex15_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.2a/Ex15_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.3a/Ex15_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.4a/Ex15_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.5a/Ex15_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.6a/Ex15_6a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.6b/Ex15_6b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.7a/Ex15_7a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1a/Ex16_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1b/Ex16_1b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1c/Ex16_1c.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.2a/Ex16_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.3a/Ex16_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.1a/Ex17_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.2a/Ex17_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.3a/Ex17_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.4a/Ex17_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1a/Ex18_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1b/Ex18_1b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1c/Ex18_1c.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1d/Ex18_1d.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1e/Ex18_1e.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1f/Ex18_1f.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.2a/Ex18_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.3a/Ex18_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.3b/Ex18_3b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4a/Ex18_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4b/Ex18_4b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4c/Ex18_4c.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.5a/Ex18_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.5b/Ex18_5b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.6a/Ex18_6a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.6b/Ex18_6b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.1a/Ex19_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.2a/Ex19_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.3a/Ex19_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.4a/Ex19_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.4b/Ex19_4b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.5a/Ex19_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.1a/Ex2_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.1b/Ex2_1b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.2a/Ex2_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.3a/Ex2_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.4a/Ex2_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.5a/Ex2_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH20/EX20.1a/Ex20_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH21/EX21.1a/Ex21_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1a/Ex3_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1b/Ex3_1b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1c/Ex3_1c.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1d/Ex3_1d.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1e/Ex3_1e.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2a/Ex3_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2b/Ex3_2b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2c/Ex3_2c.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.3a/Ex3_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.4a/Ex3_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.5a/Ex3_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.5b/Ex3_5b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.6a/Ex3_6a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.6b/Ex3_6b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1a/Ex4_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1b/Ex4_1b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1c/Ex4_1c.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1d/Ex4_1d.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.2a/Ex4_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3a/Ex4_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3b/Ex4_3b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3c/Ex4_3c.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.4a/Ex4_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.4b/Ex4_4b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.5a/Ex4_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.1a/Ex5_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.2a/Ex5_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.2b/Ex5_2b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.3a/Ex5_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.4a/Ex5_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.5a/Ex5_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.1a/Ex6_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.2a/Ex6_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.3a/Ex6_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.4a/Ex6_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.1a/Ex7_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.2a/Ex7_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.3a/Ex7_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.3b/Ex7_3b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4a/Ex7_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4b/Ex7_4b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4c/Ex7_4c.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.1a/Ex8_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.2a/Ex8_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.2b/Ex8_2b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.3a/Ex8_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.4a/Ex8_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.4b/Ex8_4b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1a/Ex9_1a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1b/Ex9_1b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1c/Ex9_1c.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.2a/Ex9_2a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.2b/Ex9_2b.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.3a/Ex9_3a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.4a/Ex9_4a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.5a/Ex9_5a.R create mode 100644 Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/README.txt create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH10/EX10.1/Ex10_1.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH11/EX11.1/Ex11_1.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH11/EX11.2/Ex11_2.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.1/Ex12_1.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.2/Ex12_2.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.3/Ex12_3.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.4/Ex12_4.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.5/Ex12_5.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.6/Ex12_6.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.1/Ex13_1.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.10/Ex13_10.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.11/Ex13_11.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.2/Ex13_2.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.3/Ex13_3.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.4/Ex13_4.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.5/Ex13_5.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.6/Ex13_6.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.7/Ex13_7.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.8/Ex13_8.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.9/Ex13_9.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.1/Ex14_1.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.2.a/Ex14_2a.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.2b/Ex14_2b.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.3/Ex14_3.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.4/Ex14_4.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.5/Ex14_5.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH15/EX15.1/Ex15_1.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH15/EX15.2/Ex15_2.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.1/Ex16_1.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.2/Ex16_2.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.3/Ex16_3.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.4/Ex16_4.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.5/Ex16_5.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.6/Ex16_6.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.7.a/Ex16_7a.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.7.b/Ex16_7b.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH17/EX17.1/Ex17_1.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.1/Ex2_1.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.2/Ex2_2.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.3/Ex2_3.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.4/Ex2_4.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.1/Ex3_1.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.2/Ex3_2.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.3/Ex3_3.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.4/Ex3_4.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.5/Ex3_5.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.6/Ex3_6.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.7/Ex3_7.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.1/Ex4_1.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.10/Ex4_10.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.11/Ex4_11.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.12/Ex4_12.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.13/Ex4_13.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.14/Ex4_14.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.15/Ex4_15.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.16/Ex4_16.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.17/Ex4_17.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.18/Ex4_18.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.19/Ex4_19.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.2/Ex4_2.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.3/Ex4_3.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.4/Ex4_4.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.5/Ex4_5.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.6/Ex4_6.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.7/Ex4_7.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.8/Ex4_8.zip create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.9/Ex4_9.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH5/EX5.1/Ex5_1.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.1/Ex6_1.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.10/Ex6_10.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.2/Ex6_2.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.3/Ex6_3.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.4/Ex6_4.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.5/Ex6_5.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.6/Ex6_6.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.7/Ex6_7.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.8/Ex6_8.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.9/Ex6_9.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.1/Ex7_1.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.10/Ex7_10.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.11/Ex7_11.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.12/Ex7_12.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.13.a/Ex7_13a.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.13.b/Ex7_13b.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.2/Ex7_2.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.3/Ex7_3.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.4/Ex7_4.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.5/Ex7_5.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.6/Ex7_6.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.7/Ex7_7.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.8.a/Ex7_8a.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.8b/Ex7_8b.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.9.a/Ex7_9a.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.9.b/Ex7_9b.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.a/Ex8_1a.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.b/Ex8_1b.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.c/Ex8_1c.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.2/Ex8_2.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.3.a/Ex8_3a.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.3.b/Ex8_3b.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.4/Ex8_4.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.5/Ex8_5.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.6/Ex8_6.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.a/Ex8_7a.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.b/Ex8_7b.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.c/Ex8_7c.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.a/Ex8_8a.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.b/Ex8_8b.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.c/Ex8_8c.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.1.a/Ex9_1a.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.1.b/Ex9_1b.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.2/Ex9_2.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.3/Ex9_3.R create mode 100644 Statistics_For_Management_And_Economics_by_Gerald_Keller/README.txt create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1a/Ex1_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1c/Ex1_1c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1d/Ex1_1d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1e/Ex1_1e.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2a/Ex1_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2b/Ex1_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2c/Ex1_2c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2d/Ex1_2d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2e/Ex1_2e.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.4a/Ex1_4a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.1a/Ex10_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.1b/Ex10_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.2a/Ex10_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.2b/Ex10_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.3a/Ex10_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.1a/Ex11_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.1b/Ex11_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2a/Ex11_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2b/Ex11_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2c/Ex11_2c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3a/Ex11_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3b/Ex11_3b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3c/Ex11_3c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4a/Ex11_4a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4b/Ex11_4b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4c/Ex11_4c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.1a/Ex12_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.1b/Ex12_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.2a/Ex12_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3a/Ex12_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3b/Ex12_3b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3c/Ex12_3c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3d/Ex12_3d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.4a/Ex12_4a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.4b/Ex12_4b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.5a/Ex12_5a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.5b/Ex12_5b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.6a/Ex12_6a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.6b/Ex12_6b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7a/Ex12_7a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7b/Ex12_7b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7c/Ex12_7c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7d/Ex12_7d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7e/Ex12_7e.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1a/Ex13_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1b/Ex13_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1c/Ex13_1c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1d/Ex13_1d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2a/Ex13_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2b/Ex13_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2c/Ex13_2c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.3a/Ex13_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.3b/Ex13_3b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4a/Ex13_4a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4b/Ex13_4b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4c/Ex13_4c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.1a/Ex14_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2a/Ex14_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2b/Ex14_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2c/Ex14_2c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.3a/Ex14_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1a/Ex2_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1b/Ex2_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1c/Ex2_1c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1d/Ex2_1d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2a/Ex2_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2b/Ex2_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2c/Ex2_2c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.3a/Ex2_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1a/Ex3_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1b/Ex3_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1c/Ex3_1c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1d/Ex3_1d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1e/Ex3_1e.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.2a/Ex3_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.2b/Ex3_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3a/Ex3_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3b/Ex3_3b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3c/Ex3_3c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1a/Ex4_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1b/Ex4_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1c/Ex4_1c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.2a/Ex4_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.2b/Ex4_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.3a/Ex4_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1a/Ex5_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1b/Ex5_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1c/Ex5_1c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2a/Ex5_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2b/Ex5_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2c/Ex5_2c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2d/Ex5_2d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.3a/Ex5_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.3b/Ex5_3b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4a/Ex5_4a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4b/Ex5_4b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4c/Ex5_4c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.1a/Ex6_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.1b/Ex6_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.2a/Ex6_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.2b/Ex6_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.3a/Ex6_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.3b/Ex6_3b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4a/Ex6_4a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4b/Ex6_4b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4c/Ex6_4c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1a/Ex7_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1b/Ex7_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1c/Ex7_1c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1d/Ex7_1d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1e/Ex7_1e.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2a/Ex7_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2b/Ex7_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2c/Ex7_2c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.3a/Ex7_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.3b/Ex7_3b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.4a/Ex7_4a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.4b/Ex7_4b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1a/Ex8_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1b/Ex8_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1c/Ex8_1c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1d/Ex8_1d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1e/Ex8_1e.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2a/Ex8_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2b/Ex8_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2c/Ex8_2c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.3a/Ex8_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.4a/Ex8_4a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5a/Ex8_5a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5b/Ex8_5b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5c/Ex8_5c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1a/Ex9_1a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1b/Ex9_1b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1c/Ex9_1c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1d/Ex9_1d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2a/Ex9_2a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2b/Ex9_2b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2c/Ex9_2c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.3a/Ex9_3a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.4a/Ex9_4a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.4b/Ex9_4b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.5a/Ex9_5a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6a/Ex9_6a.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6b/Ex9_6b.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6c/Ex9_6c.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6d/Ex9_6d.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6e/Ex9_6e.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6f/Ex9_6f.R create mode 100644 Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/README.txt create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.1/Ex10.5_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.2/Ex10.5_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.3/Ex10.5_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.6.1/Ex10.6_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.7.1/Ex10.7_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.1/Ex11.4_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.2/Ex11.4_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.3/Ex11.4_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.4/Ex11.4_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.7/Ex11.4_7.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.8/Ex11.4_8.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.1/Ex12.9.3_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.2/Ex12.9.3_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.3/Ex12.9.3_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.4/Ex12.9.3_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.5/Ex12.9.3_5.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.6/Ex12.9.3_6.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.7/Ex12.9.3_7.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.8/Ex12.9.3_8.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.9/Ex12.9.3_9.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.1/Ex13.8_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.2/Ex13.8_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.3/Ex13.8_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.4/Ex13.8_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH14/EX14.4.1/Ex14.4_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH2/EX2.6.1/Ex2.6_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH3/EX3.3.1/Ex3.3_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.10.1/Ex4.10_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.7.1/Ex4.7_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.8.1/Ex4.8_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.9.1/Ex4.9_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.1/Ex5.3_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.10/Ex5.3_10.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.11/Ex5.3_11.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.12/Ex5.3_12.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.2/Ex5.3_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.3/Ex5.3_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.4/Ex5.3_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.5/Ex5.3_5.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.6/Ex5.3_6.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.7/Ex5.3_7.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.8/Ex5.3_8.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.9/Ex5.3_9.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.1/Ex5.4_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.2/EX5.4_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.3/Ex5.4_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.7/Ex5.4_7.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.8/Ex5.4_8.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.9/Ex5.4_9.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.1/Ex5.5_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.10/Ex5.5_10.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.11/Ex5.5_11.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.2/Ex5.5_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.3/Ex5.5_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.4/Ex5.5_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.6/Ex5.5_6.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.7/Ex5.5_7.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.8/Ex5.5_8.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.9/Ex5.5_9.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.7.1/Ex5.7_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.7.2/Ex5.7_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.2.1/Ex6.2_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.1/Ex6.3_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.2/Ex6.3_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.3/Ex6.3_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.4/Ex6.3_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.4.1/Ex6.4_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.5.1/Ex6.5_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.1/Ex7.5_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.2/Ex7.5_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.3/Ex7.5_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.4/Ex7.5_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.5/Ex7.5_5.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.6/Ex7.5_6.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.1/Ex7.6_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.2/Ex7.6_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.3/Ex7.6_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.2/Ex7.7_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.3/Ex7.7_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.5/Ex7.7_5.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.6/Ex7.7_6.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.7/Ex7.7_7.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.1/Ex7.8_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.10/Ex7.8_10.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.2/Ex7.8_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.5/Ex7.8_5.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.6/Ex7.8_6.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.9/Ex7.8_9.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.1/Ex8.10_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.2/Ex8.10_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.3/Ex8.10_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.4/Ex8.10_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.1/Ex8.11_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.2/Ex8.11_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.3/Ex8.11_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.12.1/Ex8.12_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.12.2/Ex8.12_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.13.1/Ex8.13_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.13.2/Ex8.13_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.14.1/Ex8.14_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.14.2/Ex8.14_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.15.1/Ex8.15_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.15.2/Ex8.15_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.1/Ex8.8_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.10/Ex8.8_10.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.11/Ex8.8_11.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.2/Ex8.8_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.3/Ex8.8_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.4/Ex8.8_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.5/Ex8.8_5.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.6/Ex8.8_6.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.7/Ex8.8_7.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.8/Ex8.8_8.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.9/Ex8.8_9.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.1/Ex8.9_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.2/Ex8.9_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.3/Ex8.9_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.4/Ex8.9_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.1/Ex9.7_1.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.2/Ex9.7_2.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.3/Ex9.7_3.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.4/Ex9.7_4.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.5/Ex9.7_5.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.6/Ex9.7_6.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.7/Ex9.7_7.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.8/Ex9.7_8.R create mode 100644 Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/README.txt create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.16/Ex1_16.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.20/Ex1_20.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.21/Ex1_21.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.22/Ex1_22.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.23/Ex1_23.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.24/Ex1_24.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.26/Ex1_26.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.32/Ex1_32.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.33/Ex1_33.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.34/Ex1_34.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.12/Ex2_12.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.12/worldmarket.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.16/Ex2_16.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.16/worldmarket.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.20/Ex2_20.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.20/spam_botnets.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.21/Ex2_21.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.21/spam_botnets.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.22/Ex2_22.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.22/spam_botnets.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.23/Ex2_23.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.23/spam_botnets.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.24/Ex2_24.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.24/target.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.3/Ex2_3.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.3/spam_botnets.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.4/Ex2_4.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.4/spam_botnets.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.5/Ex2_5.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.5/govtdebt.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.6/Ex2_6.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.6/govtdebt.csv create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.7/Ex2_7.R create mode 100644 The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.7/govtdebt.csv diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.a/Ex1_2a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.a/Ex1_2a.R new file mode 100644 index 00000000..2b277618 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.a/Ex1_2a.R @@ -0,0 +1,7 @@ +no_of_women = 10 +children_per_women = 3 + +no_of_choices = no_of_women*children_per_women + +print(no_of_choices) + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.b/Ex1_2b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.b/Ex1_2b.R new file mode 100644 index 00000000..edde73aa --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.b/Ex1_2b.R @@ -0,0 +1,8 @@ +no_of_freshmen = 3 +no_of_sophmores = 4 +no_ofjuniors = 5 +no_of_seniors = 2 + +ans = no_of_seniors*no_ofjuniors*no_of_sophmores*no_of_freshmen + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.c/Ex1_2c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.c/Ex1_2c.R new file mode 100644 index 00000000..5bfc5353 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.c/Ex1_2c.R @@ -0,0 +1,5 @@ +no_of_letters = 26 +no_of_digits = 10 + +ans = (no_of_digits^4)*(no_of_letters^3) +print(ans) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.e/Ex1_2e.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.e/Ex1_2e.R new file mode 100644 index 00000000..4ba49d25 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX2.e/Ex1_2e.R @@ -0,0 +1,12 @@ +no_of_letters = 26 +no_of_digits = 10 + +ans = 1 +for(i in 0:3){ + ans = ans * (no_of_digits - i); +} +for(i in 0:2){ + ans = ans * (no_of_letters - i); +} + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.a/Ex1_3a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.a/Ex1_3a.R new file mode 100644 index 00000000..0f217d7f --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.a/Ex1_3a.R @@ -0,0 +1,5 @@ +no_of_players = 9 + +ans = factorial(no_of_players) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.b.a/Ex1_3ba.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.b.a/Ex1_3ba.R new file mode 100644 index 00000000..289cd47e --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.b.a/Ex1_3ba.R @@ -0,0 +1,6 @@ +no_of_women = 4 +no_of_men = 6 + +ans = factorial(no_of_men+no_of_women) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.b.b/Ex1_3bb.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.b.b/Ex1_3bb.R new file mode 100644 index 00000000..71dc0645 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.b.b/Ex1_3bb.R @@ -0,0 +1,6 @@ +no_of_women = 4 +no_of_men = 6 + +ans = factorial(no_of_men)*factorial(no_of_women) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.c/Ex1_3c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.c/Ex1_3c.R new file mode 100644 index 00000000..8be7d8cf --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.c/Ex1_3c.R @@ -0,0 +1,11 @@ +no_of_math_books = 4 +no_of_chem_books = 3 +no_of_history_books = 2 +no_of_lang_book = 1 + +no_of_types_of_books = 4 +no_of_orderings = factorial(no_of_types_of_books) + +ans = no_of_orderings*factorial(no_of_math_books)*factorial(no_of_chem_books)*factorial(no_of_history_books)*factorial(no_of_lang_book) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.d/Ex1_3d.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.d/Ex1_3d.R new file mode 100644 index 00000000..303ac6b9 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.d/Ex1_3d.R @@ -0,0 +1,9 @@ +no_of_p = 3 +no_of_r = 1 +no_of_e = 2 + +total_chars = no_of_p + no_of_r + no_of_e + +ans = factorial(total_chars)/ (factorial(no_of_p) * factorial(no_of_r) * factorial(no_of_e)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.e/Ex1_3e.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.e/Ex1_3e.R new file mode 100644 index 00000000..808bbeef --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.e/Ex1_3e.R @@ -0,0 +1,8 @@ +no_of_russians = 4 +no_of_americans = 3 +no_of_brits = 2 +no_of_brazillians = 1 + +ans = factorial(no_of_brazillians + no_of_americans + no_of_brits + no_of_russians) / (factorial(no_of_russians)*factorial(no_of_brits)*factorial(no_of_americans)*factorial(no_of_brazillians)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.f/Ex1_3f.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.f/Ex1_3f.R new file mode 100644 index 00000000..7a37e283 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX3.f/Ex1_3f.R @@ -0,0 +1,7 @@ +no_of_white_flags = 4 +no_of_red_flags = 3 +no_of_blue_flags = 2 + +ans = factorial(no_of_white_flags + no_of_red_flags + no_of_blue_flags) / (factorial(no_of_white_flags) * factorial(no_of_red_flags) * factorial(no_of_blue_flags)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX4.a/Ex1_4a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX4.a/Ex1_4a.R new file mode 100644 index 00000000..201c2141 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX4.a/Ex1_4a.R @@ -0,0 +1,6 @@ +total_people = 20 +committee_size = 3 + +ans = choose(total_people, committee_size) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX4.b/Ex1_4b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX4.b/Ex1_4b.R new file mode 100644 index 00000000..d3006b89 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX4.b/Ex1_4b.R @@ -0,0 +1,15 @@ +total_men = 7 +req_men = 3 +total_women = 5 +req_women = 2 + +ans1 = choose(total_men, req_men) * choose(total_women, req_women) +print(ans1) + +no_of_feuding_men = 2 + +feuding_groups = choose(no_of_feuding_men, no_of_feuding_men) * choose(total_men - no_of_feuding_men, req_men - no_of_feuding_men) + +ans2 = (choose(total_men, req_men) - feuding_groups) * choose(total_women, req_women) + +print(ans2) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.a/Ex1_5a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.a/Ex1_5a.R new file mode 100644 index 00000000..0250dd56 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.a/Ex1_5a.R @@ -0,0 +1,7 @@ +patrollers = 5 +station_officers = 2 +reserve = 3 + +ans = factorial(patrollers + station_officers + reserve) / (factorial(patrollers) * factorial(station_officers) * factorial(reserve)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.b/Ex1_5b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.b/Ex1_5b.R new file mode 100644 index 00000000..d77a78f7 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.b/Ex1_5b.R @@ -0,0 +1,6 @@ +teamA_size = 5 +teamB_size = 5 + +ans = factorial(teamA_size + teamB_size) / (factorial(teamA_size) * factorial(teamB_size)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.c/Ex1_5c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.c/Ex1_5c.R new file mode 100644 index 00000000..c348dc4b --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.c/Ex1_5c.R @@ -0,0 +1,6 @@ +team_size = 5 +no_of_teams = 2 + +ans = factorial(team_size*no_of_teams) / ((factorial(team_size)^2) * factorial(no_of_teams)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.d/Ex1_5d.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.d/Ex1_5d.R new file mode 100644 index 00000000..b5190b6c --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX5.d/Ex1_5d.R @@ -0,0 +1,9 @@ +no_of_players = 8 +no_of_winners = 4 + +ans1 = factorial(no_of_winners)*choose(no_of_players,no_of_winners) +cat("Ans to a)", ans1, "\n") + +ans2 = factorial(no_of_players) +cat("Ans to b)", ans2, "\n") + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX6.a/Ex1_6a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX6.a/Ex1_6a.R new file mode 100644 index 00000000..f0e62da7 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX6.a/Ex1_6a.R @@ -0,0 +1,6 @@ +const = 3 +no_of_vars = 2 + +ans = choose(const + no_of_vars - 1, no_of_vars - 1) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX6.b/Ex1_6b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX6.b/Ex1_6b.R new file mode 100644 index 00000000..243c2594 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH1/EX6.b/Ex1_6b.R @@ -0,0 +1,10 @@ +no_of_vars = 4 +const = 20 + +ans1 = choose(const + no_of_vars - 1, no_of_vars - 1) +print(ans1) + +no_of_vars_updated = 5 + +ans2 = choose(const + no_of_vars_updated - 1, no_of_vars_updated - 1) +print(ans2) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX3.b/Ex2_3b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX3.b/Ex2_3b.R new file mode 100644 index 00000000..596369cf --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX3.b/Ex2_3b.R @@ -0,0 +1,5 @@ +p_of_a_side = 1/6 +no_of_even_sides = 3 + +ans = p_of_a_side * no_of_even_sides +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX4.a/Ex2_4a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX4.a/Ex2_4a.R new file mode 100644 index 00000000..de77ed08 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX4.a/Ex2_4a.R @@ -0,0 +1,6 @@ +p_book1 = 0.5 +p_book2 = 0.4 +p_both_books = 0.3 + +ans = 1 - (p_book1 + p_book2 - p_both_books) +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.a/Ex2_5a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.a/Ex2_5a.R new file mode 100644 index 00000000..3ef6d02c --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.a/Ex2_5a.R @@ -0,0 +1,9 @@ +#install.packages("MASS") +require(MASS) + +favourable_outcomes = 6 +total_outcomes = 36 + +ans = favourable_outcomes / total_outcomes + +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.b/Ex2_5b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.b/Ex2_5b.R new file mode 100644 index 00000000..d12da2d2 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.b/Ex2_5b.R @@ -0,0 +1,15 @@ +#install.packages("MASS") +require(MASS) + +total_white_balls = 6 +total_black_balls = 5 + +fav_no_of_white_balls = 1 +fav_no_of_black_balls = 2 + +drawn_balls = 3 + +ans = (choose(total_white_balls, fav_no_of_white_balls) * choose(total_black_balls, fav_no_of_black_balls)) / choose(total_black_balls + total_white_balls, drawn_balls) + +print(fractions(ans)) + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.c/Ex2_5c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.c/Ex2_5c.R new file mode 100644 index 00000000..74fb3470 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.c/Ex2_5c.R @@ -0,0 +1,13 @@ +#install.packages("MASS") +require(MASS) +total_men = 6 +total_women = 9 + +fav_no_of_men = 3 +fav_no_of_women = 2 + +commmittee_size = 5 + +ans = (choose(total_women, fav_no_of_women) * choose(total_men, fav_no_of_men)) / choose(total_men + total_women, commmittee_size ) + +print(fractions(ans)) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.f/Ex2_5f.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.f/Ex2_5f.R new file mode 100644 index 00000000..77e130c3 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.f/Ex2_5f.R @@ -0,0 +1,7 @@ +hand_size = 5 +total_cards = 52 + +no_of_straights = 10*(4^5 - 4) +ans = no_of_straights / choose(total_cards, hand_size) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.g/Ex2_5g.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.g/Ex2_5g.R new file mode 100644 index 00000000..1de2cab0 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.g/Ex2_5g.R @@ -0,0 +1,7 @@ +total_hands = 5 +total_cards = 52 + +total_full_houses = 13*12*choose(4,2)*choose(4,3) +ans = total_full_houses / choose(total_cards, total_hands) + +print(ans) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.h.a/Ex2_5ha.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.h.a/Ex2_5ha.R new file mode 100644 index 00000000..df83cf86 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.h.a/Ex2_5ha.R @@ -0,0 +1,8 @@ +total_cards = 52 +suite_size = 13 + +p_13spades = 1 / choose(total_cards, suite_size) + +ans = 4*p_13spades + +print(ans) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.h.b/Ex2_5hb.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.h.b/Ex2_5hb.R new file mode 100644 index 00000000..2eb08808 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.h.b/Ex2_5hb.R @@ -0,0 +1,9 @@ +total_cards = 52 +suite_size = 13 + +no_of_aces = 4 +ace_per_suite = 1 + +ans = (factorial(no_of_aces)* (factorial(total_cards - no_of_aces)/ factorial(suite_size - ace_per_suite)^4)) / (factorial(total_cards) / factorial(suite_size)^4) + +print(ans) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.i/Ex2_5i.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.i/Ex2_5i.R new file mode 100644 index 00000000..52a7e824 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.i/Ex2_5i.R @@ -0,0 +1,11 @@ +days_in_a_year = 365 +n = 0 +p = 1 +i = 0 +while(p >= 0.5){ + p = p*(days_in_a_year - i)/ days_in_a_year + n = n + 1 + i = i + 1 +} + +print(n) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.k/Ex2_5k.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.k/Ex2_5k.R new file mode 100644 index 00000000..d6546498 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.k/Ex2_5k.R @@ -0,0 +1,12 @@ +P_2i <- function(i, o = 20, d = 20){ + k = (factorial(o - 2*i) / (2^(o/2 - i) * factorial(o/2 - i)))^2 + numer = ((dim(combn(o, 2*i))[2])^2) * factorial(2*i) * k + denom = (factorial(o + d) / (2^20 * factorial(o))) + return(numer / denom) +} + +for(i in 0:10){ + cat("P(", i,") =", P_2i(i), "\n") +} + + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.l/Ex2_5l.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.l/Ex2_5l.R new file mode 100644 index 00000000..2bf7f4d7 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.l/Ex2_5l.R @@ -0,0 +1,11 @@ +no_tennis = 36 +no_squash = 28 +no_badminton = 18 +no_tennis_badminton = 12 +no_tennis_squash = 22 +no_badminton_squash = 9 +no_all = 4 + +ans = no_tennis + no_squash + no_badminton - no_badminton_squash - no_tennis_badminton - no_tennis_squash + no_all + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.n/Ex2_5n.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.n/Ex2_5n.R new file mode 100644 index 00000000..3495b0e6 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX5.n/Ex2_5n.R @@ -0,0 +1,10 @@ +no_of_couples = 10 + +ans = 0 + +for(i in 1:10){ + ans = ans + ((-1)^(i+1)) * choose(10,i) * (2^i) * factorial(19 - i) / factorial(19) +} + +ans = 1 - ans +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX7.a/Ex2_7a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX7.a/Ex2_7a.R new file mode 100644 index 00000000..b4053813 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH2/EX7.a/Ex2_7a.R @@ -0,0 +1,13 @@ +#P[i] = probability of (i+1)th horse winning + +P = c(0.2, 0.2, 0.15, 0.15, 0.1, 0.1, 0.1) +print(P) + +v1 = P[1] + P[2] + P[3] +print(v1) +v2 = P[1] + P[5] + P[6] + P[7] +if(v1 > v2){ + print("First wager") +} else{ + print("Second wager") +} diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.a/Ex3_2a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.a/Ex3_2a.R new file mode 100644 index 00000000..4b4aab39 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.a/Ex3_2a.R @@ -0,0 +1,11 @@ +#P_Lx denotes P(Lsub(x)) +P_Lx <- function(x){ + return(x/2) +} + +# P_F denotes P(F) +P_F = 1 - P_Lx(1) + +ans = P_F / (1 - P_Lx(0.75)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.b.a/Ex3_2ba.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.b.a/Ex3_2ba.R new file mode 100644 index 00000000..41d9fc15 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.b.a/Ex3_2ba.R @@ -0,0 +1,10 @@ +#install.packages("MASS") +require(MASS) +#P_X denotes P(X) +P_B = 1/4 +P_F = 1/2 + +#P(BF) = P(B) +ans = P_B / P_F + +print(fractions(ans)) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.b.b/Ex3_2bb.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.b.b/Ex3_2bb.R new file mode 100644 index 00000000..203aeadd --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.b.b/Ex3_2bb.R @@ -0,0 +1,10 @@ +#install.packages("MASS") +require(MASS) +#P_X denotes P(X) +P_B = 1/4 +P_A = 3/4 + +#P(BA) = P(B) +ans = P_B / P_A + +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.c/Ex3_2c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.c/Ex3_2c.R new file mode 100644 index 00000000..90b71fe7 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.c/Ex3_2c.R @@ -0,0 +1,6 @@ +total_north_south = 26 +suite_size = 13 + +ans = choose(5,3) * choose(total_north_south - 5, suite_size - 3) / choose(total_north_south, suite_size) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.e/Ex3_2e.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.e/Ex3_2e.R new file mode 100644 index 00000000..457cc3d2 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.e/Ex3_2e.R @@ -0,0 +1,10 @@ +#install.packages("MASS") +require(MASS) + +#P_X denotes P(X) P_XgC denotes P(X|C) + +P_C = 1/2 +P_AgC = 2/3 + +ans = P_C * P_AgC +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.f.a/Ex3_2fa.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.f.a/Ex3_2fa.R new file mode 100644 index 00000000..5170e5b1 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.f.a/Ex3_2fa.R @@ -0,0 +1,15 @@ +#install.packages("MASS") +require(MASS) + +#P_X denotes P(X) P_XgC denotes P(X|C) + +no_of_red_balls = 8 +no_of_blue_balls = 4 + +P_R1 = no_of_red_balls / (no_of_blue_balls + no_of_red_balls) +P_R2gR1 = (no_of_red_balls - 1 ) / (no_of_blue_balls + no_of_red_balls - 1) + +ans = P_R1 * P_R2gR1 + +print(fractions(ans)) + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.h/Ex3_2h.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.h/Ex3_2h.R new file mode 100644 index 00000000..dcbc71cb --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX2.h/Ex3_2h.R @@ -0,0 +1,10 @@ +#P_X denotes P(X) P_XgC denotes P(X|C) + +P_E1 = 1 +P_E2gE1 = 39/51 +P_E3gE1E2 = 26/50 +P_E4gE1E2E3 = 13/49 + +ans = P_E1 * P_E2gE1 * P_E3gE1E2 * P_E4gE1E2E3 + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.a.1/Ex3_3a1.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.a.1/Ex3_3a1.R new file mode 100644 index 00000000..b612cff0 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.a.1/Ex3_3a1.R @@ -0,0 +1,9 @@ +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_A1gA = 0.4 +P_A = 0.3 + +P_A1gAc = 0.2 +ans = P_A1gA * P_A + P_A1gAc * (1 - P_A) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.a.2/Ex3_3a2.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.a.2/Ex3_3a2.R new file mode 100644 index 00000000..91c00bd9 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.a.2/Ex3_3a2.R @@ -0,0 +1,11 @@ +#install.packages("MASS") +require(MASS) +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_A = 0.3 +P_A1 = 0.26 +P_A1gA = 0.4 + +ans = P_A * P_A1gA / P_A1 +print(fractions(ans)) + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.d/Ex3_3d.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.d/Ex3_3d.R new file mode 100644 index 00000000..2c266646 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.d/Ex3_3d.R @@ -0,0 +1,9 @@ +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_D = 0.005 +P_EgD = 0.95 +P_EgDc = 0.01 + +ans = P_EgD * P_D / (P_EgD*P_D + P_EgDc*(1 - P_D)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.e/Ex3_3e.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.e/Ex3_3e.R new file mode 100644 index 00000000..a07c9fd3 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.e/Ex3_3e.R @@ -0,0 +1,9 @@ +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_D = 0.6 +P_EgD = 1 +P_EgDc = 0.3 + +ans = P_D*P_EgD / (P_EgD*P_D + P_EgDc*(1 - P_D)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.f/Ex3_3f.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.f/Ex3_3f.R new file mode 100644 index 00000000..169d365c --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.f/Ex3_3f.R @@ -0,0 +1,9 @@ +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_G = 0.6 +P_CgG = 1 +P_CgGc = 0.2 + +ans = P_G*P_CgG / (P_G*P_CgG + (1 - P_G)*P_CgGc) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.i/Ex3_3i.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.i/Ex3_3i.R new file mode 100644 index 00000000..f2adf74b --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.i/Ex3_3i.R @@ -0,0 +1,12 @@ +#install.packages("MASS") +require(MASS) +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_A = 2/3 +P_headsgA = 1/4 +P_B = 1/3 +P_headsgB = 3/4 + +ans = P_A*P_headsgA / (P_B*P_headsgB) + +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.l/Ex3_3l.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.l/Ex3_3l.R new file mode 100644 index 00000000..92c04f89 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.l/Ex3_3l.R @@ -0,0 +1,17 @@ +#install.packages("MASS") +require(MASS) + +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_RgRB = 1/2 +P_RB = 1/3 + +P_RgRR = 1 +P_RR = 1/3 + +P_RgBB = 0 +P_BB = 1/3 + +ans = P_RgRB*P_RB / (P_RgBB*P_BB + P_RgRB*P_RB + P_RgRR*P_RR) + +print(fractions(ans)) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.n.a/Ex3_3na.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.n.a/Ex3_3na.R new file mode 100644 index 00000000..660ca45b --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.n.a/Ex3_3na.R @@ -0,0 +1,13 @@ +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_F1 = 0.2 +P_F2 = 0.3 +P_F3 = 0.5 + +P_AgF1 = 0.7 +P_AgF2 = 0.4 +P_AgF3 = 0.3 + +ans = P_AgF1*P_F1 + P_AgF2*P_F2 + P_AgF3*P_F3 + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.n.b/Ex3_3nb.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.n.b/Ex3_3nb.R new file mode 100644 index 00000000..05009e23 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.n.b/Ex3_3nb.R @@ -0,0 +1,25 @@ +#install.packages("MASS") +require(MASS) +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_FgA <- function(P_F, P_AgF){ + P_A = 0.41 + return(P_F*P_AgF/P_A) +} +P_AgF1 = 0.7 +P_F1 = 0.2 + +P_AgF2 = 0.4 +P_F2 = 0.3 + +P_AgF3 = 0.3 +P_F3 = 0.5 + +cat("P(F1 | A) = ") +print(fractions(P_FgA(P_F1, P_AgF1))) + +cat("P(F2 | A) = ") +print(fractions(P_FgA(P_F2, P_AgF2))) + +cat("P(F3 | A) = ") +print(fractions(P_FgA(P_F3, P_AgF3))) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.o/Ex3_3o.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.o/Ex3_3o.R new file mode 100644 index 00000000..651adf2c --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX3.o/Ex3_3o.R @@ -0,0 +1,41 @@ +#P_EgX denotes P(E|X) +#P_Ec denotes P(E complement) + +ex_criminals = 10000 +tot_pop = 1000000 +P_hair_match = 10^-5 + +alpha = function(c){ + c/(ex_criminals*c + tot_pop - ex_criminals) +} + +P_MgG = (1 - P_hair_match)^(ex_criminals - 1) + +P_all_aj = function(c){ + (1 - ex_criminals*alpha(c))/ (1 - alpha(c)) +} + +P_MgGc = function(c){ + P_hair_match * P_all_aj(c) * (1 - P_hair_match)^(ex_criminals - 1) +} + +P_G = alpha + +P_GgM = function(c){ + (P_MgG * P_G(c)) / (P_MgG*P_G(c) + P_MgGc(c)*(1 - P_G(c))) +} + +#case 1, let c=100 +c1 = 100 +ans1 = P_GgM(c1) +cat("For c =", c1, "alpha =", alpha(c1), "and P(G|M) =", P_GgM(c1), "\n") + +#case 2, let c=10 +c2 = 10 +ans2 = P_GgM(c2) +cat("For c =", c2, "alpha =", alpha(c2), "and P(G|M) =", P_GgM(c2), "\n") + +#case3, let c=1 +c3 = 1 +ans3 = P_GgM(c3) +cat("For c =", c3, "alpha =", alpha(c3), "and P(G|M) =", P_GgM(c3), "\n") diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX4.h/Ex3_4h.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX4.h/Ex3_4h.R new file mode 100644 index 00000000..ba710a42 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX4.h/Ex3_4h.R @@ -0,0 +1,18 @@ +#install.packages("MASS") +require(MASS) +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_En <- function(n){ + ans = ((13/18)^(n-1))*1/9 + return(ans) +} +ans = 0 +ix = P_En(1) +i = 2 +while(ix != 0){ + ans = ans + ix + ix = P_En(i) + i = i+1 +} + +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX5.a/Ex3_5a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX5.a/Ex3_5a.R new file mode 100644 index 00000000..531715d2 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH3/EX5.a/Ex3_5a.R @@ -0,0 +1,16 @@ +#install.packages("MASS") +require(MASS) +#P_X denotes P(X), P_XgC denotes P(X|C), P_Xc denotes P(X) complement + +P_A1gA = 0.4 +P_A = 0.3 +P_A1 = 0.26 + +P_AgA1 = P_A1gA * P_A / P_A1 + +P_A2gAA1 = 0.4 +P_A2gAcA1 = 0.2 + +P_A2gA1 = P_A2gAA1 * P_AgA1 + P_A2gAcA1 * (1 - P_AgA1) + +print(P_A2gA1) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX1.b/Ex4_1b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX1.b/Ex4_1b.R new file mode 100644 index 00000000..b3d91332 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX1.b/Ex4_1b.R @@ -0,0 +1,17 @@ +#Chapter 4, Random Variables +#Example 1b, Page-118 + +#P calculates that the random variable X takes the value i +P <- function(i){ + x = choose(i-1,2)/choose(20,3) + return(x) +} + +ans = 0 + +# calculate the sum of probabilities from X=17 to 20 +for(i in 17:20){ + ans = ans + P(i) +} +print(ans) + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX1.d/Ex4_1d.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX1.d/Ex4_1d.R new file mode 100644 index 00000000..5fc65645 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX1.d/Ex4_1d.R @@ -0,0 +1,16 @@ +#Chapter 4, Random Variables +#Example 1d, Page-119 + +#P[i] denotes P(X=i) + +P <- rep(4) + +P[0] <- (choose(5,3) + choose(3,1)*choose(3,1)*choose(5,1))/choose(11,3) + +P[1] <- (choose(3,1)*choose(5,2) + choose(3,2)*choose(3,1))/choose(11,3) + +P[2] <- (choose(3,2)*choose(5,1))/choose(11,3) + +P[3] <- choose(3,3)/choose(11,3) + +print(sum(P)) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX10.a/Ex4_10a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX10.a/Ex4_10a.R new file mode 100644 index 00000000..2be81a5c --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX10.a/Ex4_10a.R @@ -0,0 +1,49 @@ +#install.packages("MASS") +require("MASS") +#required to calculate limits +sentinal = exp(-12) +#note F_x denotes F(x) and P_X(i) denotes P(X < i) + +F_x = function(x){ + if(x < 0){ + return(0) + } + + if(x < 1){ + return(x/2) + } + + if(x < 2){ + return(2/3) + } + if(x < 3){ + return(11/12) + } + else{ + return(1) + } +} + +P_X = function(F, b){ + return(F(b - sentinal)) +} + +ans1 = P_X(F_x, 3) + +cat("Answer to part a: ") +print(fractions(ans1)) + +ans2 = F_x(1) - P_X(F_x, 1) + +cat("Answer to part b: ") +print(fractions(ans2)) + +ans3 = 1 - F_x(1/2) + +cat("Answer to part c: ") +print(fractions(ans3)) + +ans4 = F_x(4) - F_x(2) + +cat("Answer to part d: ") +print(fractions(ans4)) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX3.a/Ex4_3a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX3.a/Ex4_3a.R new file mode 100644 index 00000000..53a17915 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX3.a/Ex4_3a.R @@ -0,0 +1,8 @@ +#install.packages("MASS") +require(MASS) + +X = 1:6 +w = rep(1/6, 6) + +ans = weighted.mean(X, w) +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX3.d/Ex4_3d.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX3.d/Ex4_3d.R new file mode 100644 index 00000000..f85551b9 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX3.d/Ex4_3d.R @@ -0,0 +1,11 @@ +#P_Xei denotes P(X=i) + +P_Xe36 = 36/120 +P_Xe40 = 40/120 +P_Xe44 = 44/120 + +w = c(P_Xe36, P_Xe40, P_Xe44) +X = c(36, 40, 44) + +ans = weighted.mean(X, w) +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX4.a/Ex4_4a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX4.a/Ex4_4a.R new file mode 100644 index 00000000..480498c8 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX4.a/Ex4_4a.R @@ -0,0 +1,11 @@ +#P_Xei denotes P(X=i) + +P_Ye1 = 0.3 + 0.2 +P_Ye0 = 0.5 + +w = c(P_Ye0, P_Ye1) +X = 0:1 + +ans = weighted.mean(X, w) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX5.a/Ex4_5a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX5.a/Ex4_5a.R new file mode 100644 index 00000000..89d0bfde --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX5.a/Ex4_5a.R @@ -0,0 +1,16 @@ +#E_X denotes E[X], Var_X denotes Var(X) + +#install.packages("MASS") +require(MASS) + +X = 1:6 +w = rep(1/6, 6) + +E_X = weighted.mean(X, w) + +X1 = X^2 +E_X1 = weighted.mean(X1, w) + +Var_X = E_X1 - E_X^2 + +print(fractions(Var_X)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.a/Ex4_6a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.a/Ex4_6a.R new file mode 100644 index 00000000..43f881f5 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.a/Ex4_6a.R @@ -0,0 +1,13 @@ +#install.packages("MASS") +require("MASS") + +n = 5 +p = 1/2 +x = 0:5 + +ans = dbinom(x, size = n, prob = p) + +for(i in x){ + cat("P{ X =", i, "} =") + print(fractions(ans[i+1])) +} \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.b/Ex4_6b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.b/Ex4_6b.R new file mode 100644 index 00000000..d54219bc --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.b/Ex4_6b.R @@ -0,0 +1,6 @@ +p = 0.01 +n = 10 + +ans = 1 - pbinom(1, size = n, prob = p) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.c/Ex4_6c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.c/Ex4_6c.R new file mode 100644 index 00000000..8408c7bb --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.c/Ex4_6c.R @@ -0,0 +1,13 @@ +#install.packages("MASS") +require(MASS) + +n = 3 +p = 1/6 +x = 0:3 +P_X = dbinom(x, size = n, prob = p) + +X = c(-1, 1, 2, 3) + +ans = weighted.mean(X, P_X) + +print(fractions(ans)) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.d/Ex4_6d.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.d/Ex4_6d.R new file mode 100644 index 00000000..846d336f --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.d/Ex4_6d.R @@ -0,0 +1,7 @@ +#install.packages("MASS") +require(MASS) +n = 4 +p = 3/4 + +ans = dbinom(3, size = n, prob = p) +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.h/Ex4_6h.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.h/Ex4_6h.R new file mode 100644 index 00000000..1ede99af --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.h/Ex4_6h.R @@ -0,0 +1,9 @@ +n = 6 +p = 0.4 +x = 0:6 + +P_X = dbinom(x, size = n, prob = p) + +for(i in 0:6){ + cat("P{ X =", i, "} =", P_X[i+1], "\n") +} \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.i/Ex4_6i.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.i/Ex4_6i.R new file mode 100644 index 00000000..05b82d1e --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX6.i/Ex4_6i.R @@ -0,0 +1,8 @@ +n = 100 +p = 0.75 + +ans1 = dbinom(70, size = n, prob = p) +cat("P{X = 70} = ", ans1, "\n") + +ans2 = pbinom(70, size = n, prob = p) +cat("P{X <= 70} = ", ans2, "\n") \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.a/Ex4_7a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.a/Ex4_7a.R new file mode 100644 index 00000000..34afa07c --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.a/Ex4_7a.R @@ -0,0 +1,4 @@ +l = 1/2 + +ans = 1 - dpois(0, lambda = l) +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.b/Ex4_7b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.b/Ex4_7b.R new file mode 100644 index 00000000..db2b43bd --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.b/Ex4_7b.R @@ -0,0 +1,11 @@ +n = 10 +p = 0.1 +x = 1 + +binom_ans = pbinom(x, size = n, prob = p) +cat("Ans :", binom_ans, "\n") + +l = n*p + +pois_ans = ppois(x, l) +cat("Poisson approximation yields : ", pois_ans) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.c/Ex4_7c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.c/Ex4_7c.R new file mode 100644 index 00000000..07aa3d44 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.c/Ex4_7c.R @@ -0,0 +1,5 @@ +l = 3.2 +q = 2 + +ans = ppois(q, lambda = l) +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.e.a/Ex4_7ea.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.e.a/Ex4_7ea.R new file mode 100644 index 00000000..21ca8703 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.e.a/Ex4_7ea.R @@ -0,0 +1,6 @@ +no_of_weeks = 2 +l = 2 * no_of_weeks +x = 2 + +ans = 1 - ppois(x, lambda = l) +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.f/Ex4_7f.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.f/Ex4_7f.R new file mode 100644 index 00000000..c44985a8 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX7.f/Ex4_7f.R @@ -0,0 +1,9 @@ +l1 = 100 +x1 = 90 +ans1 = ppois(x1, l1) +cat("Ans to part a) ", ans1, "\n") + +l2 = 1000 +x2 = 1075 +ans2 = ppois(x2, l2) +cat("Ans to part b) ", ans2) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX8.g/Ex4_8g.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX8.g/Ex4_8g.R new file mode 100644 index 00000000..4fdabca9 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX8.g/Ex4_8g.R @@ -0,0 +1,11 @@ +#E_X denotes E[X], Var_X denotes Var(X) + +r = 4 +p = 1/6 + +E_X = r/p + +Var_X = r*(1-p) / p^2 + +cat("Expected value =", E_X, "\n") +cat("Variance =", Var_X, "\n") \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX8.i/Ex4_8i.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX8.i/Ex4_8i.R new file mode 100644 index 00000000..562cf3ca --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH4/EX8.i/Ex4_8i.R @@ -0,0 +1,11 @@ +lot_size = 10 + +P_4defectives = 0.3 +P_1defective = 0.7 + +inspect_size = 3 + +P_acceptance = choose(4,0)*choose(6,3)*P_4defectives / choose(lot_size, inspect_size) + choose(1,0)*choose(9,3)*P_1defective / choose(lot_size, inspect_size) + +ans = 1 - P_acceptance +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.a.a/Ex5_1aa.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.a.a/Ex5_1aa.R new file mode 100644 index 00000000..43dc8396 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.a.a/Ex5_1aa.R @@ -0,0 +1,10 @@ +#install.packages("MASS") +require(MASS) + +integrand = function(x){ + 4*x - 2*x^2 +} + +C = 1 / integrate(integrand, lower = 0, upper = 2)$value + +print(fractions(C)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.a.b/Ex5_1ab.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.a.b/Ex5_1ab.R new file mode 100644 index 00000000..bec56f4b --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.a.b/Ex5_1ab.R @@ -0,0 +1,12 @@ +#install.packages("MASS") +require("MASS") + +integrand = function(x){ + C = 3/8 + C*(4*x - 2*x^2) +} + + +ans = integrate(integrand, lower = 1, upper = 2)$value + +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.b.a/Ex5_1ba.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.b.a/Ex5_1ba.R new file mode 100644 index 00000000..4e9a7f19 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.b.a/Ex5_1ba.R @@ -0,0 +1,11 @@ +#note l denotes lambda + +integrand = function(x){ + exp(-x/100) +} + +l = 1 / integrate(integrand, lower = 0, upper = Inf)$value + +ans = l* integrate(integrand, lower = 50, upper = 150)$value + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.b.b/Ex5_1bb.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.b.b/Ex5_1bb.R new file mode 100644 index 00000000..0a19d524 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.b.b/Ex5_1bb.R @@ -0,0 +1,10 @@ +#note l denotes lambda +integrand = function(x){ + exp(-x/100) +} + +l = 0.01 + +ans = l* integrate(integrand, lower = 0, upper = 100)$value + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.c/Ex5_1c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.c/Ex5_1c.R new file mode 100644 index 00000000..aedd15f1 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX1.c/Ex5_1c.R @@ -0,0 +1,14 @@ +#install.packages("MASS") +require(MASS) + +integrand = function(x){ + 100/x^2 +} + +P_Ei = integrate(integrand, lower = 100, upper = 150)$value + +n = 5 +x = 2 + +ans = dbinom(x, size = n, prob = P_Ei) +print(fractions(ans)) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX2.a/Ex5_2a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX2.a/Ex5_2a.R new file mode 100644 index 00000000..96c6f901 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX2.a/Ex5_2a.R @@ -0,0 +1,9 @@ +#install.packages("MASS") +require("MASS") + +integrand = function(x){ + 2*x^2 +} + +ans = integrate(integrand, lower = 0, upper = 1)$value +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX2.e/Ex5_2e.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX2.e/Ex5_2e.R new file mode 100644 index 00000000..93aed1e2 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX2.e/Ex5_2e.R @@ -0,0 +1,14 @@ +#install.packages("MASS") +require("MASS") + +integrand = function(x){ + 2*x^3 +} + +E_X = 2/3 + +E_X2 = integrate(integrand, lower = 0, upper = 1)$value + +ans = E_X2 - E_X^2 + +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX3.b/Ex5_3b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX3.b/Ex5_3b.R new file mode 100644 index 00000000..943ec801 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX3.b/Ex5_3b.R @@ -0,0 +1,18 @@ +#install.packages("MASS") +require("MASS") + +min = 0 +max = 10 + +ans1 = punif(3, min = min, max = max) +cat("Ans to a)") +print(fractions(ans1)) + + +ans2 = 1 - punif(6, min = min, max = max) +cat("Ans to b)") +print(fractions(ans2)) + +ans3 = punif(8, min = min, max = max) - punif(3, min = min, max = max) +cat("Ans to c)") +print(fractions(ans3)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX3.c/Ex5_3c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX3.c/Ex5_3c.R new file mode 100644 index 00000000..9aaf3d85 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX3.c/Ex5_3c.R @@ -0,0 +1,19 @@ +#install.packages("MASS") +require("MASS") + +#returns the probability of U(0,30) +uni = function(lower, upper){ + alpha = 0 + beta = 30 + + P_X = punif(upper, min = alpha, max = beta) - punif(lower, min = alpha, max = beta) + return(P_X) +} + +ans1 = uni(10 , 15) + uni(25, 30) +cat("Ans for a)") +print(fractions(ans1)) + +ans2 = uni(0, 5) + uni(15, 20) +cat("Ans for b)") +print(fractions(ans2)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.b/Ex5_4b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.b/Ex5_4b.R new file mode 100644 index 00000000..2eaa9655 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.b/Ex5_4b.R @@ -0,0 +1,13 @@ +mu = 3 +sigma = sqrt(9) + +ans1 = pnorm(5, mu, sigma) - pnorm(2, mu, sigma) + +cat("Ans to a) ", ans1, "\n") + +ans2 = 1 - pnorm(0, mu, sigma) +cat("Ans to b) ", ans2, "\n") + + +ans3 = 1 - pnorm(9, mu, sigma) + pnorm(-3, mu, sigma) +cat("Ans to c) ", ans3, "\n") \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.c/Ex5_4c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.c/Ex5_4c.R new file mode 100644 index 00000000..4c8bb03a --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.c/Ex5_4c.R @@ -0,0 +1,5 @@ +cat("Grade A:", (1 - pnorm(1))*100, "%\n") +cat("Grade B:", (pnorm(1) - pnorm(0))*100, "%\n") +cat("Grade C:", (pnorm(0) - pnorm(-1))*100, "%\n") +cat("Grade D:", (pnorm(2) - pnorm(1))*100, "%\n") +cat("Grade E:", (pnorm(-2))*100, "%\n") \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.d/Ex5_4d.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.d/Ex5_4d.R new file mode 100644 index 00000000..2e70ce12 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.d/Ex5_4d.R @@ -0,0 +1,8 @@ + +mu = 270 +sigma = sqrt(100) + +#P(X > 290) = 1 - P(X <= 290) +ans = 1 - pnorm(290, mu, sigma) + pnorm(240, mu, sigma) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.e/Ex5_4e.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.e/Ex5_4e.R new file mode 100644 index 00000000..2e0d3e6d --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.e/Ex5_4e.R @@ -0,0 +1,6 @@ + +P_EgOne = 1 - pnorm(1.5) +cat("P{error|message is 1} =", P_EgOne, "\n") + +P_EgZero = 1 - pnorm(2.5) +cat("P{error|message is 0} =", P_EgZero, "\n") diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.f/Ex5_4f.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.f/Ex5_4f.R new file mode 100644 index 00000000..4ceefee0 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.f/Ex5_4f.R @@ -0,0 +1,11 @@ +n = 40 +p = 1/2 +x = 20 +mu = n*p +sigma = sqrt(n*p*(1-p)) + +ans1 = pnorm(x + 0.5, mean = mu, sd = sigma) - pnorm(x - 0.5, mean = mu, sd = sigma) +cat("Ans through normal approximation:", ans1, "\n") + +ans2 = dbinom(x, size = n, prob = p) +cat("Ans:", ans2) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.g/Ex5_4g.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.g/Ex5_4g.R new file mode 100644 index 00000000..62f5d50e --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.g/Ex5_4g.R @@ -0,0 +1,9 @@ +n = 450 +p = 0.3 + +mu = n*p +sigma = sqrt(n*p*(1-p)) + +ans = 1 - pnorm(150.5, mu, sigma) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.h/Ex5_4h.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.h/Ex5_4h.R new file mode 100644 index 00000000..a145a3ac --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.h/Ex5_4h.R @@ -0,0 +1,9 @@ +n = 100 +p = 1/2 + +mu = n*p +sigma = sqrt(n*p*(1-p)) + +ans = 1 - pnorm(64.5, mu, sigma) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.i/Ex5_4i.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.i/Ex5_4i.R new file mode 100644 index 00000000..9e9e46cb --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX4.i/Ex5_4i.R @@ -0,0 +1,20 @@ + +P_Sn = function(n){ + p = 0.52 + mu = p*n + sigma = sqrt(n * p * (1-p)) + ans = 1 - pnorm( 0.5 * n, mu, sigma) + return(ans) +} + +N = c(11, 101, 1001) + +for(i in N){ + cat("For n =", i, "P(Sn > 0.5*n) =", P_Sn(i), "\n") +} + +i = 1 +while(P_Sn(i) < 0.95){ + i = i + 1 +} +cat("For at least 95%, n =", i, "\n") \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX5.b/Ex5_5b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX5.b/Ex5_5b.R new file mode 100644 index 00000000..6a286af6 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX5.b/Ex5_5b.R @@ -0,0 +1,7 @@ +lambda = 1/10 + +ans1 = 1 - pexp(10, lambda) +cat("Ans to a)", ans1, "\n") + +ans2 = pexp(20, lambda) - pexp(10, lambda) +cat("Ans to b)", ans2, "\n") diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX5.e/Ex5_5e.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX5.e/Ex5_5e.R new file mode 100644 index 00000000..b58efe70 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH5/EX5.e/Ex5_5e.R @@ -0,0 +1,8 @@ +#install.packages('rmutil') +require(rmutil) + +P_EgOne = plaplace(-1.5) +cat("P{error|message is 1} =", P_EgOne, "\n") + +P_EgZero = plaplace(-2.5) +cat("P{error|message is 0} =", P_EgZero, "\n") diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.a/Ex6_1a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.a/Ex6_1a.R new file mode 100644 index 00000000..f5146f3a --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.a/Ex6_1a.R @@ -0,0 +1,18 @@ +#install.packages("MASS") +require("MASS") + +P_XY = function(x, y){ + blue = 5 + red = 3 + white = 4 + lot_size = 3 + ans = choose(blue-x-y, lot_size-x-y) * choose(red, x) * choose(white, y) / choose(blue+white+red, lot_size) +} + +lot_size = 3 +for(i in 0:lot_size){ + for(j in 0:(lot_size - i)){ + cat("p(", i,",",j,") =") + print(fractions(P_XY(i,j))) + } +} \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.b/Ex6_1b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.b/Ex6_1b.R new file mode 100644 index 00000000..97959fbe --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.b/Ex6_1b.R @@ -0,0 +1,18 @@ +P = c(.15, .2, .35, .3) + +P_BG <- function(i, j){ + if((i + j) >=4){ + return(0) + }else{ + ans = P[(i + j) + 1] * ((factorial(i + j)/(factorial(i) * factorial(j)))/2^(i + j)) + return(ans) + } +} + +max_children = 3 +for(i in 0:max_children){ + for(j in 0:max_children){ + cat("p(", i,",",j,") =", P_BG(i,j), "\n") + } +} + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.c.a/Ex6_1ca.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.c.a/Ex6_1ca.R new file mode 100644 index 00000000..d63e193b --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.c.a/Ex6_1ca.R @@ -0,0 +1,16 @@ +myfun = function(x,y) (2*exp(-x)*exp(-2*y)) +llimx = 1 +ulimx = Inf + +llimy = 0 +ulimy = 1 + +f = function(){ + return(integrate(function(y) { + sapply(y, function(y) { + integrate(function(x) myfun(x,y), llimx, ulimx)$value + }) + }, llimy, ulimy)) +} +ans = f()$value +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.c.b/Ex6_1cb.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.c.b/Ex6_1cb.R new file mode 100644 index 00000000..72aeb831 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX1.c.b/Ex6_1cb.R @@ -0,0 +1,19 @@ +#install.packages("MASS") +require("MASS") + +myfun <- function(x,y) (2*exp(-x)*exp(-2*y)) +llimx <- 0 + +llimy <- 0 +ulimy <- Inf + +f <- function(){ + return(integrate(function(y) { + sapply(y, function(y) { + integrate(function(x) myfun(x,y), llimx, y)$value + }) + }, llimy, ulimy)) +} +ans = f()$value + +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX2.c/Ex6_2c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX2.c/Ex6_2c.R new file mode 100644 index 00000000..f7b06cc6 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX2.c/Ex6_2c.R @@ -0,0 +1,16 @@ +#install.packages('pracma') +#install.packages('MASS') +require('pracma') +require(MASS) + +integrand = function(x, y){ + 1/60^2 +} + +xm = function(y){ + y - 10 +} + +ans = 2*integral2(integrand, xmin = 10, xmax = 60, ymin = 0, ymax = xm )$Q + +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.c.a/Ex6_3ca.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.c.a/Ex6_3ca.R new file mode 100644 index 00000000..da3c82bc --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.c.a/Ex6_3ca.R @@ -0,0 +1,16 @@ +#note E_Xab denotes E(Xa + Xb) +na = 26 +pa = 0.4 +E_Xa = na*pa +Var_Xa = na*pa*(1-pa) + +nb = 18 +pb = 0.7 +E_Xb = nb*pb +Var_Xb = nb*pb*(1-pb) + +E_Xab = E_Xa + E_Xb +Var_Xab = Var_Xa + Var_Xb + +ans = 1 - pnorm(25 - 1/2, E_Xab, sqrt(Var_Xab)) +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.c.b/Ex6_3cb.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.c.b/Ex6_3cb.R new file mode 100644 index 00000000..9944cb12 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.c.b/Ex6_3cb.R @@ -0,0 +1,17 @@ +#note E_Xab denotes E(Xa - Xb) +na = 26 +pa = 0.4 +E_Xa = na*pa +Var_Xa = na*pa*(1-pa) + +nb = 18 +pb = 0.7 +E_Xb = nb*pb +Var_Xb = nb*pb*(1-pb) + +E_Xab = E_Xa - E_Xb +Var_Xab = Var_Xa + Var_Xb + +ans = 1 - pnorm(1 - 1/2, E_Xab, sqrt(Var_Xab)) +print(ans) + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.d.a/Ex6_3da.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.d.a/Ex6_3da.R new file mode 100644 index 00000000..113ec124 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.d.a/Ex6_3da.R @@ -0,0 +1,6 @@ +mu = 0.0165 +sigma = 0.0730 + +p = 1 - pnorm(0, mu, sigma) +ans = p^2 +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.d.b/Ex6_3db.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.d.b/Ex6_3db.R new file mode 100644 index 00000000..fb8b9b16 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX3.d.b/Ex6_3db.R @@ -0,0 +1,9 @@ +mu = 0.0165 +sigma = 0.0730 + +mu = mu*2 +sigma = sqrt(2 * sigma^2) + +ans = 1 - pnorm(0, mu, sigma) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX4.a/Ex6_4a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX4.a/Ex6_4a.R new file mode 100644 index 00000000..6cf8fe78 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX4.a/Ex6_4a.R @@ -0,0 +1,18 @@ +#install.packages("MASS") +require("MASS") +#note pxi denotes Px(i) + +p00 = 0.4 +p01 = 0.2 +p10 = 0.1 +p11 = 0.3 + +py1 = p01 + p11 + +px0 = p01/py1 + +px1 = p11/py1 + +print(fractions(px0)) + +print(fractions(px1)) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX6.b/Ex6_6b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX6.b/Ex6_6b.R new file mode 100644 index 00000000..d9e60c97 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH6/EX6.b/Ex6_6b.R @@ -0,0 +1,10 @@ +#install.packages("MASS") +require("MASS") + +integrand = function(x){ + x*(1-x) +} + +ans = factorial(3)/factorial(1)^2 * integrate(integrand, lower = 1/4, upper = 3/4)$value + +print(fractions(ans)) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX2.r/Ex7_2r.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX2.r/Ex7_2r.R new file mode 100644 index 00000000..d3aadb84 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX2.r/Ex7_2r.R @@ -0,0 +1,10 @@ +no_of_chipmunks = 15 +total_trees = 52 + +p = 7/52 +Xi = rep(1, no_of_chipmunks) +E_Xi = Xi*p + +E_X = sum(E_Xi) + +print(E_X) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.a/Ex7_5ea.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.a/Ex7_5ea.R new file mode 100644 index 00000000..5b35df51 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.a/Ex7_5ea.R @@ -0,0 +1,27 @@ +#Note P_Xi denotes P(X=i), E_XgYi denotes E[X|Y = i] + +Pi = function(i){ + if(i>7){ + i = 14 - i + } + ans = (i-1)/36 +} + +E_RgSi = function(i){ + if(i == 2 || i == 3 || i == 7 || i == 11 || i == 12){ + return(1) + } + else{ + ans = 1 + 1/(Pi(i)+Pi(7)) + return(ans) + } +} + +E_R = 0 + +for(i in 2:12){ + E_R = E_R + E_RgSi(i) * Pi(i) +} + +print(E_R) + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.b/Ex7_5eb.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.b/Ex7_5eb.R new file mode 100644 index 00000000..5505d908 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.b/Ex7_5eb.R @@ -0,0 +1,27 @@ +#Note P_Xi denotes P(X=i), E_XgYi denotes E[X|Y = i] + +Pi = function(i){ + if(i>7){ + i = 14 - i + } + ans = (i-1)/36 +} + +P_Si = function(c){ + if(i == 7 || i == 11){ + return(Pi(i)) + } + if( i == 2 || i == 3 || i == 12){ + return(0) + } + else{ + ans = Pi(i)^2 / (Pi(i) + Pi(7)) + } +} + +p = 0 +for(i in 2:12){ + p = p + P_Si(i) +} + +print(p) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.c/Ex7_5ec.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.c/Ex7_5ec.R new file mode 100644 index 00000000..739784bf --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH7/EX5.e.c/Ex7_5ec.R @@ -0,0 +1,44 @@ +#Note P_Xi denotes P(X=i), E_XgYi denotes E[X|Y = i] + +p = 0.493 +E_R = 3.376 + +E_RgSi = function(i){ + if(i == 2 || i == 3 || i == 7 || i == 11 || i == 12){ + return(1) + } + else{ + ans = 1 + 1/(Pi(i)+Pi(7)) + return(ans) + } +} + +Pi = function(i){ + if(i>7){ + i = 14 - i + } + ans = (i-1)/36 +} + +Qi = function(i){ + if( i == 2 || i == 3 || i == 12){ + return(0) + } + if( i == 7 || i == 11){ + return(Pi(i)/p) + } + else{ + ans = Pi(i)^2 / (p * (Pi(i) + Pi(7))) + return(ans) + } +} + +E_Rgwin = 0 + +for(i in 2:12){ + E_Rgwin = E_Rgwin + E_RgSi(i)*Qi(i) +} + +E_Rglose = (E_R - E_Rgwin*p)/ (1-p) + +print(E_Rglose) diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX2.b/Ex8_2b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX2.b/Ex8_2b.R new file mode 100644 index 00000000..14659aeb --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX2.b/Ex8_2b.R @@ -0,0 +1,12 @@ +alpha = 0 +beta = 10 + +E_X = (alpha + beta)/ 2 +Var_X = (beta - alpha)^2 / 12 + +ans1 = Var_X/ 4^2 + +cat("From Chebyshev's inequality, P{|X-5| > 4} <=", ans1, "\n") + +ans2 = punif(1, min = alpha, max = beta) + 1 - punif(9, min = 0, max = 10) +cat("Exact ans, P{|X-5| > 4} =", ans2, "\n") \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.a/Ex8_3a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.a/Ex8_3a.R new file mode 100644 index 00000000..fc9d53a9 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.a/Ex8_3a.R @@ -0,0 +1,12 @@ +P = function(n){ + acc = 0.5 + ans = pnorm(0.5*sqrt(n)/2, 0, 1) - pnorm(-0.5*sqrt(n)/2, 0, 1) + return(ans) +} + +i = 1 +while(P(i) < 0.95){ + i = i+1 +} + +print(i) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.b/Ex8_3b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.b/Ex8_3b.R new file mode 100644 index 00000000..8f369767 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.b/Ex8_3b.R @@ -0,0 +1,6 @@ +mu = 100 +var = mu + +ans = 1 - pnorm(120 - 1/2, mu, sqrt(var)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.c/Ex8_3c.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.c/Ex8_3c.R new file mode 100644 index 00000000..0c642e92 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.c/Ex8_3c.R @@ -0,0 +1,18 @@ +p = 1/6 +E_X = 0 +E_X2 = 0 +no_of_die_rolls = 10 +for(i in 1:6){ + E_X = E_X + p*i + E_X2 = E_X2 + p*i^2 +} +print(E_X) +print(E_X2) + +Var_X = (E_X2 - E_X^2)*no_of_die_rolls +E_X = E_X*no_of_die_rolls + +ans = pnorm(40 + 1/2, E_X, sqrt(Var_X)) - pnorm(30 - 1/2, E_X, sqrt(Var_X)) + +print(ans) + diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.d/Ex8_3d.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.d/Ex8_3d.R new file mode 100644 index 00000000..85f6bda9 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.d/Ex8_3d.R @@ -0,0 +1,11 @@ +E_X = 1/2 +Var_X = 1/12 + +n = 10 + +E_X = 1/2*10 +Var_X = 1/12*10 + +ans = 1 - pnorm(6, E_X, sqrt(Var_X)) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.e/Ex8_3e.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.e/Ex8_3e.R new file mode 100644 index 00000000..f7ad768f --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX3.e/Ex8_3e.R @@ -0,0 +1,9 @@ +mu = 20 +sd = 4 +n = 25 +mu = mu*n +sd = sd*sqrt(n) + +ans = pnorm(450, mu, sd) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX5.a/Ex8_5a.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX5.a/Ex8_5a.R new file mode 100644 index 00000000..d42df346 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX5.a/Ex8_5a.R @@ -0,0 +1,7 @@ +mu = 100 +var = 400 +a = 20 + +ans = var/(var + a^2) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX5.b/Ex8_5b.R b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX5.b/Ex8_5b.R new file mode 100644 index 00000000..a5484999 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/CH8/EX5.b/Ex8_5b.R @@ -0,0 +1,14 @@ +tot_men = 100 +tot_people = 200 + +E_Xi = tot_men/(tot_people - 1) + +E_X = E_Xi * tot_men + +Var_X = E_X * (tot_men - 1)/(tot_people - 1) + 2 * choose(tot_men, 2)* ((tot_men*(tot_men - 1))/((tot_people - 1)*(tot_people - 3)) - (tot_men/(tot_people - 1))^2) + +a = E_X - 30 + +ans = Var_X / (Var_X + a^2) + +print(ans) \ No newline at end of file diff --git a/A_First_Course_In_Probability_by_Sheldon_Ross/README.txt b/A_First_Course_In_Probability_by_Sheldon_Ross/README.txt new file mode 100644 index 00000000..2e134997 --- /dev/null +++ b/A_First_Course_In_Probability_by_Sheldon_Ross/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Anuj Singh +Course: Btech +Branch: Computer Science And Engineering +College/Institute/Organization: Indian Institute Of Technology, Bhilai + +About The Book + +Book: A First Course In Probability +Author: Sheldon Ross +Publisher: Pearson, Usa +Year Of Publication: 2008 +ISBN: 013603313X +Edition: 8 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.1/Ex10_1.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.1/Ex10_1.r new file mode 100644 index 00000000..63f8e6b5 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.1/Ex10_1.r @@ -0,0 +1,18 @@ +# y denote the number of successes in the n sample trials, +# sample proportion +y=330 +n=870 +pie=y/n +sigma=sqrt((pie*(1-pie))/n) + +alpha=0.05 +z.alpha=qnorm(1-alpha) +error=z.alpha*sigma +# the 90% confidence interval on the proportion of cancer +#patients who will survive at least 5 years +left_i=pie-error +right_i=pie+error +print(left_i) +print(right_i) + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.10/Ex10_10.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.10/Ex10_10.r new file mode 100644 index 00000000..3b5b0ce4 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.10/Ex10_10.r @@ -0,0 +1,15 @@ +obsereved_cell_number = c(120,60,10,10) +expected_cell_number=c(100,50,20,30) +# test statistic +Xsquare = 0 +i=1 +while(i<=length(obsereved_cell_number)){ + Xsquare=Xsquare+(((obsereved_cell_number[i]-expected_cell_number[i])^2)/expected_cell_number[i]) + i=i+1 +} +print(Xsquare) +# critical value +alpha = 0.05 +X.alpha=qchisq(1-alpha,df=3) +# The computed value of xsquare is greater than x.alpha, so we reject the null hypothes + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.11/Ex10_11.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.11/Ex10_11.r new file mode 100644 index 00000000..cad6b5f8 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.11/Ex10_11.r @@ -0,0 +1,28 @@ +yi=c(0,1,2,3,4,5,6,7) +ni=c(6,23,29,31,27,13,8,13) +n=sum(ni) +ybar=sum(yi*ni)/sum(ni) +print(ybar) +# ybar value in book is calculated wrong +# The Poisson probabilities +Pyi=c(dpois(0,ybar),dpois(1,ybar),dpois(2,ybar),dpois(3,ybar),dpois(4,ybar),dpois(5,ybar),dpois(6,ybar),dpois(7,ybar)) +print(Pyi) +# Expected cell count +Ei=n*Pyi +print(Ei) + +# test statistic +i=1 +X2=0 +while(i<9){ + X2=X2+(((ni[i]-Ei[i])^2)/Ei[i]) + i=i+1 +} +print(X2) # ans in book is calculate wrong +df=6 + +pvalue=pchisq(X2,df,lower.tail = FALSE) +print(pvalue) +# as p-value <=.01 model is Poisson model provides an Unacceptable fit to data + + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.12/Ex10_12.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.12/Ex10_12.r new file mode 100644 index 00000000..3f6ff0b8 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.12/Ex10_12.r @@ -0,0 +1,38 @@ +moderate=c(15,32,18,5) +mildly=c(8,29,23,18) +severe=c(1,20,25,22) +all_ages=c(sum(moderate),sum(mildly),sum(severe)) +all_servetiles=c(24,81,66,45) +grand_total=216 +# For row 1,the estimated expected number of occurrences +E11=(sum(moderate)*all_servetiles[1])/grand_total +print(E11) +E12=(sum(moderate)*all_servetiles[2])/grand_total +print(E12) +E13=(sum(moderate)*all_servetiles[3])/grand_total +print(E13) +E14=(sum(moderate)*all_servetiles[4])/grand_total +print(E14) + +# For row 2,the estimated expected number of occurrences +E21=(sum(mildly)*all_servetiles[1])/grand_total +print(E21) +E22=(sum(mildly)*all_servetiles[2])/grand_total +print(E22) +E23=(sum(mildly)*all_servetiles[3])/grand_total +print(E23) +E24=(sum(mildly)*all_servetiles[4])/grand_total +print(E24) + +# For row 3,the estimated expected number of occurrences +E31=(sum(severe)*all_servetiles[1])/grand_total +print(E31) +E32=(sum(severe)*all_servetiles[2])/grand_total +print(E32) +E33=(sum(severe)*all_servetiles[3])/grand_total +print(E33) +E34=(sum(severe)*all_servetiles[4])/grand_total +print(E34) + +dt=data.frame(cbind(E11,E12,E13,E14),cbind(E21,E22,E23,E24),cbind(E31,E32,E33,E34)) +dt diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.13/Ex10_13.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.13/Ex10_13.r new file mode 100644 index 00000000..ccc05dbc --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.13/Ex10_13.r @@ -0,0 +1,15 @@ +n = c(15,32,18,5,8,29,23,18,1,20,25,22) +E=c( 7.78,26.25,21.39,14.58,8.67,29.25,23.83,16.25,7.56,25.50,20.78,14.17) +# test statistic +Xsquare = 0 +i=1 +while(i<=length( n)){ + Xsquare=Xsquare+(((n[i]-E[i])^2)/E[i]) + i=i+1 +} +print(Xsquare) +# critical value +alpha = 0.05 +X.alpha=qchisq(1-alpha,df=6) +# The computed value of xsquare is greater than x.alpha, so we reject the null hypothes + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.14/Ex10_14.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.14/Ex10_14.r new file mode 100644 index 00000000..bea18584 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.14/Ex10_14.r @@ -0,0 +1,15 @@ +n = c(50,59,161,88,20,40,56,52,188,4,3,5,2,66,6) +E=c(67.5,67.5,135,37,37,74,74,74,148,3,3,6,18.5,18.5,37) +# test statistic +Xsquare = 0 +i=1 +while(i<=length( n)){ + Xsquare=Xsquare+(((n[i]-E[i])^2)/E[i]) + i=i+1 +} +print(Xsquare) +# critical value +alpha = 0.001 +X.alpha=qchisq(1-alpha,df=8) +# The computed value of xsquare is greater than x.alpha, so we reject the null hypothes + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.15/Ex10_15.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.15/Ex10_15.r new file mode 100644 index 00000000..aed7ab4f --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.15/Ex10_15.r @@ -0,0 +1,12 @@ + # odds of a randomly chosen person carrying HIV +p=.001/.009 +# occurrence of a positive test result causes the odds to change to +p_hiv=.001 +p_positive_hiv=.95 +p_nothiv=.999 +p_positive_nothiv=.02 +P_occurencepositive=(p_hiv*p_positive_hiv)/(p_nothiv*p_positive_nothiv) +print(P_occurencepositive) + +# The odds of carrying HIV do go up given a positive test result, from about +#.001 (to 1) to about .0475 (to 1). \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.16/Ex10_16.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.16/Ex10_16.r new file mode 100644 index 00000000..fc891383 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.16/Ex10_16.r @@ -0,0 +1,18 @@ +low=c(250,750) +high=c(400,1600) +odds_ratio=(250/750)/(400/1600) +print(odds_ratio) +# We will next compute a 95% confidence interval for the odds ratio +a= log(odds_ratio) +sigma=sqrt(1/low[1]+1/low[2]+1/high[1]+1/high[2]) +print(sigma) +# The 95% confidence interval for the odds ratio is obtained by first computing +error=1.96*sigma +left_i=a-error +right_i=a+error + +print(left_i) +print(right_i) +print("confidence interval") +print(exp(left_i)) +print(exp(right_i)) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.17/Ex10_17.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.17/Ex10_17.r new file mode 100644 index 00000000..66c68fd6 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.17/Ex10_17.r @@ -0,0 +1,22 @@ + # for clinic 1 +r1=c(50,50) +c1=c(55,45) + +# for clinic 2 +r2=c(50,50) +c2=c(55,45) + +# for clinic 3 +r3=c(50,50) +c3=c(74,26) +nh=100 +# The numerator of the CMH statistic +N=((40-((r1[1]*c1[1])/nh))+(35-((r2[1]*c2[1])/nh))+(43-((r3[1]*c3[1])/nh)))^2 +print(N) + +D=((r1[1]*r1[2]*c1[1]*c1[2])/(nh^2*(nh-1)))+((r2[1]*r2[2]*c2[1]*c2[2])/(nh^2*(nh-1)))+((r3[1]*r3[2]*c3[1]*c3[2])/(nh^2*(nh-1))) +print(D) + +X2=N/D +print(X2) +# For df = 1, this result is significant at the p < .001 level. the drug-treated groups have consistently higher improvement rates than the placebo groups. \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.2/Ex10_2.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.2/Ex10_2.r new file mode 100644 index 00000000..e5461727 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.2/Ex10_2.r @@ -0,0 +1,29 @@ +# y denote the number of successes in the n sample trials, +# sample proportion +y=43 +n=50 +pie=y/n +sigma=sqrt((pie*(1-pie))/n) +alpha=0.025 +z.alpha=qnorm(1-alpha) +error=z.alpha*sigma +# 95% confidence interval +left_i=pie-error +right_i=pie+error +print(" Wald 95 % confidence interval") +print(left_i) +print(right_i) + +# Using the WAC confidence interval, we need to compute: +ybar = y + 0.5*(z.alpha^2) +nbar = n + (z.alpha^2) +pie_bar=ybar/nbar + + +sigma_bar=sqrt((pie_bar*(1-pie_bar))/nbar) +error_bar=z.alpha*sigma_bar +left=pie_bar-error_bar +right=pie_bar+error_bar +print(" WAC 95% confidence interval") +print(left) +print(right) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.3/Ex10_3.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.3/Ex10_3.r new file mode 100644 index 00000000..5fa6d4aa --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.3/Ex10_3.r @@ -0,0 +1,13 @@ +y=50 +n=50 +alpha=.05 +# If we used the standard estimator of pie +pie=y/n +# The point estimator would be given by +pie_adj=(n+(3/8))/(n+(3/4)) +print(pie_adj) +# A 95% confidence interval for pie would be +left_i=(alpha/2)^(1/n) +right_i=1 +print(left_i) +print(right_i) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.4/Ex10_4.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.4/Ex10_4.r new file mode 100644 index 00000000..ad942cd3 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.4/Ex10_4.r @@ -0,0 +1,15 @@ +alpha=0.025 +pie=0.5 +E=0.03 +z.alpha=qnorm(1-alpha) +# sample size necessary to achieve this accuracy +n=((z.alpha^2)*pie*(1-pie))/E^2 +print(ceiling(n)) +# 1,068 programs would need to be tested in order to be 95% confident that +#the estimate of pie is within .03 of the actual value of pie + +pie=0.8 +n=((z.alpha^2)*pie*(1-pie))/E^2 +print(n) +# if the designer was fairly certain that the actual value of pie was at least .80, +#then the required sample size can be greatly reduced. \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.5/Ex10_5.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.5/Ex10_5.r new file mode 100644 index 00000000..ea8f17ec --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.5/Ex10_5.r @@ -0,0 +1,23 @@ +y=1200 +n=2500 +pie=y/n +sigma=sqrt((pie*(1-pie))/n) +pie0=0.44 +#test statistic +z=(pie-pie0)/sigma +print(z) +# critical value +alpha=0.05 +z.alpha=qnorm(1-alpha) +#Because the observed value of z exceeds the critical value 1.645, we conclude that the +#percentage of students that participate in binge drinking exceeds the national percentage of 44% +nbar = n + (z.alpha^2) +pie_bar=(y+z.alpha)/nbar + +sigma_bar=sqrt((pie_bar*(1-pie_bar))/nbar) +error_bar=z.alpha*sigma_bar +left=pie_bar-error_bar +right=pie_bar+error_bar +print(left) +print(right) +# the percentage of binge drinkers at the university is, with 95% confidence,between 46% and 50% diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.6/Ex10_6.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.6/Ex10_6.r new file mode 100644 index 00000000..06d8f696 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.6/Ex10_6.r @@ -0,0 +1,15 @@ +pie1=413/527 +pie2=392/608 +# The sample awareness proportion is higher in Wichita, so let's make Wichita region 1. +#The estimated standard error is +sigma=sqrt(((pie1*(1-pie1))/527)+((pie2*(1-pie2))/608)) +print(sigma) +alpha=0.025 +z.alpha=qnorm(1-alpha) +error=z.alpha*sigma +# 95% confidence interval +left_i=(pie1-pie2)-error +right_i=(pie1-pie2)+error +print(left_i) +print(right_i) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.7/Ex10_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.7/Ex10_7.r new file mode 100644 index 00000000..d3d49055 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.7/Ex10_7.r @@ -0,0 +1,21 @@ +pie1=94/125 +pie2=113/175 +# The sample awareness proportion is higher in Wichita, so let's make Wichita region 1. +#The estimated standard error is +sigma=sqrt(((pie1*(1-pie1))/125)+((pie2*(1-pie2))/175)) + +#test statistic +z=(pie1-pie2)/sigma +print(z) +alpha=0.05 +z.alpha=qnorm(1-alpha) +zstar=qnorm(1-alpha/2) +# Since z is greater than z.alpha, we reject H0 and conclude that the observations +#support the hypothesis +error=zstar*sigma +# 95% confidence interval +left_i=(pie1-pie2)-error +right_i=(pie1-pie2)+error +print(left_i) +print(right_i) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.8/Ex10_8.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.8/Ex10_8.r new file mode 100644 index 00000000..5e796865 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.8/Ex10_8.r @@ -0,0 +1,10 @@ + +data = rbind(c(38,4), c(14,7) ) + +print(data) +# fisher test +fisher.test(data, alternative="greater") +alpha=0.025 +# as pvalue > alpha then we conclude that there is not +#significant evidence that the proportion of patients obtaining a successful outcome +#is higher for drug PV than for drug P. \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.9/Ex10_9.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.9/Ex10_9.r new file mode 100644 index 00000000..106249b0 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH10/EX10.9/Ex10_9.r @@ -0,0 +1,14 @@ +p_1calf=0.83 +p_2calf=0.02 +p_0calf=0.15 + +# event A= dams gives birth to no healthy progeny ,1 healthy progeny,2 healthy progeny(n1=1,n2=1,n3=1) + +P_eventA=(factorial(3)*(p_0calf^1*p_1calf^1*p_2calf^1))/(factorial(1)*factorial(1)*factorial(1)) +print(P_eventA) + # event B= 3 dams give birth to 1 healthy progeny(n1=0,n2=3,n3=0) +P_eventB=(factorial(3)*(p_0calf^0*p_1calf^3*p_2calf^0))/(factorial(0)*factorial(3)*factorial(0)) +print(P_eventB) +# the probability of obtaining exactly three healthy progeny from three dams +p=P_eventA+P_eventB +print(p) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.10/Ex11_10.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.10/Ex11_10.r new file mode 100644 index 00000000..f838841e --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.10/Ex11_10.r @@ -0,0 +1,14 @@ + +heat_loss <- c(86,80,77 , 78,84,75 ,33,38,43) +temperature <- c(20,20,20,40,40,40,60,60,60) +plot(temperature,heat_loss) +# Apply the lm() function. +relation <- lm(heat_loss~temperature) + +print(summary(relation)) + # linear regression model : y= 109-1.07*x +anova(relation) +# y and y-ycap for the nine observations +cbind( temperature,heat_loss,predict(relation),resid(relation)) +plot(predict(relation),resid(relation)) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.11/Ex11_11.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.11/Ex11_11.r new file mode 100644 index 00000000..5f55af19 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.11/Ex11_11.r @@ -0,0 +1,26 @@ + +heat_loss <- c(86,80,77 , 78,84,75 ,33,38,43) +temperature <- c(81,81,81,79,79,79,38,38,38) + +# Apply the lm() function. +relation <- lm(heat_loss~temperature) + +aov(relation) + +SSPexp=134 +SSresidual=894.5 #calculated in 11.10 +SSlack=SSresidual-SSPexp + +MSPexp=SSPexp/6 +MSlack=SSlack/1 +# test statistic +F=MSlack/MSPexp +print(F) +alpha=0.05 + +fvalue=qf(1-alpha,df1 = 1,df2 = 6) +if(F>fvalue){ + print(" we reject H0 and conclude that there is significant lack of fit for a linear regression model") +}else{ + print("we do not reject H0 and conclude that there is no significant lack of fit for a linear regression model") +} diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.12/Ex11_12.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.12/Ex11_12.r new file mode 100644 index 00000000..9425d102 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.12/Ex11_12.r @@ -0,0 +1,14 @@ + +x <- c(1,2,3,4,5,6,7,8,9,10) +y <- c(1.4,2.3,3.1,4.2,5.1,5.8,6.8,7.6,8.7,9.5) +xbar=mean(x) +# Apply the lm() function. +relation <- lm(y~x) +print(summary(relation)) + +# linear regression model : y=.9012*x+.4934 + mod=lm(x~y) + predict(mod,data.frame(y=4),interval = "prediction",level = 0.95) + # the 95% prediction limits for x are 3.65 to 4.13 + + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.13/Ex11_13.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.13/Ex11_13.r new file mode 100644 index 00000000..6de2a7f7 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.13/Ex11_13.r @@ -0,0 +1,7 @@ +eggs=c(27,32,39,48,59,67,71,65,73,67,78,72,81,74,83,75,84,77,83,76,82,75,78,77,75,73,71,70,68,65) +weight=c(2.1,2.3,2.4,2.5,2.9,3.1,3.2,3.3,3.4,3.4,3.5,3.5,3.5,3.6,3.6,3.6,3.6,3.7,3.7,3.7,3.8,3.9,4.0,4.3,4.4,4.7,4.8,4.9,5.0,5.1) + plot(weight,eggs) + # correlation coefficient + cor(eggs,weight) + + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.14/Ex11_14.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.14/Ex11_14.r new file mode 100644 index 00000000..0926b16d --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.14/Ex11_14.r @@ -0,0 +1,8 @@ +# SS(Total) = Syy +SStotal=6066.1667 +rxy=0.606 +SSregression = (rxy^2)*SStotal +print(SSregression) + +SSresidual=SStotal-SSregression +print(SSresidual) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.15/Ex11_15.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.15/Ex11_15.r new file mode 100644 index 00000000..8134da32 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.15/Ex11_15.r @@ -0,0 +1,20 @@ + +y <- c(41, 39, 47, 51, 43, 40, 57, 46, 50, 59, 61, 52) +x<- c( 24 ,30 ,33 ,35 ,36 ,36 ,37 ,37 ,38 ,40 ,43 ,49) + +# Apply the lm() function. +relation <- lm(y~x) + +print(summary(relation)) +cor(y,x) +# For all 12 observations, the output shows a correlation coefficient of .646 +# after subseting x>=37 + +y1 <- c( 57, 46, 50, 59, 61, 52) +x1<- c( 37 ,37 ,38 ,40 ,43 ,49) +# Apply the lm() function. +relation <- lm(y1~x1) +print(summary(relation)) + cor(y1,x1) +# For subset having x greater than or equal to 37, the output shows a correlation coefficient of .188 + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.16/Ex11_16.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.16/Ex11_16.r new file mode 100644 index 00000000..4a4f50cc --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.16/Ex11_16.r @@ -0,0 +1,4 @@ +y <- c(41, 39, 47, 51, 43, 40, 57, 46, 50, 59, 61, 52) + +x<- c( 24 ,30 ,33 ,35 ,36 ,36 ,37 ,37 ,38 ,40 ,43 ,49) +cor.test(y,x) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.17/Ex11_17.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.17/Ex11_17.zip new file mode 100644 index 00000000..0a8207ff Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.17/Ex11_17.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.2/Ex11_2.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.2/Ex11_2.r new file mode 100644 index 00000000..264d4784 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.2/Ex11_2.r @@ -0,0 +1,14 @@ +# Sales Volume +y=c(25,55,50,75,110,138,90,60,10,100) +# % of Ingredients Purchased Directly, +x=c(10,18,25,40,50,63,42,30,5,55) +# Sxy is the sum of x deviations times y deviations and Sxx is the sum of x deviations squared. + +Sxx=(x-mean(x))^2 +Sxy=(x-mean(x))*(y-mean(y)) + +# least-squares estimates of slope and intercept +Beta1=sum(Sxy)/sum(Sxx) +Beta0=mean(y)-Beta1*mean(x) + print(Beta1) + print(Beta0) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.3/Ex11_3.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.3/Ex11_3.r new file mode 100644 index 00000000..9460bcd0 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.3/Ex11_3.r @@ -0,0 +1,9 @@ +xbar=31.80 +ybar=2.785 +Sxx=485.60 +Syy=7.36 +Sxy=55.810 +Beta1=Sxy/Sxx +Beta0=ybar-Beta1*xbar +print(Beta1) +print(Beta0) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.4/Ex11_4.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.4/Ex11_4.r new file mode 100644 index 00000000..717d3628 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.4/Ex11_4.r @@ -0,0 +1,17 @@ +soil_ph <- c(3.3,3.4,3.4,3.5,3.6,3.6,3.7,3.7,3.8,3.8,3.9,4.0,4.1,4.2,4.3,4.4,4.5,5.0,5.1,5.2) +grow_ret <- c(17.78,21.59,23.84,15.13,23.45,20.87,17.78,20.09,17.78,12.46,14.95,15.87,17.45,14.35,14.64,17.25,12.57,7.15,7.50,4.34) + +# Apply the lm() function. +relation <- lm(grow_ret~soil_ph) + +print(summary(relation)) +anova(relation) +# The regression equation : GrowthRet = 47.475 - 7.86 SoilpH + # The estimated intercept (constant) +beta0=47.475 +# estimated slope (Soil pH) +beta1=-7.859 +# least square prediction +y=47.475-7.859*4 +print(y) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.7/Ex11_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.7/Ex11_7.r new file mode 100644 index 00000000..59c40d92 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.7/Ex11_7.r @@ -0,0 +1,12 @@ +beta1=-7.859 # caclulated in 11.4 +error=1.090 +alpha=0.05/2 +df=18 +t.alpha=qt(1-alpha,df) +print(t.alpha) +# corresponding confidence interval for the true value of beta1 +left_i=beta1-t.alpha*error +right_i=beta1+t.alpha*error +print("confidence interval") +print(left_i) +print(right_i) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.8/Ex11_8.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.8/Ex11_8.r new file mode 100644 index 00000000..d69f085f --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH11/EX11.8/Ex11_8.r @@ -0,0 +1,8 @@ +F_statistic=52.01 # computed in example 11.4 +F_statistic +t_statistic=-7.212 +# both are calculated in 11.4 +p=t_statistic^2 +# t^2 equals the F value, to within round-off error. +p + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.11/Ex12_11.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.11/Ex12_11.r new file mode 100644 index 00000000..7f33cb2b --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.11/Ex12_11.r @@ -0,0 +1,24 @@ +y=c(1.5 ,2.1, 1.8, 2.2, 2.2, 2.0, 2.1, 1.9, 2.8, 1.9, 2.0, 2.7, 2.4, 2.3, 2.0, 1.7, 2.3, 0.9, 1.2, 1.9, 0.8, 2.2, 2.3, 1.7, 1.6, 1.6, 2.8, 2.7, 1.3 ,2.1, 2.5, 1.5, 2.4, 2.3, 1.9, 1.5, 2.4, 2.3, 1.7 ,2.0 ,1.9, 2.3, 2.1, 2.2, 1.8, 2.1, 2.2, 1.3, 2.5, 2.2, 1.4, 2.2 ,2.5 ,1.8) +x1=c(139.8, 143.3, 154.2 ,176.6 ,154.3, 185.4, 177.9, 158.8, 159.8, 123.9, 164.2, 146.3, 172.6 ,147.5 ,163.0, 159.8 ,162.7, 133.3 ,142.8 ,146.6 ,141.6, 158.9, 151.9, 153.3 ,144.6, 133.3, 153.6, 158.6, 108.4, 157.4 ,141.7, 151.1, 149.5, 144.3 ,166.6 ,153.6 ,144.1, 148.7, 159.9, 162.8 ,145.7 ,156.7, 162.3, 164.7, 134.4, 160.1, 143.0, 141.6, 152.0, 187.1, 122.9, 157.1 ,155.1 ,133.6) +x2=c(19.1, 21.1, 21.2, 23.2, 22.4 ,22.1, 21.6, 19.0 ,20.9 ,22.0 ,19.5 ,19.8 ,20.7 ,21.0 ,21.2 ,20.4 ,20.0 ,21.1 ,22.6 ,23.0 ,22.1, 22.8 ,21.8 ,20.0 ,22.9 ,22.9 ,19.4 ,21.0 ,21.1 ,20.1 ,19.8 ,21.8 ,20.5 ,21.0, 21.4 ,20.8 ,20.3 ,19.1 ,19.6 ,21.3 ,20.0, 19.2 ,22.1 ,19.1, 20.9 ,21.1 ,20.5 ,21.7 ,20.8 ,21.5, 22.6 ,23.4 ,20.8, 22.5) +x3=c(18.1, 15.3, 15.3, 17.7, 17.1, 16.4, 17.3, 16.8, 15.5 ,13.8, 17.0, 13.8, 16.8, 15.3, 14.2, 16.8, 16.6, 17.5, 18.0 ,15.7 ,19.1, 13.4, 13.6, 16.1, 15.8 ,18.2 ,13.3, 14.9, 16.7 ,15.7, 13.5, 18.8 ,14.9 ,17.2 ,17.4, 16.4, 13.3, 15.4, 17.4, 16.2, 18.6, 16.4, 19.0, 17.1, 15.6, 14.2, 17.1, 14.5 ,17.3, 14.6, 18.6, 14.2, 16.0, 15.4) +x4=c(133.6 ,144.6, 164.6, 139.4 ,127.3, 137.3, 144.0 ,141.4, 127.7 ,124.2 ,135.7 ,116.1 ,109.0, 131.0, 143.3 ,156.6 ,120.1, 131.8, 149.4 ,106.9, 135.6 ,164.6 ,162.6 ,134.8 ,154.0 ,120.7 ,151.9, 133.6 ,142.8 ,168.2 ,120.5, 135.6, 119.5 ,119.0 ,150.8, 144.0 , 124.7 ,154.4 ,136.7 ,152.4 ,133.6, 113.2 ,81.6 ,134.8, 130.4 ,162.1, 144.7 ,163.1, 137.1 ,156.0 ,127.2 ,121.4 ,155.3, 140.4) + +relation = lm(y~x1+x2+x3+x4) +print(summary(relation)) +anova(relation) +SSregression=1.8028+0.6973+2.4205+1.1856 +print(SSregression) +df=4 +MSregression=SSregression/df +print(MSregression) +MSresidual=0.08967 + +# test statistic +F=MSregression/MSresidual +print(F) +fvalue=qf(1-0.01,4,49) +# F>fvalue, therefore there is strong evidence in the data to reject the null hypothesis to reject the null hypothesis + + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.12/Ex12_12.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.12/Ex12_12.r new file mode 100644 index 00000000..b13daaf3 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.12/Ex12_12.r @@ -0,0 +1,15 @@ +# linear regression model : y= 0.15085 - 0.00288x1 - 0.00759x2 + 0.26528x3 +SStotal=3.328 +SSresidual=0.674 +n=21 +R2=(SStotal-SSresidual)/SStotal +print(R2) + +#test statistic +F=(R2/3)/((1-R2)/(n-4)) +print(F) +alpha=0.05 +fvalue=qf(1-alpha,df1=3,df2 = 17) +print(fvalue) +# Because the computed F statistic, , is greater than fvalue, we reject H0 and +#conclude that one or more of the x values has some predictive power diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.13/Ex12_13.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.13/Ex12_13.r new file mode 100644 index 00000000..bfb9de37 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.13/Ex12_13.r @@ -0,0 +1,13 @@ +beta1=.2652 +se=.1012 +n=21 +k=3 +df=n-(k+1) +alpha=0.025 +tvalue=qt(1-alpha,df) +print(tvalue) +left_i=beta1-tvalue*se +right_i=beta1+tvalue*se +print(" 95% confidence interval") +print(left_i) +print(right_i) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.14/Ex12_14.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.14/Ex12_14.r new file mode 100644 index 00000000..9a8858a4 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.14/Ex12_14.r @@ -0,0 +1,13 @@ +beta1=.01291 +se=.00283 +n=54 +k=4 +df=n-(k+1) +alpha=0.05 +tvalue=qt(1-alpha,df) +print(tvalue) +left_i=beta1-tvalue*se +right_i=beta1+tvalue*se +print(" 95% confidence interval") +print(left_i) +print(right_i) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.15/Ex12_15.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.15/Ex12_15.r new file mode 100644 index 00000000..d18c8699 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.15/Ex12_15.r @@ -0,0 +1,11 @@ +beta1=.01291 +se=.00283 +# test statistic +t=beta1/se +print(t) +n=54 +k=4 +df=n-(k+1) +alpha=0.05 +tvalue=qt(1-alpha,df) + #the computed value of the test statistic > tvalue . we conclude there is significant evidence to reject H0 \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.16/Ex12_16.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.16/Ex12_16.r new file mode 100644 index 00000000..c4b29904 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.16/Ex12_16.r @@ -0,0 +1,11 @@ +# test statistic +t=.26528/.10127 +print(t) +df=17 +t1value=qt(1-0.01,df) +t2value=qt(1-0.005,df) +print(t1value) +print(t2value) + # Thus, H0 would be rejected at the alpha= .01 level but not at the alpha= .005 level +pvalue =pt(-t, df) +print(pvalue) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.17/Ex12_17.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.17/Ex12_17.r new file mode 100644 index 00000000..1c06c1e0 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.17/Ex12_17.r @@ -0,0 +1,28 @@ +catch=c(3.6,.8,2.5,2.9,1.4,.9,3.2,2.7,2.2,5.9,3.3,2.9,3.6,2.4,.9,2.0,1.9,3.1,2.6,3.4) +residence=c(92.2,86.7,80.2,87.2,64.9,90.1,60.7,50.9,86.1,90.0,80.4,75.0,70.0,64.6,50.0,50.0,51.2,40.1,45.0,50.0) +size=c(.21,.30,.31,.40,.44,.56,.78,1.21,.34,.40,.52,.66,.78,.91,1.10,1.24,1.47,2.21,2.46,2.80) +access=c(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1) +structures=c(81,26,52,64,40,22,80,60,30,90,74,50,61,40,22,50,37,61,39,53) +relation = lm(catch~residence+size+access+structures) +print(summary(relation)) +anova(relation) + +# for reduced model +print(" for reduced model") +relation = lm(catch~residence+size) +print(summary(relation)) +anova(relation) +# complete linear regression model : -2.78 + .0268x1 + .504x2 + .743x3 + .0511x4 +# reduced model : -.87 + .0394x1 + .828x2 +# test statistic +SSregression_complete=24.0624 +SSregression_reduced=2.913 +Ssresidual_complete=2.2756 +n=20 +a=(SSregression_complete-SSregression_reduced)/2 +b=(Ssresidual_complete)/(n-5) +F=a/b +print(F) +fvalue=qf(1-.01,2,15) +print(fvalue) +# The value of the test statistic is much larger than the tabled value, so we have conclusive evidence that the access and structure variables add predictive value \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.2/Ex12_2.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.2/Ex12_2.r new file mode 100644 index 00000000..ba1e0ae5 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.2/Ex12_2.r @@ -0,0 +1,16 @@ +# model : y = b0 + b1x1 + b2x2 + b3x3 +e +#x1 = 1 if system 2 is used, x1 = 0 otherwise +#x2 = 1 if system 3 is used, x2 = 0 otherwise +#x3 = 1 if system 4 is used, x3 = 0 otherwise +u1=7 +u2=9 +u3=6 +u4=15 +b0=u1 +b1=u2-u1 +b2=u3-u1 +b3=u4-u1 +print(b0) +print(b1) +print(b2) +print(b3) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.21/Ex12_21.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.21/Ex12_21.zip new file mode 100644 index 00000000..cf41ac6e Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.21/Ex12_21.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.22/Ex12_22.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.22/Ex12_22.r new file mode 100644 index 00000000..27c0d0ff --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.22/Ex12_22.r @@ -0,0 +1,9 @@ + +CK <- c(20, 60, 100, 140, 180, 220, 260, 300, 340, 380, 420, 460, 500) +y <- cbind( c(2, 13, 30, 30, 21, 19, 18, 13, 19, 15, 7, 8, 35) , c(88, 26, 8, 5, 0, 1, 1, 1, 0, 0, 0, 0, 0)) +model1=glm(y~CK, family = binomial) +summary(model1) +cbind(CK,PRED=predict(model1,type = "response")) + # probability that a patient had a heart attack when the CK level in the patient was 140 is .868 + + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.26/Ex12_26.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.26/Ex12_26.r new file mode 100644 index 00000000..21fe66c3 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.26/Ex12_26.r @@ -0,0 +1,13 @@ +C <- matrix(c(-2,4,6,2,4,1),2,3) +D <- matrix(c(3,9,7,2,5,1,4,-2,8),3,3) +E <- matrix(c(4,8,1,-1,6,-6,0,4,7),3,3) +# C+D cannot be computed because of different dimensions. + +x=D+E +y=D-E +z=C%*%D +p=t(E) +x +y +z +p \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.27/Ex12_27.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.27/Ex12_27.r new file mode 100644 index 00000000..8f981cae --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.27/Ex12_27.r @@ -0,0 +1,14 @@ +B <- matrix(c(7,9,3,5),2,2) +C <- matrix(c(3,2,3,2,8,1,4,-2,8),3,3) +determinant_B=det(B) +determinant_C=det(C) +determinant_B +determinant_C +solve(B) +solve(C) +# B* inverse B +x=zapsmall(solve(B)%*%B) +x +# C* inverse C +y=zapsmall(solve(C)%*%C) +y diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.28/Ex12_28.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.28/Ex12_28.r new file mode 100644 index 00000000..55730eea --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.28/Ex12_28.r @@ -0,0 +1,11 @@ +Y <- matrix(c(25,19,33,23),4,1) +X <- matrix(c(1,1,1,1,-2,-2,2,2,5,-5,5,-5),4,3) +transpose_X=t(X) +transpose_X_X=transpose_X%*%X +transpose_X_Y=transpose_X%*%Y +inverse_transpose_X_X=solve(transpose_X_X) + +beta=inverse_transpose_X_X%*%transpose_X_Y +beta +# prediction equation is +y=25.0+1.5*x1+0.8*x2 \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.29/Ex12_29.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.29/Ex12_29.r new file mode 100644 index 00000000..b79cc134 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.29/Ex12_29.r @@ -0,0 +1,13 @@ +Y <- matrix(c(25,19,33,23),4,1) +X <- matrix(c(1,1,1,1,-2,-2,2,2,5,-5,5,-5),4,3) +transpose_X=t(X) +transpose_Y=t(Y) +transpose_X_X=transpose_X%*%X +transpose_X_Y=transpose_X%*%Y +inverse_transpose_X_X=solve(transpose_X_X) + +beta=inverse_transpose_X_X%*%transpose_X_Y +transpose_Y_Y=transpose_Y%*%Y +transpose_Y_Y +SSresidual=transpose_Y_Y-t(beta)%*%transpose_X_Y +SSresidual \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.3/Ex12_3.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.3/Ex12_3.r new file mode 100644 index 00000000..2312e64d --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.3/Ex12_3.r @@ -0,0 +1,8 @@ +u1=7 +u2=9 +u3=6 +u4=15 +x=(u3-u1)-(u2-u1) +y=(u3-u1)-(u4-u1) +print(x) +print(y) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.30/Ex12_30.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.30/Ex12_30.r new file mode 100644 index 00000000..a7c7159b --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.30/Ex12_30.r @@ -0,0 +1,15 @@ +Y <- matrix(c(25,19,33,23),4,1) +X <- matrix(c(1,1,1,1,-2,-2,2,2,5,-5,5,-5),4,3) +transpose_X=t(X) +transpose_Y=t(Y) +transpose_X_X=transpose_X%*%X +transpose_X_Y=transpose_X%*%Y +inverse_transpose_X_X=solve(transpose_X_X) + +beta=inverse_transpose_X_X%*%transpose_X_Y +transpose_Y_Y=transpose_Y%*%Y +SSresidual=transpose_Y_Y-t(beta)%*%transpose_X_Y +SSregression=t(beta)%*%transpose_X_Y-(sum(Y)^2/4) +SSregression +SStotal=SSregression+SSresidual +SStotal \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.31/Ex12_31.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.31/Ex12_31.r new file mode 100644 index 00000000..4db247b8 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.31/Ex12_31.r @@ -0,0 +1,15 @@ + ## prediction equation is + #y=25.0+1.5*x1+0.8*x2 +Y <- matrix(c(25,19,33,23),4,1) +X <- matrix(c(1,1,1,1,-2,-2,2,2,5,-5,5,-5),4,3) +transpose_X=t(X) +transpose_X_X=transpose_X%*%X +inverse_transpose_X_X=solve(transpose_X_X) +inverse_transpose_X_X +# for estimated standard error use inverse_trasnpose_X_X matrix +s_beta0=2*sqrt(0.25) +s_beta0 +s_beta1=2*sqrt(0.0625) +s_beta2=2*sqrt(0.01) +s_beta1 +s_beta2 diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.5/Ex12_5.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.5/Ex12_5.r new file mode 100644 index 00000000..2b8d01d0 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.5/Ex12_5.r @@ -0,0 +1,18 @@ +y=c(4.3,5.5,6.8,8.0,4.0,5.2,6.6,7.5,2.0,4.0,5.7,6.5) +x1=c(4,5,6,7,4,5,6,7,4,5,6,7) +x2=c(.20,.20,.20,.20,.30,.30,.30,.30,.40,.40,.40,.40) + +cbind(sum(y),sum(x1),sum(x2),sum(y*x1),sum(y*x2),sum(x1*x2),sum(x1^2),sum(x2^2)) +# three normal equations for this model +# 66.1=12*beta0+66*beta1+3.6*beta2 +# 383.3=66*beta0+378*beta1+19.8*beta2 +# 19.19=3.6*beta0+19.8*beta1+1.16*beta2 +relation = lm(y~x1+x2) +print(summary(relation)) +anova(relation) +# linear regression model : y=0.667+1.316*x1-8.000*x2 +x1=6.5 +x2=.35 +y=0.667+1.316*x1-8.000*x2 +print(y) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.6/Ex12_6.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.6/Ex12_6.r new file mode 100644 index 00000000..cd6a4dbe --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.6/Ex12_6.r @@ -0,0 +1,8 @@ +y=c(1.5 ,2.1, 1.8, 2.2, 2.2, 2.0, 2.1, 1.9, 2.8, 1.9, 2.0, 2.7, 2.4, 2.3, 2.0, 1.7, 2.3, 0.9, 1.2, 1.9, 0.8, 2.2, 2.3, 1.7, 1.6, 1.6, 2.8, 2.7, 1.3 ,2.1, 2.5, 1.5, 2.4, 2.3, 1.9, 1.5, 2.4, 2.3, 1.7 ,2.0 ,1.9, 2.3, 2.1, 2.2, 1.8, 2.1, 2.2, 1.3, 2.5, 2.2, 1.4, 2.2 ,2.5 ,1.8) +x1=c(139.8, 143.3, 154.2 ,176.6 ,154.3, 185.4, 177.9, 158.8, 159.8, 123.9, 164.2, 146.3, 172.6 ,147.5 ,163.0, 159.8 ,162.7, 133.3 ,142.8 ,146.6 ,141.6, 158.9, 151.9, 153.3 ,144.6, 133.3, 153.6, 158.6, 108.4, 157.4 ,141.7, 151.1, 149.5, 144.3 ,166.6 ,153.6 ,144.1, 148.7, 159.9, 162.8 ,145.7 ,156.7, 162.3, 164.7, 134.4, 160.1, 143.0, 141.6, 152.0, 187.1, 122.9, 157.1 ,155.1 ,133.6) +x2=c(19.1, 21.1, 21.2, 23.2, 22.4 ,22.1, 21.6, 19.0 ,20.9 ,22.0 ,19.5 ,19.8 ,20.7 ,21.0 ,21.2 ,20.4 ,20.0 ,21.1 ,22.6 ,23.0 ,22.1, 22.8 ,21.8 ,20.0 ,22.9 ,22.9 ,19.4 ,21.0 ,21.1 ,20.1 ,19.8 ,21.8 ,20.5 ,21.0, 21.4 ,20.8 ,20.3 ,19.1 ,19.6 ,21.3 ,20.0, 19.2 ,22.1 ,19.1, 20.9 ,21.1 ,20.5 ,21.7 ,20.8 ,21.5, 22.6 ,23.4 ,20.8, 22.5) +x3=c(18.1, 15.3, 15.3, 17.7, 17.1, 16.4, 17.3, 16.8, 15.5 ,13.8, 17.0, 13.8, 16.8, 15.3, 14.2, 16.8, 16.6, 17.5, 18.0 ,15.7 ,19.1, 13.4, 13.6, 16.1, 15.8 ,18.2 ,13.3, 14.9, 16.7 ,15.7, 13.5, 18.8 ,14.9 ,17.2 ,17.4, 16.4, 13.3, 15.4, 17.4, 16.2, 18.6, 16.4, 19.0, 17.1, 15.6, 14.2, 17.1, 14.5 ,17.3, 14.6, 18.6, 14.2, 16.0, 15.4) +x4=c(133.6 ,144.6, 164.6, 139.4 ,127.3, 137.3, 144.0 ,141.4, 127.7 ,124.2 ,135.7 ,116.1 ,109.0, 131.0, 143.3 ,156.6 ,120.1, 131.8, 149.4 ,106.9, 135.6 ,164.6 ,162.6 ,134.8 ,154.0 ,120.7 ,151.9, 133.6 ,142.8 ,168.2 ,120.5, 135.6, 119.5 ,119.0 ,150.8, 144.0 , 124.7 ,154.4 ,136.7 ,152.4 ,133.6, 113.2 ,81.6 ,134.8, 130.4 ,162.1, 144.7 ,163.1, 137.1 ,156.0 ,127.2 ,121.4 ,155.3, 140.4) + +relation = lm(y~x1+x2+x3+x4) +print(summary(relation)) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.8/Ex12_8.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.8/Ex12_8.r new file mode 100644 index 00000000..dd9aacfa --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.8/Ex12_8.r @@ -0,0 +1,15 @@ +y=c(1.5 ,2.1, 1.8, 2.2, 2.2, 2.0, 2.1, 1.9, 2.8, 1.9, 2.0, 2.7, 2.4, 2.3, 2.0, 1.7, 2.3, 0.9, 1.2, 1.9, 0.8, 2.2, 2.3, 1.7, 1.6, 1.6, 2.8, 2.7, 1.3 ,2.1, 2.5, 1.5, 2.4, 2.3, 1.9, 1.5, 2.4, 2.3, 1.7 ,2.0 ,1.9, 2.3, 2.1, 2.2, 1.8, 2.1, 2.2, 1.3, 2.5, 2.2, 1.4, 2.2 ,2.5 ,1.8) +x1=c(139.8, 143.3, 154.2 ,176.6 ,154.3, 185.4, 177.9, 158.8, 159.8, 123.9, 164.2, 146.3, 172.6 ,147.5 ,163.0, 159.8 ,162.7, 133.3 ,142.8 ,146.6 ,141.6, 158.9, 151.9, 153.3 ,144.6, 133.3, 153.6, 158.6, 108.4, 157.4 ,141.7, 151.1, 149.5, 144.3 ,166.6 ,153.6 ,144.1, 148.7, 159.9, 162.8 ,145.7 ,156.7, 162.3, 164.7, 134.4, 160.1, 143.0, 141.6, 152.0, 187.1, 122.9, 157.1 ,155.1 ,133.6) +x2=c(19.1, 21.1, 21.2, 23.2, 22.4 ,22.1, 21.6, 19.0 ,20.9 ,22.0 ,19.5 ,19.8 ,20.7 ,21.0 ,21.2 ,20.4 ,20.0 ,21.1 ,22.6 ,23.0 ,22.1, 22.8 ,21.8 ,20.0 ,22.9 ,22.9 ,19.4 ,21.0 ,21.1 ,20.1 ,19.8 ,21.8 ,20.5 ,21.0, 21.4 ,20.8 ,20.3 ,19.1 ,19.6 ,21.3 ,20.0, 19.2 ,22.1 ,19.1, 20.9 ,21.1 ,20.5 ,21.7 ,20.8 ,21.5, 22.6 ,23.4 ,20.8, 22.5) +x3=c(18.1, 15.3, 15.3, 17.7, 17.1, 16.4, 17.3, 16.8, 15.5 ,13.8, 17.0, 13.8, 16.8, 15.3, 14.2, 16.8, 16.6, 17.5, 18.0 ,15.7 ,19.1, 13.4, 13.6, 16.1, 15.8 ,18.2 ,13.3, 14.9, 16.7 ,15.7, 13.5, 18.8 ,14.9 ,17.2 ,17.4, 16.4, 13.3, 15.4, 17.4, 16.2, 18.6, 16.4, 19.0, 17.1, 15.6, 14.2, 17.1, 14.5 ,17.3, 14.6, 18.6, 14.2, 16.0, 15.4) +x4=c(133.6 ,144.6, 164.6, 139.4 ,127.3, 137.3, 144.0 ,141.4, 127.7 ,124.2 ,135.7 ,116.1 ,109.0, 131.0, 143.3 ,156.6 ,120.1, 131.8, 149.4 ,106.9, 135.6 ,164.6 ,162.6 ,134.8 ,154.0 ,120.7 ,151.9, 133.6 ,142.8 ,168.2 ,120.5, 135.6, 119.5 ,119.0 ,150.8, 144.0 , 124.7 ,154.4 ,136.7 ,152.4 ,133.6, 113.2 ,81.6 ,134.8, 130.4 ,162.1, 144.7 ,163.1, 137.1 ,156.0 ,127.2 ,121.4 ,155.3, 140.4) + +relation = lm(y~x1+x2+x3+x4) + +anova(relation) +SSresidual=4.3938 +df=49 # by looking at table given in question +# Std. Error of the Estimate +SE=sqrt(SSresidual/df) +print(SE) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.9/Ex12_9.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.9/Ex12_9.r new file mode 100644 index 00000000..d87f27b5 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH12/EX12.9/Ex12_9.r @@ -0,0 +1,12 @@ +y=c(1.5 ,2.1, 1.8, 2.2, 2.2, 2.0, 2.1, 1.9, 2.8, 1.9, 2.0, 2.7, 2.4, 2.3, 2.0, 1.7, 2.3, 0.9, 1.2, 1.9, 0.8, 2.2, 2.3, 1.7, 1.6, 1.6, 2.8, 2.7, 1.3 ,2.1, 2.5, 1.5, 2.4, 2.3, 1.9, 1.5, 2.4, 2.3, 1.7 ,2.0 ,1.9, 2.3, 2.1, 2.2, 1.8, 2.1, 2.2, 1.3, 2.5, 2.2, 1.4, 2.2 ,2.5 ,1.8) +x1=c(139.8, 143.3, 154.2 ,176.6 ,154.3, 185.4, 177.9, 158.8, 159.8, 123.9, 164.2, 146.3, 172.6 ,147.5 ,163.0, 159.8 ,162.7, 133.3 ,142.8 ,146.6 ,141.6, 158.9, 151.9, 153.3 ,144.6, 133.3, 153.6, 158.6, 108.4, 157.4 ,141.7, 151.1, 149.5, 144.3 ,166.6 ,153.6 ,144.1, 148.7, 159.9, 162.8 ,145.7 ,156.7, 162.3, 164.7, 134.4, 160.1, 143.0, 141.6, 152.0, 187.1, 122.9, 157.1 ,155.1 ,133.6) +x2=c(19.1, 21.1, 21.2, 23.2, 22.4 ,22.1, 21.6, 19.0 ,20.9 ,22.0 ,19.5 ,19.8 ,20.7 ,21.0 ,21.2 ,20.4 ,20.0 ,21.1 ,22.6 ,23.0 ,22.1, 22.8 ,21.8 ,20.0 ,22.9 ,22.9 ,19.4 ,21.0 ,21.1 ,20.1 ,19.8 ,21.8 ,20.5 ,21.0, 21.4 ,20.8 ,20.3 ,19.1 ,19.6 ,21.3 ,20.0, 19.2 ,22.1 ,19.1, 20.9 ,21.1 ,20.5 ,21.7 ,20.8 ,21.5, 22.6 ,23.4 ,20.8, 22.5) +x3=c(18.1, 15.3, 15.3, 17.7, 17.1, 16.4, 17.3, 16.8, 15.5 ,13.8, 17.0, 13.8, 16.8, 15.3, 14.2, 16.8, 16.6, 17.5, 18.0 ,15.7 ,19.1, 13.4, 13.6, 16.1, 15.8 ,18.2 ,13.3, 14.9, 16.7 ,15.7, 13.5, 18.8 ,14.9 ,17.2 ,17.4, 16.4, 13.3, 15.4, 17.4, 16.2, 18.6, 16.4, 19.0, 17.1, 15.6, 14.2, 17.1, 14.5 ,17.3, 14.6, 18.6, 14.2, 16.0, 15.4) +x4=c(133.6 ,144.6, 164.6, 139.4 ,127.3, 137.3, 144.0 ,141.4, 127.7 ,124.2 ,135.7 ,116.1 ,109.0, 131.0, 143.3 ,156.6 ,120.1, 131.8, 149.4 ,106.9, 135.6 ,164.6 ,162.6 ,134.8 ,154.0 ,120.7 ,151.9, 133.6 ,142.8 ,168.2 ,120.5, 135.6, 119.5 ,119.0 ,150.8, 144.0 , 124.7 ,154.4 ,136.7 ,152.4 ,133.6, 113.2 ,81.6 ,134.8, 130.4 ,162.1, 144.7 ,163.1, 137.1 ,156.0 ,127.2 ,121.4 ,155.3, 140.4) + +relation = lm(y~x1+x2+x3+x4) + +anova(relation) + +# cofficient of determination +summary(relation)$r.squared diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.10/Ex13_10.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.10/Ex13_10.zip new file mode 100644 index 00000000..fb047017 Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.10/Ex13_10.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.12/Ex13_12.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.12/Ex13_12.zip new file mode 100644 index 00000000..b86e1aad Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.12/Ex13_12.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.14/Ex13_14.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.14/Ex13_14.zip new file mode 100644 index 00000000..a931094b Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.14/Ex13_14.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.15/Ex13_15.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.15/Ex13_15.zip new file mode 100644 index 00000000..48a86f50 Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.15/Ex13_15.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.19/Ex13_19.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.19/Ex13_19.zip new file mode 100644 index 00000000..7a8ee156 Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.19/Ex13_19.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.3/Ex13_3.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.3/Ex13_3.zip new file mode 100644 index 00000000..393bdeb3 Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.3/Ex13_3.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.7/Ex13_7.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.7/Ex13_7.zip new file mode 100644 index 00000000..cf09d8bc Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.7/Ex13_7.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.9/Ex13_9.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.9/Ex13_9.zip new file mode 100644 index 00000000..78e5e476 Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH13/EX13.9/Ex13_9.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.1/Ex14_1.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.1/Ex14_1.r new file mode 100644 index 00000000..6e63bd1d --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.1/Ex14_1.r @@ -0,0 +1,5 @@ +# we obtain a random permutation of the numbers 1 to 16. +x=sample(1:16) +# We thus obtain the assignment of paints to the highway sections +values=c("P1","P1","P1","P1","P2","P2","P2","P2","P3","P3","P3","P3","P4","P4","P4","P4") +cbind(x,values) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.10/Ex14_10.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.10/Ex14_10.zip new file mode 100644 index 00000000..36853086 Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.10/Ex14_10.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.11/Ex14_11.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.11/Ex14_11.r new file mode 100644 index 00000000..540752c4 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.11/Ex14_11.r @@ -0,0 +1,20 @@ +y1bar=25.1 +y2bar=23.5 +y3bar=37.8 + +MSE=10.278 +sigma=sqrt(MSE) + +# crtical value +alpha = 0.025 +z.alpha=qt(1-alpha,df=15) + +# For panels 2 and 3, we have nt = 10 observations per panel, thus confidence interval will be +n=10 +error=sigma*z.alpha*sqrt(2/n) +# thus confidence interval will be +left_i=(y3bar-y2bar)-error +right_i=(y3bar-y2bar)+error +print("confidence interval is") +print(left_i) +print(right_i) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.12/Ex14_12.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.12/Ex14_12.r new file mode 100644 index 00000000..8101fe0a --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.12/Ex14_12.r @@ -0,0 +1,9 @@ +alpha=0.05 +q.alpha=qtukey(1-alpha,3,15) +n=10 +sw2=10.28 # calculated in 14.10 +W=q.alpha*(sqrt(sw2/n)) +W +sample_means=c(25.1,23.5,37.8) +# by ordering sample mean from lowest to highest , we rank display panels by 2 1 3 +# if diffrence between means > W then we declare them to be significantly different from each other \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.13/Ex14_13.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.13/Ex14_13.r new file mode 100644 index 00000000..522a6d0e --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.13/Ex14_13.r @@ -0,0 +1,10 @@ +sigma=(70-40)/4 + +alpha=0.025 +z.alpha=qnorm(1-alpha) + +E=4 #given +# number of replications is +n=((sigma^2)*(z.alpha^2))/E^2 +print(n) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.2/Ex14_2.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.2/Ex14_2.r new file mode 100644 index 00000000..ca5872e9 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.2/Ex14_2.r @@ -0,0 +1,25 @@ +paint_data=c(28, 35, 27, 21,21, 36, 25 ,18,26, 38, 27, 17,16, 25, 22, 18) +ybar=sum(paint_data)/length(paint_data) +print(ybar) +# total sum of squares +TSS=0 +i=1 +while(i<=length(paint_data)){ + TSS=TSS+(paint_data[i]-ybar)^2 + i=i+1 +} +print(TSS) +# between treatment sum of squares + +yi=c(mean(paint_data[1:4]),mean(paint_data[5:8]),mean(paint_data[9:12]),mean(paint_data[13:16])) + +SST=0 +j=1 +while(j<=length(paint_data)/4){ + SST=SST+4*((yi[j]-ybar)^2) + j=j+1 +} +print(SST) +# sum of squares for error +SSE=TSS-SST +print(SSE) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.6/Ex14_6.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.6/Ex14_6.zip new file mode 100644 index 00000000..cf49c43e Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.6/Ex14_6.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.7/Ex14_7.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.7/Ex14_7.zip new file mode 100644 index 00000000..6b56f4a0 Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH14/EX14.7/Ex14_7.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.1/Ex15_1.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.1/Ex15_1.zip new file mode 100644 index 00000000..284d4f09 Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.1/Ex15_1.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.11/Ex15_11.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.11/Ex15_11.r new file mode 100644 index 00000000..e04b41a6 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.11/Ex15_11.r @@ -0,0 +1,9 @@ +t=9 +v=16 +r=3 +sw2=2.847 +qvalue=qtukey(1-0.05,t,v) +W=qvalue*sqrt(sw2/r) +W + # any pair of treatment means having a difference between corresponding +#sample means exceeding 4.9 would be declared significantly different \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.12/Ex15_12.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.12/Ex15_12.zip new file mode 100644 index 00000000..addd0830 Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.12/Ex15_12.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.5/Ex15_5.zip b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.5/Ex15_5.zip new file mode 100644 index 00000000..4f756bdc Binary files /dev/null and b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.5/Ex15_5.zip differ diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.7/Ex15_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.7/Ex15_7.r new file mode 100644 index 00000000..9d227087 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH15/EX15.7/Ex15_7.r @@ -0,0 +1,9 @@ +MSR=11128.14 +MSC=544.44 +t=5 +MSE=2887.29 +# relative efficiency of this Latin square design relative to a completely randomized design is +re=(MSR+MSC+(t-1)*MSE)/((t+1)*MSE) +re + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.1/Ex3_1.R b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.1/Ex3_1.R new file mode 100644 index 00000000..50b46546 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.1/Ex3_1.R @@ -0,0 +1,12 @@ +selling_price<- c( 26.6, 25.3 ,23.8 ,24.0, 27.5, + 21.1 ,25.9 ,22.6, 23.8, 25.1, + 22.6 ,27.5 ,26.8 ,23.4, 27.5, + 20.8 ,20.4, 22.4 ,27.5, 23.7, + 22.2 ,23.8, 23.2, 28.7,27.5) + # The mode of a set of measurements is defined to be the measurement that occurs most often +table(selling_price) +# determining Mode +modal_selling_price<-table(selling_price) +print("modal selling price of data") +names(modal_selling_price)[which(modal_selling_price==max(modal_selling_price))] + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.10/Ex3_10.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.10/Ex3_10.r new file mode 100644 index 00000000..3264ea3a --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.10/Ex3_10.r @@ -0,0 +1,11 @@ +# simple varaince and standard deviation +ClassInterval <- c("16.25-18.75", "18.75-21.25", "21.25-23.75","23.75-26.25", "26.25-28.75", " 28.75-31.25", " 31.25-33.75", "33.75-36.25","36.25-38.75", " 38.75- 41.25","41.25- 43.75") +freq <- c( 2,7,7,14,17,24,11,11,3,3,1) +mid_interval<- c(17.5,20.0,22.5,25.0,27.5,30.0,32.5,35.0,37.5,40.0,42.5) +fmi<-freq*mid_interval + +mean_y<-sum(fmi)/sum(freq) +sample_variance <-(sum(freq*((mid_interval-mean_y)^2)/(sum(freq)-1))) +print(sample_variance) +standard_deviation <-sqrt(sample_variance) +print(standard_deviation) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.12/Ex3_12.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.12/Ex3_12.r new file mode 100644 index 00000000..9b78c40a --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.12/Ex3_12.r @@ -0,0 +1,14 @@ +y<-c(26 ,28 ,30, 37 ,33 ,30, + 29 ,39 ,49 ,31, 38 ,36, + 33 ,24, 34, 40 ,29, 41, + 40, 29, 35 ,44 ,32, 45, + 35 ,26, 42, 36 ,37 ,35) +mean_y<-sum(y)/length(y) +print(mean_y) +sample_variance <-(sum((y-mean_y)^2/(length(y)-1))) +print(sample_variance) +standard_deviation <-sqrt(sum((y-mean_y)^2/(length(y)-1))) +print(standard_deviation) +# we obtain an approximate value for s by dividing the range by 4: +s=(max(y)-min(y))/4; +print(s) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.13/Ex3_13.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.13/Ex3_13.r new file mode 100644 index 00000000..e77527d0 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.13/Ex3_13.r @@ -0,0 +1,10 @@ +crime_rate=c(876,578,718,388,562,971,698,298,673,537,642,856,376,508,529,393,354,735,811,504,807,719,464,410,491,557,771,685,448,571,189,661,877,563,647,447,336,526,624,605,496,296,628,481,224,868,804,210,421,435,291,393,605,341,352,374,267,684,685,460,466,498,562,739,562,817,690,720,758,731,480,559,505,703,809,706,631,626,639,585,570,928,516,885,751,561,1020,592,814,843) + +median(crime_rate) +lower_quartile=quantile(crime_rate,0.25) +lower_quartile +upper_quartile=quantile(crime_rate,0.75) +upper_quartile +IQR(crime_rate) +# book answer will vary because median is calculated wrong in book. + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.14/Ex3_14.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.14/Ex3_14.r new file mode 100644 index 00000000..26d93a89 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.14/Ex3_14.r @@ -0,0 +1,16 @@ +crime_rate=c(876,578,718,388,562,971,698,298,673,537,642,856,376,508,529,393,354,735,811,504,807,719,464,410,491,557,771,685,448,571,189,661,877,563,647,447,336,526,624,605,496,296,628,481,224,868,804,210,421,435,291,393,605,341,352,374,267,684,685,460,466,498,562,739,562,817,690,720,758,731,480,559,505,703,809,706,631,626,639,585,570,928,516,885,751,561,1020,592,814,843) + +lower_quartile= 464.5 +upper_quartile=718.5 # calculated in previous example + +iqr=IQR(crime_rate) + +lower_inner_fence= lower_quartile - (1.5*iqr) +upper_inner_fence= upper_quartile + (1.5*iqr) +lower_outer_fence= lower_quartile - (3*iqr) +upper_outer_fence= upper_quartile +(3*iqr) +print(lower_inner_fence) +print(upper_inner_fence) +print(lower_outer_fence) +print(upper_outer_fence) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.15/Ex3_15.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.15/Ex3_15.r new file mode 100644 index 00000000..b0792d00 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.15/Ex3_15.r @@ -0,0 +1,4 @@ +crime_rate=c(876,578,718,388,562,971,698,298,673,537,642,856,376,508,529,393,354,735,811,504,807,719,464,410,491,557,771,685,448,571,189,661,877,563,647,447,336,526,624,605,496,296,628,481,224,868,804,210,421,435,291,393,605,341,352,374,267,684,685,460,466,498,562,739,562,817,690,720,758,731,480,559,505,703,809,706,631,626,639,585,570,928,516,885,751,561,1020,592,814,843) + +boxplot(crime_rate, horizontal = TRUE, axes = FALSE, staplewex = 1) +text(x=fivenum(crime_rate), labels =fivenum(crime_rate), y=1.25) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.16/Ex3_16.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.16/Ex3_16.r new file mode 100644 index 00000000..a62332da --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.16/Ex3_16.r @@ -0,0 +1,10 @@ +x<-c(20,23,29,27,30,34,35,37,40,43) +y<-c(1.32,1.67,2.17,2.70,2.75,2.87,3.65,2.86,3.61,4.25) +z<-(x-mean(x))*(y-mean(y)) + +A<-sum(z) +p<-sum((x-mean(x))*(x-mean(x))) +q<-sum((y-mean(y))*(y-mean(y))) +B<-sqrt(p*q) +cofficient<-A/B +print((cofficient)) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.2/Ex3_2.R b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.2/Ex3_2.R new file mode 100644 index 00000000..8227829e --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.2/Ex3_2.R @@ -0,0 +1,17 @@ +# median +percentage<-c(95 ,86 ,78 ,90, 62, 73 ,89 ,92 ,84 ,76) +new_list<-sort(percentage) +n<-length(percentage) + +if(n%%2==0) { + a<-new_list[n/2] + print(a) + b<-new_list[(n/2)+1] + print(b) + print("medain is") + print((a+b)/2) +} else { + m<-(n+1)/2 + print("median s") + print(new_list[m]) +} \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.3/Ex3_3.R b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.3/Ex3_3.R new file mode 100644 index 00000000..c510025b --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.3/Ex3_3.R @@ -0,0 +1,20 @@ +# mean and median +productivity<-c(4.4 ,4.9, 4.2 ,4.4, 4.8 ,4.9, 4.8, 4.5, 4.3 ,4.8 ,4.7 ,4.4, 4.2) +new_list<-sort(productivity) +n<-length(productivity) + +if(n%%2==0) { + a<-new_list[n/2] + print(a) + b<-new_list[(n/2)+1] + print(b) + print("medain is") + print((a+b)/2) +} else { + m<-(n+1)/2 + print("output value of median is") + print(new_list[m]) +} +print(" output value of mode is ") +modal_productivity<-table(productivity) +names(modal_productivity)[which(modal_productivity==max(modal_productivity))] \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.4/Ex3_4.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.4/Ex3_4.r new file mode 100644 index 00000000..467de39f --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.4/Ex3_4.r @@ -0,0 +1,34 @@ +# median for interval data +Median_calculate <- function(frequencies, intervals, sep = NULL, trim = NULL) { + # If "sep" is specified, the function will try to create the + # required "intervals" matrix. "trim" removes any unwanted + # characters before attempting to convert the ranges to numeric. + if (!is.null(sep)) { + if (is.null(trim)) pattern <- "" + else if (trim == "cut") pattern <- "\\[|\\]|\\(|\\)" + else pattern <- trim + intervals <- sapply(strsplit(gsub(pattern, "", intervals), sep), as.numeric) + } + + Midpoints <- rowMeans(intervals) + cf <- cumsum(frequencies) + Midrow <- findInterval(max(cf)/2, cf) + 1 + L <- intervals[1, Midrow] # lower class boundary of median class + h <- diff(intervals[, Midrow]) # size of median class + f <- frequencies[Midrow] # frequency of median class + cf2 <- cf[Midrow - 1] # cumulative frequency class before median class + n_2 <- max(cf)/2 # total observations divided by 2 + + unname(L + (n_2 - cf2)/f * h) +} + + +mydataframe <- structure(list(Class_interval = c("16.25-18.75", "18.75-21.25", "21.25-23.75", + "23.75-26.25", "26.25-28.75", " 28.75-31.25", " 31.25-33.75", "33.75-36.25", + "36.25-38.75", " 38.75- 41.25","41.25- 43.75"), freq = c(2L, 7L, 7L, 14L, + 17L, 24L, 11L, 11L, 3L, 3L,1L)), .Names = c("class_interval", "freq"), + class = "data.frame", row.names = c(NA, -11L)) +print(mydataframe) + +Median_calculate(mydataframe$freq, mydataframe$class_interval, sep = "-") + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.5/Ex3_5.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.5/Ex3_5.r new file mode 100644 index 00000000..2c4462e1 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.5/Ex3_5.r @@ -0,0 +1,12 @@ +# mean +accounts_due<-c(55.20, 4.88 ,271.95, + 18.06, 180.29, 365.29, + 28.16, 399.11 ,807.80, + 44.14, 97.47, 9.98, + 61.61, 56.89 ,82.73) +n<-sum(accounts_due) +d<-length(accounts_due) +mean_accountsdue<-n/d +print(mean_accountsdue) +total_overdueamount=150*mean_accountsdue +print(total_overdueamount) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.6/Ex3_6.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.6/Ex3_6.r new file mode 100644 index 00000000..bb98a7a8 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.6/Ex3_6.r @@ -0,0 +1,13 @@ + # mean for interval data +ClassInterval <- c("16.25-18.75", "18.75-21.25", "21.25-23.75","23.75-26.25", "26.25-28.75", " 28.75-31.25", " 31.25-33.75", "33.75-36.25","36.25-38.75", " 38.75- 41.25","41.25- 43.75") +freq <- c( 2,7,7,14,17,24,11,11,3,3,1) +mid_interval<- c(17.5,20.0,22.5,25.0,27.5,30.0,32.5,35.0,37.5,40.0,42.5) +fmi<-freq*mid_interval + +List<- data.frame(ClassInterval, freq, mid_interval,fmi) +print(List) +print("mean is") +print(sum(fmi)/sum(freq)) + + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.7/Ex3_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.7/Ex3_7.r new file mode 100644 index 00000000..6684a69c --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.7/Ex3_7.r @@ -0,0 +1,9 @@ +# range +accounts_due<-c(55.20, 4.88 ,271.95, + 18.06, 180.29, 365.29, + 28.16, 399.11 ,807.80, + 44.14, 97.47, 9.98, + 61.61, 56.89 ,82.73) +range(accounts_due) +diff=max(accounts_due)-min(accounts_due) +print(diff) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.8/Ex3_8.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.8/Ex3_8.r new file mode 100644 index 00000000..2a22fe14 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.8/Ex3_8.r @@ -0,0 +1,8 @@ +# pth percentile +L <- 33.75 +n <- 100 +cfb <- 82 +f90 <- 11 +w <-2.5 +P<-L+(w/f90)*(0.9*n-cfb) +print(P) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.9/Ex3_9.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.9/Ex3_9.r new file mode 100644 index 00000000..296fa2bc --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH3/EX3.9/Ex3_9.r @@ -0,0 +1,4 @@ +y <- c(5,4,3,1,3) +mean_y<-sum(y)/length(y) +sample_variance <-(sum((y-mean_y)^2/(length(y)-1))) +print(sample_variance) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.1/Ex4_1.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.1/Ex4_1.r new file mode 100644 index 00000000..2ba76d2f --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.1/Ex4_1.r @@ -0,0 +1,12 @@ + # probability +# given +probability_A<-0.5 +probability_A_Compliment<-1 - probability_A +print(probability_A_Compliment) +probability_B<-0.2 +probability_B_Compliment<-1 - probability_B +print(probability_B_Compliment) +probability_A_intersection_B<-0.05 +print(probability_A_intersection_B) +probability_A_union_B<-probability_A+probability_B-probability_A_intersection_B +print(probability_A_union_B) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.10/Ex4_10.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.10/Ex4_10.r new file mode 100644 index 00000000..92869a90 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.10/Ex4_10.r @@ -0,0 +1,10 @@ +# Mean and Standard Deviation of the Binomial Probability Distribution +#number of trials +n<-20 +# the probability of success of single event is +z<-0.85 +Mean<-n*z +print(Mean) +standard_deviation=sqrt(n*z*(1-z)) +print(standard_deviation) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.11/Ex4_11.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.11/Ex4_11.r new file mode 100644 index 00000000..b840f3eb --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.11/Ex4_11.r @@ -0,0 +1,15 @@ +# Mean and Standard Deviation of the Binomial Probability Distribution +#number of trials +n<-1218 +# the probability of success of single event is +z<-0.5 +Mean<-n*z +print(Mean) +standard_deviation=sqrt(n*z*(1-z)) +print(standard_deviation) +# survey of 1,218 customersrevealsthat 516 would add the new service +observed_valueof_y=516 +# y = 516 is more than (3 * standard_deviation), or 52.35, less than Mean +# thus the observed number of customers in sample who would add the new service is too small +print(" Consequently, the company concluded that offering the new service was not a good idea") + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.12/Ex4_12.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.12/Ex4_12.r new file mode 100644 index 00000000..64653ee5 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.12/Ex4_12.r @@ -0,0 +1,18 @@ +# Poisson Distribution +# Poisson probability of observing y events in a unit of time or space is given by the formula +# probability_y<-((U^y)*(e^-U))/factorial(y) +# U is the average value of y +U<-2.3 +# The probability that a trap contains exactly four field mice is computed +y<-4 +probability_findingexactlyfour<-((U^y)*(exp(1)^-U))/factorial(y) +print(probability_findingexactlyfour) +# The probability That a trap contains atmost four feild mice is computed as +probability_findingatmost_four=(((U^0)*(exp(1)^-U))/factorial(0))+(((U^1)*(exp(1)^-U))/factorial(1))+(((U^2)*(exp(1)^-U))/factorial(2))+(((U^3)*(exp(1)^-U))/factorial(3))+(((U^4)*(exp(1)^-U))/factorial(4)) +print(probability_findingatmost_four) +# The probability of finding more than four field mice +probability_findingmorethanfour=1-probability_findingatmost_four +print(probability_findingmorethanfour) + + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.13/Ex4_13.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.13/Ex4_13.r new file mode 100644 index 00000000..3caeab20 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.13/Ex4_13.r @@ -0,0 +1,17 @@ +#number of trials +n<-1000 +# the probability of success of single event is +z<-0.001 +Mean<-n*z +print(Mean) + # Applying the Poisson probability distribution with U= 1 + +U<-1 +# probability that none of a patients administered the drug experiences a particular side effect + +y<-0 +probability_nopatientsideeffect<-((U^y)*(exp(1)^-U))/factorial(y) +print(probability_nopatientsideeffect) + + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.15/Ex4_15.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.15/Ex4_15.r new file mode 100644 index 00000000..1a054f30 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.15/Ex4_15.r @@ -0,0 +1,5 @@ +# calculate probability in normal distribution with R +# variable y with normal distribution N(??, ??), where ??=20 and ?? = 2 +# pnorm function gives the probability of a normally distributed random number to be less that the value of a given number. +# the probability that a measurement will be less than 23 is given by +pnorm(23,mean =20,sd=2) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.16/Ex4_16.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.16/Ex4_16.r new file mode 100644 index 00000000..610c78fe --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.16/Ex4_16.r @@ -0,0 +1,5 @@ +# calculate probability in normal distribution with R +# variable y with normal distribution N(??, ??), where ??=20 and ?? = 2 +# pnorm function gives the probability of a normally distributed random number to be less that the value of a given number. +# the probability that a measurement will be less than 16 is given by +pnorm(16,mean =20,sd=2) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.17/Ex4_17.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.17/Ex4_17.r new file mode 100644 index 00000000..427cc63f --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.17/Ex4_17.r @@ -0,0 +1,8 @@ +# variable y with normal distribution N(??, ??), where ??=70 and ?? = 13 +# the probability that a measurement will be less than 60 is given by +pnorm(60,mean =70,sd=13) +# probability that a randomly selected vehicle will have emission levels greater than 90 ppb +pnorm(90,mean =70,sd=13,lower.tail = FALSE) +# the probability that a randomly selected vehicle will have emission levels between 60 and 90 ppb +pnorm(90,mean =70,sd=13)-pnorm(60,mean =70,sd=13) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.18/Ex4_18.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.18/Ex4_18.r new file mode 100644 index 00000000..248b629b --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.18/Ex4_18.r @@ -0,0 +1,4 @@ +# percentile of normal distribution using r +# we will use qnorm function +# 10 th percentile of Normal distribution Mean = 70 and SD=13 +qnorm(0.10,70,13) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.19/Ex4_19.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.19/Ex4_19.r new file mode 100644 index 00000000..7d8c7621 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.19/Ex4_19.r @@ -0,0 +1,11 @@ +# percentile of normal distribution using r +# we will use qnorm function +# 75th percentile of Normal distribution Mean = 530 and SD=205 +mu=530 +sigma=205 +z_75percentile=0.67 +y=mu+sigma*z_75percentile +print(y) + print(" Thus , 25% of the tax returns in this classification exceed $667.35 in the amount owed the government.") + + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.2/Ex4_2.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.2/Ex4_2.r new file mode 100644 index 00000000..d7f70453 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.2/Ex4_2.r @@ -0,0 +1,4 @@ +probability_A<-0.6 +probability_B_BY_A<-5/9 +probability_A_intersection_B<-probability_A*probability_B_BY_A +print(probability_A_intersection_B) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.20/Ex4_20.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.20/Ex4_20.r new file mode 100644 index 00000000..22917d25 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.20/Ex4_20.r @@ -0,0 +1,7 @@ +cities<-c("c1","c2","c3","c4","c5","c6","c7","c8","c9","c10") +# All possible samples are +t(combn(cities, 2)) +total_pairs<-nrow(t(combn(cities, 2))) +# the probability associated with each sample in a random sample of 2 cities selected from the population +probability_selecting2cities<-1/total_pairs +print(probability_selecting2cities) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.21/Ex4_21.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.21/Ex4_21.r new file mode 100644 index 00000000..d4c6649a --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.21/Ex4_21.r @@ -0,0 +1,5 @@ +student<-c(0:849) +# we can sample number of students according to our wish using sample function +sample(student , 20) +# We would repeat the process in subsequent weeks . + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.22/Ex4_22.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.22/Ex4_22.r new file mode 100644 index 00000000..738421ad --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.22/Ex4_22.r @@ -0,0 +1,9 @@ +population<-c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) +# There are 45 possible samples of 2 items selected from the 10 items. +combn(population, 2) +samps<-combn(population, 2) +xbars <- colMeans(samps) +table(xbars) +prop.table(table(xbars)) + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.24/Ex4_24.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.24/Ex4_24.r new file mode 100644 index 00000000..e6d04a24 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.24/Ex4_24.r @@ -0,0 +1,17 @@ +# y has a normal distribution with mean = 160 and sd = 20. +# the probability that a single blood pressure measurement will fail to detect that the patient has high blood pressure is <150 +pnorm(150,mean =160,sd=20) +# If five blood pressure measurements are taken at various times during the day +sd <-20/sqrt(5) + # the probability that the average of the five measurements will be less than 150 +pnorm(150,160,sd=8.94) +# measurements would be required in a given day so that there +#is at most 1% probability of failing to detect that the patient has high blood pressure +standard_deviation=20 +n=((-2.326*standard_deviation)/(150-160))^2 +print(n) +# It would require at least 22 measurements in order to achieve +# the goal of at most a 1% chance of failing to detect high blood pressure. + + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.25/Ex4_25.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.25/Ex4_25.r new file mode 100644 index 00000000..dd39b652 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.25/Ex4_25.r @@ -0,0 +1,9 @@ +# Normal Approximation to the Binomial +# number of trails +n<-1000 +# probability of success of single event +z<-0.5 +Mean<-n*z +s<-sqrt(n*z*(1-z)) + # the probability of observing 460 or fewer +pnorm(460,mean=Mean,sd=s) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.26/Ex4_26.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.26/Ex4_26.r new file mode 100644 index 00000000..bb3a93c8 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.26/Ex4_26.r @@ -0,0 +1,9 @@ +# Normal Approximation to the Binomial +# number of trails +n<-100 +# probability of success of single event +z<-0.2 +Mean<-n*z +s<-sqrt(n*z*(1-z)) +# e probability that at least 15 of the 100 drugs are eventually licensed (>14.5) +pnorm(14.5, mean=Mean, sd=s, lower.tail=FALSE) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.27/Ex4_27.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.27/Ex4_27.r new file mode 100644 index 00000000..299890d5 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.27/Ex4_27.r @@ -0,0 +1,8 @@ +Cholesterol_Reading=c(133,137,148,149,152,167,174,179,189,192,201,209,210,211,218,238,245,248,253,257) +normal_quantile=c(-1.96,-1.44,-1.15,-.935,-.755,-.598,-.454,-.319,-.189,-.063,.063,.189,.319,.454,.598,.755,.935,1.15,1.44,1.96) +plot(normal_quantile,Cholesterol_Reading) +model1=lm(Cholesterol_Reading~normal_quantile) +summary(model1) + # Cholesterol = 195.5 + 39.4884 Normal Quantiles +# . The 20 points appear to be relatively close to the fitted line and thus the normal quantile plot would appear to suggest that the normality of the population distribution is plausible. + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.28/Ex4_28.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.28/Ex4_28.r new file mode 100644 index 00000000..aa439a1a --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.28/Ex4_28.r @@ -0,0 +1,10 @@ +#corrrlation cofficient +# Cholesterol Reading +y=c(133,137,148,149,152,167,174,179,189,192,201,209,210,211,218,238,245,248,253,257) +#Normal Quantile +x=c(-1.868,-1.403,-1.128,-.919,-.744,-.589,-.448,-.315,-.187,-.062,.062,.187,.315,.448,.589,.744,.919,1.128,1.403,1.868) + +# correlation cofficient + cor(y,x) + + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.3/Ex4_3.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.3/Ex4_3.r new file mode 100644 index 00000000..4db29514 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.3/Ex4_3.r @@ -0,0 +1,10 @@ +probability_light=0.50 +probability_medium=0.30 +probability_heavy=0.20 +# probability that member is light , medium and heavy and no books borrow +probability_0_light=0.60 +probability_0_medium=0.15 +probability_0_heavy=0.05 +# the probability that the member is a light purchaser and purchases no books in 3 months +p=(probability_light*probability_0_light)/((probability_light*probability_0_light)+(probability_medium*probability_0_medium)+(probability_heavy*probability_0_heavy)) +print(p) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.4/Ex4_4.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.4/Ex4_4.r new file mode 100644 index 00000000..a26285bc --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.4/Ex4_4.r @@ -0,0 +1,20 @@ +p_d1=0.028 +p_d2=0.012 +p_d3=0.032 +p_d4=0.928 +p_a4_d1=0.02 +p_a4_d2=0.09 +p_a4_d3=0.10 +p_a4_d4=0.95 +# the probabilities that the board has no defect or a D1, D2, or D3 type of defect +p_nodefect_or_d1=(p_d1*p_a4_d1)/((p_d1*p_a4_d1)+(p_d2*p_a4_d2)+(p_d3*p_a4_d3)+(p_d4*p_a4_d4)) +print(p_nodefect_or_d1) + +p_nodefect_or_d2=(p_d2*p_a4_d2)/((p_d1*p_a4_d1)+(p_d2*p_a4_d2)+(p_d3*p_a4_d3)+(p_d4*p_a4_d4)) +print(p_nodefect_or_d2) + +p_nodefect_or_d3=(p_d3*p_a4_d3)/((p_d1*p_a4_d1)+(p_d2*p_a4_d2)+(p_d3*p_a4_d3)+(p_d4*p_a4_d4)) +print(p_nodefect_or_d3) + +p_nodefect_or_d4=(p_d4*p_a4_d4)/((p_d1*p_a4_d1)+(p_d2*p_a4_d2)+(p_d3*p_a4_d3)+(p_d4*p_a4_d4)) +print(p_nodefect_or_d4) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.7/Ex4_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.7/Ex4_7.r new file mode 100644 index 00000000..f85ea509 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.7/Ex4_7.r @@ -0,0 +1,14 @@ +# The probability of observing y successes in n trials of a binomial experiment +# number of trials +n<-20 +# let probability of success on a single trial be z +z<-0.85 +# probability that 18 or more of the 20 seeds will germinate? +y<-18 +probability_for18seeds<-(factorial(n))/(factorial(y)*factorial(n-y))*(z^y)*(1-z)^(n-y) +y<-19 +probability_for19seeds<-(factorial(n))/(factorial(y)*factorial(n-y))*(z^y)*(1-z)^(n-y) +y<-20 +probability_for20seeds<-(factorial(n))/(factorial(y)*factorial(n-y))*(z^y)*(1-z)^(n-y) +total_probability<-probability_for18seeds+probability_for19seeds+probability_for20seeds +print(total_probability) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.8/Ex4_8.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.8/Ex4_8.r new file mode 100644 index 00000000..e8d64c1f --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.8/Ex4_8.r @@ -0,0 +1,8 @@ +#number of trials +n<-5 +# the probability of success when one person is selected from the population is +z<-0.9 +# probability that all five heads of the households are employed +y<-5 +probability_forall5employed<-(factorial(n))/(factorial(y)*factorial(n-y))*(z^y)*(1-z)^(n-y) +print(probability_forall5employed) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.9/Ex4_9.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.9/Ex4_9.r new file mode 100644 index 00000000..16a912ec --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH4/EX4.9/Ex4_9.r @@ -0,0 +1,12 @@ +#number of trials +n<-5 +# the probability of success when one person is selected from the population is +z<-0.9 +# probability that exactly one person in the sample of five households is unemployed. + +y<-4 +probability_forexactone_unemployed<-(factorial(n))/(factorial(y)*factorial(n-y))*(z^y)*(1-z)^(n-y) +print(probability_forexactone_unemployed) +# the probability of one or fewer being unemployed +probability_foroneorfew_unemployed=((factorial(n))/(factorial(4)*factorial(n-4))*(z^4)*(1-z)^(n-4))+((factorial(n))/(factorial(5)*factorial(n-5))*(z^5)*(1-z)^(n-5)) +print(probability_foroneorfew_unemployed) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.1/Ex5_1.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.1/Ex5_1.r new file mode 100644 index 00000000..172e1dcf --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.1/Ex5_1.r @@ -0,0 +1,11 @@ +# Calculating a Confidence Interval From a Normal Distribution +n<-50 + a<-2.8 + s<-0.6 + # we will use a 95% confidence level and wish to find the confidence interval + margin <- qnorm(0.975)*s/sqrt(n) + left_i <- a-margin + right_i <- a+margin + print("Confidence interval is") + print(left_i) + print(right_i) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.10/Ex5_10.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.10/Ex5_10.r new file mode 100644 index 00000000..62e37921 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.10/Ex5_10.r @@ -0,0 +1,17 @@ +ybar=33 +sigma=8.4 +n=35 +alpha = .05 +# critical value +z.alpha = qnorm(1-alpha) +z1=function(mu0){ + z=abs((ybar- mu0)/(sigma/sqrt(n))) + b=pnorm(z.alpha-z) + return(b) +} +muo=c(33,32,31,30,29,28,27,26,25) +beta=c(z1(33),z1(32),z1(31),z1(30),z1(29),z1(28),z1(27),z1(26),z1(25)) +pwr=1-beta +rbind(muo,beta,pwr) + + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.11/Ex5_11.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.11/Ex5_11.r new file mode 100644 index 00000000..48629aa7 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.11/Ex5_11.r @@ -0,0 +1,9 @@ +sd<-.225 +z_foralpha=qnorm(1-0.05) +z_forbeta=qnorm(1-0.01) +zstar<-z_foralpha+z_forbeta +E<-16.37 - 16.27 +sample_size<- zstar^2 * sd * sd/ E^2 +print(ceiling(sample_size)) +# the manufacturer must obtain a random sample of n = 80 boxes to conduct this test + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.12/Ex5_12.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.12/Ex5_12.r new file mode 100644 index 00000000..ab925424 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.12/Ex5_12.r @@ -0,0 +1,17 @@ + +ybar = 390 # sample mean +mu0 = 380 # hypothesized value +sigma = 35.2 # population standard deviation +n = 50 # sample size +z = (ybar- mu0)/(sigma/sqrt(n)) + # test statistic + +p_value=1-pnorm(z) +print(p_value) +alpha=0.01 +if(p_value>alpha){ + print("we fail to reject H0") +print(" data do not support the research hypothesis.") + }else{ + print("reject H0") + } diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.13/Ex5_13.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.13/Ex5_13.r new file mode 100644 index 00000000..6933ab6b --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.13/Ex5_13.r @@ -0,0 +1,17 @@ + +ybar = 31.2 # sample mean +mu0 = 33 # hypothesized value +sigma = 8.4 # population standard deviation +n = 35 # sample size +z = (ybar- mu0)/(sigma/sqrt(n)) +# test statistic + +p_value=pnorm(z) +print(p_value) +alpha=0.05 +if(p_value>alpha){ + print("we fail to reject H0") + print(" data do not support the research hypothesis(insufficient evidence).") +}else{ + print("reject H0") +} diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.14/Ex5_14.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.14/Ex5_14.r new file mode 100644 index 00000000..4e5f7eb0 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.14/Ex5_14.r @@ -0,0 +1,20 @@ + +ybar = 178.2 # sample mean +mu0 = 190 # hypothesized value +sigma = 45.3 # population standard deviation +n = 100 # sample size +z = (ybar- mu0)/(sigma/sqrt(n)) +print(z) +k=abs(z) +# test statistic + # formula based on level of significance +p_value=2*(1-pnorm(k)) +print(p_value) +# mentioned p value in book is wrong +alpha=0.01 +if(p_value>alpha){ + print("we fail to reject H0") + print(" data do not support the research hypothesis(insufficient evidence).") +}else{ + print(" there is very little evidence in the data to support the research hypothesis hence we will reject H0") +} diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.15/Ex5_15.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.15/Ex5_15.r new file mode 100644 index 00000000..1ef29e4b --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.15/Ex5_15.r @@ -0,0 +1,17 @@ +y<-c(.593 ,.142, .329, .691 ,.231 ,.793 ,.519 ,.392, .418 ) +ybar = mean(y) +mu0 = 0.3 +sigma = sd(y) +n = 9 # sample size +z = abs((ybar- mu0)/(sigma/sqrt(n))) +print(z) +p_value=2*(1-pnorm(z)) +print(p_value) +alpha=0.01 +if(p_value>alpha){ + print("we fail to reject H0") + print(" data do not support the research hypothesis(insufficient evidence).") +}else{ + print("reject H0") +} + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.17/Ex5_17.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.17/Ex5_17.r new file mode 100644 index 00000000..0305c2b6 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.17/Ex5_17.r @@ -0,0 +1,17 @@ +confidence_interval <- function(vector, interval) { + # Standard deviation of sample + vec_sd <- sd(vector) + # Sample size + n <- length(vector) + # Mean of sample + vec_mean <- mean(vector) + # Error according to t distribution + error <- qt((interval + 1)/2, df = n - 1) * vec_sd / sqrt(n) + # Confidence interval as a vector + ans <- c("lower" = vec_mean - error, "upper" = vec_mean + error) + return(ans) +} +vector <- c(2.7, 2.4, 1.9, 2.6, 2.4, 1.9, 2.3, + 2.2, 2.5 ,2.3 ,1.8, 2.5, 2.0 ,2.2 ) +confidence_interval(vector, 0.95) + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.18/Ex5_18.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.18/Ex5_18.r new file mode 100644 index 00000000..c7f07688 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.18/Ex5_18.r @@ -0,0 +1,15 @@ +confidence_interval <- function(vector, interval) { + # Standard deviation of sample + vec_sd <- sd(vector) + # Sample size + n <- length(vector) + # Mean of sample + vec_mean <- mean(vector) + # Error according to t distribution + error <- qt((interval + 1)/2, df = n - 1) * vec_sd / sqrt(n) + # Confidence interval as a vector + ans <- c("lower" = vec_mean - error, "upper" = vec_mean + error) + return(ans) +} +vector <- c( 29, 30, 53, 75, 89, 34, 21, 12, 58, 84, 92, 117, 115, 119, 109, 115, 134, 253, 289, 287 ) +confidence_interval(vector, 0.95) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.19/Ex5_19.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.19/Ex5_19.r new file mode 100644 index 00000000..9109299f --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.19/Ex5_19.r @@ -0,0 +1,18 @@ + +ybar = 105.75 # sample mean +mu0 = 75 # hypothesized value +sigma = 82.429 # population standard deviation +n = 20 # sample size +# test statistic +t = abs((ybar- mu0)/(sigma/sqrt(n))) + print(t) + +# formula based on level of significance + m=33 + B=1000 +p_value= m/B + print(p_value) +alpha=0.05 +# our p value< alpha , therfore +print("we conclude that there is sufficient evidence that the mean cotanine level exceeds 75 in the population of children under CPS supervision") + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.2/Ex5_2.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.2/Ex5_2.r new file mode 100644 index 00000000..d7d978ba --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.2/Ex5_2.r @@ -0,0 +1,11 @@ +# Calculating a Confidence Interval From a Normal Distribution +n<-50 +a<-27.3 +s<-12.1 +# we will use a 99% confidence level and wish to find the confidence interval +margin <- qnorm(0.995)*s/sqrt(n) +left_i <- a-margin +right_i <- a+margin +print("Confidence interval is") +print(left_i) +print(right_i) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.20/Ex5_20.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.20/Ex5_20.r new file mode 100644 index 00000000..e0cc239b --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.20/Ex5_20.r @@ -0,0 +1,6 @@ +x<-c(14.2, 5.3 ,2.9, 4.2,1.2, 4.3, 1.1, 2.6 ,6.7 ,7.8 ,25.9, 43.8, 2.7, + 5.6, 7.8 ,3.9, 4.7, 6.5, 29.5 ,2.1 ,34.8 ,3.6 ,5.8, 4.5, 6.7 ) +bootmed = apply(matrix(sample(x, rep=TRUE, 10^4*length(x)), nrow=10^4), 1, median) +# The 95% confidence interval for the population median is given by +print("Confidence interval is") + quantile(bootmed, c(.025, 0.975)) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.21/Ex5_21.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.21/Ex5_21.r new file mode 100644 index 00000000..6896978f --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.21/Ex5_21.r @@ -0,0 +1,6 @@ +# large scale approximation +n<-25 +alpha<-0.05 +z.half.alpha=qnorm(1-alpha/2) +C_alpha2_n=(n/2)-z.half.alpha*sqrt(n/4) +print(C_alpha2_n) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.23/Ex5_23.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.23/Ex5_23.r new file mode 100644 index 00000000..995714a6 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.23/Ex5_23.r @@ -0,0 +1,13 @@ +# Large-Sample Approximation +n=25 +B=13 +# test statstic +Bst=(B-(n/2))/(sqrt(n/4)) +print(Bst) +# critical value +alpha=0.05 +z.alpha=qnorm(1-alpha/2) +print(z.alpha) +print("e BST is not greater than z.alpha, we fail to reject H0") +pvalue=1-pnorm(Bst) +print(pvalue) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.3/Ex5_3.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.3/Ex5_3.r new file mode 100644 index 00000000..556b3a57 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.3/Ex5_3.r @@ -0,0 +1,10 @@ +# the 95% confidence level would imply the 97.5th percentile of the normal distribution at the upper tail +zstar <-qnorm(.975) +# standard deviation + sd <- 125 + # level of accuracy + E <- 25 +sample_size<- zstar^2 * sd * sd/ E^2 + print(ceiling(sample_size)) + # A sample size of 97 or larger is recommended to obtain an estimate of the mean textbook + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.4/Ex5_4.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.4/Ex5_4.r new file mode 100644 index 00000000..167cdf05 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.4/Ex5_4.r @@ -0,0 +1,8 @@ +# the 99% confidence level would imply the 99.5th percentile of the normal distribution at the upper tail +zstar <- qnorm(0.995) +width_interval<-0.50 +E<-width_interval/2 +sd<-0.75 +sample_size<- zstar^2 * sd * sd/ E^2 +print(ceiling(sample_size)) +# the federal agency must obtain a random sample of 60 cereal cartons to estimate . \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.5/Ex5_5.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.5/Ex5_5.r new file mode 100644 index 00000000..658626d5 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.5/Ex5_5.r @@ -0,0 +1,15 @@ +# Hypothesis Testing or one-tailed test + +ybar = 573 # sample mean + mu0 = 520 # hypothesized value + sigma = 124 # population standard deviation + n = 36 # sample size + z = (ybar- mu0)/(sigma/sqrt(n)) + print(z) # test statistic + + # We then compute the critical value at .025 significance level. + # For alpha= .025, reject the null hypothesis if lies more than 1.96 + alpha = .025 + z.alpha = qnorm(1-alpha) + print(z.alpha) + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.6/Ex5_6.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.6/Ex5_6.r new file mode 100644 index 00000000..f79bca1c --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.6/Ex5_6.r @@ -0,0 +1,17 @@ +# two tailed test +ybar = 178.2 # sample mean +mu0 = 190 # hypothesized value +sigma = 45.3 # population standard deviation +n = 100 # sample size +# We compute the critical value at .025 significance level. +alpha = .05 +z.half.alpha = qnorm(1-alpha/2) +# critical values +lr=mu0-(z.half.alpha*sigma)/sqrt(n) +ur=mu0+(z.half.alpha*sigma)/sqrt(n) +paste0(" lower rejection = ",lr) +paste0("upper rejection = ",ur) +z = (ybar- mu0)/(sigma/sqrt(n)) +print(z) # test statistic + + print("The test statistic doesnot lies between the critical values(i.e. |z|>critical value). Hence, at .025 significance level, we reject the null hypothesis") diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.7/Ex5_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.7/Ex5_7.r new file mode 100644 index 00000000..f5bdb33c --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.7/Ex5_7.r @@ -0,0 +1,18 @@ + + +ybar = 390 # sample mean +mu0 = 380 # hypothesized value +sigma = 35.2 # population standard deviation +n = 50 # sample size +z = (ybar- mu0)/(sigma/sqrt(n)) +print(z) # test statistic + +# We then compute the critical value at .01 significance level. +# For alpha= .01, reject the null hypothesis if lies more than 2.33 +alpha = .01 +# critical value +z.alpha = qnorm(1-alpha) +print(z.alpha) +print("the observed value of z < critical value, so we might be tempted to accept the null hypothesis") +# but Beta is not computed so there is insufficient evidence to reject the null hypothesis. +# To reach a conclusion about whether to accept or reject H0, beta should be calculated. diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.8/Ex5_8.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.8/Ex5_8.r new file mode 100644 index 00000000..31968463 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.8/Ex5_8.r @@ -0,0 +1,25 @@ + + +ybar = 380 # sample mean +mu0 = 395 # hypothesized value +sigma = 35.2 # population standard deviation +n = 50 # sample size +z = abs((ybar- mu0)/(sigma/sqrt(n))) + # test statistic +print(z) +# We then compute the critical value at .01 significance level. +alpha = .01 +# critical value +z.alpha = qnorm(1-alpha) +print(z.alpha) +# computing Beta for hypothesized value +Beta_onetailedtest<-pnorm(z.alpha-z) +print(Beta_onetailedtest) +# power for test +powerfortest<-1-Beta_onetailedtest +print(powerfortest) + + + + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.9/Ex5_9.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.9/Ex5_9.r new file mode 100644 index 00000000..44173f70 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH5/EX5.9/Ex5_9.r @@ -0,0 +1,16 @@ + + +ybar = 31.2 # sample mean +mu0 = 33 # hypothesized value +sigma = 8.4 # population standard deviation +n = 35 # sample size +z = (ybar- mu0)/(sigma/sqrt(n)) +print(z) # test statistic + +# We then compute the critical value at .05 significance level. +# For alpha = .05, we will reject the null hypothesis if z <= -1.645 +alpha = .05 +z.alpha = qnorm(1-alpha) +# the observed value of z is not less than -z.alpha, the test statistic does not fall in the rejection region. + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.1/Ex6_1.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.1/Ex6_1.r new file mode 100644 index 00000000..56e54ea8 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.1/Ex6_1.r @@ -0,0 +1,24 @@ +# confidence interval for indpendent sample +fresh=c(10.2, 10.6,10.5 ,10.7,10.3, 10.2,10.8, 10.0,9.8 ,10.6 ) +stored=c( 9.8, 9.7, + 9.6, 9.5, + 10.1, 9.6, + 10.2, 9.8, + 10.1 ,9.9) +n1=length(fresh) +n2= length(stored) +y1bar = mean(fresh) +y2bar=mean(stored) +s1=sd(fresh) +s2=sd(stored) +# common standard deviation +sp=sqrt(((n1-1)*s1*s1+(n2-1)*s2*s2)/(n1+n2-2)) + +# the t-percentile based on df for 95% confidence interval +tstar=qt( .975, df=18) + margin=tstar*sp*sqrt((1/n1)+(1/n2)) + left_i=(y1bar-y2bar)-margin + right_i=(y1bar-y2bar)+margin + print("confidence interval is") + print(left_i) + print(right_i) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.10/Ex6_10.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.10/Ex6_10.r new file mode 100644 index 00000000..46475c2d --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.10/Ex6_10.r @@ -0,0 +1,7 @@ +# one sided test +sigma=2.4 +delta=1.5 +z_alpha=qnorm(0.05) +z_beta=qnorm(0.10) +sample_size=2*(sigma^2)*((z_alpha+z_beta)^2)/(delta^2) +print(sample_size) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.11/Ex6_11.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.11/Ex6_11.r new file mode 100644 index 00000000..2bbbcefe --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.11/Ex6_11.r @@ -0,0 +1,9 @@ + +sigma=2.4 +delta=1.5 +z_alpha=qnorm(0.05) +z_beta=qnorm(0.10) +m=3 +# replace 2 with (m+1)/m i.e 4/3 +sample_size=(4/3)*(sigma^2)*((z_alpha+z_beta)^2)/(delta^2) +print(sample_size) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.2/Ex6_2.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.2/Ex6_2.r new file mode 100644 index 00000000..60bb1c29 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.2/Ex6_2.r @@ -0,0 +1,19 @@ +# confidence interval for indpendent sample + +n1= 10 +n2= 9 +y1bar = 8.27 +y2bar=6.78 +s1=2.956 +s2=2.565 +# common standard deviation +sp=sqrt(((n1-1)*s1*s1+(n2-1)*s2*s2)/(n1+n2-2)) + +# the t-percentile based on df for 95% confidence interval +tstar=qt( .975, df=18) +margin=tstar*sp*sqrt((1/n1)+(1/n2)) +left_i=(y1bar-y2bar)-margin +right_i=(y1bar-y2bar)+margin +print("confidence interval is") +print(left_i) +print(right_i) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.3/Ex6_3.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.3/Ex6_3.r new file mode 100644 index 00000000..34a8fee7 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.3/Ex6_3.r @@ -0,0 +1,34 @@ +# confidence interval for indpendent sample + +n1= 12 +n2= 12 +y1bar = 26.58 +y2bar=39.67 +s1=14.36 +s2=13.86 +# solving part c +# common standard deviation +sp=sqrt(((n1-1)*s1*s1+(n2-1)*s2*s2)/(n1+n2-2)) + +# the t-percentile based on df for 95% confidence interval +tstar=qt( .975, df=18) +margin=tstar*sp*sqrt((1/n1)+(1/n2)) +left_i=(y1bar-y2bar)-margin +right_i=(y1bar-y2bar)+margin +print("confidence interval is") +print(left_i) +print(right_i) + +# solving part a and b +t=(y1bar-y2bar)/((sp)*sqrt((1/n1)+(1/n2))) +print(t) +# crtitical value +alpha= 0.05 +df=n1+n2-2 +t.alpha=qt(0.05, df=22) +if(t<=t.alpha){ + print(" We will reject H0") +}else{ + print("we will fail to reject H0 (no significant evidence") +} + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.4/Ex6_4.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.4/Ex6_4.r new file mode 100644 index 00000000..bc851cdc --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.4/Ex6_4.r @@ -0,0 +1,24 @@ +n1= 33 +n2= 12 +y1bar = 25.2 +y2bar=33.9 +s1=8.6 +s2=17.4 + + +t=(y1bar-y2bar)/(sqrt((s1*s1/n1)+(s2*s2/n2))) +print(t) +# To compute the rejection and p-value, we need to compute the approximate df +c=((s1*s1)/n1)/(((s1*s1)/n1)+((s2*s2)/n2)) +print(c) +df=((n1-1)*(n2-1))/((1-c)^2*(n1-1)+(c*c)*(n2-1)) +print(df) +# crtitical value +alpha= 0.05 + +t.alpha=qt(0.05, df=13) +if(t<=t.alpha){ + print(" We will reject H0") +}else{ + print("we fail to reject H0 (no significant evidence") +} \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.5/Ex6_5.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.5/Ex6_5.r new file mode 100644 index 00000000..69f10a13 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.5/Ex6_5.r @@ -0,0 +1,22 @@ +library(DescTools) +x = c(0.90, 0.37, 1.63, 0.83, 0.95, 0.78, 0.86, 0.61, 0.38, 1.97) +y = c(1.46, 1.45, 1.76 ,1.44, 1.11 ,3.07 ,0.98 ,1.27 ,2.56 ,1.32) + +cbind(c(x,y),rank(c(x,y))) + +a <- wilcox.test(x,y,correct=FALSE,conf.int = TRUE) +n1 <- length(x) +a$statistic <- a$statistic + n1*(n1+1)/2 +names(a$statistic) <- "T.W" +a +# T<83 so we reject H0 and conclude there is significant evidence that the placebo population has smaller reaction times than the population of alcohol consumers +# p value calculated in book is wrong +# confidence interval for delta (-1.08, -0.25) + +# 95% confidence interval for the placebo population median +MedianCI(x,conf.level = 0.95,na.rm = FALSE, method = "exact",R = 10000) +# # 95% confidence interval for the alcohol population median +MedianCI(y,conf.level = 0.95,na.rm = FALSE, method = "exact",R = 10000) + + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.6/Ex6_6.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.6/Ex6_6.r new file mode 100644 index 00000000..be5913ed --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.6/Ex6_6.r @@ -0,0 +1,16 @@ +x=c(11.0,11.2,11.2,11.2,11.4,11.5,11.6,11.7,11.8,11.9,11.9,12.1,10.2,10.3,10.4,10.6,10.6,10.7,10.8,10.8,10.9,11.1,11.1,11.3) +y=rank(x) +cbind(x,y) +rep(table(y), table(y)) +n1=12 +n2=12 +mut=n1*(n1+n2+1)/2 +s=((n1*n2)/12)*((n1+n2+1)-(48/((n1+n2)*(n1+n2-1)))) +sigmat=sqrt(s) +T=216 # sum of ranks of before clean up values +Z=(T-mut)/sigmat +Z +# This value exceeds 1.645, so we reject H0 and conclude that the distribution of before-cleanup measurements is shifted to the right of the corresponding distribution of after-cleanup measurements +# part b +si=(n1*n2*(n1+n2+1))/n1 +sqrt(si) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.7/Ex6_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.7/Ex6_7.r new file mode 100644 index 00000000..a7f012eb --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.7/Ex6_7.r @@ -0,0 +1,3 @@ +garage1=c(17.6,20.2,19.5,11.3,13.0,16.3,15.3,16.2,12.2,14.8,21.3,22.1,16.9,17.6,18.4) +garage2=c(17.3,19.1,18.4,11.5,12.7,15.8,14.9,15.3,12.0,14.2,21.0,21.0,16.1,16.7,17.5) +t.test(garage1,garage2) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.8/Ex6_8.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.8/Ex6_8.r new file mode 100644 index 00000000..97924a58 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.8/Ex6_8.r @@ -0,0 +1,6 @@ +garage1=c(17.6,20.2,19.5,11.3,13.0,16.3,15.3,16.2,12.2,14.8,21.3,22.1,16.9,17.6,18.4) +garage2=c(17.3,19.1,18.4,11.5,12.7,15.8,14.9,15.3,12.0,14.2,21.0,21.0,16.1,16.7,17.5) +t.test(garage1,garage2,paired = TRUE) +tvalue=qt(1-0.05,14) +# t>tvale we reject H0 and conclude that mean repair estimate for garage I is greater than that for garage II + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.9/Ex6_9.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.9/Ex6_9.r new file mode 100644 index 00000000..13b45bc2 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH6/EX6.9/Ex6_9.r @@ -0,0 +1,18 @@ +library(DescTools) +brandA=c(211.4,204.4,202.0,201.9,202.4,202.0,202.4,207.1,203.6,216.0,208.9,208.7,213.8,201.6,201.8,200.3,201.8,201.5,212.1,203.4) +brandB=c(186.3,205.7,184.4,203.6,180.4,202.0,181.5,186.7,205.7,189.1,183.6,188.7,188.6,204.2,181.6,208.7,181.5,208.7,186.8,182.9) +difference=brandA-brandB + +y=rank(replace(abs(difference),abs(difference)==0,NA),na='keep'); +cbind(difference,y) +# sum of positive and negative ranks are +Tminus=1+2+3+4+5+6 +Tplus= 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 +15 + 16 +17.5 +18 + 19 +T=min(Tminus,Tplus) +T +# T<53, we reject H0 and conclude that brand A fertilizer tends to produce more grass than brand B +difference=difference[-6] + + +MedianCI(difference,conf.level = 0.95,na.rm = FALSE, method = "exact",R = 999) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.1/Ex7_1.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.1/Ex7_1.r new file mode 100644 index 00000000..7f0662b9 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.1/Ex7_1.r @@ -0,0 +1,21 @@ +weights=c(501.4, 498.0, 498.6 ,499.2, 495.2 ,501.4 ,509.5 ,494.9 ,498.6, 497.6, + 505.5 ,505.1 ,499.8 ,502.4, 497.0 ,504.3 ,499.7 ,497.9 ,496.5, 498.9, + 504.9 ,503.2 ,503.0 ,502.6 ,496.8 ,498.2, 500.1 ,497.9 ,502.2, 503.2) +n=length(weights) +ybar=mean(weights) +s=sd(weights) +# The upper-tail chi-square value +XU=qchisq(.995, df=29) +# The lower-tail chi-square value +XL=qchisq(.005, df=29) +# The 99% confidence interval for standard deviation +right_i=sqrt((n-1)*(s^2)/(XL)) +left_i=sqrt((n-1)*(s^2)/(XU)) +print(left_i) +print(right_i) +# The 99% confidence interval for mean +margin <- qnorm(0.995)*s/sqrt(n) +left_interval_mean=ybar-margin +right_interval_mean=ybar+margin +print(left_interval_mean) +print(right_interval_mean) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.2/Ex7_2.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.2/Ex7_2.r new file mode 100644 index 00000000..044243ac --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.2/Ex7_2.r @@ -0,0 +1,28 @@ +readings=c(203.1, 184.5, 206.8 ,211.0 ,218.3, 174.2, 193.2 ,201.9 ,199.9 ,194.3, + 199.4, 193.6, 194.6 ,187.2 ,197.8 ,184.3, 196.1, 196.4 ,197.5 ,187.9) +n=length(readings) +ybar=mean(readings) +s=sd(readings) +muo=5 +# test static +X=(n-1)*(s^2)/(muo^2) +print(X) +#critical value +alpha=0.05 +X.alpha=qchisq(1-0.05,df=19) + +# the null hypothesis, H0 is rejected if the value of the X is greater than X.alpha +#Since the computed value of the X., 74.61, is greater than the +# critical value 30.14, there is sufficient evidence to reject H0 +# The upper-tail chi-square value +XU=qchisq(.975, df=19) +# The lower-tail chi-square value +XL=qchisq(1-.975, df=19) +# The 95% confidence interval for standard deviation +right_i=sqrt((n-1)*(s^2)/(XL)) +left_i=sqrt((n-1)*(s^2)/(XU)) +print(left_i) +print(right_i) + + + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.4/Ex7_4.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.4/Ex7_4.r new file mode 100644 index 00000000..0e45b759 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.4/Ex7_4.r @@ -0,0 +1,5 @@ +#the upper .025 percentile for the F distribution with df1 = 10 and df2 =7 is + +upper_percentile=qf(1-0.025,10,7) +lower_percentile=1/upper_percentile +print(lower_percentile) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.5/Ex7_5.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.5/Ex7_5.r new file mode 100644 index 00000000..a40a780b --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.5/Ex7_5.r @@ -0,0 +1,15 @@ + +y1bar=38.48 +s1=16.37 +n1=40 +y2bar=26.93 +s2=9.88 +n2=40 +# test statistic +F=s1^2/s2^2 +print(F) +#critical value +alpha=0.05 +f.alpha=qf(1-alpha/2,39,39) +# we reject H0 if F>=f.alpha + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.6/Ex7_6.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.6/Ex7_6.r new file mode 100644 index 00000000..6c6dd3b2 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.6/Ex7_6.r @@ -0,0 +1,17 @@ +# confidence interval for the ratio of the two variances + +y1bar=38.48 +s1=16.37 +n1=40 +y2bar=26.93 +s2=9.88 +n2=40 +alpha=0.05 +FU=qf(1-alpha/2,39,39) +FL=1/FU + +# confidence interval for sigma1^2/sigma2^2 +left_i=(s1^2/s2^2)*FL +right_i=(s1^2/s2^2)*FU +print(left_i) +print(right_i) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.7/Ex7_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.7/Ex7_7.r new file mode 100644 index 00000000..9c2c3bb9 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.7/Ex7_7.r @@ -0,0 +1,15 @@ + +y1bar=20.04 +s1=0.474 +n1=10 +y2bar=9.99 +s2=0.233 +n2=16 +alpha=0.10 +FU=qf(1-alpha/2,15,9) +FL=1/FU +# confidence interval for sigma1/sigma2 +left_i=sqrt((s1^2/s2^2)*FL) +right_i=sqrt((s1^2/s2^2)*FU) +print(left_i) +print(right_i) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.8/Ex7_8.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.8/Ex7_8.r new file mode 100644 index 00000000..c7a42906 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.8/Ex7_8.r @@ -0,0 +1,15 @@ +s=c(8.69, 6.89, 80.22) +s_min=min(s) +s_max=max(s) +#test statistic +F=s_max/s_min +print(F) + +# critical value +alpha=0.05 +df=8 +F.alpha=qnorm(alpha/2,8) +print(F.alpha) + +# Reject H0 if F >=F.alpha +# conclusion : Thus, we reject H0 and conclude that the variances are not all equa \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.9/Ex7_9.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.9/Ex7_9.r new file mode 100644 index 00000000..d7d4b668 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH7/EX7.9/Ex7_9.r @@ -0,0 +1,10 @@ +# install car package by writing install.packages("car") command in console +library(car) +y=c(4.2,2.9,0.2,25.7,6.3,7.2,2.3,9.9,5.3,6.5,0.2,11.3,0.3,17.1,51.0,10.1,0.3,0.6,7.9,7.2,7.2,6.4,9.9,3.5,10.6,10.8,10.6,8.4,6.0,11.9) +additive=c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3) +leveneTest(y,additive) +critical_value=qf(1-0.05,2,27) +critical_value +# L < critical value we fail to reject and conclude that there is insufficient evidence of a difference in the population variances of the percentage increase in mpg for the three additives. + + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.1/Ex8_1.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.1/Ex8_1.r new file mode 100644 index 00000000..da039ef6 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.1/Ex8_1.r @@ -0,0 +1,18 @@ + +Group1 <- c(5,17,12,10,4) +Group2 <- c(19,10,9,7,5) +Group3 <- c(25,15,12,9,8) + +Combined_Groups <- data.frame(cbind(Group1, Group2, Group3)) # combines the data into a single data set. +Combined_Groups # shows spreadsheet like results +#summary(Combined_Groups) # min, median, mean, max + +Stacked_Groups <- stack(Combined_Groups) +Stacked_Groups #shows the table Stacked_Groups + +Anova_Results <- aov(values ~ ind, data = Stacked_Groups) +summary(Anova_Results) # shows Anova_Results + + +# answer given in book is wrong because sample varaince calcaulated for group 1 column in book is 33.7 which is wrong +# correct sample varaince is 28.3 \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.2/Ex8_2.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.2/Ex8_2.r new file mode 100644 index 00000000..492def28 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.2/Ex8_2.r @@ -0,0 +1,15 @@ + +Group1 <- c(96,79,91,85,83,91,82,87) +Group2 <- c(77,76,74,73,78,71,80) +Group3 <- c(66,73,69,66,77,73,71,70,74) + + +cols <- list(m=Group1, y=Group2,z=Group3) +as.data.frame(lapply(cols, `length<-`, max(sapply(cols, length)))) +cols +Stacked_Groups <- stack(cols) +Stacked_Groups #shows the table Stacked_Groups + +Anova_Results <- aov(values ~ ind, data = Stacked_Groups) +summary(Anova_Results) # shows Anova_Results + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.3/Ex8_3.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.3/Ex8_3.r new file mode 100644 index 00000000..8a006a05 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.3/Ex8_3.r @@ -0,0 +1,17 @@ +M=c(62,60,60,25,24,23,20,13,12,6) +C=c(62,62,24,24,22,20,19,10,8,8) +P=c(37,31,15,15,14,14,14,5,3,2) + +Group1=abs(M-median(M)) +Group2=abs(C-median(C)) +Group3=abs(P-median(P)) + +Combined_Groups <- data.frame(cbind(Group1, Group2, Group3)) # combines the data into a single data set. +Combined_Groups # shows spreadsheet like results +#summary(Combined_Groups) # min, median, mean, max + +Stacked_Groups <- stack(Combined_Groups) +Stacked_Groups #shows the table Stacked_Groups + +Anova_Results <- aov(values ~ ind, data = Stacked_Groups) +summary(Anova_Results) # shows Anova_Results diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.4/Ex8_4.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.4/Ex8_4.r new file mode 100644 index 00000000..472b751f --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.4/Ex8_4.r @@ -0,0 +1,43 @@ +Mean=c(2.2, 4.6 ,21.2 ,31.4) +Standard_deviation=c(1.476,2.119,4.733,5.52) +s_min=min(Standard_deviation) +s_max=max(Standard_deviation) +# test statistic +F=s_max^2/s_min^2 +print(F) +# The critical value of F > F.alpha +# we reject the hypothesis of homogeneity +#of the population variances. + +distance_1km=c(1,5,2,1,2,2,4,3,0,2) +distance_5km=c(4,8,2,3,8,5,6,4,3,3) +distance_10km=c(20,26,24,11,28,20,19,19,21,24) +distance_20km=c(37,30,26,24,41,25,36,31,31,33) +print(Standard_deviation[1]^2/Mean[1]) +print(Standard_deviation[2]^2/Mean[2]) +print(Standard_deviation[3]^2/Mean[3]) +print(Standard_deviation[4]^2/Mean[4]) +i=1 +while(i<11){ + distance_1km[i]=sqrt(distance_1km[i]+0.375) + i=i+1 +} +i=1 +while(i<11){ + distance_5km[i]=sqrt(distance_5km[i]+0.375) + i=i+1 +} +i=1 +while(i<11){ + distance_10km[i]=sqrt(distance_10km[i]+0.375) + i=i+1 +} +i=1 +while(i<11){ + distance_20km[i]=sqrt(distance_20km[i]+0.375) + i=i+1 +} +combined_group=data.frame(cbind(distance_1km,distance_5km,distance_10km,distance_20km)) +combined_group + + \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.7/Ex8_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.7/Ex8_7.r new file mode 100644 index 00000000..7112e9f9 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH8/EX8.7/Ex8_7.r @@ -0,0 +1,15 @@ +# the rank sum test +Methodist=c(62,60,60,25,24,23,20,13,12,6) +Catholic=c( 62,62,24,24,22,20,19,10,8,8) +Pentecostal=c(37,31,15,15,14,14,14,5,3,2 ) +n=30 +data.value <- c( Methodist,Catholic,Pentecostal) + +data.rank <- rank(data.value) +data <- data.frame(data.value, data.rank) +print(data) + Sumofranks=c(182.5,167.5,115) + #test statistic + H=(12/(n*(n+1)))*((Sumofranks[1]^2+Sumofranks[2]^2+Sumofranks[3]^2)/10)-3*(n+1) + print(H) + diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.1/Ex9_1.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.1/Ex9_1.r new file mode 100644 index 00000000..fe943fbe --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.1/Ex9_1.r @@ -0,0 +1,21 @@ +sample_size=c(5,4,6,5) +#l1=y1bar-y3bar +#l2=y2bar-y4bar +# We can rewrite the contrasts in the following form: +#l1=y1bar+0*y2bar-y3bar+0*y4bar +#l2=0*y1bar+y2bar+0*y3bar-y4bar +# thus we identify a1 = 1, a2 = 0, a3 =-1, a4 = 0 and b1 =0, b2 = 1, b3 =0, b4 =-1 +a=c(1,0,-1,0) +b=c(0,1,0,-1) +test=0 +i=1 +while(i<=length(sample_size)){ + test=test+(a[i]*b[1])/sample_size[i] + i=i+1 +} +print(test) +if(test==0){ + print("hence the contrasts are orthogonal.") +}else{ + print("hence the contrasts are not orthogonal") +} diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.11/Ex9_11.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.11/Ex9_11.r new file mode 100644 index 00000000..90890086 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.11/Ex9_11.r @@ -0,0 +1,18 @@ +y1bar=1.175 +y2bar=1.293 +y3bar=1.328 +y4bar=1.415 +y5bar=1.500 + +alpha=0.05 +q.alpha=4.158 +MSError=0.0153 +LSD=q.alpha*sqrt((MSError)/6) +print(LSD) + +# the 95% confidence interval for y3bar-y1bar +left_i=(y3bar-y1bar)-LSD +right_i=(y3bar-y1bar)+LSD +print("Confidence interval is") +print(left_i) +print(right_i) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.13/Ex9_13.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.13/Ex9_13.r new file mode 100644 index 00000000..dd47a1a3 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.13/Ex9_13.r @@ -0,0 +1,30 @@ +# install package by writing install.packages("DunnettTests") command in console +# install package by writing install.packages(mvtnorm") command in console +library(DunnettTests) +library(mvtnorm) +alpha=0.05 +k=4 +v=25 +n=6 + + cvSUDT(k=4,alpha=0.05,alternative="U",df = 25,corr = .5) + # max value of critical value is taken +critical_value=2.28 # approx +sw2=0.0153 +# test statistic +D=critical_value*sqrt((2*sw2)/n) +print(D) +# conclusion +yi=c(1.293,1.328,1.415,1.500) +yc=1.175 +i=1 +while (i<5) { + if((yi[i]-yc)=F_alpha_l_1_25 +F1 = 13.71 # computed in 9.5 +F2 = 8.48 +F3 = 0.24 +F4 = 1.42 +# we would declare contrast l1 and l2 significantly different from 0 because their F ratios are greater than 7.24. diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.7/Ex9_7.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.7/Ex9_7.r new file mode 100644 index 00000000..ca965adc --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.7/Ex9_7.r @@ -0,0 +1,9 @@ +F=5.96 # computed from 9.3 +alpha=0.05 +MSError=.0153 +F_value=qf(1-alpha,df1=4,df2 = 25) +# as the F >F_value +print(" we reject H0 and conclude that at least one of the population means differs from the rest") +t.alpha=qt(1-alpha/2,df=25) +LSD=t.alpha*(sqrt((2*MSError)/6)) +print(LSD) diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.9/Ex9_9.r b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.9/Ex9_9.r new file mode 100644 index 00000000..fb6a58b2 --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/CH9/EX9.9/Ex9_9.r @@ -0,0 +1,18 @@ +y1bar=1.175 +y2bar=1.293 +y3bar=1.328 +y4bar=1.415 +y5bar=1.500 + +alpha=0.05 +tstar=qt(1-alpha/2,df=25) +MSError=0.0153 +LSD=tstar*sqrt((2*MSError)/6) +print(LSD) + +# the 95% confidence interval for y3bar-y1bar +left_i=(y3bar-y1bar)-LSD +right_i=(y3bar-y1bar)+LSD +print("Confidence interval is") +print(left_i) +print(right_i) \ No newline at end of file diff --git a/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/README.txt b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/README.txt new file mode 100644 index 00000000..4547f90b --- /dev/null +++ b/An_Introduction_To_Statistical_Methods_And_Data_Analysis_by_R_Lyman_Ott_And_Michael_Longnecker/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Himanshu Gupta +Course: Be +Branch: Information Technology +College/Institute/Organization: Sgsits Indore + +About The Book + +Book: An Introduction To Statistical Methods And Data Analysis +Author: R Lyman Ott And Michael Longnecker +Publisher: Cengage Learning, Canada +Year Of Publication: 2010 +ISBN: 0-495-01758-2 +Edition: 6 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.1/EX10_1.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.1/EX10_1.R new file mode 100644 index 00000000..6a800674 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.1/EX10_1.R @@ -0,0 +1,26 @@ +#Paint Drying Time(Pg no. 377) + +foo = function() +{ + X1bar = 121 + X2bar = 112 + std_dev1 = std_dev2 = 8 + n1 = n2 =10 + delta0 = 0 + + statistic = (X1bar-X2bar-delta0)/sqrt((std_dev1^2/n1)+(std_dev2^2/n2)) + statistic + + p = 1 - pnorm(statistic,0,1,lower.tail = TRUE) + p + + if(p<0.05) + { + print("Null hypothesis is rejected ") + } + else + { + print("Null hypothesis is accepted") + } +} +foo() \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.10/EX10_10.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.10/EX10_10.R new file mode 100644 index 00000000..bf2875a1 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.10/EX10_10.R @@ -0,0 +1,9 @@ +#Axial Stress(Pg no. 397) + +n1 = n2 = 10 +rank1 = c(2,3,4,8,9,11,13,15,16,18) + +w1 = sum(rank1) + +w2 = (((n1+n2)*(n1+n2+1))/2) - w1 +w2 \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.11/EX10_11.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.11/EX10_11.R new file mode 100644 index 00000000..77dd7f48 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH10/EX10.11/EX10_11.R @@ -0,0 +1,22 @@ +#Shear Strength of Steel Girder(Pg no. 401) + +foo = function() +{ + km = c(1.186,1.151,1.322,1.339,1.200,1.402,1.365,1.537,1.559) + lm = c(1.061,0.992,1.063,1.062,1.065,1.178,1.037,1.086,1.052) + ans = t.test(km,lm, alternative = "two.sided", paired = TRUE) + statistic = ans$statistic + print(statistic) + alpha = 0.05 + p_value = ans$p.value + + if(p_valuecompare) + { + print("We reject the null hypothesis and conclude that the variable x2 (die height) contributes significantly to the model") + } + else + { + print("Unable to reject the null hypothesis") + } +} +foo() \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.5/EX12_5.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.5/EX12_5.R new file mode 100644 index 00000000..03e9aff7 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH12/EX12.5/EX12_5.R @@ -0,0 +1,31 @@ +#Wire Bond Strength One-Sided Coefficient Test(Pg no. 501) + +foo = function() +{ + beta2 = 0.012528 + std_err = 0.002793 + + statistic = (beta2 - 0.01)/std_err + statistic + + t0 = qt(0.25,22,lower.tail = FALSE) + t0 + t1 = qt(0.10,22,lower.tail = FALSE) + t1 + + p_max = 1 - pnorm(t0,0,1) + p_min = 1 -pnorm(t1,0,1) + + p = 1 - pnorm(statistic,0,1) + p + + if(p_min

",LSD) +cat("4 vs 2 =",y4-y2,">",LSD) +cat("4 vs 3 =",y4-y3,">",LSD) +cat("3 vs 1 =",y3-y1,">",LSD) +cat("3 vs 2 =",y3-y2,">",LSD) +cat("2 vs 1 =",y2-y1,">",LSD) + \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.4/EX13_4.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.4/EX13_4.R new file mode 100644 index 00000000..a4deb8ce --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.4/EX13_4.R @@ -0,0 +1,20 @@ + +#Textile Manufacturing(Pg no. 560) +obs1 = c(98,91,96,95) +obs2 = c(97,90,95,96) +obs3 = c(99,93,97,99) +obs4 = c(96,92,95,98) + +data = rbind(obs1,obs2,obs3,obs4) + +tag = c("obs1","obs2","obs3","obs4") + +M = c(t(as.matrix(data))) +n_row = 4 +n_col = 4 + +op <- gl(n_row,1,n_col*n_row,factor(tag)) + +m <- gl(n_col,n_row,n_row*n_col) + +summary(aov(M~op+m)) diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.5/EX13_5.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.5/EX13_5.R new file mode 100644 index 00000000..c83aae7b --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH13/EX13.5/EX13_5.R @@ -0,0 +1,24 @@ +#Fabric Strength(Pg no. 565) + +obs1 = c(1.3,2.2,1.8,3.9) +obs2 = c(1.6,2.4,1.7,4.4) +obs3 = c(0.5,0.4,0.6,2.0) +obs4 = c(1.2,2.0,1.5,4.1) +obs5 = c(1.1,1.8,1.3,3.4) + +data = rbind(obs1,obs2,obs3,obs4,obs5) + +tag = c("obs1","obs2","obs3","obs4","obs5") + +M = c(t(as.matrix(data))) +n_row <- 4 +n_col <- 5 + +op <- gl(n_row,1,n_col*n_row,factor(tag)) + +m <- gl(n_col,n_row,n_row*n_col) + + +summary(aov(M~op+m)) + +# The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH14/EX14.1/EX14_1.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH14/EX14.1/EX14_1.R new file mode 100644 index 00000000..052f8386 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH14/EX14.1/EX14_1.R @@ -0,0 +1,69 @@ +#Aircraft Primer Paint(pg no. 586) + +foo = function() +{ + n = 3 + a = 3 + b = 2 + dripping = matrix(c(4.0,4.5,4.3,5.6,4.9,5.4,3.8,3.7,4.0),nrow = 3,ncol = 3,byrow = TRUE) + spraying = matrix(c(5.4,4.9,5.6,5.8,6.1,6.3,5.5,5.0,5.0),nrow = 3,ncol = 3,byrow = TRUE) + types = c(28.7,34.1,27.0) + methods = c(40.2,49.6) + interaction = c(12.8, 15.9, 15.9, 18.2, 11.5, 15.5) + + total = sum(dripping) + sum(spraying) + + Yijk = sum(dripping^2) + sum(spraying^2) + SSt = Yijk - (total^2/(a*b*n)) + cat("SSt =",SSt,"\n") + + Yi = sum(types^2) + SStypes = (Yi/(b*n)) - (total^2/(a*b*n)) + cat("SStypes =",SStypes,"\n") + + Yj = sum(methods^2) + SSmethods = (Yj/(a*n)) - (total^2/(a*b*n)) + cat("SSmethods =",SSmethods,"\n") + + Yij = sum(interaction^2) + SSinteraction = (Yij/n) - (total^2/(a*b*n)) - SStypes - SSmethods + cat("SSinteraction =",SSinteraction,"\n") + + SSe = SSt - SStypes - SSmethods -SSinteraction + cat("SSe =",SSe,"\n") + + f2 = qf(0.05, df1=2, df2=12, lower.tail = FALSE) + f1 = qf(0.05, df1=1, df2=12, lower.tail = FALSE) + + f0_types = (SStypes/2)/(SSe/12) + f0_methods = (SSmethods/1)/(SSe/12) + f0_interaction = (SSinteraction/2)/(SSe/12) + + if(f2= x) + { + print("Outcome of Set S={low, medium,high} is low") + print("Outcome of Set S={yes, no} is no") + } else if(max_recycle_time <= x) + { + print("Outcome of Set S={low, medium,high} is high") + print("Outcome of Set S={yes, no} is no") + } +} + +foo() \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.10/EX2_10.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.10/EX2_10.R new file mode 100644 index 00000000..e48dbe3d --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.10/EX2_10.R @@ -0,0 +1,7 @@ +#Printed circuit board(Pg no. 24) + +locations = 8 +components = 4 +designs = factorial(locations)/factorial(components) + +cat(designs,"different designs are possible") \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.11/EX2_11.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.11/EX2_11.R new file mode 100644 index 00000000..0af7d32e --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.11/EX2_11.R @@ -0,0 +1,7 @@ +#Hospital schedule(Pg no. 24) + +knee_surgery = 3 +hip_surgery = 2 +sequences = factorial(knee_surgery+hip_surgery)/(factorial(knee_surgery)*factorial(hip_surgery)) + +cat(sequences,"sequences are possible") \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.12/EX2_12.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.12/EX2_12.R new file mode 100644 index 00000000..105447a0 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.12/EX2_12.R @@ -0,0 +1,12 @@ +#Bar code 39(Pg no. 24) + +black_bars = 5 +narrow_bars = 3 +wide_bars = 2 +bars = factorial(black_bars)/(factorial(narrow_bars)*factorial(wide_bars)) + +narrow_spaces = 3 +wide_spaces = 1 +codes = bars*(narrow_spaces+wide_spaces) + +cat("The number of possible codes is",codes) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.13/EX2_13.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.13/EX2_13.R new file mode 100644 index 00000000..e4fb8c15 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.13/EX2_13.R @@ -0,0 +1,7 @@ +#Printed circuit board layout(Pg no. 25) + +locations = 8 +identical_components = 5 +designs = factorial(locations)/(factorial(identical_components)*factorial(locations-identical_components)) + +cat("Number of possible designs is",designs) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.14/EX2_14.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.14/EX2_14.R new file mode 100644 index 00000000..4650e202 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.14/EX2_14.R @@ -0,0 +1,20 @@ +#Sampling without replacement(Pg no. 25) + +size = 6 +total_parts = 50 +defective_parts = 3 +non_defective_parts = 47 + +step_1 = choose(defective_parts,2) + +remaining_parts = size - 2 + +step_2 = choose(non_defective_parts, remaining_parts) + +num_of_subsets = step_1*step_2 + +cat("the number of subsets of size 6 that contain exactly 2 defective parts is",num_of_subsets) + +diff_subsets = choose(total_parts, size) + +cat("total number of different subsets of size 6 is",diff_subsets) diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.15/EX2_15.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.15/EX2_15.R new file mode 100644 index 00000000..9424b662 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.15/EX2_15.R @@ -0,0 +1,8 @@ +#Laser diodes(Pg no. 30) + +num_of_diodes = 30 +individual_probability = 0.01 + +total_probability = num_of_diodes*individual_probability + +cat("Probability of E is", total_probability) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.16/Ex2_16.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.16/Ex2_16.R new file mode 100644 index 00000000..023ede16 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.16/Ex2_16.R @@ -0,0 +1,22 @@ +#Probabilities of Events(Pg no. 31) + +a = 0.1 +b = 0.3 +c = 0.5 +d = 0.1 + +A = a + b +B = b + c + d +C = d + +cat("P(A) =",A) +cat("P(B) =",B) +cat("P(C) =",C) + +cat("P(A_bar) =",1-A) +cat("P(B_bar) =",1-B) +cat("P(C_bar) =",1-C) + +cat("P(A_intersection_B) =",b) +cat("P(A_union_B) =",a+b+c+d) +cat("P(A_intersection_c) =",0) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.17/EX2_17.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.17/EX2_17.R new file mode 100644 index 00000000..8f81bcb9 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.17/EX2_17.R @@ -0,0 +1,10 @@ +#Contamination particles(Pg no. 31) + +zero_contaminant = 0.4 +three_contaminants = 0.10 +four_contaminants = 0.05 +five_and_above_contaminants = 0.10 + +E = three_contaminants+four_contaminants+five_and_above_contaminants + +cat("P(E) = ",E,"is the probability that a wafer contains three or more particles in the inspected location") \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.18/EX2_18.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.18/EX2_18.R new file mode 100644 index 00000000..8ccb7710 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.18/EX2_18.R @@ -0,0 +1,19 @@ +#Refer to code EX2_14(Sampling without replacement) + +#Manufacturing Inspection(Pg no. 32) + +size = 6 +non_defective_parts = 47 +num_of_subsets = 535095 +diff_subsets = 15890700 + +P1 = num_of_subsets/diff_subsets + +#subset with no defective parts +subset2 = choose(non_defective_parts,size) + +P2 = subset2/diff_subsets + +cat("Probability that a sample contains exactly 2 defective parts is",P1) +cat("Probability that no defective parts are selected is",P2) +#The answer might slightly vary due to rounding off values diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.19/EX2_19.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.19/EX2_19.R new file mode 100644 index 00000000..d044bafe --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.19/EX2_19.R @@ -0,0 +1,15 @@ +#install.packages("MASS") +library(MASS) + +#Semiconductor Wafers(Pg no. 35) + +total = 940 +high = 358 +center = 626 +high_and_center = 112 +high_or_center = (high+center-high_and_center) +ans = high_or_center/total +ans = fractions(ans) +print(ans) + +#The answer might slightly vary due to reducing of values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.20/EX2_20.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.20/EX2_20.R new file mode 100644 index 00000000..abf93e69 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.20/EX2_20.R @@ -0,0 +1,14 @@ +#Semiconductor wafers and location(Pg no. 36) + +E1 = 0.15 #probability that a wafer contains four or more particles +E2 = 0.28 #probability that a wafer was at the edge +E1_and_E2 = 0.04 +E1_or_E2 = E1+E2-E1_and_E2 + +E3 = 0.60 #probability that a wafer contains less than two particles +E4 = 0.03 #probability that a wafer is both at the edge and contains more than four particles +E3_and_E4 = 0 #mutually exclusive +E3_or_E4 = E3+E4-E3_and_E4 + +cat("probability of E1 union E2 is",E1_or_E2) +cat("probability of E3 union E4 is",E3_or_E4) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.22/EX2_22.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.22/EX2_22.R new file mode 100644 index 00000000..c463029c --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.22/EX2_22.R @@ -0,0 +1,12 @@ +#Surface flaws and defectives(Pg no. 40) + +f1 = 40 #total_surface flaws +d1 = 10 #defectiv and surface flawed +P1 = d1/f1 + +d2 = 18 #defective but not surface flawed +f2 = 400 - f1 #without surface flawed +P2 = d2/f2 + +cat("conditional probability P(d1|f1) is",P1) +cat("conditional probability P(d2|f2) is",P2) diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.23/EX2_23.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.23/EX2_23.R new file mode 100644 index 00000000..ddc18122 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.23/EX2_23.R @@ -0,0 +1,39 @@ +#install.packages("MASS") +library(MASS) + +#Tree Diagram(Pg no. 41) + +D_and_F = 10/400 +F = 40/400 +D = 28/400 +Dbar_and_F = 30/400 +D_and_Fbar = 18/400 +Dbar_and_Fbar = 342/400 +Fbar = 1-F + +D_given_F = D_and_F/F +D_given_F = fractions(D_given_F) +print("P(D|F) is") +print(D_given_F) + +F_given_D = D_and_F/D +F_given_D = fractions(F_given_D) +print("P(F|D) is") +print(F_given_D) + +Dbar_given_F = Dbar_and_F/F +Dbar_given_F = fractions(Dbar_given_F) +print("P(Dbar|F) is") +print(Dbar_given_F) + +D_given_Fbar = D_and_Fbar/Fbar +D_given_Fbar = fractions(D_given_Fbar) +print("P(D|Fbar) is") +print(D_given_Fbar) + +Dbar_given_Fbar = Dbar_and_Fbar/Fbar +Dbar_given_Fbar = fractions(Dbar_given_Fbar) +print("P(Dbar|Fbar) is") +print(Dbar_given_Fbar) + +#The answer might slightly vary due to reducing of values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.24/EX2_24.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.24/EX2_24.R new file mode 100644 index 00000000..eb4d4a7e --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.24/EX2_24.R @@ -0,0 +1,12 @@ +#install.packages("MASS") +library(MASS) + +#Random inspection(Pg no. 42) + +remaining_parts = 49 #total remaining parts +defective_parts = 2 #total defective parts remaining + +P = defective_parts/remaining_parts +P = fractions(P) +print(P) +cat("conditional probability P(B|A) is ",P) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.25/EX2_25.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.25/EX2_25.R new file mode 100644 index 00000000..fa2959d6 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.25/EX2_25.R @@ -0,0 +1,13 @@ +#Continue to EX2_24 + +#(Pg no. 43) + +total = 50 +defective_parts = 3 +non_defective_parts = 47 + +p = (defective_parts/total)*((defective_parts-1)/(total-1))*(non_defective_parts/(total-2)) + +cat(p,"is the probability that the first two parts selected are defective and the third is not defective") + +#The answer may slightly vary due to rounding off values diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.26/EX2_26.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.26/EX2_26.R new file mode 100644 index 00000000..503cc15a --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.26/EX2_26.R @@ -0,0 +1,7 @@ +#Machine stages(Pg no. 45) + +A = 0.90 #probability of that first stage of machining meets specifications +B_given_A = 0.95 #Given A, probability that a second stage of machining meets specifications +A_and_B = B_given_A*A + +cat(A_and_B,"is the probability that both stages meet specifications") \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.27/EX2_27.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.27/EX2_27.R new file mode 100644 index 00000000..e58eb863 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.27/EX2_27.R @@ -0,0 +1,14 @@ +#Semiconductor contamination(Pg no. 46) + +high = 0.20 #probability of high level of contamination +not_high = 1 - high #probability of not high level of contamination +product_fail_given_high = 0.10 +product_fail_given__not_high = 0.005 + +product_fail = (product_fail_given_high*high)+(product_fail_given__not_high*not_high) + +cat(product_fail,"is probability that the product fails") + + + + diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.28/EX2_28.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.28/EX2_28.R new file mode 100644 index 00000000..b60643fe --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.28/EX2_28.R @@ -0,0 +1,12 @@ +#Semiconductor failures(Pg no. 47) + +high = 0.20 #probability of high level of contamination +medium = 0.30 #probability of medium level of contamination +low = 0.50 #probability of low level of contamination +product_fail_given_high = 0.10 +product_fail_given_medium = 0.01 +product_fail_given_low = 0.001 + +product_fail = (product_fail_given_high*high)+(product_fail_given_medium*medium)+(product_fail_given_low*low) + +cat(product_fail,"is probability that the product fails") \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.29/EX2_29.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.29/EX2_29.R new file mode 100644 index 00000000..b419015d --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.29/EX2_29.R @@ -0,0 +1,14 @@ +#install.packages("MASS") +library(MASS) + +#Sampling with replacement(Pg no. 49) + +# A : event that first part is defective +# B : event that second part is defective + +B_given_A = 3 +A = 3 +total = 50 +P = fractions((B_given_A*A)/(total*total)) +print(P) +cat("probability that both parts are defective is",P) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.30/EX2_30.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.30/EX2_30.R new file mode 100644 index 00000000..6ff176c3 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.30/EX2_30.R @@ -0,0 +1,13 @@ +#install.packages("MASS") +library(MASS) + +#Flaws and functions(Pg no. 49) + +defective_and_surface_flawed = 2 +total_defective_parts = 20 +total_surface_flawed = 40 +P = fractions((defective_and_surface_flawed*defective_and_surface_flawed)/(total_defective_parts*total_surface_flawed)) +print(P) +cat("probability of surface flawed and defevtive is",P) + +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.31/EX2_31.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.31/EX2_31.R new file mode 100644 index 00000000..b20d7719 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.31/EX2_31.R @@ -0,0 +1,11 @@ +#Continuation of Ex2_14 + +#(Pg no. 50) + +B_given_A = 2/49 +A = 3/50 +B_given_Abar = 3/49 +Abar = 1-A + +B = (B_given_A*A)+(B_given_Abar*Abar) +cat("P(B) =",B) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.32/EX2_32.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.32/EX2_32.R new file mode 100644 index 00000000..ccbca5d1 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.32/EX2_32.R @@ -0,0 +1,8 @@ +#Series circuit(Pg no. 51) + +l = 0.80 #probability that left device operate +r = 0.90 #probability that right device operate + +l_and_r = l*r + +cat("The probability that the circuit operates is",l_and_r) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.33/EX2_33.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.33/EX2_33.R new file mode 100644 index 00000000..b342d495 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.33/EX2_33.R @@ -0,0 +1,11 @@ +#Semiconductor wafers(Pg no. 51) + +contamination = 0.01 +no_contamination = 1- contamination +wafers = 15 + +total_probability = no_contamination^wafers + +cat("The probability that no large particles are found is ",total_probability) + +#The answer may slightly vary due rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.34/EX2_34.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.34/EX2_34.R new file mode 100644 index 00000000..5a5aa37a --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.34/EX2_34.R @@ -0,0 +1,14 @@ +#Parallel circuit(Pg no. 51) + +top = 0.95 #top device does operate +bottom = 0.95 #bottom device does operate + +t = 1 - top #top device does not operate +b = 1 - bottom #bottom device does not operate + +t_and_b = t*b + +top_or_bottom = 1 - t_and_b + +cat("The probability that the circuit operates is",top_or_bottom) + diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.35/EX2_35.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.35/EX2_35.R new file mode 100644 index 00000000..a2a7ef44 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.35/EX2_35.R @@ -0,0 +1,10 @@ +#Advanced circuit(Pg no. 52) + +left = 1 - 0.1^3 +middle = 1 - 0.05^2 +right = 0.99 + +operates = left*middle*right + +cat(operates,"is the probability that the circuit operates") +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.37/EX2_37.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.37/EX2_37.R new file mode 100644 index 00000000..e68b0322 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.37/EX2_37.R @@ -0,0 +1,12 @@ +#Medical Diagnostic(Pg no. 55) + +p_given_i = 0.99 #test signals positive with illness +n_given_i = 0.95 #test signals negative with illness +i = 0.0001 #illness in population + +p_given_not_i = 0.05 + +i_given_p = (p_given_i*i)/((p_given_i*i)+(p_given_not_i*(1-i))) + +cat(i_given_p,"is the probability that you have the illness given test is positive") +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.4/EX2_4.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.4/EX2_4.R new file mode 100644 index 00000000..e6929239 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.4/EX2_4.R @@ -0,0 +1,23 @@ +#Automobile options(Pg no. 19) +foo<-function(){ + number_of_possible_outcomes_of_automatic_transmission = 2 + #Set S = {With an automatic transmission, Without an automatic transmission} + + number_of_possible_outcomes_of_sunroof = 2 + #Set S = {With a sunroof, Without a sunroof} + + number_of_possible_outcomes_of_sterio_system = 3 + #Set S = {Sterio system 1, Sterio system 2, Sterio system 3} + + number_of_possible_outcomes_of_exterior_color = 4 + #Set S = {Exterior color 1, Exterior color 2, Exterior color 3, Exterior color 4} + + total_no_of_outcome = number_of_possible_outcomes_of_automatic_transmission* + number_of_possible_outcomes_of_sunroof* + number_of_possible_outcomes_of_sterio_system* + number_of_possible_outcomes_of_exterior_color + + cat("The sample space contains",total_no_of_outcome,"outcomes") +} + +foo() diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.5/EX2_5.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.5/EX2_5.R new file mode 100644 index 00000000..6435d837 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.5/EX2_5.R @@ -0,0 +1,25 @@ +#Automobile Colors(Pg no. 20) +foo<-function(){ + vehicle_types = 12 + + exterior_color_black = 2 + #Set S = {black, red} + + exterior_color_white = 4 + #Set S = {black, white, blue, brown} + + exterior_color_blue = 3 + #Set S = {black, red, blue} + + exterior_color_brown = 1 + #Set S = {brown} + + total_no_of_outcome = vehicle_types*exterior_color_black+ + vehicle_types*exterior_color_white+ + vehicle_types*exterior_color_blue+ + vehicle_types*exterior_color_brown + + cat("The sample space contains",total_no_of_outcome,"vehicle types") +} + +foo() diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.8/EX2_8.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.8/EX2_8.R new file mode 100644 index 00000000..55e29146 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.8/EX2_8.R @@ -0,0 +1,18 @@ +#Hospital Emergency Visits(Pg no. 21) + +total = c(5292,6991,5640,4329) +lwbs = c(195,270,246,242) +admitted = c(1277,1558,666,984) +not_admitted = c(3820,5163,4728,3103) +df = data.frame("total" = total, "lwbs" = lwbs, "admitted" = admitted, "not_admitted" = not_admitted) +# A is the event that a visit is to hospital 1 +# B is the event that the result of the visit is LWBS +A_intersection_B = df$lwbs[1] +Abar = sum(df$total[2:4]) +A_union_B = df$total[1] + sum(df$lwbs[2:4]) + +cat("A union B =",A_union_B) +cat("A intersection B =",A_intersection_B) +cat("Abar =",Abar) + +# The answer given in textbook for A intersection B is wrong \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.9/EX2_9.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.9/EX2_9.R new file mode 100644 index 00000000..18b8f588 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH2/EX2.9/EX2_9.R @@ -0,0 +1,8 @@ +#Web site design(Pg no. 23) +colors = 4 +fonts = 3 +image_positions = 3 + +designs = colors*fonts*image_positions + +cat(designs,"different designs are possible") diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.10/EX3_10.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.10/EX3_10.R new file mode 100644 index 00000000..553a2f9a --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.10/EX3_10.R @@ -0,0 +1,20 @@ +#Marketing(Pg no. 75) + +B_revenue1 = 7 # in million dollars +B_probability1 = 0.3 + +B_revenue2 = 2 # in million dollars +B_probability2 = 0.7 + +u = B_revenue1*B_probability1 + B_revenue2*B_probability2 +#expectation in million dollars + +v = ((B_revenue1-u)^2)*B_probability1 + ((B_revenue2-u)^2)*B_probability2 +#variance in million dollars squared + +sd = sqrt(v) + +cat("Expectation E(Y) =",u) +cat("Variance V(Y) =",v) +cat("Standard Deviation SD(Y) =",sd) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.11/EX3_11.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.11/EX3_11.R new file mode 100644 index 00000000..2f05a61f --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.11/EX3_11.R @@ -0,0 +1,14 @@ +#Messages(Pg no. 76) + + x = c(10,11,12,13,14,15) # number of messages + probability = c(0.08,0.15,0.30,0.20,0.20,0.07) + + u = weighted.mean(x,probability) #expectation + + v = weighted.mean((x-u)^2,probability)#variance + + sd = sqrt(v) + cat("Expectation E(X) =",u) + cat("Variance V(X) =",v) + cat("Standard Deviation SD(X) =",sd) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.12/EX3_12.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.12/EX3_12.R new file mode 100644 index 00000000..ca98fd30 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.12/EX3_12.R @@ -0,0 +1,12 @@ +#Digital channel continuation(Pg no. 76) + +error_bits = list(0,1,2,3,4) +probability = list(0.656,0.2916,0.0486,0.0036,0.0001) + +index = c(1:length(error_bits)) +u = 0.00 #expectation +for (i in index) { + u = u + (((as.double(error_bits[i]))^2)*as.double(probability[i])) +} + +cat("Expectation E[h(X)] =",u) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.14/EX3_14.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.14/EX3_14.R new file mode 100644 index 00000000..454b56cc --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.14/EX3_14.R @@ -0,0 +1,12 @@ +#Number of voice lines(Pg no. 78) + +max_lines = 48 +min_lines = 0 + +u = (max_lines+min_lines)/2 #expectation + +sd = sqrt((((max_lines-min_lines+1)^2)-1)/12) #standard deviation + +cat("Expectation E(X) =",u) +cat("Standard Deviation SD(X) =",sd) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.15/EX3_15.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.15/EX3_15.R new file mode 100644 index 00000000..c6a65112 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.15/EX3_15.R @@ -0,0 +1,13 @@ +#Refer to EX3_14(Number of voice lines) + +#Proportion of voice lines(Pg no. 79) + +u = 24 #expectation E(X) +v = 199.94 #variance Var(X) + +u1 = u/48 #expectation E(Y) +v1 = v/(48^2) #variance Var(Y) + +cat("Expectation E(Y) =",u1) +cat("Variance Var(Y) =",v1) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.16/EX3_16.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.16/EX3_16.R new file mode 100644 index 00000000..8bd3479b --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.16/EX3_16.R @@ -0,0 +1,15 @@ +#install.packages("combinat") +library(combinat) + +#Digital channel(Pg no. 80) + +error = 0.1 +not_error = 1 - error + +P = error*not_error*error*not_error #probability of 2 errors + +outcomes = dim(combn(4,2))[2] + +total_probability = outcomes*P + +cat("Probability P(X=2) =",total_probability) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.17/EX3_17.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.17/EX3_17.R new file mode 100644 index 00000000..51aa3edd --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.17/EX3_17.R @@ -0,0 +1,14 @@ +#install.packages("combinat") +library(combinat) + +#Binomial coefficient(Pg no. 82) + + +A = dim(combn(10,3))[2] +A + +B = dim(combn(15,10))[2] +B + +C = dim(combn(100,4))[2] +C diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.18/EX3_18.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.18/EX3_18.R new file mode 100644 index 00000000..ca7a9866 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.18/EX3_18.R @@ -0,0 +1,16 @@ +#Organic pollution(Pg no. 83) + +n = 18 #number of samples +p = 0.1 + +# P(X=2) +A = dbinom(2,n,p) +A + +# P(X>=4) == 1 - P(X<4) +B = 1 - pbinom(3,n,p) +B + +# P(3<=X && X<7) +C = dbinom(3,n,p) + dbinom(4,n,p) + dbinom(5,n,p) + dbinom(6,n,p) +C \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.19/EX3_19.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.19/EX3_19.R new file mode 100644 index 00000000..2d148ab2 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.19/EX3_19.R @@ -0,0 +1,11 @@ +#Mean and Variance(Pg no. 84) + +n = 4 +p = 0.1 + +u = n*p + +v = n*p*(1-p) + +cat("E(X) =",u) +cat("Var(X) =",v) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.2/EX3_2.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.2/EX3_2.R new file mode 100644 index 00000000..183bc202 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.2/EX3_2.R @@ -0,0 +1,8 @@ +#Camera flash tests(Pg no. 66) + +pass = 0.8 +fail = 1 - pass + +ppf = pass*pass*fail + +cat("the probability that the first and second cameras pass the test and third one fails is",ppf) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.20/EX3_20.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.20/EX3_20.R new file mode 100644 index 00000000..4a70f58e --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.20/EX3_20.R @@ -0,0 +1,9 @@ +#Digital channel(Pg no. 87) + +error = 0.1 +not_error = 1 - error + +P = (not_error^4)*error + +cat("P(X=5) =",P) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.21/EX3_21.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.21/EX3_21.R new file mode 100644 index 00000000..dc7c1965 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.21/EX3_21.R @@ -0,0 +1,10 @@ +#Wafer contamination(Pg no. 88) + +contaminated = 0.01 + +n = 125 #num of wafers + +p = dgeom(n,contaminated) + +cat("P(X=125) =",p) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.22/EX3_22.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.22/EX3_22.R new file mode 100644 index 00000000..9d2c1aeb --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.22/EX3_22.R @@ -0,0 +1,11 @@ +#Mean and standard deviation(Pg no. 88) + +p = 0.1 + +u = 1/p + +sd = sqrt((1-p)/(p^2)) + +cat("The mean until the first error is",u) +cat("The standard deviation before the first error is",sd) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.24/EX3_24.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.24/EX3_24.R new file mode 100644 index 00000000..46351aa9 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.24/EX3_24.R @@ -0,0 +1,8 @@ +#Digital Channel(Pg no. 89) + +error_prob = 0.1 +n = 10 +n_error = 3 +ans = dnbinom((n-n_error-1),(n_error+1),error_prob) + +cat("Answer is",ans) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.25/EX3_25.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.25/EX3_25.R new file mode 100644 index 00000000..0ec8c717 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.25/EX3_25.R @@ -0,0 +1,11 @@ +#Camera flashes(Pg no. 91) + +p = 0.2 +r = 3 +x = 5 + +#P(X<=5) +B = pnbinom((x-r),r,p) + +cat(B,"is the probability that the third failure is obtained in five or fewer tests") +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.26/EX3_26.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.26/EX3_26.R new file mode 100644 index 00000000..7c07bb4b --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.26/EX3_26.R @@ -0,0 +1,16 @@ +#Sampling without replacement(Pg no. 93) + +# P(X=0) +A = (choose(50,0)*choose(800,2))/choose(850,2) +A + + +# P(X=1) +B = (choose(50,1)*choose(800,1))/choose(850,2) +B + +# P(X=2) +C = (choose(50,2)*choose(800,0))/choose(850,2) +C + +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.27/EX3_27.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.27/EX3_27.R new file mode 100644 index 00000000..c58a2697 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.27/EX3_27.R @@ -0,0 +1,24 @@ +#Parts from suppliers(Pg no. 94) + +supplier1 = 100 #parts from local supplier +supplier2 = 200 #parts from distant supplier + +#P(X=4) +A = (choose(supplier1,4)*choose(supplier2,0))/choose(supplier1+supplier2,4) + +#P(X>=2) +B = 0.0 +for (i in 2:4) +{ + B = B + (choose(supplier1,i)*choose(supplier2,4-i))/choose(supplier1+supplier2,4) +} + +#P(X>=1) == 1 - P(X=0) +temp = ((choose(supplier1,0)*choose(supplier2,4))/choose(supplier1+supplier2,4)) +C = 1 - temp + +cat(A,"is the probability that all 4 parts are from the local supplier") +cat(B,"is the probability that two or more parts in the sample are from the local supplier") +cat(C,"is the probability that at least one part in the sample is from the local supplier") + +#The answer may slightly vary due to rounding off values diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.28/EX3_28.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.28/EX3_28.R new file mode 100644 index 00000000..1e9fe0f5 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.28/EX3_28.R @@ -0,0 +1,13 @@ +#Mean and variance(Pg no. 95) + +size = 4 +p = 100/300 + +u = size*p #expectation + +v = size*(1/3)*(2/3)*((300-4)/299) #variance + +cat("E(X) =",u) +cat("Var(X) =",v) + +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.29/EX3_29.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.29/EX3_29.R new file mode 100644 index 00000000..e95a05a3 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.29/EX3_29.R @@ -0,0 +1,10 @@ +#Customer Sample(Pg no. 96) + +p = 0.7 #P(A) +n = 50 #no.of sample suctomers + +#P(X>45) +B = 1 - pbinom(45,50,p) + +cat(B,"is the probability that X>45 have purchased from the corporation in the last three months") +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.31/EX3_31.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.31/EX3_31.R new file mode 100644 index 00000000..d5e2594d --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.31/EX3_31.R @@ -0,0 +1,19 @@ +#Calculations of wire flaws(Pg no. 99) + +mean = 2.3 #flaws per mm(millimeter) +t = 1 #mm +#P(X=2) +A = dpois(2,lambda = mean*t) + +t = 5 #mm +#P(X=10) +B = dpois(10, lambda = mean*t) + +t = 2 #mm +#P(X>-1) == 1 - P(X=0) +C = 1 - dpois(0,lambda = mean*t) + +cat("the probability of two flaws in 1 millimeter of wire is",A) +cat("the probability of 10 flaws in 5 millimeters of wire is",B) +cat("the probability of at least one flaw in 2 millimeters of wire is",C) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.32/EX3_32.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.32/EX3_32.R new file mode 100644 index 00000000..9546d156 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.32/EX3_32.R @@ -0,0 +1,18 @@ +#Magnetic storage and contamination(Pg no. 101) + +mean = 0.1 #particles per cm(centiimeter)^2 +t = 100 #cm^2 + +#P(X=12) +A = dpois(12, lambda = mean*t) + +#P(X=0) +B = dpois(0, lambda = mean*t) + +#P(X<=12) +C = ppois(12, lambda = mean*t) + +cat("P(X=12) =",A) +cat("P(X=0) =",B) +cat("P(X<=12) =",C) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.5/EX3_5.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.5/EX3_5.R new file mode 100644 index 00000000..3457b1e8 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.5/EX3_5.R @@ -0,0 +1,20 @@ +#Wafer contamination(Pg no. 68) +foo = function() + { + p = 0.01 #contaminent present + a = 1 - p #contaminent absent + x = readline(prompt = "Enter x:") + x = as.integer(x) + if (x>=1) + { + px = (a^(x-1))*p + cat("probability P( X =",x,") is ",px) + } + else + { + cat("Error! input must be >=1") + } + +} + +foo() \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.6/EX3_6.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.6/EX3_6.R new file mode 100644 index 00000000..655b368e --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.6/EX3_6.R @@ -0,0 +1,14 @@ +#Digital channel(Pg no. 71) + +#probability of error in given number(X) of bits +zero = 0.6561 # P(X=0) +one = 0.2916 # P(X=1) +two = 0.0486 # P(X=2) +three = 0.0036 # P(X=3) + + +X = zero + one + two + three +Y = zero + one + two + +cat("P(X<=3) =",X) +cat("P(X=3) =",X-Y) diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.7/EX3_7.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.7/EX3_7.R new file mode 100644 index 00000000..57ccc3cd --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.7/EX3_7.R @@ -0,0 +1,19 @@ +#Cumulative distribution function(Pg no. 72) + +" +F(x) = 0 -- { x < -2} +F(x) = 0.2 -- { -2 <= x < 0} +F(x) = 0.7 -- { 0<= x < 2} +F(x) = 1 -- { 2 <= x} + +f(-2) = ? +f(0) = ? +f(2) = ? +" +P1 = 0.2 - 0.0 +P2 = 0.7 - 0.2 +P3 = 1.0 - 0.7 + +cat("f(-2) =",P1) +cat("f(0) =",P2) +cat("f(2) =",P3) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.8/EX3_8.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.8/EX3_8.R new file mode 100644 index 00000000..cb3d73dc --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.8/EX3_8.R @@ -0,0 +1,25 @@ +#Sampling without replacement(Pg no. 72) + +total = 850 +unconforming = 50 +conforming = total - unconforming + +X0 = (conforming/total)*((conforming-1)/(total-1)) +X1 = 2*(conforming/total)*(unconforming/(total-1)) +X2 = (unconforming/total)*((unconforming-1)/(total-1)) + +F0 = round(X0, digits = 3) +F0 +F1 = round(X0 + X1, digits = 3) +F1 +F2 = X0 + X1 + X2 +F2 +cat( +" +F(x) = 0 -- { x < 0} +F(x) = ",F0," -- { 0 <= x < 1} +F(x) = ",F1," -- { 1 <= x < 2} +F(x) = ",F2," -- { 2 <= x} + +") +#The values may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.9/EX3_9.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.9/EX3_9.R new file mode 100644 index 00000000..c7792bca --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH3/EX3.9/EX3_9.R @@ -0,0 +1,16 @@ +#Digital channel(Pg no. 75) + +error_bits = c(0,1,2,3,4) +probability = c(0.656,0.2916,0.0486,0.0036,0.0001) +df = data.frame('error_bits' = error_bits, 'probability' = probability) + +index = c(1:length(error_bits)) + +u = weighted.mean(error_bits, probability) #expectation + +v = weighted.mean((error_bits-u)^2,probability) #variance + + +cat("Expectation E(X) =",round(u, digits = 1)) +cat("Variance V(X) =",v) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.1/EX4_1.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.1/EX4_1.R new file mode 100644 index 00000000..3c65fe64 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.1/EX4_1.R @@ -0,0 +1,10 @@ +#Electric Current(Pg no. 110) + +#P(X<5) +integrand <- function(x) {5} +q = integrate(Vectorize(integrand), lower = 4.9, upper = 5) +cat("P(X<5) =",q$value) + +#P(4.951.26) =",p1) + +#P(X < 20.86) +p1 = pnorm(20.86,0,1) +cat("P(X<20.86) =",p1) + +#P(X > -1.37) = P(X < 1.37) +p1 = pnorm(1.37,0,1) +cat("P(X>-1.37) =",p1) + +#P(-1.25 < X < 0.37) +pmin = pnorm(0.37,0,1) +pmax = pnorm(-1.25,0,1) +cat("P(-1.25 < Z < 0.37) =",pmin-pmax) + +#P(X <= -4.6) +p = pnorm(-3.99,0,1) +cat("Since P(X<=-3.99) =",round(p, digits = 6),"and P(X<= − 4.6) < P(X<= − 3.99) P(X <= -4.6) almost equal to zero") +#the answer given in textbook is wrong for P(X < 20.86) diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.13/EX4_13.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.13/EX4_13.R new file mode 100644 index 00000000..2e508478 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.13/EX4_13.R @@ -0,0 +1,10 @@ +#Normally distributed current(Pg no. 123) + +mean = 10 #mA +v = 4 #mA^2 +x = 13 #mA + +p = 1 - pnorm(x, mean ,sqrt(v)) +p + +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.14/EX4_14.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.14/EX4_14.R new file mode 100644 index 00000000..40fa7602 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.14/EX4_14.R @@ -0,0 +1,19 @@ +#Normally distributed current(Pg no. 124) + +mean = 10 #mA +v = 4 #mA^2 + +#P(912.60} +integrand <- function(x) {20*(exp(-20*(x-12.5)))} +P = integrate(integrand,lower = 12.6,upper = Inf) +P + +# P {12.500.1) +p1 = pexp(x,mean,lower.tail = FALSE) + +#P(0.033 x) = 0.90 +x = log(0.90)/(-mean) +cat("the length of time x such that P ( X > x ) = 0 . 90 is",round(x*60, digits = 2),"minutes") +cat("the mean time until the next log-on is", (1/mean)*60,"minutes") +cat("The standard deviation of the time until the next log-on is",(1/mean)*60,"minutes") \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.22/EX4_22.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.22/EX4_22.R new file mode 100644 index 00000000..1a6c1928 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.22/EX4_22.R @@ -0,0 +1,16 @@ +#Lack of memory property(Pg no. 135) + +u = 1.4 #expectation in min +#P(X<0.5min) +f = 1 - exp(-(0.5/1.4)) +cat("probability that we detect a particle within 30 seconds of starting the counter is",f) + +#P(3< X <3.5) +f1 = (1 - exp(-(3.5/1.4))) - (1 - exp(-(3/1.4))) + +#P(X >3) +f2 = 1 - (1 - exp(-(3/1.4))) + +#P(X <3.5 | X >3) = P(3< X <3.5) / P(X >3) +result = f1/f2 +round(result,digits = 2) diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.23/EX4_23.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.23/EX4_23.R new file mode 100644 index 00000000..c401e729 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.23/EX4_23.R @@ -0,0 +1,10 @@ +#Processor failure(Pg no. 139) + +mean = 0.0001 #failure per hr +failures = 40000 + +u = mean * failures #expectation + +#P(X > 40,000) = P(N <= 3) +p = ppois(3, lambda = u) +round(p,digits = 3) diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.24/EX4_24.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.24/EX4_24.R new file mode 100644 index 00000000..ad1549d9 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.24/EX4_24.R @@ -0,0 +1,24 @@ + +#(Pg no. 141) + +#P(X>25) +p = ppois(9,lambda = 12.5) +round(p, digits = 3) + + r= 10 + lambda = 0.5 + + mean = r/lambda + mean + + variance = r/(lambda^2) + variance + + sd = variance^0.5 + round(sd, digits = 2) + + #P(X <= x) = 0.95 + x = qgamma(p = 0.95, shape = r, scale = 1/lambda) + cat("A schedule that allows'",x,"hours to prepare 10 slides should be met 95% of the time") + + \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.25/EX4_25.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.25/EX4_25.R new file mode 100644 index 00000000..395c7dc5 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.25/EX4_25.R @@ -0,0 +1,10 @@ +#Bearing Wear(Pg no. 144) + +mean = 5000*0.5*sqrt(pi) +mean + +#P(X>6000) +p = pweibull(q = 6000,shape = 2, scale = 5000,lower.tail = FALSE) + +cat("only ",round(p*100,digits = 1),"% of all bearings last at least 6000 hours") + diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.26/EX4_26.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.26/EX4_26.R new file mode 100644 index 00000000..adaa8144 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.26/EX4_26.R @@ -0,0 +1,19 @@ +#Semiconductor Laser(Pg no. 147) + +o = 10 +w = 1.5 + +#P(X > 10000) +p = 1 - plnorm(10000, meanlog = o, sdlog = w) +cat("P(X > 10000) =",p) + +x = qlnorm(0.99,o,w,lower.tail = FALSE) +cat("x =",round(x,digits = 2),"hours") + +E_x = exp(o+(w^2/2)) +cat("mean =",round(E_x,digits = 1),"hours") + +V_x = (exp((2*o)+(w^2)))*(exp((w^2))-1) +cat("standard deviation =",sqrt(V_x),"hours") + +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.27/EX4_27.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.27/EX4_27.R new file mode 100644 index 00000000..a657c624 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.27/EX4_27.R @@ -0,0 +1,10 @@ + +#(Pg no. 149) + +alpha = 2.5 +beta = 1 + + +#P(X > 0.7) + p = pbeta(q = 0.7, shape1 = alpha, shape2 = beta, lower.tail = FALSE) + cat("P(X > 0.7) =",round(p,digits = 2)) diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.28/EX4_28.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.28/EX4_28.R new file mode 100644 index 00000000..aec9ae5d --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.28/EX4_28.R @@ -0,0 +1,13 @@ + +#(Pg no. 150) + +a = 8 +b = 20 +m = 16 + +mean = (a+(4*m)+b)/6 +cat("mean =",round(mean,digits = 3)) +alpha = ((mean-a)*((2*m)-a-b))/((m-mean)*(b-a)) +cat("alpha =",round(alpha,digits = 3)) +beta = (alpha*(b-mean))/(mean-a) +cat("beta =",round(beta,digits = 3)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.5/EX4_5.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.5/EX4_5.R new file mode 100644 index 00000000..70b51b61 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.5/EX4_5.R @@ -0,0 +1,9 @@ +#install.packages("Deriv") +library(Deriv) + +#Reaction time(Pg no. 113) + +#P(X<200) +f = function(x){1-(exp(-(0.01*x)))} +f(200) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.6/EX4_6.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.6/EX4_6.R new file mode 100644 index 00000000..a859d24d --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.6/EX4_6.R @@ -0,0 +1,13 @@ +#Electric current(Pg no. 115) + +# Expectation +integrand <- function(x) {5*x} +P = integrate(integrand,lower = 4.9,upper = 5.1) +P + +# Variance +integrand <- function(x) {5*(x-10)^2} +Q = integrate(integrand,lower = 4.9,upper = 5.1) +Q + +#The answer provided in textbook is wrong \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.7/EX4_7.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.7/EX4_7.R new file mode 100644 index 00000000..a8d01597 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.7/EX4_7.R @@ -0,0 +1,7 @@ +#Continuation of EX4_1 + +#(Pg no. 115) + +integrand <- function(x) {0.0001*(x^2)} +P = integrate(integrand,lower = 4.9,upper = 5.1) +P #watts \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.8/EX4_8.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.8/EX4_8.R new file mode 100644 index 00000000..bdba644f --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.8/EX4_8.R @@ -0,0 +1,15 @@ +#Hole diameter(Pg no. 115) + +# Expectation +integrand <- function(x) {x*20*(exp(-20*(x-12.5)))} +u = integrate(integrand,lower = 12.5,upper = Inf) +u + +# Variance +integrand <- function(x) {((x - 12.55)^2)*20*(exp(-20*(x-12.5)))} +v = integrate(integrand,lower = 12.5,upper = Inf) +v + +sd = sqrt(v$value) #Standard deviation +sd +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.9/EX4_9.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.9/EX4_9.R new file mode 100644 index 00000000..3188a108 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH4/EX4.9/EX4_9.R @@ -0,0 +1,19 @@ +#Uniform current(Pg no. 117) + +# P {4.951000,X2>1000,X3>1000,X4>1000)=",round(p,digits = 5)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.15/EX5_15.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.15/EX5_15.R new file mode 100644 index 00000000..b00cb66c --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.15/EX5_15.R @@ -0,0 +1,12 @@ +#install.packages("MASS") +library(MASS) + +#Probability as a Ratio of Volumes(Pg no. 168) + +area1 = 4*pi +area2 = pi + +p = area2/area1 +cat("Prabability is",fractions(p)) +ans = fractions(p) +ans \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.16/EX5_16.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.16/EX5_16.R new file mode 100644 index 00000000..75dedcc8 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.16/EX5_16.R @@ -0,0 +1,18 @@ +#(Pg no. 168) + +#P(X2 = 0) +P_0 = 0.4 + +#P(X2 = 1) +P_1 = 0.3 + +#P(X2 = 2) +P_2 = 0.2 + +#P(X2 = 3) +P_3 = 0.1 + +x = c(0,1,2,3) + +E = weighted.mean(x,c(P_0,P_1,P_2,P_3)) +cat("E(X2) =",E) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.18/EX5_18.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.18/EX5_18.R new file mode 100644 index 00000000..d2b62828 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.18/EX5_18.R @@ -0,0 +1,21 @@ +#Layer Thickness(Pg no. 170) + +mean1 = 10000 +std_dev1 = 250 +mean2 = 1000 +std_dev2 = 20 +mean3 = 80 +std_dev3 = 4 + +#P(92002000) +f <- function(y) +{ + (exp((-(0.002*y))))*(1-exp(-(0.001*y))) +} +v = integrate(f, lower = 2000, upper = Inf) +ans = (6*10^-3)*(v$value) +cat("P(Y>2000) =",round(ans,digits = 2)) diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.5/EX5_5.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.5/EX5_5.R new file mode 100644 index 00000000..f371bb12 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.5/EX5_5.R @@ -0,0 +1,15 @@ +#Conditional Probabilities for Mobile Response Time(Pg no. 162) + +P3_1 = 0.25 +P3_2 = 0.2 +P3_3 = 0.05 +P3_4 = 0.05 + +f3 = P3_1 + P3_2 + P3_3 + P3_4 + +cat("P(Y=1|X=3) =",round((P3_1/f3),digits = 3)) +cat("P(Y=2|X=3) =",round((P3_2/f3),digits = 3)) +cat("P(Y=3|X=3) =",round((P3_3/f3),digits = 3)) +cat("P(Y=4|X=3) =",round((P3_4/f3),digits = 3)) + +#The answer may slightly vary due to rounding off values diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.6/EX5_6.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.6/EX5_6.R new file mode 100644 index 00000000..21234975 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.6/EX5_6.R @@ -0,0 +1,10 @@ +#Conditional Probability(Pg no. 163) + +#P(Y>2000|X=1500) +f <- function(y) +{ + 0.002*(exp((0.002*1500)-(0.002*y))) +} +v = integrate(f, lower = 2000, upper = Inf) +ans = v$value +cat("P(Y>2000|X=1500) =",round(ans,digits = 3)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.8/EX5_8.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.8/EX5_8.R new file mode 100644 index 00000000..a2b26d0d --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.8/EX5_8.R @@ -0,0 +1,10 @@ +#Conditional Mean And Variance(Pg no. 164) + +#E(Y|X=1500) +f <- function(y) +{ + y*(0.002*(exp((0.002*1500)-(0.002*y)))) +} +v = integrate(f, lower = 1500, upper = Inf) +ans = v$value #ms +cat("E(Y|X=1500) =",ans) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.9/EX5_9.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.9/EX5_9.R new file mode 100644 index 00000000..e3956a40 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH5/EX5.9/EX5_9.R @@ -0,0 +1,8 @@ +#(Pg no. 164) +y = c(1,2,3,4) +prob = c(0.05,0.1,0.1,0.75) +u = weighted.mean(y,prob) +cat("E(Y|1) =",u) + +v = weighted.mean((y-u)^2, prob) +cat("V(Y|1) =",round(v, digits = 3)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.1/EX6_1.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.1/EX6_1.R new file mode 100644 index 00000000..9b0ed27e --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.1/EX6_1.R @@ -0,0 +1,7 @@ +#Sample mean(Pg no. 200) + +obs = c(12.6,12.9,13.4,12.3,13.6,13.5,12.6,13.1) +x = mean(obs) + +cat("sample mean is",x,"pounds") + diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.2/EX6_2.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.2/EX6_2.R new file mode 100644 index 00000000..54b8a8c2 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.2/EX6_2.R @@ -0,0 +1,9 @@ +#Sample variance(Pg no. 202) + +obs = c(12.6,12.9,13.4,12.3,13.6,13.5,12.6,13.1) + +v = var(obs) +sd = sd(obs) + +cat("sample variance is ",round(v,digits = 4)) #pounds^2 +cat("sample standard deviation is",round(sd,digits = 2)) #pounds \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.3/EX6_3.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.3/EX6_3.R new file mode 100644 index 00000000..470b2130 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH6/EX6.3/EX6_3.R @@ -0,0 +1,11 @@ +#Sample variance shortcut(Pg no. 203) + +samples = c(12.6,12.9,13.4,12.3,13.6,13.5,12.6,13.1) +n = length(samples) #number of samples +x = sum(samples) # sum of individual samples +y = sum(samples^2) # sum of square of individual samples + +v = (y - ((x)^2/n))/(n-1) + +cat("sample variance is ",v) #pounds^2 +cat("sample standard deviation is",round(sqrt(v),digits = 2)) #pounds \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.1/EX7_1.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.1/EX7_1.R new file mode 100644 index 00000000..515fbc3c --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.1/EX7_1.R @@ -0,0 +1,13 @@ +#Resistors(Pg no. 175) + +n = 25 +mean = 100 #ohms +x = 95 #ohms + +sd = mean/(sqrt(n)) #standard deviation +z = (x - mean)/sd + +#P(x<95) = P(Z<-2.5) +p = pnorm(-2.5) +round(p, digits = 4) + diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.17/EX7_17.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.17/EX7_17.R new file mode 100644 index 00000000..bfca9846 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.17/EX7_17.R @@ -0,0 +1,10 @@ +#Bayes Estimator for the Mean of a Normal Distribution(Pg no. 265) + +n = 10 +variance = 4 +mean0 = 0 +variance0 = 1 +sample_mean = 0.75 + +estimated_mean = ((variance/n)*mean0 + (variance0)*sample_mean)/(1 + (variance/n)) +cat("Estimated mean is ",round(estimated_mean,digits = 3)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.3/EX7_3.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.3/EX7_3.R new file mode 100644 index 00000000..5f2ea4c9 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.3/EX7_3.R @@ -0,0 +1,22 @@ +#Aircraft engine life(Pg no. 147) + +mean1 = 5000 +mean2 = 5050 + +variance1 = 10 +variance2 = 6 + +mean = mean2 - mean1 +varianve = (variance2)^2 + (variance1)^2 + +x = 25 + +z = (x-mean)/sqrt(varianve) + +#P(X2 - X1 >=25) = P(Z >= z) +p = 1 - pnorm(z) +p + +cat(round(p,digits = 4),"is the probability that the difference in sample means between the new and the old process will be at least 25 hours") + +# The answer may slightly vary due to rounding off of values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.5/EX7_5.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.5/EX7_5.R new file mode 100644 index 00000000..d015a8bc --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.5/EX7_5.R @@ -0,0 +1,9 @@ +#Thermal conductivity(Pg no. 252) + +n = 10 +obs = c(41.60 , 41.48 , 42.34 , 41.95 , 41.86 , 42.18 , 41.72 , 42.26 , 41.81 , 42.04) +sd = sd(obs) #standard deviation + +se = sd/sqrt(n) #standard error + +cat("standard error is ",round(se,digits = 4)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.9/EX7_9.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.9/EX7_9.R new file mode 100644 index 00000000..9609689d --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH7/EX7.9/EX7_9.R @@ -0,0 +1,13 @@ +#Gamma Distribution Moment Estimators(Pg no. 258) + +n = 8 +x = 21.65 +y = 6639.40 #sum of square of individual samples + +r = x^2/(((1/n)*y)-(x)^2) +r + +lamda = x/(((1/n)*y)-(x)^2) +round(lamda,digits = 4) + +# The answer may slightly vary due to rounding off of values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.1/EX8_1.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.1/EX8_1.R new file mode 100644 index 00000000..c28ce614 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.1/EX8_1.R @@ -0,0 +1,11 @@ +#Metallic Material Transition(Pg no. 274) + +n = 10 +sd = 1 +z = qnorm(0.025,lower.tail = FALSE) +mean = 64.46 + +min = mean - z*(sd/sqrt(n)) +max = mean + z*(sd/sqrt(n)) + +cat("The resulting 95% CI is",round(min,digits = 2),"<= u <= ",round(max,digits = 2)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.10/EX8_10.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.10/EX8_10.R new file mode 100644 index 00000000..aa9ea91b --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.10/EX8_10.R @@ -0,0 +1,12 @@ +#The Agresti-Coull CI on a Proportion(Pg no. 294) + +p = 0.12 +n = 85 +z = qnorm(0.025,lower.tail = FALSE) + +ucl = (p+((z^2)/(2*n))+(z*sqrt(((p*(1-p))/n)+((z^2)/(4*(n^2))))))/(1+((z^2)/n)) +lcl = (p+((z^2)/(2*n))-(z*sqrt(((p*(1-p))/n)+((z^2)/(4*(n^2))))))/(1+((z^2)/n)) + +cat("UCL =",round(ucl,digits = 4)) +cat("LCL =",round(lcl,digits = 4)) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.11/EX8_11.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.11/EX8_11.R new file mode 100644 index 00000000..729f4a23 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.11/EX8_11.R @@ -0,0 +1,12 @@ +#Alloy Adhesion(Pg no. 298) + +n = 22 +sd = 3.55 +df = n - 1 +t = qt(0.025,df,lower.tail = FALSE) +mean = 13.71 + +min = mean - t*sd*sqrt(1+(1/n)) +max = mean + t*sd*sqrt(1+(1/n)) + +cat("A 95% prediction interval on the load at failure for this specimen is",round(min,digits = 2),"<= X <= ",round(max,digits = 2)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.12/EX8_12.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.12/EX8_12.R new file mode 100644 index 00000000..89cdf061 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.12/EX8_12.R @@ -0,0 +1,16 @@ +#install.packages("tolerance") +library(tolerance) + +#Alloy Adhesion(Pg no. 299) + +n = 22 +sd = 3.55 +mean = 13.71 +k = K.factor(n, f = NULL, 0.05, 0.90, side = 2) + +min = mean - k*sd +max = mean + k*sd + +cat("The desired tolerance interval is [",round(min,digits = 2),",",round(max,digits = 2),"]") + +# The answer may slightly vary due to rouding off values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.2/EX8_2.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.2/EX8_2.R new file mode 100644 index 00000000..ecc447a6 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.2/EX8_2.R @@ -0,0 +1,10 @@ +#Metallic Material Transition(Pg no. 276) + +e = 0.5 #error in estimation +z = qnorm(0.025,lower.tail = FALSE) +sd = 1 + +n = ((z*sd)/e)^2 +n = ceiling(n) + +cat("the required sample size is",n) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.3/EX8_3.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.3/EX8_3.R new file mode 100644 index 00000000..4b8f3967 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.3/EX8_3.R @@ -0,0 +1,10 @@ +#One-Sided Confidence Bound(Pg no. 277) + +n = 10 +sd = 1 +z = qnorm(0.05,lower.tail = FALSE) +mean = 64.46 + +min = mean - z*(sd/sqrt(n)) + +cat("the interval is",round(min,digits = 2),"<= u") \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.4/EX8_4.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.4/EX8_4.R new file mode 100644 index 00000000..6f783c69 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.4/EX8_4.R @@ -0,0 +1,15 @@ +#The Exponential Distribution(Pg no. 278) + +x = c(2.84,2.37,7.52,2.76,3.83,1.32,8.43,2.25,1.63,0.27) +n = length(x) +df = 2*n #degrees of freedom +Cl = qchisq(0.025,20,lower.tail = TRUE) +Cu = qchisq(0.025,20,lower.tail = FALSE) +x_sum = sum(x) + +upper_bound = Cu/(2*x_sum) +lower_bound = Cl/(2*x_sum) + +cat("The 95% two-sided CI on lambda is",round(lower_bound,digits = 4),"<= lambda <=",round(upper_bound,digits = 4)) + +# The values may slightly vary due to rounding off of values \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.5/EX8_5.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.5/EX8_5.R new file mode 100644 index 00000000..efa2daf3 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.5/EX8_5.R @@ -0,0 +1,11 @@ +#Mercury Contamination(Pg no. 279) + +n = 53 +sd = 0.3486 +z = qnorm(0.025,lower.tail = FALSE) +mean = 0.5250 + +min = mean - z*(sd/sqrt(n)) +max = mean + z*(sd/sqrt(n)) + +cat("The approximate 95% CI is",round(min,digits = 4),"<= u <= ",round(max,digits = 4)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.6/EX8_6.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.6/EX8_6.R new file mode 100644 index 00000000..72f13fa6 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.6/EX8_6.R @@ -0,0 +1,7 @@ +#Alloy Adhesion(Pg no. 285) +obs = c(19.8,15.4,11.4,19.5,10.1,18.5,14.1,8.8,14.9,7.9,17.6,13.6,7.5,12.7,16.7,11.9,15.4,11.9,15.8,11.4,15.4,11.4) +ans = t.test(obs) + +min = ans$conf.int[1] +max = ans$conf.int[2] +cat("The resulting 95% CI is",round(min,digits = 2),"<= u <= ",round(max,digits = 3)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.7/EX8_7.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.7/EX8_7.R new file mode 100644 index 00000000..041d640c --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.7/EX8_7.R @@ -0,0 +1,10 @@ +#Detergent Filling(Pg no. 289) + +sample_variance = 0.0153 #fluidounce +n = 20 #bottles +x = qchisq(0.95,19, lower.tail = FALSE) +variance = ((n-1)*sample_variance)/x +sd = sqrt(variance) + +cat("A 95% upper confidence bound on variance is",round(variance,digits = 4)) +cat("A 95% upper confidence bound on standard deviation is",round(sd, digits = 2)) \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.8/EX8_8.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.8/EX8_8.R new file mode 100644 index 00000000..8ffa651f --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.8/EX8_8.R @@ -0,0 +1,15 @@ +#Crankshaft Bearings(Pg no. 292) + +n = 85 +x = 10 +p = round(x/n, digits = 2) +p +z = round(qnorm(0.025,lower.tail = FALSE),digits = 2) +z + +p_min = p - (z*sqrt((p*(1-p))/n)) +p_max = p + (z*sqrt((p*(1-p))/n)) + +cat("A 95% two-sided confi dence interval for p is",round(p_min,digits = 4),"<= p <=",round(p_max,digits = 4)) + +# The answer given in the textbook is wrong for the upper bound \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.9/EX8_9.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.9/EX8_9.R new file mode 100644 index 00000000..5f851963 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH8/EX8.9/EX8_9.R @@ -0,0 +1,14 @@ +#Crankshaft Bearings(Pg no. 293) + +p = 0.12 +e = 0.05 +z = qnorm(0.025,lower.tail = FALSE) + +n = (z/e)^2 * p * (1-p) +n = ceiling(n) + +cat("sample size is",n) + +n = (z/e)^2 * 0.25 +n = ceiling(n) +n \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.10/EX9_10.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.10/EX9_10.R new file mode 100644 index 00000000..cafd67dd --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.10/EX9_10.R @@ -0,0 +1,24 @@ +#Automobile Engine Controller(Pg no. 346) + +foo= function() +{ + x = 4 + n = 200 + p0 = 0.05 + + statistic = (x - (n*p0))/sqrt(n*p0*(1-p0)) + statistic + + p_value = pnorm(statistic,0,1) + p_value + + if(p_value < p0) + { + print("Null hypothesis is rejected") + } + else + { + print("Unable to reject the null hypothesis") + } +} +foo() \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.11/EX9_11.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.11/EX9_11.R new file mode 100644 index 00000000..e64dfde1 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.11/EX9_11.R @@ -0,0 +1,17 @@ +#Automobile Engine Controller Type II Error(Pg no. 347) + +p0 = 0.05 +n = 200 +p = 0.03 +z_alpha = qnorm(p0,0,1,lower.tail = FALSE) + +x = (p0 - p - (z*sqrt((p0*(1-p0))/n)))/sqrt((p*(1-p))/n) + +beta = 1 - pnorm(x,0,1) + +z_beta = qnorm(0.10,0,1,lower.tail = FALSE) +z_beta + +n = (((z_alpha*sqrt(p0*(1-p0))) + (z_beta*sqrt(p*(1-p))))/(p-p0))^2 +n = floor(n) +n \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.12/EX9_12.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.12/EX9_12.R new file mode 100644 index 00000000..087b8600 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.12/EX9_12.R @@ -0,0 +1,39 @@ +#Printed Circuit Board Defects-Poisson Distribution(Pg no. 351) + +foo = function() +{ + n = 60 + defects = c(0,1,2,3) + obsv_freq = c(32,15,9,4) + observed_mean = weighted.mean(defects,obsv_freq) + + p1 = dpois(0,lambda = observed_mean) + p2 = dpois(1,lambda = observed_mean) + p3 = dpois(2,lambda = observed_mean) + p4 = 1 - (p1+p2+p3) + + obsv_freq = c(obsv_freq[1],obsv_freq[2],(obsv_freq[3]+obsv_freq[4])) + + expected_freq = c(n*p1,n*p2,(n*p3+n*p4)) + + statistic = 0.0 + + for(i in 1:3) + { + statistic = statistic + (((obsv_freq[i] - expected_freq[i])^2)/expected_freq[i]) + } + statistic + + x1 = qchisq(0.9,1) + x2 = qchisq(0.95,1) + + if(x1compare) +{ + print("Reject null hypothesis") +} +else +{ + print("there is no strong evidence of a problem with incorrectly filled bottles") +} +} +foo() \ No newline at end of file diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.9/EX9_9.R b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.9/EX9_9.R new file mode 100644 index 00000000..65ec7fe2 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/CH9/EX9.9/EX9_9.R @@ -0,0 +1,10 @@ +#Automated Filling Sample Size(Pg no. 343) + +sd = 0.125 +sd0 = 0.10 +n1 = 20 +alpha = 0.05 + +lambda = sd/sd0 + +cat("With n =",n1,"and lambda =",lambda,"there is only 40% chance that the null hypothesis will be rejected") diff --git a/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/README.txt b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/README.txt new file mode 100644 index 00000000..7eecee03 --- /dev/null +++ b/Applied_Statistics_And_Probability_For_Engineers_by_Douglas_C._Montgomery_And_George_C._Runger/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Shaik Sameer +Course: Btech +Branch: Information Technology +College/Institute/Organization: Indian Institute Of Information Technology, Vadodara + +About The Book + +Book: Applied Statistics And Probability For Engineers +Author: Douglas C. Montgomery And George C. Runger +Publisher: John Wiley & Sons, Usa +Year Of Publication: 2014 +ISBN: 9781118539712 +Edition: 6 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.18/Ex11_18.R b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.18/Ex11_18.R new file mode 100644 index 00000000..4e355398 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.18/Ex11_18.R @@ -0,0 +1,18 @@ +#page no .95 +#problem 17 +#load package ---->measurements +library(measurements) +#functions: +area_wire = function(p,l,r) +{ + return(p*l/r) +} +#formula used: R = p*l/a +#given: +r = 5 #resistance of wire +l = 1.5 #lenght in kilmeter +l1 = conv_unit(l,'km','m') +p = 17.2 * 10^-6 # resistivity of wire in mm +p1 = conv_unit(p,'mm','m') +a = area_wire(p1,l1,r) #area of cross-section of wire +print(a) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.19/Ex11_19.R b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.19/Ex11_19.R new file mode 100644 index 00000000..e5d76171 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.19/Ex11_19.R @@ -0,0 +1,18 @@ +#page no .95 +#problem 19 +#load package ---->measurements +library(measurements) +#functions: +R = function(p,v,n,t) +{ + return((p*v)/(n*t)) +} +#formula used: pv=nrt +# r = pv/nt +#given: +p = 3 * 10^6 #pressure of gas in pascal +v = 0.90 #volume of gas +m = 2.81 #mass of gas in kg +t = 231 # temperature in kelvin +r = R(p,v,m,t) #constant +print(r) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.22/Ex11_22.R b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.22/Ex11_22.R new file mode 100644 index 00000000..84a47792 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.22/Ex11_22.R @@ -0,0 +1,11 @@ +#page no. 96 +#problem 22 +#formula used : s=ut+(1/2)at^2 +# a = ((s-ut)*2)/t^2 + +#given: +s = 168 #distance travelled in meter +u = 10 #initial velocity in m/s +t = 6 #time in seconds +a = ((s-u*t)*2)/t^2 # acceleration in m/s^2 +print(a) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.24/Ex11_24.R b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.24/Ex11_24.R new file mode 100644 index 00000000..26ba2554 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.24/Ex11_24.R @@ -0,0 +1,11 @@ +#page no.97 +#problem 24 +#formula used: e=fl/ax +# x = fl/ae + +f = 20*10^6 #force when carrying load +e = 70 * 10^9 # modulus of elasticity +a = 0.1 #cross-sectional area +l = 1.4 # lenght of bar +x = (f*l)/(a*e) #extension of bar in m +print(x*1000) #extension in mm diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.28/Ex11_28.R b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.28/Ex11_28.R new file mode 100644 index 00000000..d230f6c1 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH11/EX11.28/Ex11_28.R @@ -0,0 +1,10 @@ +#page no. 97 +#problem 28 +#formula used: D/d = sqrt((f+p)/(f-p)) +# (D/d)^2= (f+p)/(f-p) +#given: +D= 21.5 +d = 10.75 +p = 1800 +f = (p*(1+(D/d)^2))/(((D/d)^2)-1) #stress of thick cylinder +print(f) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.17/Ex13_17.R b/Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.17/Ex13_17.R new file mode 100644 index 00000000..0944c8a7 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.17/Ex13_17.R @@ -0,0 +1,22 @@ +#page no . 120 +#problem 17 +# formula used : matrix multiplication +# x = A(inverse) * B +#given: c = a+bt + + + #case 1 + c1 = 52 + t1 = 100 + #eq1 = (52 = a + 100b) + #case 2 + c2 = 172 + t2 = 400 + #eq2 = (172 = a+400b) + +# for solving a and b, form matrix + A = array(data = c(1,1,100,400),dim = c(2,2)) + B = c(52,172) + + solve(A,B) #value of a and b respectivily + \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.18/Ex13_18.R b/Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.18/Ex13_18.R new file mode 100644 index 00000000..36e4ec23 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.18/Ex13_18.R @@ -0,0 +1,18 @@ +#page no. 121 +#problem 18 +#given: +# x+y+z = 4 +# 2x-2y+4z = 33 +#3x-2y-2z = 2 + +# formula used : matrix multiplication +# x = A(inverse) * B + +A = array(data=c(1,2,3,1,-2,-2,1,4,-2),dim =c(3,3)) +B = c(4,33,2) +X = solve(A,B) +cat("x=",X[1]) #value of x + +cat("y=",X[2]) #value of y + +cat("z=",X[3]) #value of z \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.4/Ex13_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.4/Ex13_4.R new file mode 100644 index 00000000..bd393170 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH13/EX13.4/Ex13_4.R @@ -0,0 +1,9 @@ +#page no. 113 +#problem 4 +# formula used : matrix multiplication +# x = A(inverse) * B + +A = array(data = c(7,6,-2,5), dim = c(2,2)) +B = c(26,29) + +solve(A,B) #value of a and b respectivily \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.18/Ex14_18.R b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.18/Ex14_18.R new file mode 100644 index 00000000..cd8d6aed --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.18/Ex14_18.R @@ -0,0 +1,31 @@ +#page no. 129 +#problem 18 + +#function: + +# Constructing Quadratic Formula +roots <- function(a,b,c){ + if(delta(a,b,c) > 0){ # first case D>0 + x_1 = (-b+sqrt(delta(a,b,c)))/(2*a) + x_2 = (-b-sqrt(delta(a,b,c)))/(2*a) + result = c(x_1,x_2) + } + else if(delta(a,b,c) == 0){ # second case D=0 + x = -b/(2*a) + } + else {"There are no real roots."} # third case D<0 +} + +# Constructing delta +delta<-function(a,b,c){ + b^2-4*a*c +} + +#given: quadratic eq. +# x^2+2x-8 = 0 + +a = 1 +b = 2 +c = -8 +x12 = roots(a,b,c) #roots of quadratic equation +print(x12) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.19/Ex14_19.R b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.19/Ex14_19.R new file mode 100644 index 00000000..f67ccafc --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.19/Ex14_19.R @@ -0,0 +1,31 @@ +#page no. 129 +#problem 18 + +#function: + +# Constructing Quadratic Formula +roots <- function(a,b,c){ + if(delta(a,b,c) > 0){ # first case D>0 + x_1 = (-b+sqrt(delta(a,b,c)))/(2*a) + x_2 = (-b-sqrt(delta(a,b,c)))/(2*a) + result = c(x_1,x_2) + } + else if(delta(a,b,c) == 0){ # second case D=0 + x = -b/(2*a) + } + else {"There are no real roots."} # third case D<0 +} + +# Constructing delta +delta<-function(a,b,c){ + b^2-4*a*c +} + +#given: quadratic eq. +# 3x^2+-11x-4 = 0 + +a = 3 +b = -11 +c = -4 +x12 = roots(a,b,c) #roots of quadratic equation +print(x12) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.22/Ex14_22.R b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.22/Ex14_22.R new file mode 100644 index 00000000..cb5509bd --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.22/Ex14_22.R @@ -0,0 +1,34 @@ +#page no. 129 +#problem 18 + +#function: + + +roots <- function(a, b, c){ + + pos_root <- ((-b) + sqrt((b^2) - 4*a*c)) / (2*a) + + neg_root <- ((-b) - sqrt((b^2) - 4*a*c)) / (2*a) + + return(pos_root) #length can not be negative, so take +ve root + + print(neg_root) + +} + +#given: +area = 23.6 #area of rectangle +#l = x #let lenght of rectangle be x +#b = x -3.10 # breadth is 3.10 shorter than length +#eq. formed --->area = l*b +# 23.6 = x*(x-3.10) +# 23.6 = x^2-3.1x +# x^2-3.1x-23.6=0 +a = 1 +b = -3.1 +c = -23.6 +x12 = roots(a,b,c) #roots of quadratic equation +l = x12 +b = x12 - 3.10 +print(l) #length of rectangle +print(b) #breadth of rectangle diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.26/Ex14_26.R b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.26/Ex14_26.R new file mode 100644 index 00000000..98629397 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.26/Ex14_26.R @@ -0,0 +1,27 @@ +#page no. 131 +#problem 26 +# funtion: +roots <- function(a, b, c){ + + pos_root <- ((-b) + sqrt((b^2) - 4*a*c)) / (2*a) + + neg_root <- ((-b) - sqrt((b^2) - 4*a*c)) / (2*a) + + return(pos_root) #radius can not be negative, so take +ve root + + print(neg_root) + +} +# given: area of cone = (pi*r*l) + pi*r^2 + +area = 486.2 #area of cone +l = 15.3 # slant height of cone +# after placing values we get eq. +# r^2+15.3r-482.2/pi + +a = 1 +b = 15.3 +c = -482.2/pi +r = roots(a,b,c) +dia = 2*r #diameter of cone base +print(dia) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.5/Ex14_5.R b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.5/Ex14_5.R new file mode 100644 index 00000000..0ab10241 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.5/Ex14_5.R @@ -0,0 +1,31 @@ +#page no. 125 +#problem 5 + +#function: + +# Constructing Quadratic Formula +roots <- function(a,b,c){ + if(delta(a,b,c) > 0){ # first case D>0 + x_1 = (-b+sqrt(delta(a,b,c)))/(2*a) + x_2 = (-b-sqrt(delta(a,b,c)))/(2*a) + result = c(x_1,x_2) + } + else if(delta(a,b,c) == 0){ # second case D=0 + x = -b/(2*a) + } + else {"There are no real roots."} # third case D<0 +} + +# Constructing delta +delta<-function(a,b,c){ + b^2-4*a*c +} + +#given: quadratic eq. +# x^2+3x-4 = 0 + +a = 1 +b = 3 +c = -4 +x12 = roots(a,b,c) #roots of quadratic equation +print(x12) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.7/Ex14_7.R b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.7/Ex14_7.R new file mode 100644 index 00000000..bc58e795 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH14/EX14.7/Ex14_7.R @@ -0,0 +1,31 @@ +#page no. 126 +#problem 7 + +#function: + +# Constructing Quadratic Formula +roots <- function(a,b,c){ + if(delta(a,b,c) > 0){ # first case D>0 + x_1 = (-b+sqrt(delta(a,b,c)))/(2*a) + x_2 = (-b-sqrt(delta(a,b,c)))/(2*a) + result = c(x_1,x_2) + } + else if(delta(a,b,c) == 0){ # second case D=0 + x = -b/(2*a) + } + else {"There are no real roots."} # third case D<0 +} + +# Constructing delta +delta<-function(a,b,c){ + b^2-4*a*c +} + +#given: quadratic eq. +# x^2-5x+6 = 0 + +a = 1 +b = -5 +c = 6 +x12 = roots(a,b,c) #roots of quadratic equation + print(x12) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.1/Ex15_1.R b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.1/Ex15_1.R new file mode 100644 index 00000000..cdbe39bf --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.1/Ex15_1.R @@ -0,0 +1,6 @@ +#page no. 135 +#problem 1 +#function used: log(x,base) +n = 9 # number to evaluate +base = 3 #log base +print(log(n,base)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.2/Ex15_2.R b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.2/Ex15_2.R new file mode 100644 index 00000000..81fde93f --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.2/Ex15_2.R @@ -0,0 +1,7 @@ +#page no. 135 +#problem 2 +#function used: log10(x) +#given: +n = 10 # number to evaluate +val = log10(n) #log base 10 function +print(val) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.3/Ex15_3.R b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.3/Ex15_3.R new file mode 100644 index 00000000..3427a7e7 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.3/Ex15_3.R @@ -0,0 +1,6 @@ +#page no. 135 +#problem 3 +#function used: log(x,base) +n = 8 # number to evaluate +base = 16 #log base 16 +print(log(n,base)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.4/Ex15_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.4/Ex15_4.R new file mode 100644 index 00000000..39b1bc98 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.4/Ex15_4.R @@ -0,0 +1,6 @@ +#page no. 135 +#problem 4 +#function used: log10(x) +n = 0.001 # number to evaluate +val = log10(n) +print(val) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.6/Ex15_6.R b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.6/Ex15_6.R new file mode 100644 index 00000000..4e7dd937 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH15/EX15.6/Ex15_6.R @@ -0,0 +1,6 @@ +#page no. 136 +#problem 6 +#function used: log(x,base) +n = 1/81 # number to evaluate +base = 3 #log base +print(log(n,base)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.1/Ex16_1.R b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.1/Ex16_1.R new file mode 100644 index 00000000..f1d43b89 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.1/Ex16_1.R @@ -0,0 +1,6 @@ +#page no.141 +#problem 1 +#Function used: exp(x) +#given: +print(0.0256*(exp(5.21)-exp(2.49))) #evaluate the following + diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.15/Ex16_15.R b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.15/Ex16_15.R new file mode 100644 index 00000000..c81ff162 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.15/Ex16_15.R @@ -0,0 +1,19 @@ +#page no. 147 +#problem 15 +#function: +log(exp(1)) + +find_x = function(l,r) +{ + #apply log on both sides L.H.S and R.H.S + l = log(l) #r = log(exp(3*x)) + #r = 3*x*log(exp(1)) ------>log(exp(1))=1 + # to find x + return(x=l/r) +} + +#given: +l = 7/4 # values on L.H.S +r = 3 # exp power and multiple factor of x +result = find_x(l,r) +print(result) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.18/Ex16_18.R b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.18/Ex16_18.R new file mode 100644 index 00000000..0b76afb0 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.18/Ex16_18.R @@ -0,0 +1,34 @@ +#page no. 147 +#problem 18 +#load package --->measurements +library(measurements) +#formula used: alpha = (1/theta)log(R/R0) +# +#function: + +find_alpha = function(theta,R,R0) +{ + return((1/theta)*log(R/R0)) +} + + +find_theta = function(alpha,R,R0) +{ + return((1/alpha)*log(R/R0)) +} + +#given: +r0 = 5 #kilo_ohms +R0 = conv_unit(r0,'km','m') # resistance in ohms + +r = 6 #kilo_ohms +R = conv_unit(r,'km','m') # resistance in ohms + +theta = 1500 #temperature in C +alpha = find_alpha(theta,R,R0) + +r_new = 5.4 #kilo_ohm +R_new = conv_unit(r_new,'km','m') +theta_new = find_theta(alpha,R_new,R0) + +print(theta_new) # temperature to nearest degree diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.19/Ex16_19.R b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.19/Ex16_19.R new file mode 100644 index 00000000..4183ad95 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.19/Ex16_19.R @@ -0,0 +1,25 @@ +#page no. 147 +#problem 19 + +#load package --->measurements +library(measurements) +#formula used: Q = Q0*exp((-k*t) +# k = (1/t)log(Q0/Q)------> after applying log on both sides +#NEWTON's COOLING LAW +#function: + +find_k = function(t,Q0,Q) +{ + return((1/t)*log(Q0/Q)) +} + + +#given: +Q0 = 56.6 #tenperature in C + +Q = 16.5 #tenperature in C + +t = 76 #time in seconds +k_constant = find_k(t,Q0,Q) + +print(k_constant) # constant value diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.2/Ex16_2.R b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.2/Ex16_2.R new file mode 100644 index 00000000..84d58732 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.2/Ex16_2.R @@ -0,0 +1,20 @@ +#page no. 142 +#problem 2 +#function used: exp() + +exp_add = function(x,y) +{ + return(exp(x)+exp(y)) +} + + +exp_sub = function(x,y) +{ + return(exp(x)-exp(y)) +} + +#given: +a = 0.25 #powers of exp +b = -0.25 +cal = 5*(exp_sub(a,b)/exp_add(a,b)) # evaluate +print(cal) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.3/Ex16_3.R b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.3/Ex16_3.R new file mode 100644 index 00000000..f368a1dd --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.3/Ex16_3.R @@ -0,0 +1,18 @@ +#page no. 142 +#problem 3 +#function used: exp() +#formula used: v = V*exp(-t/CR) +#load package ------>measurements +library(measurements) +#given: + +V = 300 # volts +t = 50 # time in milliseconds +t1 = conv_unit(t,'msec','sec') #time in seconds +c = 10 #in microFarad +c1 = conv_unit(c,'um','m') +R = 47 # kilo_ohms +R1 = conv_unit(R,'km','m') + +v =V*exp(-t1/(c1*R1)) +print(v) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.4/Ex16_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.4/Ex16_4.R new file mode 100644 index 00000000..df12e931 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.4/Ex16_4.R @@ -0,0 +1,12 @@ +#page no. 143 +#problem 4 +#function used: factorial() +exp_expansion = function(x) +{ + return(1+(x/1)+(x^2/factorial(2))+(x^3/factorial(3))+(x^4/factorial(4))) +} + +#given: +n = 0.5 #power of exp +val = 5*exp_expansion(n) +print(val) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.5/Ex16_5.R b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.5/Ex16_5.R new file mode 100644 index 00000000..2605421f --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH16/EX16.5/Ex16_5.R @@ -0,0 +1,12 @@ +#page no. 143 +#problem 5 +#function used: factorial() +exp_expansion = function(x) +{ + return(1+(x/1)+(x^2/factorial(2))+(x^3/factorial(3))+(x^4/factorial(4))) +} + +#given: +n = -1 #power of exp +val = 3*exp_expansion(n) +print(val) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.1/Ex22_1.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.1/Ex22_1.R new file mode 100644 index 00000000..dcb7c0df --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.1/Ex22_1.R @@ -0,0 +1,14 @@ +#page no. 221 +#problem 1 +#formula used: pythagoras theorem + +hypo = function(base,perp) +{ + return(sqrt(base^2+perp^2)) +} + +#given: +p = 4 #perpendicular height of triangle +b = 3 #base of triangle +h = hypo(b,p) #hypotenuse of triangle +print(h) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.10/Ex22_10.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.10/Ex22_10.R new file mode 100644 index 00000000..b7412ee9 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.10/Ex22_10.R @@ -0,0 +1,5 @@ +#page no .225 +#problem 10 +#given: +angle = 1.481 +sinQ = sin(angle) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.11/Ex22_11.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.11/Ex22_11.R new file mode 100644 index 00000000..9fb8db93 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.11/Ex22_11.R @@ -0,0 +1,7 @@ +#pageno.225 +#problem 11 +#function used: cos() +#given: + angle=3*pi/5 + cosQ = cos(angle) + print(cosQ) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.2/Ex22_2.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.2/Ex22_2.R new file mode 100644 index 00000000..09e6f62c --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.2/Ex22_2.R @@ -0,0 +1,16 @@ +#page no. 221 +#problem 2 +#formula used: pythagoras theorem + + +prep = function(hypo , base) +{ + return(sqrt(hypo^2 - base^2)) +} + + +#given: +b = 5 #perpendicular height of triangle +h = 13 #hypotenuse of triangle +p = prep(h,b) #base of triangle +print(p) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.3/Ex22_3.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.3/Ex22_3.R new file mode 100644 index 00000000..3040faa2 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.3/Ex22_3.R @@ -0,0 +1,25 @@ +#page no. 221 +#problem 3 +#formula used: pythagoras theorem + + +hypotenuse = function(base,perp) +{ + return(sqrt(base^2+perp^2)) +} + +distance = function(speed,time) +{return(speed*time)} + +#given: +s1 = 300 #speed of one air craft in km/hr +s2 = 220 #speed of second air craft in km/hr +time = 4 #In hr +d1=distance(s1,time) #travels in north +d2=distance(s2,time) #travels in west + +# both airplane make right angle triangle +d3 = hypotenuse(d1,d2) #distance b/w two airplanes +print(d3) + + diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.4/Ex22_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.4/Ex22_4.R new file mode 100644 index 00000000..f0823af9 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.4/Ex22_4.R @@ -0,0 +1,22 @@ +#page no. 223 +#problem 4 +#formula used: sin=p/h cos=b/h tan=p/b + +sinQ = function(x,y) +{return(x/y)} + +cosQ = function(x,y) +{return(x/y)} + +tanQ = function(x,y) +{return(x/y)} + +#given: right angle triangle +b = 12 +p =5 +h = 13 +cat("sinQ=",sinQ(p,h)) + +cat("cosQ=",cosQ(b,h)) + +cat("tanQ=",tanQ(p,b)) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.5/Ex22_5.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.5/Ex22_5.R new file mode 100644 index 00000000..03909554 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.5/Ex22_5.R @@ -0,0 +1,39 @@ +#page no. 223 +#problem 5 +#formula used: sin=p/h cos=b/h tan=p/b + + +hypotenuse = function(base,perp) +{ + return(sqrt(base^2+perp^2)) +} + +sinQ = function(x,y) +{return(x/y)} + +cosQ = function(x,y) +{return(x/y)} + +tanQ = function(x,y) +{return(x/y)} + +#given: right angle triangle +base = 4.62 +perp = 3.47 +height = hypotenuse(base,perp) +print(height) +cat("sinC=",sinQ(perp,height)) + +cat("cosC=",cosQ(base,height)) + +cat("tanC=",tanQ(perp,base)) + +# rotate the sides +b = perp +p = base +h = height +cat("sinA=",sinQ(p,h)) + +cat("cosA=",cosQ(b,h)) + +cat("tanA=",tanQ(p,b)) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.6/Ex22_6.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.6/Ex22_6.R new file mode 100644 index 00000000..108ddeeb --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.6/Ex22_6.R @@ -0,0 +1,45 @@ +#page no. 223 +#problem 6 +#formula used: sin=p/h cos=b/h tan=p/b + + +hypotenuse = function(base,perp) +{ + return(sqrt(base^2+perp^2)) +} + +sinQ = function(x,y) +{return(x/y)} + +cosQ = function(x,y) +{return(x/y)} + +tanQ = function(x,y) +{return(x/y)} + + + +#given: right angle triangle + tanB = 8/15 #tan = p/b + #according to angle B + p = 8 #perpendicular lenght opposite angle B + b = 15 #base lenght opposite angle B + h = hypotenuse(b,p) + + cat("sinB=",sinQ(p,h)) + + cat("cosB=",cosQ(b,h)) + + #cat("tanB=",tanQ(p,b)) + + #according to angle A + base = p#base lenght opposite angle A + perp = b#perpendicular lenght opposite angle A + height = h + + cat("sinA=",sinQ(perp,height)) + + #cat("cosA=",cosQ(base,height)) + + cat("tanA=",tanQ(perp,base)) + \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.8/Ex22_8.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.8/Ex22_8.R new file mode 100644 index 00000000..62276316 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.8/Ex22_8.R @@ -0,0 +1,11 @@ +#page no. 225 +#problem 8 +#formula used: sin=p/h cos=b/h tan=p/b + +#given: +angle_degree = 43 # angle in degree +angle_min = 39 # angle in min + +#angel is 43 degree 39 min +angle = ((angle_degree*60)+angle_min)/60 #conversion of angle into degree +sinQ = sin(angle) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.9/Ex22_9.R b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.9/Ex22_9.R new file mode 100644 index 00000000..e1a1ca02 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH22/EX22.9/Ex22_9.R @@ -0,0 +1,15 @@ +#page no .225 +#problem 9 +# conversion minutes to degree +angle = function(x,y) +{ + return(((x*60)+y)/60) +} +#given: +angle_degree = 62 # angle in degree +angle_min = 12 # angle in min + +deg = angle(angle_degree,angle_min) + +cosQ = cos(deg) +cat("6cosQ:",6*cosQ) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.10/Ex26_10.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.10/Ex26_10.R new file mode 100644 index 00000000..5971b266 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.10/Ex26_10.R @@ -0,0 +1,27 @@ +#page no. 272 +#problem 10 +# formula used : #formula used : area of rectangle = l*b +#given: +l = 6 # length of building +b = 8#breadth of building + +###triangle on top +base = 8 +base_right = base/2 #base of right angle triangle +hypo = 5 +height = sqrt(hypo^2 - (base_right^2)) + +area_rect <- function(x,y) #area of rectangle +{ + a = x*y + return(a) +} + +area_triangle <- function(x,y) #area of right angle triangle +{ + a = (x*y)/2 + return(a) +} + +area_building = area_rect(l,b) + area_triangle(base,height) +print(area_building) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.11/Ex26_11.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.11/Ex26_11.R new file mode 100644 index 00000000..e943322e --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.11/Ex26_11.R @@ -0,0 +1,12 @@ +#page no.273 +#problem 11 +#formula used: area of circle = pi*r^2 + +area_circle = function(r) +{ + return(pi*r^2) +} + +#given: +r = 5 #radius of circle +print(area_circle(r)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.12/Ex26_12.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.12/Ex26_12.R new file mode 100644 index 00000000..454812b2 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.12/Ex26_12.R @@ -0,0 +1,13 @@ +#page no.273 +#problem 12 +#formula used: area of circle = pi*r^2 + +area_circle = function(r) +{ + return(pi*r^2) +} + +#given: +dia = 15 #diameter of circle +r = dia/2 #radius of circle +print(area_circle(r)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.13/Ex26_13.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.13/Ex26_13.R new file mode 100644 index 00000000..76480b64 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.13/Ex26_13.R @@ -0,0 +1,18 @@ +#page no.273 +#problem 13 +#formula used: area of circle = pi*r^2 + +area_circle = function(r) +{ + return(pi*r^2) +} + +radius_cir <- function(cir) +{ + r = cir/(2*pi) + return(r) +} +#given: +circ = 70 #circumference of circle +r = radius_cir(circ) #radius of circle +print(area_circle(r)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.14/Ex26_14.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.14/Ex26_14.R new file mode 100644 index 00000000..2412e61b --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.14/Ex26_14.R @@ -0,0 +1,18 @@ +#page no. 274 +#problem 14 +# formula used : area of sector=(theta/360)*area of circle + +area_circle = function(r) +{ + return(pi*r^2) +} + +area_sector<- function(theta,r) +{ + a = (theta/360)*area_circle(r) +} + +#given: +r = 6 #radius of circle +theta = 50 # angle subtended at center +print(area_sector(theta,r)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.15/Ex26_15.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.15/Ex26_15.R new file mode 100644 index 00000000..47924d96 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.15/Ex26_15.R @@ -0,0 +1,19 @@ +#page no. 274 +#problem 15 +# formula used : area of sector=(theta/360)*area of circle + +area_circle = function(r) +{ + return(pi*r^2) +} + +area_sector<- function(theta,r) +{ + a = (theta/360)*area_circle(r) +} + +#given: +dia = 80 #diameter of circle +r = dia/2 #radius of circle +theta = 107 # angle subtended at center(107 degree 42 minutes) +print(area_sector(theta,r)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.16/Ex26_16.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.16/Ex26_16.R new file mode 100644 index 00000000..dac38a76 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.16/Ex26_16.R @@ -0,0 +1,16 @@ +#page no. 274 +#problem 16 +#formula used: area of circle = pi*r^2 + +area_circle = function(r) +{ + return(pi*r^2) +} + +#give: +D = 5.45 #diameter of outer circle +d = 2.25 #diameter of inner circle +R = D/2 #radius of outer circle +r = d/2 #radius of inner circle +area_shaft = area_circle(R) - area_circle(r) +print(area_shaft) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.17/Ex26_17.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.17/Ex26_17.R new file mode 100644 index 00000000..abaab8fc --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.17/Ex26_17.R @@ -0,0 +1,15 @@ +#page no. 275 +#problem 17 +# formula used : area of regular octagon =8*((1/2)*base*height) +# 8 times area of triangle + +area_triangle = function(b,h) +{ + return((b*h)/2) +} +#given: +base = 5 +H = 12 # total height across the flat +h = H/2 +area_octagon=8*area_triangle(base,h) +print(area_octagon) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.18/Ex26_18.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.18/Ex26_18.R new file mode 100644 index 00000000..475b65a1 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.18/Ex26_18.R @@ -0,0 +1,17 @@ +#page no. 275 +#problem 18 +# formula used : area of regular hexagon =6*((1/2)*base*height) +# 6 times area of triangle + +area_triangle = function(b,h) +{ + return((b*h)/2) +} +#given: +base = 8 +b = base/2 #base of right angle triangle +hypo = base #hypotenuse of right angle triangle +h = sqrt(hypo^2 - b^2) + +area_hexagon=6*area_triangle(base,h) +print(area_hexagon) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.2/Ex26_2.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.2/Ex26_2.R new file mode 100644 index 00000000..a70d8925 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.2/Ex26_2.R @@ -0,0 +1,17 @@ +#page n0.269 +#problem 2 +area_square <- function(x) +{ + a = x^2 + return(a) +} + +peri_square <- function(x) +{ + return(p = 4*x) + +} + +n = 4#side of square +print(area_square(n)) +print(peri_square(n)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.3/Ex26_3.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.3/Ex26_3.R new file mode 100644 index 00000000..38ed9024 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.3/Ex26_3.R @@ -0,0 +1,23 @@ +#page no.269 +#problem 3 +#formula used : area of rectangle = l*b +# perimeter of rectangle = 2*(l+b) +#given: + +l = 7 #length of rectangle +b = 4.5 #breadth of rectangle +area_rect <- function(x,y) #area of rectangle +{ + a = x*y + return(a) +} + +peri_rect <- function(x,y) #perimeter of rectangle +{ + return(p = 2*(l+b)) + +} + +print(area_rect(l,b)) + +print(peri_rect(l,b)) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.4/Ex26_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.4/Ex26_4.R new file mode 100644 index 00000000..ec157a47 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.4/Ex26_4.R @@ -0,0 +1,21 @@ +#page no. 269 +#problem 4 + +#formula used : area of parallelogram = base * perpendicular height +#given: + +l = 16 #one side of parallelogram +b = 9 #second side of parallelogram +L = 21 # distance from one point to another point (horizontally) +base = L-l #base of right angle triangle +hypo = b # hypotenuse of right angle triangle +h = sqrt(hypo^2 - base^2) + + +area_para <- function(x,y) #area of parallelogram +{ + a = x*y + return(a) +} + +print(area_para(l,h)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.5/Ex26_5.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.5/Ex26_5.R new file mode 100644 index 00000000..4438c936 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.5/Ex26_5.R @@ -0,0 +1,17 @@ +#page no.271 +#problem 5 +#formula used : area of right angle triangle = base*height/2 + +#given: +base = 1.92 +hypo = 5.68 +height = sqrt(hypo^2 - base^2) + + +area_triangle <- function(x,y) #area of right angle triangle +{ + a = (x*y)/2 + return(a) +} + +print(area_triangle(base,height)) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.6/Ex26_6.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.6/Ex26_6.R new file mode 100644 index 00000000..0e979a01 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.6/Ex26_6.R @@ -0,0 +1,15 @@ +#page no. 271 +#problem 6 +#formula used: area of trapezium = ((sum of parallel sides)*perpendicular distance)/2 + +#given: +l1 = 27.4 #length of one parallel side +l2 = 8.6 # length of 2nd parallel side +h = 5.5 # perpendicular distance b/w two parallel sides +area_trapezium <- function(x,y,z) #area of trapezium +{ + a = ((x+y)*z)/2 + return(a) +} + +print(area_trapezium(l1,l2,h)) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.7/Ex26_7.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.7/Ex26_7.R new file mode 100644 index 00000000..0c57907a --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.7/Ex26_7.R @@ -0,0 +1,22 @@ +#page no. 271 +#problem 7 +# formula used : #formula used : area of rectangle = l*b +#load package ----->measurments +library(measurements) +#given: +l = 820 #length of rectangle in mm +b = 400 #breadth of rectangle in mm +area_rect <- function(x,y) #area of rectangle +{ + a = x*y + return(a) +} +area = area_rect(l,b) +#part(a) +cat("area in mm^2:",area) + +#part(b) +cat("area in cm^2:",conv_unit(area,'mm2','cm2')) + +#part(c) +cat("area in m^2:",conv_unit(area,'mm2','m2')) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.8/Ex26_8.R b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.8/Ex26_8.R new file mode 100644 index 00000000..6755c459 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH26/EX26.8/Ex26_8.R @@ -0,0 +1,16 @@ +#page no. 271 +#problem 8 +# formula used : #formula used : area of rectangle = l*b +#given: +L = 100 #outer length of frame +B = 50 #outer breadth of frame +w = 4 # width of frame +l = L-2*w # inner length of frame +b = B -2*w #inner breadth of frame +area_rect <- function(x,y) #area of rectangle +{ + a = x*y + return(a) +} +area_frame = area_rect(L,B) - area_rect(l,b) +print(area_frame) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.1/Ex27_1.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.1/Ex27_1.R new file mode 100644 index 00000000..8875da74 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.1/Ex27_1.R @@ -0,0 +1,12 @@ +#page no. 279 +#problem 1 +#formula used: circumference of circle = 2*pi*r + +peri_circle = function(r) +{ + return(pi*r*2) +} + +#given: +r = 12 #radius of circle +print(peri_circle(r)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.10/Ex27_10.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.10/Ex27_10.R new file mode 100644 index 00000000..941ac028 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.10/Ex27_10.R @@ -0,0 +1,22 @@ +#page no. 282 +#problem 10 +#formula used: area of circle = pi*r^2 +# cicumference of circle = 2*pi*r + +area_circle = function(r) +{ + return(pi*r^2) +} + +radius_cir <- function(cir) +{ + r = cir/(2*pi) + return(r) +} + + +#given: +circ = 60 # circumference of circle +r = radius_cir(circ) +area = area_circle(r) #area of circle +print(area) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.11/Ex27_11.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.11/Ex27_11.R new file mode 100644 index 00000000..f6e125a7 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.11/Ex27_11.R @@ -0,0 +1,10 @@ +#page no. 282 +#problem 11 +#formula used: length of arc = r*theta +arc_length = function(r,theta) +{return(r*theta)} +#given: +r = 5.5 #radius of circle +theta = 1.20 # angel subtended at center in radians +s = arc_length(r,theta) # length of arc +print(s) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.12/Ex27_12.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.12/Ex27_12.R new file mode 100644 index 00000000..d46f903d --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.12/Ex27_12.R @@ -0,0 +1,21 @@ +#page no. 282 +#problem 12 +#formula used: length of arc = r*theta + +arc_radius = function(s,theta) +{return(s/theta)} + +peri_circle = function(r) +{ + return(pi*r*2) +} + +#given: + +s = 4.75 #arc of length +theta = 0.91 # angle in radian +r = arc_radius(s,theta) +dia = 2*r +print(dia) # diameter of circle + +print(peri_circle(r)) # circumference of circle \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.13/Ex27_13.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.13/Ex27_13.R new file mode 100644 index 00000000..b68164b3 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.13/Ex27_13.R @@ -0,0 +1,27 @@ +#page no. 282 +#problem 13 +# formula used: minor arc = r*theta +# circumference of circle = 2*pi*r +# major arc = circumference - minor arc + +deg2rad <- function(deg) {return((deg * pi) / (180))} #degree to radian + +peri_circle = function(r) +{ + return(pi*r*2) +} + +arc_length = function(r,theta) +{return(r*theta)} + +#given: +r = 8.4# radius of circle +theta = 125 # angle in degree +rad = deg2rad(theta) #angle in radian +#part(a) +minor_arc = arc_length(r,rad) +print(minor_arc) +#part(b) +major_arc = peri_circle(r) - minor_arc +print(major_arc) + diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.15/Ex27_15.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.15/Ex27_15.R new file mode 100644 index 00000000..829e4280 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.15/Ex27_15.R @@ -0,0 +1,20 @@ +#page no. 282 +#problem 15 +#formula used: area of sector = (1/2)*r^2*theta + +deg2rad <- function(deg)#degree to radian + { + return((deg * pi) / (180)) + } + + +area_sector<- function(theta,r) +{ + a = (1/2)*r^2*theta +} +#given: +r = 55 #radius of stadium +theta = 45 #angle in degree +rad = deg2rad(theta) #angle in radian +area = area_sector(rad,r) # maximum area +print(area) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.16/Ex27_16.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.16/Ex27_16.R new file mode 100644 index 00000000..d4758088 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.16/Ex27_16.R @@ -0,0 +1,13 @@ +#page no. 282 +#problem 15 +#formula used: area of sector = (1/2)*r^2*theta +angle = function(r,area) +{theta = (area*2)/r^2} +rad2deg <- function(rad) {return((rad * 180) / (pi))} #radian to degree +#given: +r = 1.8 #radius of garden sprayer distance +area = 2.5 # area of sector sprayed +theta = angle(r,area) # angle in radian +print(theta) +degree = rad2deg(theta) #angle in degree +print(degree) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.2/Ex27_2.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.2/Ex27_2.R new file mode 100644 index 00000000..02731d8d --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.2/Ex27_2.R @@ -0,0 +1,13 @@ +#page no. 279 +#problem 2 +#formula used: circumference of circle = 2*pi*r + +peri_circle = function(r) +{ + return(pi*r*2) +} + +#given: +dia = 75 #diameter of circle +r = dia/2 #radius of circle +print(peri_circle(r)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.3/Ex27_3.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.3/Ex27_3.R new file mode 100644 index 00000000..6cc2d87e --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.3/Ex27_3.R @@ -0,0 +1,14 @@ +#page no. 279 +#problem 3 +#formula used: circumference of circle = 2*pi*r + +radius_cir <- function(cir) +{ + r = cir/(2*pi) + return(r) +} + +#given: +circ = 112 +radius = radius_cir(circ) +print(radius) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.4/Ex27_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.4/Ex27_4.R new file mode 100644 index 00000000..5504b4c6 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.4/Ex27_4.R @@ -0,0 +1,17 @@ +#page no. 279 +#problem 4 +#formula used: pythagoras theorem + +hypotenuse <- function(b,p) +{ + h = sqrt(b^2+p^2) + return(h) +} + +#given: +ab = 150 # tangent to circle + # act as perpendicular height + r = 40 #radius of circle(base) + ao = hypotenuse(r,ab) + print(ao) + \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.5/Ex27_5.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.5/Ex27_5.R new file mode 100644 index 00000000..c3fbbdb9 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.5/Ex27_5.R @@ -0,0 +1,22 @@ +#page no. 280 +#problem 5 +#formula used: + +deg2rad <- function(deg) {return((deg * pi) / (180))} #degree to radian + +deg2rad_min = function(angle,min) #degree to radian while min are given +{ + deg = ((angle*60)+min)/60 + return(deg2rad(deg)) +} +#part(a) + #given: + d1 = 125 # angle in degree + print(deg2rad(d1)) + + +#part(b) + #given: + d2_angle = 69 # angle in degree and minutes + d2_min = 47 # 69 degree and 47 minutes + print(deg2rad_min(d2_angle,d2_min)) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.6/Ex27_6.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.6/Ex27_6.R new file mode 100644 index 00000000..7c31e6ad --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.6/Ex27_6.R @@ -0,0 +1,15 @@ +#page no. 281 +#problem 6 +#formula used: degrees to minutes +rad2deg <- function(rad) #radian to degree +{return((rad * 180) / (pi))} + + #part(a): + #given: + rad1 = 0.749 + print(rad2deg(rad1)) #in degree + + #part(b): + #given: + rad2 = (3*pi)/4 + print(rad2deg(rad2)) #in degree \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.8/Ex27_8.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.8/Ex27_8.R new file mode 100644 index 00000000..38ca7912 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.8/Ex27_8.R @@ -0,0 +1,13 @@ +#page no. 281 +#problem 8 +#formula used: area of semi circle = area of circle/2 + +area_circle = function(r) +{ + return(pi*r^2) +} + +#given: +r = 14.63 #radius of semicircle +area = (1/2)*area_circle(r) #area of semicircle +print(area) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.9/Ex27_9.R b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.9/Ex27_9.R new file mode 100644 index 00000000..3a1f1ad7 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH27/EX27.9/Ex27_9.R @@ -0,0 +1,14 @@ +#page no. 282 +#problem 9 +#formula used: area of circle = pi*r^2 + +area_circle = function(r) +{ + return(pi*r^2) +} + +#given: +dia = 35.0 #diameter of circle +r = dia/2 #radius of circle +area = area_circle(r) #area of circle +print(area) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.1/Ex28_1.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.1/Ex28_1.R new file mode 100644 index 00000000..9300192d --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.1/Ex28_1.R @@ -0,0 +1,14 @@ +# page no. 290 +#formula used: volume of cuboid = l*b*h +# : surface area of cuboid = 2*(l*b+b*h+l*h) + +#given: +l = 12 +b = 4 +h = 3 + +volume = l*b*h +print(volume) + +surface_area_of_cuboid = 2*((l*b)+(b*h)+(l*h)) +print(surface_area_of_cuboid) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.11/Ex28_11.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.11/Ex28_11.R new file mode 100644 index 00000000..c925530a --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.11/Ex28_11.R @@ -0,0 +1,15 @@ +#page no.294 +#formula used:volume of pyramid = area of base*perpendicular height/3 +#given: rectangular pyramid +l = 5 # length of rectangular base +b = 6 # breadth of rectangular base +h = 18 # height of rectangular base +vol_rect = l*b*h # Volume of rectangular base +print(vol_rect) +vol_pyramid = vol_rect # volume of pyramid == volume of rectangular metal +L = 6 #length of casted base +B = 10 # breadth of casted base +area_base = L*B # area of base +H = (3*vol_pyramid)/(area_base) #height of pyramid +print(H) + \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.12/Ex28_12.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.12/Ex28_12.R new file mode 100644 index 00000000..c043a048 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.12/Ex28_12.R @@ -0,0 +1,8 @@ +#page no.295 +#Load package -----> measurments +#formula used: volume of cone = (pi*r^2*h)/3 + +r = conv_unit(30, 'mm', 'cm') # radius of cone (mm to cm) +h = conv_unit(80, 'mm', 'cm') # height of cone (mm to cm) +volume_of_cone = (pi*r^2*h)/3 +print(volume_of_cone) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.13/Ex28_13.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.13/Ex28_13.R new file mode 100644 index 00000000..dc38439f --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.13/Ex28_13.R @@ -0,0 +1,20 @@ +#page no.295 +#formula used: volume of cone = (pi*r^2*h)/3 +# total surface area of cone = pi*r(l+r) + +# install.packages("remotes") +# remotes::install_github("cewalters/r-packages") + +r = 5 # radius of cone +h = 12 # height of cone +volume_of_cone = (pi*r^2*h)/3 +print(volume_of_cone) + +hypotenuse <- function (x, y) +{ + sqrt (x ^ 2 + y ^ 2) +} + +l = hypotenuse(r,h) #slant height +TSA = pi*r*(l+r) # total surface area of cone +print(TSA) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.15/Ex28_15.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.15/Ex28_15.R new file mode 100644 index 00000000..5842a0bf --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.15/Ex28_15.R @@ -0,0 +1,12 @@ +#page no.296 +#formula used: volume of sphere = (4*pi*r^3)/3 +# surface area of sphere = 4*pi*r^2 + +area = 201.1 # surface area of sphere +r = sqrt(area/(4*pi)) +print(r) + +dia = 2*r #diameter of sphere +print(dia) +volume = (4*pi*r^3)/3 #volume of sphere +print(volume) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.18/Ex28_18.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.18/Ex28_18.R new file mode 100644 index 00000000..ed025362 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.18/Ex28_18.R @@ -0,0 +1,11 @@ +#page no. 299 +# formula used : volume of hemisphere = (volume of sphere)/2 +# = (2*pi*r^3)/3 +# surface area of hemisphere=((surface area of sphere)/2)+area of circle +# = (2*pi*r^2)+(pi*r^2) +dia = 5.0 #diameter of hemisphere +r = dia/2 +vol = (2*pi*r^3)/3 #volume of hemisphere +print(vol) +area = (2*pi*r^2)+(pi*r^2)#surface area of hemisphere +print(area) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.23/Ex28_23.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.23/Ex28_23.R new file mode 100644 index 00000000..a966fb83 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.23/Ex28_23.R @@ -0,0 +1,42 @@ +#page no. 300 +# formula used:volume of hemisphere =(2*pi*r^3)/3 +# volume of cone = (pi*r^2*h)/3 +# volume of cylinder = pi*r^2*h +# surface area of hemisphere=(2*pi*r^2)+(pi*r^2) +# curved surface area of cylinder= 2*pi*r*h +# curved surface area of cone = pi*r*l +# <-----boiler----top-hemisphere +# middle-cylinder +# bottom-cone + +len = 8 #length of cylinder +dia = 6 # diameter of cylinder +r = dia/2 +h = 4 # height of cone +vol_h = (2*pi*r^3)/3 #volume of hemisphere +print(vol_h) + +vol_Co = (pi*r^2*h)/3#volume of cone +print(vol_Co) + +vol_Cy = pi*r^2*len#volume of cylinder +print(vol_Cy) + +vol_boiler = vol_Co + vol_Cy + vol_h +print(vol_boiler) + + +hypotenuse <- function (x, y) +{ + sqrt (x ^ 2 + y ^ 2) +} + +l = hypotenuse(r,h) #slant height + + +sa_h =(2*pi*r^2)#surface area of hemisphere +sa_Co =pi*r*l #curved surface area of cone +sa_Cy =2*pi*r*len#curved surface area of cylinder + +sa_total = sa_h + sa_Co + sa_Cy # total surface area of boiler +print(sa_total) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.24/Ex28_24.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.24/Ex28_24.R new file mode 100644 index 00000000..dd83aa05 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.24/Ex28_24.R @@ -0,0 +1,10 @@ +#page no. 302 +# formula used: volume of frustum = pi*h*((r^2+R^2+R*r))/3 + +D = 6 #diameter at bigger end +R = D/2 +d = 4 #diameter at smaller end +r = d/2 +h = 3.6 +vol = pi*h*((r^2+R^2+R*r))/3 #volume of frustum +print(vol) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.29/Ex28_29.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.29/Ex28_29.R new file mode 100644 index 00000000..71f6cf1e --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.29/Ex28_29.R @@ -0,0 +1,21 @@ +#page no. 302 +# formula used: volume of frustum = pi*h*((r^2+R^2+R*r))/3 +# volume of cylinder = pi*r^2*h + +D = 25 #diameter at bigger end +R = D/2 +d = 12 #diameter at smaller end +r = d/2 +H = 30 #height of tower +h = 12 #height of cylinder +l = H-h # height of frustum +vol_Cy = pi*R^2*h #volume of cylinder +print(vol_Cy) +vol_f = pi*l*((r^2+R^2+R*r))/3 #volume of frustum +print(vol_f) + +vol_tower = vol_Cy + vol_f +print(vol_tower) + +vol_air_space = 0.6 * vol_tower +print(vol_air_space) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.4/Ex28_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.4/Ex28_4.R new file mode 100644 index 00000000..ed74b56d --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.4/Ex28_4.R @@ -0,0 +1,11 @@ +#page no.291 +#formula used: volume of cylinder = pi*r^2*h +# total surface area = 2*pi*r*(h+r) + +dia = 12 #diameter of cylinder +r = dia/2 +h = 20 #height of cylinder +volume = pi*r^2*h +print(volume) +TSA = 2*pi*r*(h+r) #total surface area of cylinder +print(TSA) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.5/Ex28_5.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.5/Ex28_5.R new file mode 100644 index 00000000..8e49ec9b --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.5/Ex28_5.R @@ -0,0 +1,10 @@ +#page no.291 +#formula used: volume of cylinder = (area of cross-section)*length + +out_dia = 25#outer diameter of pipe +in_dia = 12 #inner diameter of pipe +h = 2.5*100 #lenght of pipe (converted meter to centimeter) +area_of_cross_section = ((pi*out_dia^2)/4)-((pi*in_dia^2)/4) +print(area_of_cross_section) +volume = (area_of_cross_section)*h +print(volume) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.9/Ex28_9.R b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.9/Ex28_9.R new file mode 100644 index 00000000..2c089aab --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH28/EX28.9/Ex28_9.R @@ -0,0 +1,7 @@ +#page no. 294 +# formula used: volume of pyramid = area of base*perpendicular height/3 +#given: square pyramid +l = 6 # side of square base +h = 16 # perpendicular height +volume = ((l*l)*h)/3 +print(volume) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.1/Ex33_1.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.1/Ex33_1.R new file mode 100644 index 00000000..fe251936 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.1/Ex33_1.R @@ -0,0 +1,11 @@ +#Page no. 356 +#Function used: mean() +# median() + +x<-c(2,3,7,5,5,13,1,7,4,8,3,4,3) #our Data Set + +mean_result = mean(x) #Computing Mean +print(mean_result) + +median_result = median(x)#Computing Median +print(median_result) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.2/Ex33_2.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.2/Ex33_2.R new file mode 100644 index 00000000..be3bb910 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.2/Ex33_2.R @@ -0,0 +1,11 @@ +#Page no. 356 +#Function used: mean() +# median() + +x<-c(27.90,34.70,54.40,18.92,47.60,39.68) #our Data Set + +mean_result = mean(x) #Computing Mean +print(mean_result) + +median_result = median(x)#Computing Median +print(median_result) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.3/Ex33_3.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.3/Ex33_3.R new file mode 100644 index 00000000..553a0968 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.3/Ex33_3.R @@ -0,0 +1,18 @@ +#page no. 357 +#Function used:with(),mean(),readLines(),gsub() + + +table_data <- "(value) (frequency) + (20.5,20.9] 3 + (21.0,21.4] 10 + (21.5,21.9] 11 + (22.0,22.4] 13 + (22.5,22.9] 9 + (23.0,23.4] 2" +L <- readLines(textConnection(table_data))#read line from connection +DF <- read.table(text = gsub("[^0-9.]", " ", L), skip = 1, as.is = TRUE)#gsub replaces all occurrences + +x <- with(DF, rep((V1 + V2)/2, V3))#computing the intermediate values + +mean_result=mean(x) +print(mean_result) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.4/Ex33_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.4/Ex33_4.R new file mode 100644 index 00000000..6803a0af --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.4/Ex33_4.R @@ -0,0 +1,38 @@ +#page no. 357 +#Function used:with(),mean(),readLines(),gsub() + + +table_data <- "(value) (frequency) +(14.5,15.5] 5 +(16.5,17.5] 8 +(18.5,19.5] 16 +(20.5,21.5] 12 +(22.5,23.5] 6 +(24.5,25.5] 3" +L <- readLines(textConnection(table_data))#read line from connection +DF <- read.table(text = gsub("[^0-9.]", " ", L), skip = 1, as.is = TRUE)#gsub replaces all occurrences + +x <- with(DF, rep((V1 + V2)/2, V3))#computing the intermediate values + +mean_result=mean(x) +print(mean_result) + +median_result=median(x) +print(median_result) + +y <- table(x) +mode_result = names(y)[which(y==max(y))] +print(mode_result) + +hist(x) +abline(v = mean_result, + col = "royalblue", + lwd = 2) + +abline(v = median_result, + col = "red", + lwd = 2) + +abline(v = mode_result, + col = "orange", + lwd = 2) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.5/Ex33_5.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.5/Ex33_5.R new file mode 100644 index 00000000..8502fef0 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.5/Ex33_5.R @@ -0,0 +1,6 @@ +#page no. 359 +#function used:var(),sqrt() + +x<-c(5,6,8,4,10,3)#data set +sd.result = sqrt(var(x))#calculating the Standard Deviation +print(sd.result)#result \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.6/Ex33_6.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.6/Ex33_6.R new file mode 100644 index 00000000..4fc1747e --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.6/Ex33_6.R @@ -0,0 +1,18 @@ +#page no. 359 +#Function used:with(),var(),sqrt(),readLines(),gsub() + + +table_data <- "(value) (frequency) +(20.5,20.9] 3 +(21.0,21.4] 10 +(21.5,21.9] 11 +(22.0,22.4] 13 +(22.5,22.9] 9 +(23.0,23.4] 2" +L <- readLines(textConnection(table_data))#read line from connection +DF <- read.table(text = gsub("[^0-9.]", " ", L), skip = 1, as.is = TRUE)#gsub replaces all occurrences + +x <- with(DF, rep((V1 + V2)/2, V3))#computing the intermediate values + +sd.result = sqrt(var(x))#calculating the Standard Deviation +print(sd.result)#result \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.1/Ex34_1.R b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.1/Ex34_1.R new file mode 100644 index 00000000..843e91ce --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.1/Ex34_1.R @@ -0,0 +1,16 @@ +#page no.363 + +n = 20 # no. of men +w = 33 # no. of women +total = n+w # total no. of people + +prob_of_men = n/total +print(prob_of_men) + +prob_of_women = w/total +print(prob_of_women) + +if((prob_of_men + prob_of_women)==1) +{ + print("no error") +} \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.2/Ex34_2.R b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.2/Ex34_2.R new file mode 100644 index 00000000..9245904a --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.2/Ex34_2.R @@ -0,0 +1,15 @@ +#page no. 363 + +#Load package ------> dice +library(dice) + + +## Probability of rolling no 4's when rolling three six-sided dice + +E=getEventProb(nrolls = 3, # number of dice rolls to make + ndicePerRoll = 1,# number of dice to use in each dice roll + nsidesPerDie = 6,# number of sides on each die + eventList = list(4), + orderMatters = FALSE) + +print(E) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.3/Ex34_3.R b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.3/Ex34_3.R new file mode 100644 index 00000000..6a125e44 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.3/Ex34_3.R @@ -0,0 +1,17 @@ +#page no. 364 +#problem 3 + +n = 10 # number of horses +win <- function(a,b)# a--->number of winner in race + # b---> total number of particpants +{ + winner <- a/b + return(winner) +} +#part(a) +prob_of_winning = win(1,n) +print(prob_of_winning) + +# part(b) +prob_of_two_races = win(1,n) * win(1,n) +print(prob_of_two_races) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.4/Ex34_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.4/Ex34_4.R new file mode 100644 index 00000000..11b94c85 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.4/Ex34_4.R @@ -0,0 +1,18 @@ +#page no. 364 +#problem 4 +#given: +prob_temp = 1/20#probability of failing due to temperature +prob_vib = 1/25 #probability of failing due to vibration +prob_hum = 1/50 #probability of failing due to humidity + +#part(a) +prob_a = prob_temp * prob_vib # fails--> temperature and vibration +print(prob_a) + +#part(b) +prob_b =prob_vib + prob_hum # fails--> humidity or vibration +print(prob_b) + +#part(c) +prob_c = (1-prob_temp) * (1-prob_hum) # NOT_fails--> temperature and humidity +print(prob_c) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.5/Ex34_5.R b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.5/Ex34_5.R new file mode 100644 index 00000000..52248966 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.5/Ex34_5.R @@ -0,0 +1,22 @@ +# page no. 365 +#problem 5 +#given: +n = 100 #total number of capacitors +n_t = 73 # capacitors within req. tolerance values +n_bt = 17 # capacitors within req. tolerance values below +n_at = n-(n_t+n_bt) #capacitors within req. tolerance values above + +probability <-function(a,b) +{ + prob = a/b + return(prob) +} + +#part(a) ----> probability with replacement +prob_n_t = probability(n_t,n) * probability(n_t,n) +print(prob_n_t) + +# part(b) ------> probability one below and second above tolerance values +# without replacement +prob_a_b = probability(n_bt,n) * probability(n_at,n-1) +print(prob_a_b) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.6/Ex34_6.R b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.6/Ex34_6.R new file mode 100644 index 00000000..d58bee7d --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.6/Ex34_6.R @@ -0,0 +1,22 @@ +#page no. 366 +#problem 6 + +n = 40 #total number of components +n_d = 5 # number of defective components +n_g = n - n_d #number of good components + +probability <-function(a,b) +{ + prob = a/b + return(prob) +} + +#part(a) +#with replacement (probability of good) +prob_a = probability(n_g,n) * probability(n_g,n) +print(prob_a) + +#part(b) +#without replacement(probability of good) +prob_b = probability(n_g,n) * probability(n_g-1,n-1) +print(prob_b) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.7/Ex34_7.R b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.7/Ex34_7.R new file mode 100644 index 00000000..357f687f --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.7/Ex34_7.R @@ -0,0 +1,26 @@ +#page no. 366 +#problem 7 + +n = 40 #total number of components +n_d = 5 # number of defective components +n_g = n - n_d #number of good components + +probability <-function(a,b) +{ + prob = a/b + return(prob) +} + +prob_def = probability(n_d,n) +print(prob_def) +prob_good = probability(n_g,n) +print(prob_good) +#part(a) +#with replacement (probability of one defective component ) +prob_a = (prob_def * prob_good) + (prob_good * prob_def) +print(prob_a) + +#part(b) +#without replacement(probability of one defective component) +prob_b = (prob_def * probability(n_g,n-1))+(prob_good * probability(n_d,n-1)) +print(prob_b) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.8/Ex34_8.R b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.8/Ex34_8.R new file mode 100644 index 00000000..74042c82 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.8/Ex34_8.R @@ -0,0 +1,9 @@ +#page no.= 366 + +b = 74 #no. of brass washers +s = 86 #no. of steel washers +a = 40 #no. of aluminium washers +t = b+s+a # total no. of washers + +probability = (s/t)*((s-1)/(t-1))*((s-2)/(t-2))#probability that all three are steel washers +print(probability) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.9/Ex34_9.R b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.9/Ex34_9.R new file mode 100644 index 00000000..2d3bd63d --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH34/EX34.9/Ex34_9.R @@ -0,0 +1,18 @@ +#page no. 366 +#problem 9 + + +b = 74 #no. of brass washers +s = 86 #no. of steel washers +a = 40 #no. of aluminium washers +t = b+s+a # total no. of washers +a_n = t - a # no. of not aluminium washers + +prob<-function(a,b) +{ + probability = a/b + return(probability) +} +# probability without replacement that no aluminium washer drwan +prob_n_alum = prob(a_n,t) *prob(a_n-1,t-1)*prob(a_n-2,t-2) +print(prob_n_alum) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.11/Ex35_11.R b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.11/Ex35_11.R new file mode 100644 index 00000000..b114395e --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.11/Ex35_11.R @@ -0,0 +1,12 @@ +#page no.376 +#problem 11 + +#load package ----->deriv +library(Deriv) +#funtion used: D()-------> derivative function w.r.t variable +#given: +# (3*x^2-5*x)/2*x ----->((3*x)/2) - (5/2) # expression after solving +y=expression(((3*x)/2) - (5/2)) + +result = D(y,'x') # differentiation w.r.t 'x' +print(result) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.12/Ex35_12.R b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.12/Ex35_12.R new file mode 100644 index 00000000..a7d0f3d9 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.12/Ex35_12.R @@ -0,0 +1,9 @@ +#page no.377 +#problem 12 +#load package ----->deriv +library(Deriv) +#funtion used: D()-------> derivative function w.r.t variable +#given: +y=expression((2*x^3/5)-(4/x^3) + (4*sqrt(x^5))+7) + +D(y,'x') # differentiation w.r.t 'x' \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.16/Ex35_16.R b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.16/Ex35_16.R new file mode 100644 index 00000000..b7943b5c --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.16/Ex35_16.R @@ -0,0 +1,9 @@ +#page no.379 +#problem 16 +#load package ----->deriv +library(Deriv) +#funtion used: D()-------> derivative function w.r.t variable +#given: +y=expression(7*sin(2*x) - 3*cos(4*x)) #sin and cos function derivatives + +D(y,'x') # differentiation w.r.t 'x' \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.25/Ex35_25.R b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.25/Ex35_25.R new file mode 100644 index 00000000..f1c7f575 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.25/Ex35_25.R @@ -0,0 +1,11 @@ +#page no.382 +#problem 25 +#load package ----->deriv +library(Deriv) +#funtion used: D()-------> derivative function w.r.t variable +#given: +y=expression(2*x^3/3 - 4/x^2 + 1/2*x -sqrt(x)) #sin and cos function derivatives + +D1=D(y,'x') # 1st order differentiation w.r.t 'x' +D2=D(D1,'x')# 2nd order differentiation w.r.t 'x' +print(D2) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.6/Ex35_6.R b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.6/Ex35_6.R new file mode 100644 index 00000000..aaa5fe2e --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.6/Ex35_6.R @@ -0,0 +1,9 @@ +#page no.376 +#problem 6 +#load package ----->deriv +library(Deriv) +#funtion used: D()-------> derivative function w.r.t variable +#given: +y=expression(5*sqrt(x)) + +D(y,'x') # differentiation w.r.t 'x' \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.9/Ex35_9.R b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.9/Ex35_9.R new file mode 100644 index 00000000..2338b74e --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH35/EX35.9/Ex35_9.R @@ -0,0 +1,9 @@ +#page no.376 +#problem 9 +#load package ----->deriv +library(Deriv) +#funtion used: D()-------> derivative function w.r.t variable +#given: +y=expression(((2*x^4)/3)-(4/x^3)+9) + +D(y,'x') # differentiation w.r.t 'x' \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.18/Ex36_18.R b/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.18/Ex36_18.R new file mode 100644 index 00000000..a098f867 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.18/Ex36_18.R @@ -0,0 +1,8 @@ +#page no. 392 +#problem 18 +#function: integrate(expression,lower,upper) --->in-built function +f = function(x) (4-x^2) #function defination --->expression + +lower_limit = -2 +upper_limit = 3 +integrate(f,lower_limit,upper_limit) #evaluating the integral value over limits diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.20/Ex36_20.R b/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.20/Ex36_20.R new file mode 100644 index 00000000..62053f58 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.20/Ex36_20.R @@ -0,0 +1,8 @@ +#page no. 392 +#problem 20 +#function: integrate(expression,lower,upper) --->in-built function +f = function(x) (x^3-5*x+1) #function defination --->expression + +lower_limit = -1 +upper_limit = 1 +integrate(f,lower_limit,upper_limit) #evaluating the integral value over limits diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.22/Ex36_22.R b/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.22/Ex36_22.R new file mode 100644 index 00000000..e257638d --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.22/Ex36_22.R @@ -0,0 +1,8 @@ +#page no. 393 +#problem 22 +#function: integrate(expression,lower,upper) --->in-built function +f = function(x) (3*sin(2*x)) #function defination --->expression + +lower_limit = 0 +upper_limit = pi/2 +integrate(f,lower_limit,upper_limit) #evaluating the integral value over limits diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.24/Ex36_24.R b/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.24/Ex36_24.R new file mode 100644 index 00000000..708ca20d --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH36/EX36.24/Ex36_24.R @@ -0,0 +1,8 @@ +#page no. 393 +#problem 24 +#function: integrate(expression,lower,upper) --->in-built function +f = function(x) (4*exp(2*x)) #function defination --->expression + +lower_limit = 1 +upper_limit = 2 +integrate(f,lower_limit,upper_limit) #evaluating the integral value over limits diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.10/Ex37_10.R b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.10/Ex37_10.R new file mode 100644 index 00000000..8cf5a234 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.10/Ex37_10.R @@ -0,0 +1,21 @@ +#page no. 405 +#problem 10 +#function: +term = function(a,n,d) # to find term value +{ + return(a+((n-1)*d)) +} +#given: +a6 = 17 #6th term of sequence---->(a+5d=17) +a13 = 38 #13th term of sequence---->(a+12d=38) + +# using matrix method X=A(inverse)*B +# we will find a(first value) and d(common difference) values + +A = array(data = c(1,1,5,12),dim = c(2,2)) +B = c(17,38) +X = solve(A,B) # calculating a and d +a = X[1] #first number of sequence +d = X[2] # common difference of AP(airthmetic progression) +a19 = term(a,19,d) # n = 19, to find 19th term of sequence +print(a19) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.12/Ex37_12.R b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.12/Ex37_12.R new file mode 100644 index 00000000..f2f92590 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.12/Ex37_12.R @@ -0,0 +1,15 @@ +#page no.406 +#problem 12 +#formula used: Sn = (n/2)*(2a+(n-1)d) -->sum of n terms in AP +#function: +Sn = function(n,a,d) #function --->sum of n terms +{ + return((n/2)*(2*a+(n-1)*d)) +} +#given: +n = 12 +seq = c(5,9,13,17) +a = seq[1] #first term of sequence +d = seq[2]-seq[1] # common difference +sum_ap = Sn(n,a,d) # sum of n-terms +print(sum_ap) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.14/Ex37_14.R b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.14/Ex37_14.R new file mode 100644 index 00000000..8860f3b2 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.14/Ex37_14.R @@ -0,0 +1,15 @@ +#page no. 406 +#problem 14 +#formula used: Sn = (n/2)*(2a+(n-1)d) -->sum of n terms in AP +# a = [2*Sn/n-(n-1)d]/2 +#function: +find = function(Sn,n,d) +{ + return((((2*Sn)/n)-((n-1)*d))/2) +} +#given: +S7 = 35 #sum of 7 terms +n = 7 # number of terms +d = 1.2 # common difference +find_a = find(S7,n,d) # first term of sequence +print(find_a) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.16/Ex37_16.R b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.16/Ex37_16.R new file mode 100644 index 00000000..44c8d8ac --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.16/Ex37_16.R @@ -0,0 +1,46 @@ +#page no.407 +#problem 16 +#load package ---->pastecs,----->dyplr +library(dplyr) +library(pastecs) +#funtion used: + +term_n = function(a,d,an) #function ---> to find number of terms +{ + return(((an-a)/d)+1) +} + +Sn = function(n,a,d) #function --->sum of n terms +{ + return((n/2)*(2*a+(n-1)*d)) +} + +#given:(0 to 207) AP divisible by 3 + +a1 = 0 #starting of range +e1 = 207 #end of range + +result <- vector("numeric") # prepare a container to store value +# divisible by 3 from (0 to 207) +for (i in c(a1:e1)) +{ + if (i%%3 == 0) + { + result[i] <- i + } +} + +seq = complete.cases(result) #removing the NA values from vector + +seq1 = c(result[seq]) #creating new vector + +seq2 = array(data = c(seq1)) #sequence (3,6,9....207) + #creating for accessing the + # values divisible by 3 + +a = seq2[1] #first number of sequence +d = seq2[2] - seq2[1] #common difference +an = last(seq2) +n = term_n(a,d,an) +sum_terms = Sn(n,a,d) #sum of n-terms in AP +print(sum_terms) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.20/Ex37_20.R b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.20/Ex37_20.R new file mode 100644 index 00000000..163b0d28 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.20/Ex37_20.R @@ -0,0 +1,18 @@ +#page no.409 +#problem 20 +#formula used: an = ar^(n-1) +#function: +find_r = function(an,a,n) #function to find common ratio + {return((an/a)**(1/(n-1)))} +#given: +a = 12 #first term of GP +a5 = 55 #5th term of GP (ar^4) +n = 5 #fith term given +r = find_r(a5,a,n) #common ratio + +#part(a) +a8 = a*r^7 +print(a8) +#part(b) +a11 = a*r^10 +print(a11) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.22/Ex37_22.R b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.22/Ex37_22.R new file mode 100644 index 00000000..192322cc --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.22/Ex37_22.R @@ -0,0 +1,15 @@ +#page no.409 +#problem 22 +#formula used: an = ar^(n-1) +# sum = a(1-r^n)/(1-r) +#function: +Sn= function(a,r,nn) #function to find ---> sum of n-terms +{return(a*(1-r^n)/(1-r))} + +#given: +seq = c(72.0,57.6,46.08) # GP sequence given +a = seq[1] #1st term of sequence +r = seq[2]/seq[1] # common ratio of sequence +n = 9 # 9 terms +sum_n = Sn(a,r,n) #sum of 9 terms +print(sum_n) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.23/Ex37_23.R b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.23/Ex37_23.R new file mode 100644 index 00000000..0365cf1b --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.23/Ex37_23.R @@ -0,0 +1,14 @@ +#page no.409 +#problem 23 +#formula used: an = ar^(n-1) +# S2inf=a/(1-r) +#function: +S2inf= function(a,r) + {return(a/(1-r))} + +#given: +seq = c(3,1,1/3) # GP sequence to infinity....... +a = seq[1] #1st term of sequence +r = seq[2]/seq[1] +sum_inf = S2inf(a,r) #sum to infinity +print(sum_inf) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.4/Ex37_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.4/Ex37_4.R new file mode 100644 index 00000000..2fc85ef6 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH37/EX37.4/Ex37_4.R @@ -0,0 +1,19 @@ +#page no. 404 +#problem 4 +#given: +term = function(n) # to find term value + { + return(3*n+1) +} + # first four term of the sequence will be a1,a2,a3,a4 +a1 = term(1) +a2 = term(2) +a3 = term(3) +a4 = term(4) + +cat("1st term::",a1) +cat("2nd term::",a2) +cat("3rd term::",a3) +cat("4th term::",a4) + + diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.1/Ex5_1.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.1/Ex5_1.R new file mode 100644 index 00000000..e9e1d0ce --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.1/Ex5_1.R @@ -0,0 +1,7 @@ +#page no.36 +#problem 1 +#laod package ------->formattable +library(formattable) +#function used: percent() +n = 0.015 #decimal to percentage +percent(n) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.10/Ex5_10.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.10/Ex5_10.R new file mode 100644 index 00000000..b0f3602d --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.10/Ex5_10.R @@ -0,0 +1,19 @@ +#page no.37 +#problem 10 +#function: +#percentage of given quantity +percent_of_quantity = function(x,y) # x---->percenatge, y----->quantity +{ + return((percent2deci(x))*y) +} + +percent2deci = function(x) +{ + return(x/100) +} + +#given: +p = 27 #percentage +n = 65 # amount of money +result = percent_of_quantity(p,n) +print(result) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.12/Ex5_12.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.12/Ex5_12.R new file mode 100644 index 00000000..bd18d448 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.12/Ex5_12.R @@ -0,0 +1,20 @@ +#page no.38 +#problem 12 +#function: +#percentage of given quantity +percent_of_quantity = function(x,y) # x---->percenatge, y----->quantity +{ + return((percent2deci(x))*y) +} + +percent2deci = function(x) +{ + return(x/100) +} + +#given: +cost = 190 #base price of ipod +VAT = 20 # VAT percentage +VAT1 = percent_of_quantity(VAT,cost) +result = VAT1 + cost #total cost of iPod (VAT+BASE price) +print(result) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.14/Ex5_14.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.14/Ex5_14.R new file mode 100644 index 00000000..2bcba223 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.14/Ex5_14.R @@ -0,0 +1,15 @@ +#page no.38 +#problem 14 +#load package ---->measurements +library(measurements) +#functions: +percent_one_wrt_second = function(x,y) +{ + return(percent(x/y)) +} +#given: +t1 = 47 #time in minutes +t2 = 2 #time in hours +t2 = conv_unit(t2,'hr','min') +result = percent_one_wrt_second(t1,t2) +print(result) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.15/Ex5_15.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.15/Ex5_15.R new file mode 100644 index 00000000..6636c188 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.15/Ex5_15.R @@ -0,0 +1,12 @@ +#page no. 38 +#problem 15 +#function: +percent_change = function(n,o) #n----> new value, o----> original value +{ + return(percent((n-o)/o)) +} +#given: +new_value = 52 #resistor value +original_value = 45 #resistor value increases +change = percent_change(new_value,original_value) +print(change) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.18/Ex5_18.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.18/Ex5_18.R new file mode 100644 index 00000000..6457c222 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.18/Ex5_18.R @@ -0,0 +1,14 @@ +#page no. 39 +#problem 18 +#function: +per_error = function(err,val) #err-->error, val ---> correct value +{ + return(percent(err/val)) +} + +#given: +cal_vol = 50 #calculated voltage +ac_vol = 50.4 #actual voltage +error = ac_vol - cal_vol # error in measurements +result = per_error(error,ac_vol) #percentage error +print(result) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.21/Ex5_21.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.21/Ex5_21.R new file mode 100644 index 00000000..b0b5b75a --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.21/Ex5_21.R @@ -0,0 +1,15 @@ +#page no. 40 +#problem 21 +#formula used:(new value/100-+change%)*100% +#function: +original_value_profit = function(new,change) #new----> new value, change in percentage +{ + return((new/(100+change))*100) + +} + +#given: +c = 40 #change in percentage (profit) +SP = 630# selling price ---->new value +result = original_value_profit(SP,c) #cost to dealer +print(result) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.23/Ex5_23.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.23/Ex5_23.R new file mode 100644 index 00000000..67b55368 --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.23/Ex5_23.R @@ -0,0 +1,8 @@ +#page no. 40 +#problem +#formula used: new value = (100 + %increase)*original value/100 +#given: +inc = 6.5 #price increased in percentage +cost = 2400 #original cost of boiler +new_price = (((100 + inc)*cost)/100) #new price of boiler +print(new_price) \ No newline at end of file diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.4/Ex5_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.4/Ex5_4.R new file mode 100644 index 00000000..39bdfbbc --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.4/Ex5_4.R @@ -0,0 +1,10 @@ +#page no.36 +#problem 4 +#function used: +percent2deci = function(x) +{ + return(x/100) +} +#given: +n = 17.5 # percentage +print(percent2deci(n)) diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.7/Ex5_7.R b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.7/Ex5_7.R new file mode 100644 index 00000000..fde3d0cd --- /dev/null +++ b/Basic_Engineering_Mathematics_by_John_Bird/CH5/EX5.7/Ex5_7.R @@ -0,0 +1,10 @@ +#page no.36 +#problem 7 +#laod package ------->formattable +library(formattable) +#function used: percent() +n1 = 57/79 #fraction to percentage +n2 = 49/67 #fraction to percentage + +percent(n1) +percent(n2) diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH1/EX1.4.1/Ex1_4_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH1/EX1.4.1/Ex1_4_1.R new file mode 100644 index 00000000..f102e7b6 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH1/EX1.4.1/Ex1_4_1.R @@ -0,0 +1,29 @@ +##Example 1.4.1 Pg.8 +##Simple random sampling of size 10 + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) + +length(age) ##Total of 189 subjects +set.seed(12) ##gives same random sample every time +srs = sample(age,10) +srs +##Answers change because of random sampling + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH1/EX1.4.2/Ex1_4_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH1/EX1.4.2/Ex1_4_2.R new file mode 100644 index 00000000..3c592000 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH1/EX1.4.2/Ex1_4_2.R @@ -0,0 +1,35 @@ +##Example 1.4.2 Pg.11 +##Systematic sample of size 10 + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) + +sys.sample = function(N,n,r){ + k = round(N/n) + #ceiling(x) rounds to the nearest integer that's larger than x. + sys.samp = seq(r, r + k*(n-1), k) + print(sys.samp) +} + +##Starting point is 4 +N = 185; n=10; r=4 +sys = sys.sample(N, n, r) ##returns n systematic sample numbers +age[sys] ##returns the sampled values + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.3.1/Ex10_3_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.3.1/Ex10_3_1.R new file mode 100644 index 00000000..a1afddbd --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.3.1/Ex10_3_1.R @@ -0,0 +1,18 @@ + +##Example 10.3.1 Pg.493 +##Multiple regression equation + +age<- c(72,68,65,85,84,90,79,74,69,87,84,79,71,76,73,86,69,66,79,87,71,81,66,81,80,82,65,73,85,83,83,76,77,83,79,69,65,71,80,81,66,76,70,76,67,72,68,102,67,66,75,91,74,90,66,75,77,78,83,85,76,75,70,79,75,94,76,84,79,78,79) +edlevel <- c(20,12,13,14,13,15,12,10,12,15,12,12,12,14,14,12,17,11,12,12,14,16,16,16,13,12,13,16,16,17,8,20,12,12,14,12,16,14,18,11,14,17,12,12,12,20,18,12,12,14,18,13,15,15,14,12,16,12,20,10,18,14,16,16,18,8,18,18,17,16,12) +cda <- c(4.57,-3.04,1.39,-3.55,-2.56,-4.66,-2.70,0.30,-4.46,-6.29,-4.43,0.18,-1.37,3.26,-1.12,-0.77,3.73,-5.92,3.17,-1.19,0.99,-2.94,-2.21,-.75,5.07,-5.86,5,0.63,2.62,1.77,-3.79,1.44,-5.77,-5.77,-4.62,-2.03,5.74,2.83,-2.40,-0.29,4.44,3.35,-3.13-2.14,9.61,7.57,2.21,-2.3,1.73,6.03,-0.02,-7.65,4.17,-0.68,-2.22,0.80,-0.75,-4.60,2.68,-3.69,4.85,-0.08,0.63,5.92,3.63,-7.07,6.39,-0.08,1.07,5.31,0.30,0.30) +dt = data.frame(age,edlevel,cda) + +pairs(dt) #multiple scatter plots + +reg <- lm(cda~age+edlevel) #multiple regression model +reg +summary(reg) + +#Answers might slightly differ due to approximation + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.1/Ex10_4_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.1/Ex10_4_1.R new file mode 100644 index 00000000..023ad834 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.1/Ex10_4_1.R @@ -0,0 +1,18 @@ +##Example 10.4.1 Pg.502 +##Coefficient of mutliple determination + +age<- c(72,68,65,85,84,90,79,74,69,87,84,79,71,76,73,86,69,66,79,87,71,81,66,81,80,82,65,73,85,83,83,76,77,83,79,69,65,71,80,81,66,76,70,76,67,72,68,102,67,66,75,91,74,90,66,75,77,78,83,85,76,75,70,79,75,94,76,84,79,78,79) +edlevel <- c(20,12,13,14,13,15,12,10,12,15,12,12,12,14,14,12,17,11,12,12,14,16,16,16,13,12,13,16,16,17,8,20,12,12,14,12,16,14,18,11,14,17,12,12,12,20,18,12,12,14,18,13,15,15,14,12,16,12,20,10,18,14,16,16,18,8,18,18,17,16,12) +cda <- c(4.57,-3.04,1.39,-3.55,-2.56,-4.66,-2.70,0.30,-4.46,-6.29,-4.43,0.18,-1.37,3.26,-1.12,-0.77,3.73,-5.92,3.17,-1.19,0.99,-2.94,-2.21,-.75,5.07,-5.86,5,0.63,2.62,1.77,-3.79,1.44,-5.77,-5.77,-4.62,-2.03,5.74,2.83,-2.40,-0.29,4.44,3.35,-3.13-2.14,9.61,7.57,2.21,-2.3,1.73,6.03,-0.02,-7.65,4.17,-0.68,-2.22,0.80,-0.75,-4.60,2.68,-3.69,4.85,-0.08,0.63,5.92,3.63,-7.07,6.39,-0.08,1.07,5.31,0.30,0.30) +dt = data.frame(age,edlevel,cda) + +reg <- lm(cda~age+edlevel) #multiple regression model +reg +summary(reg) + +#Multiple R squared value is 0.01807 +#Answers might slightly differ due to approximation + + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.2/Ex10_4_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.2/Ex10_4_2.R new file mode 100644 index 00000000..ea1fd427 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.2/Ex10_4_2.R @@ -0,0 +1,15 @@ +##Example 10.4.2 Pg.504 +##Test for parameters + +age<- c(72,68,65,85,84,90,79,74,69,87,84,79,71,76,73,86,69,66,79,87,71,81,66,81,80,82,65,73,85,83,83,76,77,83,79,69,65,71,80,81,66,76,70,76,67,72,68,102,67,66,75,91,74,90,66,75,77,78,83,85,76,75,70,79,75,94,76,84,79,78,79) +edlevel <- c(20,12,13,14,13,15,12,10,12,15,12,12,12,14,14,12,17,11,12,12,14,16,16,16,13,12,13,16,16,17,8,20,12,12,14,12,16,14,18,11,14,17,12,12,12,20,18,12,12,14,18,13,15,15,14,12,16,12,20,10,18,14,16,16,18,8,18,18,17,16,12) +cda <- c(4.57,-3.04,1.39,-3.55,-2.56,-4.66,-2.70,0.30,-4.46,-6.29,-4.43,0.18,-1.37,3.26,-1.12,-0.77,3.73,-5.92,3.17,-1.19,0.99,-2.94,-2.21,-.75,5.07,-5.86,5,0.63,2.62,1.77,-3.79,1.44,-5.77,-5.77,-4.62,-2.03,5.74,2.83,-2.40,-0.29,4.44,3.35,-3.13-2.14,9.61,7.57,2.21,-2.3,1.73,6.03,-0.02,-7.65,4.17,-0.68,-2.22,0.80,-0.75,-4.60,2.68,-3.69,4.85,-0.08,0.63,5.92,3.63,-7.07,6.39,-0.08,1.07,5.31,0.30,0.30) +dt = data.frame(age,edlevel,cda) + +reg <- lm(cda~age+edlevel) #multiple regression model +summary(reg) +summary(aov(reg)) + +#pvalue > 0.05 , hence there is a significant relationship between three variables +#Answers might slightly differ due to approximation + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.3/Ex10_4_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.3/Ex10_4_3.R new file mode 100644 index 00000000..2a83cd57 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.4.3/Ex10_4_3.R @@ -0,0 +1,17 @@ +##Example 10.4.3 Pg.505 +##Test for parameter of variable Age + +age<- c(72,68,65,85,84,90,79,74,69,87,84,79,71,76,73,86,69,66,79,87,71,81,66,81,80,82,65,73,85,83,83,76,77,83,79,69,65,71,80,81,66,76,70,76,67,72,68,102,67,66,75,91,74,90,66,75,77,78,83,85,76,75,70,79,75,94,76,84,79,78,79) +edlevel <- c(20,12,13,14,13,15,12,10,12,15,12,12,12,14,14,12,17,11,12,12,14,16,16,16,13,12,13,16,16,17,8,20,12,12,14,12,16,14,18,11,14,17,12,12,12,20,18,12,12,14,18,13,15,15,14,12,16,12,20,10,18,14,16,16,18,8,18,18,17,16,12) +cda <- c(4.57,-3.04,1.39,-3.55,-2.56,-4.66,-2.70,0.30,-4.46,-6.29,-4.43,0.18,-1.37,3.26,-1.12,-0.77,3.73,-5.92,3.17,-1.19,0.99,-2.94,-2.21,-.75,5.07,-5.86,5,0.63,2.62,1.77,-3.79,1.44,-5.77,-5.77,-4.62,-2.03,5.74,2.83,-2.40,-0.29,4.44,3.35,-3.13-2.14,9.61,7.57,2.21,-2.3,1.73,6.03,-0.02,-7.65,4.17,-0.68,-2.22,0.80,-0.75,-4.60,2.68,-3.69,4.85,-0.08,0.63,5.92,3.63,-7.07,6.39,-0.08,1.07,5.31,0.30,0.30) +dt = data.frame(age,edlevel,cda) + +reg <- lm(cda~age+edlevel) #multiple regression model +reg +summary(reg) + +#pvalue >0.05, hence significant relationship between cda and age +#Answers might slightly differ due to approximation + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.5.1/Ex10_5_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.5.1/Ex10_5_1.R new file mode 100644 index 00000000..bb1c85ac --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.5.1/Ex10_5_1.R @@ -0,0 +1,19 @@ +##Example 10.5.1 Pg.508 +##95% confidencec interval for CDA + +age<- c(72,68,65,85,84,90,79,74,69,87,84,79,71,76,73,86,69,66,79,87,71,81,66,81,80,82,65,73,85,83,83,76,77,83,79,69,65,71,80,81,66,76,70,76,67,72,68,102,67,66,75,91,74,90,66,75,77,78,83,85,76,75,70,79,75,94,76,84,79,78,79) +edlevel <- c(20,12,13,14,13,15,12,10,12,15,12,12,12,14,14,12,17,11,12,12,14,16,16,16,13,12,13,16,16,17,8,20,12,12,14,12,16,14,18,11,14,17,12,12,12,20,18,12,12,14,18,13,15,15,14,12,16,12,20,10,18,14,16,16,18,8,18,18,17,16,12) +cda <- c(4.57,-3.04,1.39,-3.55,-2.56,-4.66,-2.70,0.30,-4.46,-6.29,-4.43,0.18,-1.37,3.26,-1.12,-0.77,3.73,-5.92,3.17,-1.19,0.99,-2.94,-2.21,-.75,5.07,-5.86,5,0.63,2.62,1.77,-3.79,1.44,-5.77,-5.77,-4.62,-2.03,5.74,2.83,-2.40,-0.29,4.44,3.35,-3.13-2.14,9.61,7.57,2.21,-2.3,1.73,6.03,-0.02,-7.65,4.17,-0.68,-2.22,0.80,-0.75,-4.60,2.68,-3.69,4.85,-0.08,0.63,5.92,3.63,-7.07,6.39,-0.08,1.07,5.31,0.30,0.30) +dt = data.frame(age,edlevel,cda) + +reg <- lm(cda~age+edlevel) #multiple regression model +reg +summary(reg) + +new.dat <- data.frame(age=68,edlevel=12) #new observation +predict(reg, newdata = new.dat, interval = 'confidence') #confidence interval +predict(reg, newdata = new.dat, interval = 'prediction') #prediction interval + +#Answers might slightly differ due to approximation + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.6.1/Ex10_6_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.6.1/Ex10_6_1.R new file mode 100644 index 00000000..01f1a0d8 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.6.1/Ex10_6_1.R @@ -0,0 +1,16 @@ +##Example 10.6.1 Pg.511 +##Multiple correlation coefficient + +w<- c(193.6,137.5,145.4,117,105.4,99.9,74,74.4,112.8,125.4,126.5,115.9,98.8,94.3,99.9,83.3,72.8,83.5,59,87.2,84.4,78.1,51.9,57.1,54.7,78.6,53.7,96,89) +p<- c(6.24,8.03,11.62,7.68,10.72,9.28,6.23,8.67,6.91,7.51,10.01,8.70,5.87,7.96,12.27,7.33,11.17,6.03,7.90,8.27,11.05,7.61,6.21,7.24,8.11,10.05,8.79,10.40,11.72) +s<- c(30.1,22.2,25.7,28.9,27.3,33.4,26.4,17.2,15.9,12.2,30,24,22.6,18.2,11.5,23.9,11.2,15.6,10.6,24.7,25.6,18.4,13.5,12.2,14.8,8.9,14.9,10.3,15.4) + +reg = lm(w~p+s) +reg +summary(reg) + +#Multiple R sqaured = 0.2942 +#Answers might slightly differ due to approximation + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.6.2/Ex10_6_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.6.2/Ex10_6_2.R new file mode 100644 index 00000000..8dc9fb36 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH10/EX10.6.2/Ex10_6_2.R @@ -0,0 +1,42 @@ +##Example 10.6.2 Pg.515 +##Partial correlation coefficient + +w<- c(193.6,137.5,145.4,117,105.4,99.9,74,74.4,112.8,125.4,126.5,115.9,98.8,94.3,99.9,83.3,72.8,83.5,59,87.2,84.4,78.1,51.9,57.1,54.7,78.6,53.7,96,89) +p<- c(6.24,8.03,11.62,7.68,10.72,9.28,6.23,8.67,6.91,7.51,10.01,8.70,5.87,7.96,12.27,7.33,11.17,6.03,7.90,8.27,11.05,7.61,6.21,7.24,8.11,10.05,8.79,10.40,11.72) +s<- c(30.1,22.2,25.7,28.9,27.3,33.4,26.4,17.2,15.9,12.2,30,24,22.6,18.2,11.5,23.9,11.2,15.6,10.6,24.7,25.6,18.4,13.5,12.2,14.8,8.9,14.9,10.3,15.4) + +reg = lm(w~p+s) +reg +summary(reg) + +res1 = residuals(lm(w~p)) +res2 = residuals(lm(s~p)) +res3 = residuals(lm(w~s)) +res4 = residuals(lm(p~s)) +res5 = residuals(lm(p~w)) +res6 = residuals(lm(s~w)) + +# use Spearman correlation coefficient to calculate the all possible partial correlations +p1 = cor(res1,res2,method = "spearman") +p2 = cor(res1,res3,method = "spearman") +p3 = cor(res1,res4,method = "spearman") +p4 = cor(res1,res5,method = "spearman") +p5 = cor(res1,res6,method = "spearman") +p6 = cor(res2,res3,method = "spearman") +p7 = cor(res2,res4,method = "spearman") +p8 = cor(res2,res5,method = "spearman") +p9 = cor(res2,res6,method = "spearman") +p10 = cor(res3,res4,method = "spearman") +p11 = cor(res3,res5,method = "spearman") +p12 = cor(res3,res6,method = "spearman") +p13 = cor(res4,res5,method = "spearman") +p14 = cor(res4,res6,method = "spearman") +p15 = cor(res5,res6,method = "spearman") +p <- c(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15) +p + + +#Answers might slightly differ due to approximation + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.1.1/Ex11_1_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.1.1/Ex11_1_1.R new file mode 100644 index 00000000..b584fbd3 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.1.1/Ex11_1_1.R @@ -0,0 +1,11 @@ +##Example 11.1.1 Pg.540 +##Box and whiskers plot + +THC <- c(.30,2.75,2.27,2.37,1.12,.60,.61,.89,.33,.85,2.18,3.59,.28,1.90,1.71,.85,1.53,2.25,.88,.49,4.35,.67,2.74,.79,6.94) +log_THC <- log10(THC) +log_THC +data = data.frame(THC,log_THC) + +#install.packages("car") +library(car) +Boxplot(data,ylab="concentration") diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.1.2/Ex11_1_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.1.2/Ex11_1_2.R new file mode 100644 index 00000000..88b9434d --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.1.2/Ex11_1_2.R @@ -0,0 +1,21 @@ +##Example 11.1.2 Pg.542 +##Correlation for 3 variables + +sbp <- c(126,129,126,123,124,125,127,125,123,119,127,126,122,126,125) +weight <- c(125,130,132,200,321,100,138,138,149,180,184,251,197,107,125) +bmi <- c(24.41,23.77,20.07,27.12,39.07,20.90,22.96,24.44,23.33,25.82,26.40,31.37,26.72,20.22,23.62) +dt<-data.frame(sbp,weight,bmi) + +#install.packages("PerformanceAnalytics") +library(PerformanceAnalytics) + +chart.Correlation(dt) +##Shows correlation coefficient and significant values + +cor.test(sbp,weight) +#result shows cor = -0.289, p value = 0.296 +cor.test(sbp,bmi) +#result shows cor = -0.213, p value = 0.447 +cor.test(bmi,weight) +#result shows cor = 0.962, p value = 0.000 + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.2.1/Ex11_2_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.2.1/Ex11_2_1.R new file mode 100644 index 00000000..8bd4814a --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.2.1/Ex11_2_1.R @@ -0,0 +1,44 @@ +##Example 11.2.1 Pg.545 +##Regression model for categorical data + +grams <- c(3147,2977,3119,3487,4111,3572,3487, + 3147,3345,2665,1559,3799, + 2750,3487,3317,3544,3459,2807,3856, + 3260,2183,3204,3005,3090,3430,3119, + 3912,3572,3884,3090,2977,3799,4054, + 3430,3459,3827,3147,3289,3629,3657, + 3175,3232,3175,3657,3600,3572,709,624, + 2778,3572,3232,3317,2863,3175,3317,3714, + 2240,3345,3119,2920,3430,3232,3430,4139, + 3714,1446,3147,2580,3374,3941,2070,3345, + 3600,3232,3657,3487,2948,2722,3771,3799, + 1871,3260,3969,3771,3600,2693,3062,2693,3033,3856, + 4111,3799,3147,2920,4054,2296,3402,1871, + 4167,3402) +weeks <- c(40,41,38,38,39,41,40,41,38,34,34,38,38,40,38, + 43,45,37,40,40,42,38,36,40,39,40,39,40,41,38, + 42,37,40,38,41,39,44,38,36,36,41,43,36,40,39, + 40,25,25,36,35,38,40,37,37,40,34,36,39,39,37, + 41,35,38,39,39,28,39,31,37,40,37,40,40,41,38, + 39,38,40,40,45,33,39,38,40,40,35,45,36,41,42, + 40,39,38,36,40,36,38,33,41,37) +smoke <- c(0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0, + 1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,0, + 0,0,0,rep(0,15),1,1,0,0,0,0,0,0,0,1,rep(0,10), + 1,rep(0,11),1,0,1) +smoke = factor(smoke, labels = c("nonsmoker","smoker"),levels=c(0,1)) + +plot(weeks, grams, pch=21, + bg=c("red","green3")[unclass(smoke)]) +##red for non smokers and green for smokers + +reg = lm(grams~weeks+smoke) +summary(reg) +##Gives the estimates and corresponding p values +summary(aov(reg)) +##Gives the Anova results (sum of squares and F statistic) + + +plot(weeks, grams, pch=21, + bg=c("red","green3")[unclass(smoke)]) +abline(reg) diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.2.2/Ex11_2_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.2.2/Ex11_2_2.R new file mode 100644 index 00000000..c6cac37c --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.2.2/Ex11_2_2.R @@ -0,0 +1,41 @@ +##Example 11.2.2 Pg.549 +##Test for model parameter for categorical data + +grams <- c(3147,2977,3119,3487,4111,3572,3487, + 3147,3345,2665,1559,3799, + 2750,3487,3317,3544,3459,2807,3856, + 3260,2183,3204,3005,3090,3430,3119, + 3912,3572,3884,3090,2977,3799,4054, + 3430,3459,3827,3147,3289,3629,3657, + 3175,3232,3175,3657,3600,3572,709,624, + 2778,3572,3232,3317,2863,3175,3317,3714, + 2240,3345,3119,2920,3430,3232,3430,4139, + 3714,1446,3147,2580,3374,3941,2070,3345, + 3600,3232,3657,3487,2948,2722,3771,3799, + 1871,3260,3969,3771,3600,2693,3062,2693,3033,3856, + 4111,3799,3147,2920,4054,2296,3402,1871, + 4167,3402) +weeks <- c(40,41,38,38,39,41,40,41,38,34,34,38,38,40,38, + 43,45,37,40,40,42,38,36,40,39,40,39,40,41,38, + 42,37,40,38,41,39,44,38,36,36,41,43,36,40,39, + 40,25,25,36,35,38,40,37,37,40,34,36,39,39,37, + 41,35,38,39,39,28,39,31,37,40,37,40,40,41,38, + 39,38,40,40,45,33,39,38,40,40,35,45,36,41,42, + 40,39,38,36,40,36,38,33,41,37) +smoke <- c(0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0, + 1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,0, + 0,0,0,rep(0,15),1,1,0,0,0,0,0,0,0,1,rep(0,10), + 1,rep(0,11),1,0,1) +smoke = factor(smoke, labels = c("nonsmoker","smoker"),levels=c(0,1)) + +reg = lm(grams~weeks+smoke) +summary(reg) + +##We get the t test statistic for smokers as -2.17 +##p value is 0.033 < 0.05, hence significant +##smoking mothers associateed with reduced birth weights of babies + + + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.3.1/Ex11_3_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.3.1/Ex11_3_1.R new file mode 100644 index 00000000..4e91339b --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.3.1/Ex11_3_1.R @@ -0,0 +1,17 @@ +##Example 11.3.1 Pg.561 +##Stepwise regression model + +y = c(45,65,73,63,83,45,60,73,74,69,66,69,71,70,79,83,75,67,67,52,52,66,55,42,65,68,80,50,87,84) +x1 = c(74,65,71,64,79,56,68,76,83,62,54,61,63,84,78,65,86,61,71,59,71,62,67,65,55,78,76,58,86,83) +x2 = c(29,50,67,44,55,48,41,49,71,44,52,46,56,82,53,49,63,64,45,67,32,51,51,41,41,65,57,43,70,38) +x3 = c(40,64,79,57,76,54,66,65,77,57,67,66,67,68,82,82,79,75,67,64,44,72,60,45,58,73,84,55,81,83) +x4 = c(66,68,81,59,76,59,71,75,76,67,63,84,60,84,84,65,84,60,80,69,48,71,68,55,71,93,85,56,82,69) +x5 = c(93,74,87,85,84,50,69,67,84,81,68,75,64,78,78,55,80,81,86,79,65,81,81,58,76,77,79,84,75,79) +x6 = c(47,49,33,37,33,42,37,43,33,43,36,43,35,37,39,38,41,45,48,54,43,43,39,51,35,42,35,40,30,41) + +step(lm(y~x1+x2+x3+x4+x5+x6),direction = "both") #performs stepwise rergression + +#x1,x2,x3,x6 variables are selected + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.4.1/Ex11_4_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.4.1/Ex11_4_1.R new file mode 100644 index 00000000..5d8a0a82 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.4.1/Ex11_4_1.R @@ -0,0 +1,19 @@ +## Example 11.4.1 Page 572 +##Logistic regression + +cases <- c(21,20,92,15) +disease <- c(1,1,0,0) +disease = factor(disease,labels = c("present","absent")) +sex <- c(1,2,1,2) +sex = factor(sex,labels=c("male","female")) +dt = data.frame(disease,sex,cases) +dt +xtabs(cases~.,dt) #creates contingency table +fit <- glm(disease~sex, weights = cases, data = dt, family = "binomial") #logistic regression +summary(fit) + +##summary gives estimated calue for sex and intercept +##pvalue < 0.05, hence significant + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.4.2/Ex11_4_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.4.2/Ex11_4_2.R new file mode 100644 index 00000000..a6a045c2 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH11/EX11.4.2/Ex11_4_2.R @@ -0,0 +1,42 @@ +##Example 11.4.2 Pg.573 +##Logistic regression + +age<- c(50,59,42,50,34,49,67,44,53,45,79, + 46,62,58,70,60,67,64,62,50,61,69, + 74,65,80,69,77,61,72,67,73,75,71, + 69,78,69,74,86,49,63,63,72,64,72, + 64,72,79,75,70,73,66,75,73,71,72, + 69,76,60,79,78,62,73,46,57,53,40, + 73,68,72,59,64,78,68,67,55,71,80, + 75,69,80,79,71,69,78,75,71,69,77, + 81,78,76,84,74,59,81,74,77,59,75, + 68,81,74,65,81,62,85,84,39,52,67, + 82,84,79,81,74,85,92,69,83,82,85, + 82,74,50,55,66,49,55,73,41,64, + 46,65,50,61,64,59,73,73,65,67,60, + 69,61,79,66,68,61,63,70,68,59,64, + 62,74,61,69,76,71,61,46,69,66,57, + 60,63,63,56,70,70,63,63,65,67,68, + 84,69,78,69,79,83,67,47,57,66) + +status <- c(rep(0,122),rep(1,63)) +status +status1 = factor(status,labels = c("nonparticipating","participating"),levels=c(0,1)) +status1 + +fit <- glm(status1~1+age,family="binomial",control=glm.control(maxit=50)) #logistic regression +summary(fit) +##summary gives the estimates of intercept and age +##Also the p value to test the slope coefficient + +##A function to estimate probabilities from logistic model +est_prob <- function(x) +{ + pred = predict(fit,newdata=data.frame(age=x)) + prob = exp(pred)/(1+exp(pred)) + print(prob) +} + +est_prob(x=50) +est_prob(x=age) +plot(age,est_prob(x=age)) diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.2/Ex12_3_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.2/Ex12_3_2.R new file mode 100644 index 00000000..22e7886b --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.2/Ex12_3_2.R @@ -0,0 +1,27 @@ +##Exaxmple 12.3.2 Pg.609 +## Tests of goodness of fit - Binomial distribution + +x <- 0:10 #no. of paients out of 25 preferring new pain reliever +f <- c(5,6,8,10,10,15,17,10,10,9,0) #no. of doctors reporting this number +N <- c(0,6,16,30,40,75,102,70,80,81,0) #total number of patients preferring new pain reliever by doctor + +p = sum(N)/(25*sum(f)) ; p + +prob = dbinom(x,25,p) ;prob + +pooled1 = f[1] + f[2] #pooling first two values since <5 +Obs_f = c(pooled1,f[c(-1,-2)]) ;Obs_f +Exp_f = sum(f)*prob +pooled2 = Exp_f[1] + Exp_f[2] #pooling first two values since <5 +Exp_f = c(pooled2,Exp_f[c(-1,-2)]) ;Exp_f + +dt = data.frame(Obs_f,Exp_f) +dt +sum(Obs_f) +sum(Exp_f) + +chi_sq = sum((Obs_f-Exp_f)^2/Exp_f) ; chi_sq +p_val = pchisq(0.005,length(x)-2) ;p_val + +#Since pval < 0.005, we conclude data came from binomial distribution +#Answers slightly differ by decimals due to aproximations diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.3/Ex12_3_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.3/Ex12_3_3.R new file mode 100644 index 00000000..1d1a52eb --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.3/Ex12_3_3.R @@ -0,0 +1,24 @@ +##Exaxmple 12.3.3 Pg.611 +## Tests of goodness of fit - Poisson distribution + +x <- 0:10 +f <- c(5,14,15,23,16,9,3,3,1,1,0) +lambda = sum(x*f)/sum(f) ;lambda #mean=lambda +prob = dpois(x,lambda) ;prob + +pooled1 = f[9] + f[10] + f[11] #pooling last three values since <5 +Obs_f = c(f[c(-9,-10,-11)],pooled1) ;Obs_f +Exp_f = sum(f)*prob +pooled2 = Exp_f[9] + Exp_f[10] + Exp_f[11] #pooling first two values since <5 +Exp_f = c(Exp_f[c(-9,-10,-11)],pooled2) ;Exp_f + +dt= data.frame(Obs_f,Exp_f) +dt +sum(Obs_f);sum(Exp_f) +chi_sq = sum((Obs_f-Exp_f)^2/Exp_f) ; chi_sq +p_val = pchisq(0.05,length(x)-3) ;p_val + +#Since pval < 0.005, we conclude data came from poisson distribution +#Answer slightly differ by decimal due to approximation + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.4/Ex12_3_4.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.4/Ex12_3_4.R new file mode 100644 index 00000000..2c387aeb --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.4/Ex12_3_4.R @@ -0,0 +1,16 @@ +##Exaxmple 12.3.4 Pg.614 +## Tests of goodness of fit - Uniform distribution + +x <- c("Dec","Jan","Feb","Mar","Apr") +f <- c(62,84,17,16,21) +prop <- 1/length(x) + +Obs_f = f ;Obs_f +Exp_f = prop*sum(f) ;Exp_f + +chi_sq = sum((Obs_f-Exp_f)^2/Exp_f) ; chi_sq +p_val = pchisq(0.05,length(x)-1) ;p_val + +#Since pval < 0.005, we conclude data came from uniform distribution + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.5/Ex12_3_5.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.5/Ex12_3_5.R new file mode 100644 index 00000000..6b9c0a32 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.3.5/Ex12_3_5.R @@ -0,0 +1,17 @@ +##Exaxmple 12.3.5 Pg.616 +##Goodness of fit - Distribution of traits + +n = 200 +dominant = 43 +heterozygous = 125 +recessive = 32 + +Obs_f = c(43,125,32) +Exp_f = c(50,100,50) #1:2:1 ratio + +chi_sq = sum((Obs_f-Exp_f)^2/Exp_f) ; chi_sq +chi_critical = qchisq(0.95,2) ;chi_critical +p_val = pchisq(0.05,2) ;p_val + +#Since pval < 0.005, we conclude data came from 1:2:1 ratio distribution + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.4.1/Ex12_4_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.4.1/Ex12_4_1.R new file mode 100644 index 00000000..58811ce9 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.4.1/Ex12_4_1.R @@ -0,0 +1,16 @@ + +##Example 12.4.1 Pg.621 +##Test for independence + +x<-matrix(c(260,299,15,41,7,14),nrow=3,byrow=T) +x +rownames(x)<-c("White","Black","Other") +colnames(x)<-c("Yes","No") +print(x) + +chisq.test(x) + +#pvalue < 0.05 , hence there is relationship between race and folic acid + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.4.2/Ex12_4_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.4.2/Ex12_4_2.R new file mode 100644 index 00000000..e2762b42 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.4.2/Ex12_4_2.R @@ -0,0 +1,15 @@ +##Example 12.4.2 Pg.626 +##Test for independence + +x<-matrix(c(131,52,14,36),nrow=2,byrow=T) +x +rownames(x)<-c("Fallers","Non fallers") +colnames(x)<-c("Yes","No") +print(x) + +chisq.test(x) + +#pvalue < 0.05 , hence there is relationship between experiencing a fall and change in lifestyle + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.5.1/Ex12_5_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.5.1/Ex12_5_1.R new file mode 100644 index 00000000..d0b7d929 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.5.1/Ex12_5_1.R @@ -0,0 +1,16 @@ +##Example 12.5.1 Pg.631 +##Test for homogeneity + +x<-matrix(c(21,75,19,77),nrow=2,byrow=T) +x +rownames(x)<-c("Narcoleptic","Controls") +colnames(x)<-c("Yes","No") +print(x) + +chisq.test(x) + +#pvalue > 0.05 , hence two populations may be homogenous wrt migraine frequency +#Answer is slightly differing from the textbook + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.6.1/Ex12_6_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.6.1/Ex12_6_1.R new file mode 100644 index 00000000..7a0a586e --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.6.1/Ex12_6_1.R @@ -0,0 +1,15 @@ +##Example 12.6.1 Pg.638 +##Fishers exact test + +x<-matrix(c(9,2,12,8),nrow=2,byrow=T) +x +rownames(x)<-c("Naive","Experienced") +colnames(x)<-c("Yes","No") +print(x) + +fisher.test(x) + +#pvalue > 0.05 , hence rate of remaining on regimen for 120 weeks is same for naive and experienced groups +#Answer is slightly differing from the textbook + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.7.1/Ex12_7_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.7.1/Ex12_7_1.R new file mode 100644 index 00000000..39700c19 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.7.1/Ex12_7_1.R @@ -0,0 +1,17 @@ +##Example 12.7.1 Pg.644 +##Relative risk + +x<-matrix(c(18,199,22,216),nrow=2,byrow=T) +x +rownames(x)<-c("Not exercising","Extreme exercising") +colnames(x)<-c("cases","non cases") +print(x) + +#install.packages("mosaic") +library(mosaic) + +relrisk(x) + + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.7.2/Ex12_7_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.7.2/Ex12_7_2.R new file mode 100644 index 00000000..c2009030 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH12/EX12.7.2/Ex12_7_2.R @@ -0,0 +1,15 @@ +##Example 12.7.2 Pg.647 +##Odds ratio + +x<-matrix(c(68,3496,64,342),nrow=2,byrow=T) +x +rownames(x)<-c("Never Smoked"," smoked") +colnames(x)<-c("cases","non cases") +print(x) + +#install.packages("mosaic") +library(mosaic) + +oddsRatio(x) + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.10.1/Ex13_10_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.10.1/Ex13_10_1.R new file mode 100644 index 00000000..010abaec --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.10.1/Ex13_10_1.R @@ -0,0 +1,9 @@ +##Example 13.10.1 Pg.720 +##Test for correlation + +age <- c(20,21,22,24,27,30,31,33,35,38,40,42,44,46,48,51,53,55,58,60) +eeg <- c(98,75,95,100,99,65,64,70,85,74,68,66,71,62,69,54,63,52,67,55) + +cor.test(age,eeg) + +#pvalue < 0.05, hence age and eeg are inversely related diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.10.2/Ex13_10_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.10.2/Ex13_10_2.R new file mode 100644 index 00000000..f220f298 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.10.2/Ex13_10_2.R @@ -0,0 +1,12 @@ +##Example 13.10.2 Pg.722 +##Test for correlation + +age <- c(82,85,83,64,82,53,26,47,37,49,65,40,32,50,62,33,36,53,50,71,54,62,47,66,34,46,27,54,72,41,35,75,50,76,28) +conc <- c(169.62,48.94,41.16,63.95,21.09,5.40,6.33,4.26,3.62,4.82,108.22,10.20,2.69,6.16,23.87,2.70,3.15,60.59,4.48,46.93,30.91,34.27,41.44,109.88,2.78,4.17,6.57,61.73,47.59,10.46,3.06,49.57,5.55,50.23,6.81) + +cor.test(age,conc) + +#pvalue < 0.05, hence age and mineral concentration are inversely related + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.3.1/Ex13_3_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.3.1/Ex13_3_1.R new file mode 100644 index 00000000..bcb2d929 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.3.1/Ex13_3_1.R @@ -0,0 +1,18 @@ +##Example 13.3.1 Pg.673 +##Sign test + +score <- c(4,5,8,8,9,6,10,7,6,6) +md= median(score) +diff<-score-md +diff +sdiff<-sign(diff) +sdiff +s=length(sdiff[sdiff==1]) +s +cv=pbinom(1,9,0.5) +cv +pval = 2*cv ;pval + +#since pvalue<0.05, we conclude median score is not 5 + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.3.2/Ex13_3_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.3.2/Ex13_3_2.R new file mode 100644 index 00000000..acc25dcd --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.3.2/Ex13_3_2.R @@ -0,0 +1,17 @@ +##Example 13.3.2 Pg.677 +##Sign test for paired data + +score_x <- c(1.5,2,3.5,3,3.5,2.5,2,1.5,1.5,2,3,2) +score_y <- c(2,2,4,2.5,4,3,3.5,3,2.5,2.5,2.5,2.5) +diff<-score_x - score_y +diff +sdiff<-sign(diff) +sdiff +s=length(sdiff[sdiff==1]) +s +cv=pbinom(s,11,0.5) +cv + +#since pvalue<0.05, instruction was beneficial + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.4.1/Ex13_4_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.4.1/Ex13_4_1.R new file mode 100644 index 00000000..c5470a25 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.4.1/Ex13_4_1.R @@ -0,0 +1,8 @@ +##Example 13.4.1 Pg.683 +##Wilcoxon signed rank test + +cardiac_out <- c(4.91,4.10,6.74,7.27,7.42,7.50,6.56,4.64,5.98,3.14,3.23,5.80,6.17,5.39,5.77) +wilcox.test(cardiac_out, alternative= "two.sided", conf.int=T) + +#since pvalue>0.05, we conclude population mean may be 5.05 + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.5.1/Ex13_5_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.5.1/Ex13_5_1.R new file mode 100644 index 00000000..4be8f184 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.5.1/Ex13_5_1.R @@ -0,0 +1,21 @@ + +##Example 13.5.1 Pg.686 +##Median Test + +urban <-c(35,26,27,21,27,38,23,25,25,27,45,46,33,26,46,41) +rural <-c(29,50,43,22,42,47,42,32,50,37,34,31) +z<-c(urban,rural) +n<-length(z) ;n +u<-median(z) +a<-length(urban[urban>u]) ;a +b<-length(rural[rural>u]) ;b +c<-length(urban[urban<=u]) ;c +d<-length(rural[rural<=u]) ;d + +chi<-(n*(a*d-b*c)^2)/((a+b)*(c+d)*(a+c)*(b+d)) ;chi + +chi_critical <- qchisq(1-0.05,1,lower.tail = T) ;chi_critical +pval<- pchisq(chi,1) ;pval + +#pval > 0.05, hence two saamples may have been drawn from populations with equal median + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.6.1/Ex13_6_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.6.1/Ex13_6_1.R new file mode 100644 index 00000000..6b4cd7ac --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.6.1/Ex13_6_1.R @@ -0,0 +1,8 @@ +##Example 13.6.1 Pg.691 +##Mann Whitney test + +exposed <-c(14.4,14.2,13.8,16.5,14.1,16.6,15.9,15.6,14.1,15.3,15.7,16.7,13.7,15.3,14.0) +unexposed <-c(17.4,16.2,17.1,17.5,15,16,16.9,15,16.3,16.8) + +wilcox.test(exposed, unexposed, conf.level=0.95,conf.int=T) #for mann whitney test + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.7.1/Ex13_7_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.7.1/Ex13_7_1.R new file mode 100644 index 00000000..f32e4fdb --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.7.1/Ex13_7_1.R @@ -0,0 +1,9 @@ +##Example 13.7.1 Pg.699 +##Kolmogorov Smirnov Goodness of fit test + +values <- c(75,84,80,77,68,87,92,77,92,86,78,76,80,81,72,77,92,80,80,77,77,92,68,87,84,75,78,80,80,77,72,81,76,78,81,86) +ks.test(values, "pnorm", mean(values), sd(values), alternative = "two.sided") + +#pvalue > 0.05, hence sample would have come from normal distribution + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.8.1/Ex13_8_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.8.1/Ex13_8_1.R new file mode 100644 index 00000000..22096b7f --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.8.1/Ex13_8_1.R @@ -0,0 +1,14 @@ +##Example 13.8.1 Pg.705 +##Kruskal Wallis one way ANOVA + +cell_count <-c(12.22,28.44,28.13,38.69,54.91,3.68,4.05,6.47,21.12,3.33,54.36,27.87,66.81,46.27,30.19) +group<-c(rep(1,5),rep(2,5),rep(3,5)) +group +group1<-factor(group,labels=c("air","benzaldehyde","acetaldehyde")) +group1 +dt<-data.frame(group1,cell_count) +dt +kruskal.test(cell_count~group1) + +#pval <0.05, hence there is a difference in the average cell count among three groups + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.8.2/Ex13_8_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.8.2/Ex13_8_2.R new file mode 100644 index 00000000..d20a9c05 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.8.2/Ex13_8_2.R @@ -0,0 +1,16 @@ +##Example 13.8.2 Pg.708 +##Kruskal Wallis one way ANOVA + +book_value <-c(1735,1520,1476,1688,1702,2667,1575,1602,1530,1698,5260,4455,4480,4325,5075,5225,4613,4887,2790,2400,2655,2500,2755,2592,2601,1648,1700,3475,3115,3050,3125,3275,3300,2730,6090,6000,5894,5705,6050,6150,5110) +group<-c(rep(1,10),rep(2,8),rep(3,9),rep(4,7),rep(5,7)) +group +group1<-factor(group,labels=c("A","B","C","D","E")) +group1 +dt<-data.frame(group1,book_value) +dt +kruskal.test(book_value~group1) + +#pval <0.05, hence there is a difference in the average book value among five groups + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.9.1/Ex13_9_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.9.1/Ex13_9_1.R new file mode 100644 index 00000000..08d58c61 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.9.1/Ex13_9_1.R @@ -0,0 +1,14 @@ +##Example 13.9.1 Pg.713 +##Friedman test + +ranks_A <-c(2,2,2,1,3,1,2,1,1) +ranks_B <-c(3,3,3,3,2,2,3,3,3) +ranks_C <-c(1,1,1,2,1,3,1,2,2) +n = 9 ; k=3 +friedman = (12/(n*k*(k+1)))*(sum(ranks_A)^2+sum(ranks_B)^2+sum(ranks_C)^2) - 3*n*(k+1) +friedman +pval = pchisq(0.05/2,k-1) ;pval + +#pval <0.05, hence the three models of low volt electrical stimulator are not equally preferred + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.9.2/Ex13_9_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.9.2/Ex13_9_2.R new file mode 100644 index 00000000..9211e21c --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH13/EX13.9.2/Ex13_9_2.R @@ -0,0 +1,14 @@ +##Example 13.9.2 Pg.715 +##Friedman test + +salivaryflow <- + matrix(c(29,48,75,100,72,30,100,100,70,100,86,96,54,35,90,99,5,43,32,81,17,40,76,81,74,100,100,100,6,34,60,81,16,39,73,79,52,34,88,96,8,42,31,79,29,47,72,99,71,100,97,100,7,33,58,79,68,99,84,93,70,30,99,99), + nrow = 16, + byrow = TRUE, + dimnames = list(1 : 16, + c("A", "B", "C","D"))) +friedman.test(salivaryflow) + +#pval <0.05, hence there is a difference in the salivary flow among four groups + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.2.1/Ex2_2_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.2.1/Ex2_2_1.R new file mode 100644 index 00000000..00079584 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.2.1/Ex2_2_1.R @@ -0,0 +1,24 @@ +##Example 2.2.1 Pg.20 +##Arrange ages from smallest to largest + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) +sort(age) + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.3.1/Ex2_3_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.3.1/Ex2_3_1.R new file mode 100644 index 00000000..4f873d3d --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.3.1/Ex2_3_1.R @@ -0,0 +1,32 @@ +##Example 2.3.1 Pg.23 +##Form Class Intervals for the ages data + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) + +breaks = seq(30,90,by=10) +breaks +CI = cut(age,breaks = breaks,right=F) +CI +table(CI) #gives class interevals along with frequencies +hist(age,breaks = breaks,main = "Histogram of ages of 189 subjects") #Pg.27 +par(new=T) ##overlaps new plot +plot(table(CI),type="b") #Pg.28 +dev.off() diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.3.2/Ex2_3_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.3.2/Ex2_3_2.R new file mode 100644 index 00000000..7e6fac71 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.3.2/Ex2_3_2.R @@ -0,0 +1,26 @@ + +##Example 2.3.2 Pg.29 +##Stem and leaf plot for ages of 189 subjects + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) +stem(age,scale=0.5) + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.1/Ex2_4_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.1/Ex2_4_1.R new file mode 100644 index 00000000..bb0fad25 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.1/Ex2_4_1.R @@ -0,0 +1,24 @@ +##Example 2.4.1 Pg.38 +##Obtain the mean age + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) +mean(age) + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.2/Ex2_4_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.2/Ex2_4_2.R new file mode 100644 index 00000000..94236e7c --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.2/Ex2_4_2.R @@ -0,0 +1,26 @@ +##Example 2.4.2 Pg.39 +##Mean age of 10 subjects + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) +set.seed(12) +srs = sample(age,10) +srs +mean(srs) ##different answer due to a different random sample diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.3/Ex2_4_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.3/Ex2_4_3.R new file mode 100644 index 00000000..07854832 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.3/Ex2_4_3.R @@ -0,0 +1,24 @@ +##Example 2.4.3 Pg.40 +##Median age + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) +median(age) + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.4/Ex2_4_4.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.4/Ex2_4_4.R new file mode 100644 index 00000000..7515af9e --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.4/Ex2_4_4.R @@ -0,0 +1,28 @@ +##Example 2.4.4 Pg.40 +##Median age of sample of size 10 + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) +set.seed(12) +srs = sample(age,10) +srs +median(srs) +##different answer due to a different random sample + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.5/Ex2_4_5.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.5/Ex2_4_5.R new file mode 100644 index 00000000..91d51f74 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.5/Ex2_4_5.R @@ -0,0 +1,29 @@ + +##Example 2.4.5 Pg.41 +##Modal age + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) +table(age) ##53 is repeated 17 times is the mode + +mode = names(which(table(age)==max(table(age)))) ##returns the modal value +mode + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.6/Ex2_4_6.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.6/Ex2_4_6.R new file mode 100644 index 00000000..6828d549 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.4.6/Ex2_4_6.R @@ -0,0 +1,27 @@ +##Example 2.4.6 Pg.42 +##Skewness + +##install.packages("moments",dependencies = T) +library(moments) + +no_skew = c(5,5,6,6,6,7,7,7,7,8,8,8,8,8,9,9,9,9,10,10,10,11,11) +right_skew = c(5,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,8,8,8,8,9,9,9,10,10,11) +left_skew = c(5,6,6,7,7,7,8,8,8,8,9,9,9,9,9,10,10,10,10,10,10,11,11,11,11,11,11,11) +par(mfrow=c(1,3)) +hist(no_skew,main="No skew") +hist(right_skew,main="Right skew") +hist(left_skew,main="Left skew") +dev.off() + +descriptive <- function(x) +{ + cat("Mean = " ,mean(x), "\n") + cat("Median = " ,median(x),"\n") + cat("Mode = " ,names(which(table(x)==max(table(x)))),"\n") + cat("Skewness = " ,skewness(x)) +} +d1 = descriptive(no_skew) +d2 = descriptive(right_skew) +d3 = descriptive(left_skew) + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.1/Ex2_5_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.1/Ex2_5_1.R new file mode 100644 index 00000000..8e1a5b70 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.1/Ex2_5_1.R @@ -0,0 +1,25 @@ +##Example 2.5.1 Pg.44 +##Range of ages + +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) +Range = diff(range(age)) +Range + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.2/Ex2_5_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.2/Ex2_5_2.R new file mode 100644 index 00000000..5957cb26 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.2/Ex2_5_2.R @@ -0,0 +1,28 @@ +##Example 2.5.2 Pg.44 +##Variance of ages +age <- c(48,35,46,44,43,42,39,44,49,49, + 44,39,38,49,49,53,56,57,51,61, + 53,66,71,75,72,65,67,38,37,46, + 44,44,48,49,30,45,47,45,48,47, + 47,44,48,43,45,40,48,49,38,44, + 43,47,46,57,52,54,56,53,64,53, + 58,54,59,56,62,50,64,53,61,53, + 62,57,52,54,61,59,57,52,54,53, + 62,52,62,57,59,59,56,57,53,59, + 61,55,61,56,52,54,51,50,50,55, + 63,50,59,54,60,50,56,68,66,71, + 82,68,78,66,70,66,78,69,71,69, + 78,66,68,71,69,77,76,71,43,47, + 48,37,40,42,38,49,43,46,34,46, + 46,48,47,43,52,53,61,60,53,53, + 50,53,54,61,61,61,64,53,53,54, + 61,60,51,50,53,64,64,53,60,54, + 55,58,62,62,54,53,61,54,51,62, + 57,50,64,63,65,71,71,73,66) +set.seed(12) +srs = sample(age,10) +srs +var(srs) + +##Answers differ because of a different random sample + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.3/Ex2_5_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.3/Ex2_5_3.R new file mode 100644 index 00000000..39528699 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.3/Ex2_5_3.R @@ -0,0 +1,17 @@ +##Example 2.5.3 Pg.46 +##Coefficient of correlation + +mean1 = 145 #sample of 11 years old +sd1 = 10 +mean2 = 80 #sample of 25 years old +sd2 = 10 + +cv<-function(mean,sd) #user defined function for coefficient of variation +{cv = sd*100/mean +print(cv)} + +cv1 = cv(mean1,sd1) +cv2 = cv(mean2,sd2) + +##variation is much higher in 11 year old tan in 25 year old + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.4/Ex2_5_4.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.4/Ex2_5_4.R new file mode 100644 index 00000000..90b3f2f6 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.4/Ex2_5_4.R @@ -0,0 +1,27 @@ +##Example 2.5.4 Pg.49 +##Kurtosis + +##install.packages("moments",dependencies = T) +library(moments) + +meso = c(1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,7,7,7,8,8,9) +lepto = c(1,2,2,3,3,3,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,7,7,7,8,8,9) +platy = c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,5,5,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9) +par(mfrow=c(1,3)) +hist(meso,main="Mesokurtic",breaks = 9) +hist(lepto,main="Leptokurtic",breaks=9) +hist(platy,main="Platykurtic",breaks=9) +dev.off() + +descriptive <- function(x) +{ + cat("Mean = " ,mean(x), "\n") + cat("Median = " ,median(x),"\n") + cat("Mode = " ,names(which(table(x)==max(table(x)))),"\n") + cat("Kurtosis = " ,kurtosis(x)) +} +d1 = descriptive(meso) +d2 = descriptive(lepto) ##Kurtosis>3 +d3 = descriptive(platy) ##Kurtosis<3 + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.5/Ex2_5_5.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.5/Ex2_5_5.R new file mode 100644 index 00000000..f5dd5c83 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH2/EX2.5.5/Ex2_5_5.R @@ -0,0 +1,7 @@ +## Example 2.5.5, Pg.50 +##Refer Table 2.5.1 +##Box and whisker plot + +grf = c(14.6,24.3,24.9,27,27.2,27.4,28.2,28.8,29.9,30.7,31.5,31.6, + 32.3,32.8,33.3,33.6,34.3,36.9,38.3,44.0) +boxplot(grf, main="Box and whisker plot for GRF measurements") diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.1/Ex3_4_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.1/Ex3_4_1.R new file mode 100644 index 00000000..d3e07b2f --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.1/Ex3_4_1.R @@ -0,0 +1,12 @@ +##Example 3.4.1 Pg.69 +##Probability of member being <18 years of age + +disorder <- c("negative","bipolar","unipolar","both") +early <- c(28,19,41,53) +later <- c(35,38,44,60) +freq <- data.frame(disorder,early,later) +freq +Prob_E = sum(early)/(sum(early)+sum(later)) #no.of early subjects/total no. of subjects +Prob_E + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.2/Ex3_4_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.2/Ex3_4_2.R new file mode 100644 index 00000000..187228f5 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.2/Ex3_4_2.R @@ -0,0 +1,15 @@ +##Example 3.4.2 Pg.70 +##Conditional Probability +##A = event that family has no history of mood disorders +##E = event that subject is <18 years + +disorder <- c("negative","bipolar","unipolar","both") +early <- c(28,19,41,53) +later <- c(35,38,44,60) +freq <- data.frame(disorder,early,later) +freq + +condi_AE = freq[1,2]/sum(early) #frequency of negative-young subjects/total young subjects +condi_AE + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.3/Ex3_4_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.3/Ex3_4_3.R new file mode 100644 index 00000000..093d1e53 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.3/Ex3_4_3.R @@ -0,0 +1,12 @@ +##Exammple 3.4.3 Pg.71 +##Joint Probability of early subjects and no history of mood disorders + +disorder <- c("negative","bipolar","unipolar","both") +early <- c(28,19,41,53) +later <- c(35,38,44,60) +freq <- data.frame(disorder,early,later) +freq +prob_AE = freq[1,2]/(sum(early)+sum(later)) #frequency of negative-young subjects/total subjects +prob_AE + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.4/Ex3_4_4.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.4/Ex3_4_4.R new file mode 100644 index 00000000..eeb3b3a3 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.4/Ex3_4_4.R @@ -0,0 +1,15 @@ +##Exammple 3.4.4 Pg.71 +##Multiplication rule of early subjects and no history of mood disorders + +disorder <- c("negative","bipolar","unipolar","both") +early <- c(28,19,41,53) +later <- c(35,38,44,60) +freq <- data.frame(disorder,early,later) +freq +Prob_E = sum(early)/(sum(early)+sum(later)) #no.of early subjects/total no. of subjects +condi_AE = freq[1,2]/sum(early) #frequency of negative-young subjects/total young subjects + +Prob_AE = Prob_E*condi_AE #using multiplication rule +Prob_AE + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.5/Ex3_4_5.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.5/Ex3_4_5.R new file mode 100644 index 00000000..c12aac4f --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.5/Ex3_4_5.R @@ -0,0 +1,15 @@ +##Exammple 3.4.5 Pg.72 +##Conditional Probability of early subjects and no history of mood disorders + +disorder <- c("negative","bipolar","unipolar","both") +early <- c(28,19,41,53) +later <- c(35,38,44,60) +freq <- data.frame(disorder,early,later) +freq +Prob_E = sum(early)/(sum(early)+sum(later)) #no.of early subjects/total no. of subjects +prob_AE = freq[1,2]/(sum(early)+sum(later)) #frequency of negative-young subjects/total subjects + +Condi_AE = prob_AE/Prob_E #using multiplication rule +Condi_AE + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.6/Ex3_4_6.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.6/Ex3_4_6.R new file mode 100644 index 00000000..0e7b873e --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.6/Ex3_4_6.R @@ -0,0 +1,17 @@ +##Exammple 3.4.6 Pg.73 +##Probability of early subjects OR no history of mood disorders + +disorder <- c("negative","bipolar","unipolar","both") +early <- c(28,19,41,53) +later <- c(35,38,44,60) +freq <- data.frame(disorder,early,later) +freq + +Prob_E = sum(early)/(sum(early)+sum(later)) #no.of early subjects/total no. of subjects +Prob_A = (freq[1,2]+freq[1,3])/(sum(early)+sum(later)) #no.of negative subjects/total no. of subjects +prob_AE = freq[1,2]/(sum(early)+sum(later)) #frequency of negative-young subjects/total subjects + +Prob_AUE = Prob_A + Prob_E - prob_AE #By addition rule +Prob_AUE + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.7/Ex3_4_7.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.7/Ex3_4_7.R new file mode 100644 index 00000000..72429ea3 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.7/Ex3_4_7.R @@ -0,0 +1,18 @@ +##Exammple 3.4.7 Pg.74 +##Conditional Probability of student wears eyeglassses given he is a boy + +girls = 60 +boys = 40 +girls_glasses = 24 +boys_glasses = 16 +prob_E = 40/100 #prob that a student wears eyeglasses +prob_B = 40/100 #prob of a boy +prob_EB = 16/100 + +condi_EB = prob_EB / prob_B #conditional prob of a student wearing glasss given he is a boy +condi_EB + +prob_EB = prob_E*prob_B #joint probability +prob_EB + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.8/Ex3_4_8.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.8/Ex3_4_8.R new file mode 100644 index 00000000..4b75f1da --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.8/Ex3_4_8.R @@ -0,0 +1,9 @@ +##Example 3.4.8 Pg.75 +##Find probability of admissions that are NOT private + +N = 1200 #total no.of admissions +A = 750 #no. of private admissions +ProbA = A/N +ProbA +ProbA_bar = 1 - ProbA +ProbA_bar diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.9/Ex3_4_9.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.9/Ex3_4_9.R new file mode 100644 index 00000000..654637e4 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.4.9/Ex3_4_9.R @@ -0,0 +1,22 @@ +###Exammple 3.4.9 Pg.75 +##Marginal Probability of Early age + +disorder <- c("negative","bipolar","unipolar","both") +early <- c(28,19,41,53) +later <- c(35,38,44,60) +freq <- data.frame(disorder,early,later) +freq +prob_EA = freq[1,2]/(sum(early)+sum(later)) +prob_EA +prob_EB = freq[2,2]/(sum(early)+sum(later)) +prob_EB +prob_EC = freq[3,2]/(sum(early)+sum(later)) +prob_EC +prob_ED = freq[4,2]/(sum(early)+sum(later)) +prob_ED + +prob_E = prob_EA + prob_EB + prob_EC + prob_ED #Marginal Probability +prob_E + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.5.1/Ex3_5_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.5.1/Ex3_5_1.R new file mode 100644 index 00000000..1c4a6d24 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH3/EX3.5.1/Ex3_5_1.R @@ -0,0 +1,23 @@ +###Exammple 3.5.1 Pg.81 +##Bayes theorem Refer Table for data + +Yes_D = c(436,14) +No_Dbar = c(5,495) +dt = data.frame(Yes_D,No_Dbar,row.names = c("Positive_T","Negative_Tbar") ) +dt +prob_D = 0.113 +prob_Dbar = 1 - prob_D +condi_TD = dt[1,1]/sum(Yes_D) +condi_TDbar = dt[1,2]/sum(No_Dbar) +condi_TbarD = dt[2,1]/sum(Yes_D) +condi_TbarDbar = dt[2,2]/sum(No_Dbar) + +condi_DT = (condi_TD*prob_D)/(condi_TD*prob_D + condi_TDbar*prob_Dbar) #Bayes theorem +condi_DT +##Predictive value of positive test result is very high + +condi_DbarTbar = (condi_TbarDbar*prob_Dbar)/(condi_TbarDbar*prob_Dbar + condi_TbarD*prob_D) #Bayes theorem +condi_DbarTbar +##Predictive value of negative test result is very high + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.1/Ex4_2_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.1/Ex4_2_1.R new file mode 100644 index 00000000..015f5525 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.1/Ex4_2_1.R @@ -0,0 +1,17 @@ +##Example 4.2.1 Pg.93 +##Probability distribution from frequency table + +x = 1:8 +freq = c(62,47,39,39,58,37,4,11) +N = sum(freq) + +prob_dist = freq/N +prob_dist +sum(prob_dist) + +pdf = data.frame(x,freq,prob_dist) +pdf + +barplot(prob_dist,names.arg = x, xlab="x(no. of assistance programs)",ylab="Probability") + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.2/Ex4_2_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.2/Ex4_2_2.R new file mode 100644 index 00000000..4b6a0ba4 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.2/Ex4_2_2.R @@ -0,0 +1,18 @@ +##Example 4.2.2 Pg.95 +##Probability distribution from frequency table P(X=3) + +x = 1:8 +freq = c(62,47,39,39,58,37,4,11) +N = sum(freq) + +prob_dist = freq/N +prob_dist +sum(prob_dist) + +pdf = data.frame(x,freq,prob_dist) +pdf + +prob_3 = pdf$prob_dist[x==3] #gives the prob value at x=3 from the data frame +prob_3 + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.3/Ex4_2_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.3/Ex4_2_3.R new file mode 100644 index 00000000..1d1ca90d --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.3/Ex4_2_3.R @@ -0,0 +1,21 @@ +##Example 4.2.3 Pg.95 +##Prob that family used either one or two programs + +x = 1:8 +freq = c(62,47,39,39,58,37,4,11) +N = sum(freq) + +prob_dist = freq/N +prob_dist +sum(prob_dist) + +pdf = data.frame(x,freq,prob_dist) +pdf + +prob_1 = pdf$prob_dist[x==1] +prob_2 = pdf$prob_dist[x==2] +prob_1U2 = prob_1 + prob_2 #additive rule of mutually exclusive events +prob_1U2 + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.4/Ex4_2_4.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.4/Ex4_2_4.R new file mode 100644 index 00000000..40b0eef2 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.4/Ex4_2_4.R @@ -0,0 +1,15 @@ +##Example 4.2.4 Pg.97 +##Cumulative probability distribution and p(X<=2) + +x = 1:8 +freq = c(62,47,39,39,58,37,4,11) +N = sum(freq) +prob_dist = freq/N +cum_dist = cumsum(prob_dist) +cdf = data.frame(x,freq,prob_dist,cum_dist) +cdf + +cdf_2 = cdf$cum_dist[x==2] +cdf_2 + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.5/Ex4_2_5.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.5/Ex4_2_5.R new file mode 100644 index 00000000..62a8bc57 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.5/Ex4_2_5.R @@ -0,0 +1,15 @@ +##Example 4.2.5 Pg.97 +##Cumulative probability distribution and p(X<4)=P(X<=3) + +x = 1:8 +freq = c(62,47,39,39,58,37,4,11) +N = sum(freq) +prob_dist = freq/N +cum_dist = cumsum(prob_dist) +cdf = data.frame(x,freq,prob_dist,cum_dist) +cdf + +cdf_3 = cdf$cum_dist[x==3] +cdf_3 + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.6/Ex4_2_6.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.6/Ex4_2_6.R new file mode 100644 index 00000000..17d8013a --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.6/Ex4_2_6.R @@ -0,0 +1,15 @@ +##Example 4.2.6 Pg.97 +##Cumulative probability distribution and p(X>=5) = 1 - P(X<=4) + +x = 1:8 +freq = c(62,47,39,39,58,37,4,11) +N = sum(freq) +prob_dist = freq/N +cum_dist = cumsum(prob_dist) +cdf = data.frame(x,freq,prob_dist,cum_dist) +cdf + +ans = 1 - cdf$cum_dist[x==4] +ans + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.7/Ex4_2_7.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.7/Ex4_2_7.R new file mode 100644 index 00000000..647a9573 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.7/Ex4_2_7.R @@ -0,0 +1,17 @@ +##Example 4.2.7 Pg.97 +##Cumulative probability distribution and p(3<=X<=5) = P(X<=5) - P(X<=2) + +x = 1:8 +freq = c(62,47,39,39,58,37,4,11) +N = sum(freq) +prob_dist = freq/N +cum_dist = cumsum(prob_dist) +cdf = data.frame(x,freq,prob_dist,cum_dist) +cdf + +cdf_5 = cdf$cum_dist[x==5] +cdf_2 = cdf$cum_dist[x==2] +ans = cdf_5 - cdf_2 +ans + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.8/Ex4_2_8.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.8/Ex4_2_8.R new file mode 100644 index 00000000..55771be3 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.2.8/Ex4_2_8.R @@ -0,0 +1,20 @@ +##Example 4.2.8 Pg.98 +##mean and variance of prob distribution + +x = 1:8 +freq = c(62,47,39,39,58,37,4,11) +N = sum(freq) +prob_dist = freq/N +cum_dist = cumsum(prob_dist) +cdf = data.frame(x,freq,prob_dist,cum_dist) +cdf + +mean = sum(x*prob_dist) +mean + +variance = sum(x^2 * prob_dist) - mean^2 +variance + +sd = sqrt(variance) +sd + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.1/Ex4_3_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.1/Ex4_3_1.R new file mode 100644 index 00000000..f0a438ce --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.1/Ex4_3_1.R @@ -0,0 +1,8 @@ +##Example 4.3.1 Pg.99 +##Binomial distribution P(X=3) + +binom_3 = dbinom(3,5,0.858) #gives binomial density for x=3,n=5,p=0.858 +binom_3 + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.2/Ex4_3_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.2/Ex4_3_2.R new file mode 100644 index 00000000..abece7fc --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.2/Ex4_3_2.R @@ -0,0 +1,8 @@ +##Example 4.3.2 Pg.103 +##Binomial probability distribution + +n = 10 +x = 4 +p = 14/100 +f = dbinom(x,n,p) #prob of success for a binomial distribution +f #porb that exactly 4 mothers will be admitted to smoking diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.3/Ex4_3_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.3/Ex4_3_3.R new file mode 100644 index 00000000..9276770a --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.3/Ex4_3_3.R @@ -0,0 +1,16 @@ +##Example 4.3.3 Pg.103 +##Binomial probabilities P(X<=5) , P(X>=6) , P(6<=X<=9) , P(2<=X<=4) + +prob_a = pbinom(5,25,0.1) #gives binomial cumulative dist for x=5,n=25,p=0.1 +prob_a + +prob_b = 1 - pbinom(5,25,0.1) +prob_b + +prob_c = pbinom(9,25,0.1) - pbinom(5,25,0.1) +prob_c + +prob_d = pbinom(4,25,0.1) - pbinom(1,25,0.1) +prob_d + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.4/Ex4_3_4.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.4/Ex4_3_4.R new file mode 100644 index 00000000..040b22fb --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.3.4/Ex4_3_4.R @@ -0,0 +1,13 @@ +##Example 4.3.4 Pg.105 +##Binomial probabilities P(X=5) , P(X<=5) , P(X>=8) + +prob_a = dbinom(5,12,0.45) #gives binomial density for x=5,n=12,p=0.45 +prob_a + +prob_b = pbinom(5,12,0.55) #gives binomial cumulative dist for x=5,n=12,p=0.55 +prob_b + +prob_c = 1 - pbinom(7,12,0.55) +prob_c + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.1/Ex4_4_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.1/Ex4_4_1.R new file mode 100644 index 00000000..05a2ed9b --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.1/Ex4_4_1.R @@ -0,0 +1,7 @@ +##Example 4.4.1 Pg.110 +##Poisson distribution P(X=3) + +pois_3 = dpois(3,12) #gives poisson density for x=3, lambda = 12 +pois_3 + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.2/Ex4_4_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.2/Ex4_4_2.R new file mode 100644 index 00000000..e348ac59 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.2/Ex4_4_2.R @@ -0,0 +1,7 @@ +##Example 4.4.2 Pg.110 +##Poisson distribution P(X>=3) = 1 - P(X<=2) + +ans = 1 - ppois(2,12) #gives poisson cumulative distribution for x=2, lambda = 12 +ans + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.3/Ex4_4_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.3/Ex4_4_3.R new file mode 100644 index 00000000..aa6d991e --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.3/Ex4_4_3.R @@ -0,0 +1,6 @@ +##Example 4.4.3 Pg.110 +##Poisson distribution P(X<=1) at lambda=2 + +cum = ppois(1,2) +cum + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.4/Ex4_4_4.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.4/Ex4_4_4.R new file mode 100644 index 00000000..3fc0fd8a --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.4/Ex4_4_4.R @@ -0,0 +1,7 @@ +##Example 4.4.4 Pg.111 +##Poisson distribution P(X=3) at lambda=2 + +pois_3 = dpois(3,2) +pois_3 + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.5/Ex4_4_5.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.5/Ex4_4_5.R new file mode 100644 index 00000000..4e43b484 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.4.5/Ex4_4_5.R @@ -0,0 +1,6 @@ +##Example 4.4.5 Pg.112 +##Poisson distribution P(X>5) at lambda=2 + +pois_5 = 1 - ppois(5,2) +pois_5 + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.1/Ex4_6_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.1/Ex4_6_1.R new file mode 100644 index 00000000..a71be653 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.1/Ex4_6_1.R @@ -0,0 +1,14 @@ +##Example 4.6.1 Pg.119 +##Standard Normal Distribution +## Find P(z<2) + +p = pnorm(2,0,1) #gives probability of normal dist with mean 0 and variance 1 less than 2 +p + +#Generates a random normal densities and plots for P(z<2) +x = seq(-4,4,length=10000) +y = dnorm(x,0,1) +plot(x,y,type="l",lwd=2,col="red") +x = seq(-4,2,length=10000) +y = dnorm(x,0,1) +polygon(c(-4,x,2),c(0,y,0),col="gray") diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.2/Ex4_6_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.2/Ex4_6_2.R new file mode 100644 index 00000000..226e54e9 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.2/Ex4_6_2.R @@ -0,0 +1,17 @@ + +##Example 4.6.2 Pg 120 +##Standard normal distribution P(-2.55=2.71) + +p = 1 - pnorm(2.71,0,1) #gives probability of normal dist with mean 0 and variance 1 less than 2 +p + +#Generates a random normal densities and plots for P(z<2) +x = seq(-4,4,length=10000) +y = dnorm(x,0,1) +plot(x,y,type="l",lwd=2,col="red") +x = seq(2.71,4,length=10000) +y = dnorm(x,0,1) +polygon(c(2.71,x,4),c(0,y,0),col="gray") + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.5/Ex4_6_5.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.5/Ex4_6_5.R new file mode 100644 index 00000000..da9cd3ad --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH4/EX4.6.5/Ex4_6_5.R @@ -0,0 +1,16 @@ +##Example 4.6.5 Pg 122 +##Standard normal distribution P(0.848.5) + +mean = 5.4 ; sd = 1.3 +p = 1 - pnorm(8.5,mean,sd) +p + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.3.2/Ex5_3_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.3.2/Ex5_3_2.R new file mode 100644 index 00000000..ed923e10 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH5/EX5.3.2/Ex5_3_2.R @@ -0,0 +1,17 @@ +##Example 5.3.2 Pg.142 +##Sampling distribution of mean + +xbar = 190 ; mu = 185.6 ; sd = 12.7 ; n=10 + +z = (xbar-mu)/(sd/sqrt(n)) +z + +#Generates a random normal densities and plots for P(0.84 z_critical or pvalue<0.05 , hence significant + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.2/Ex7_2_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.2/Ex7_2_2.R new file mode 100644 index 00000000..4f1d695c --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.2/Ex7_2_2.R @@ -0,0 +1,14 @@ +##Example 7.2.2 Pg.226 +##Test for mean when population variances are known (one sided) + +mu = 30 ; xbar = 27 ; var = 20 ; n=10 +z = (xbar-mu)/sqrt(var/n) +z +z_critical = qnorm(0.05,0,1) +z_critical +pvalue = pnorm(z,0,1) +pvalue +##Z > z_critical or pvalue<0.05 , hence significant + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.3/Ex7_2_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.3/Ex7_2_3.R new file mode 100644 index 00000000..deda581a --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.3/Ex7_2_3.R @@ -0,0 +1,14 @@ +##Example 7.2.3 Pg.228 +##Test for mean when population variances are unknown (two sided) + +days<- c(14,9,18,26,12,0,10,4,8,21,28,24,24,2,3,14,9) +mu = 15 ; xbar = mean(days) ; var = var(days) ; n=17 ; df = n-1 +t = (xbar-mu)/sqrt(var/n) +t +t_critical = qt(0.05/2,df) +t_critical +pvalue = 2*pt(t,df) +pvalue + +##T > t_critical or pvalue<0.05 , hence significant + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.4/Ex7_2_4.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.4/Ex7_2_4.R new file mode 100644 index 00000000..05f72cd5 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.4/Ex7_2_4.R @@ -0,0 +1,14 @@ +##Example 7.2.4 Pg.231 +##Test for mean when population variances are known (one sided) + +mu = 140 ; xbar = 146 ; s = 27 ; n=157 +z = (xbar-mu)/(s/sqrt(n)) +z +z_critical = qnorm(1-0.05,0,1) +z_critical +pvalue = 1-pnorm(z,0,1) +pvalue +##Z > z_critical or pvalue<0.05 , hence significant + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.5/Ex7_2_5.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.5/Ex7_2_5.R new file mode 100644 index 00000000..a8efbd93 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.2.5/Ex7_2_5.R @@ -0,0 +1,15 @@ +##Example 7.2.5 Pg.232 +##Test for mean when population variances are unknown (two sided) + +circ<- c(33.38,34.34,33.46,32.15,33.95,34.13,33.99,33.85,34.45,34.10,34.23,34.19,33.97,32.73,34.05) +mu = 34.5 ; xbar = mean(circ) ; var = var(circ) ; n=length(circ) ; df = n-1 +t = (xbar-mu)/sqrt(var/n) +t +t_critical = qt(0.05/2,df) +t_critical +pvalue = 2*pt(t,df) +pvalue + +##T > t_critical or pvalue<0.05 , hence significant + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.1/Ex7_3_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.1/Ex7_3_1.R new file mode 100644 index 00000000..c163c36b --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.1/Ex7_3_1.R @@ -0,0 +1,13 @@ +##Example 7.3.1 Pg.237 +##Test for two means when population variances are known (two sided) + +mu1mu2 = 0 ; xbar1 =4.5 ;xbar2=3.4; var1 = 1; var2 =1.5 ; n1=12; n2=15 +z = ((xbar1-xbar2)-(mu1mu2))/sqrt((var1/n1)+(var2/n2)) +z +z_critical = qnorm(0.05/2,0,1) +z_critical +pvalue = 1-pnorm(z,0,1) +pvalue +##Z > z_critical or pvalue<0.05 , hence significant + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.2/Ex7_3_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.2/Ex7_3_2.R new file mode 100644 index 00000000..d9046ba7 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.2/Ex7_3_2.R @@ -0,0 +1,10 @@ +##Example 7.3.2 Pg.239 +##Test for means when population variances are unknown (one sided) + +control <-c(131,115,124,131,122,117,88,114,150,169) +sci <- c(60,150,130,180,163,130,121,119,130,148) + +t.test(control,sci) +#pvalue>0.05, hence not significant + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.3/Ex7_3_3.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.3/Ex7_3_3.R new file mode 100644 index 00000000..0a78d10c --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.3/Ex7_3_3.R @@ -0,0 +1,16 @@ +##Example 7.3.3 Pg.240 +##Test for means when population variances are unknown (two sided) + +n1 = 15 ; n2 = 30 ; xbar1 = 19.16; xbar2 = 9.53 ; s1 = 5.29; s2 = 2.69 +t = (xbar1-xbar2)/(sqrt((s1^2/n1)+(s2^2/n2))) +t +alpha = 0.05; df = n1+n2-2 +t_critical = qt(0.05/2,df) +t_critical + + +#T > Tcritical, hence significant +#Answer might slightly differ due to approximation + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.4/Ex7_3_4.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.4/Ex7_3_4.R new file mode 100644 index 00000000..5546e0c2 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.3.4/Ex7_3_4.R @@ -0,0 +1,14 @@ +##Example 7.3.4 Pg.242 +##Test for two means when population variances are known (two sided) + +mu1mu2 = 0 ; xbar1 =59.01 ;xbar2=46.61; var1 =44.89^2; var2 =34.85^2 ; n1=53; n2=54 +z = ((xbar1-xbar2)-(mu1mu2))/sqrt((var1/n1)+(var2/n2)) +z +z_critical = qnorm(1-0.01,0,1) +z_critical +pvalue = 1-pnorm(z,0,1) +pvalue +##Z < z_critical or pvalue>0.05 , hence not significant + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.4.1/Ex7_4_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.4.1/Ex7_4_1.R new file mode 100644 index 00000000..18282977 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.4.1/Ex7_4_1.R @@ -0,0 +1,13 @@ +##Example 7.4.1 Pg.251 +##Paired t test (one sided) + +preop <- c(22,63.3,96,9.2,3.1,50,33,69,64,18.8,0,34) +postop <-c(63.5,91.5,59,37.8,10.1,19.6,41,87.8,86,55,88,40) + +t.test(postop,preop,paired = T,alternative = "greater") + +#pvalue<0.05 , hence significant + + + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.5.1/Ex7_5_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.5.1/Ex7_5_1.R new file mode 100644 index 00000000..124b6606 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.5.1/Ex7_5_1.R @@ -0,0 +1,16 @@ +##Example 7.5.1 Pg.258 +##Test for proportions (one sided) + +P = 0.063 ; p =24/301 ; Q=1-P ; alpha = 0.05 ; n=301 + +z = (P - p)/(sqrt(P*Q/n)) +z = round(z,2) +z +z_critical = qnorm(alpha,0,1) +z_critical +pvalue = pnorm(z,0,1) +pvalue + +#Since p value >alpha, hence not significant + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.6.1/Ex7_6_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.6.1/Ex7_6_1.R new file mode 100644 index 00000000..43fba493 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.6.1/Ex7_6_1.R @@ -0,0 +1,15 @@ +##Example 7.6.1 Pg.261 +##Test for two proportions (one sided) + +p1 = 24/44 ; p2 =11/29 ; q1=1-p1 ; q2=1-p2 ; alpha = 0.05 ; n1=44; n2=29 +z = (p1-p2)/(sqrt((p1*q1/n1)+(p2*q2/n2))) +z = round(z,2) +z +z_critical = qnorm(1-alpha,0,1) +z_critical +pvalue = 1 - pnorm(z,0,1) +pvalue + +#Since p value >alpha, hence not significant + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.7.1/Ex7_7_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.7.1/Ex7_7_1.R new file mode 100644 index 00000000..a39d8073 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.7.1/Ex7_7_1.R @@ -0,0 +1,16 @@ +##Example 7.7.1 Pg.264 +##Test for single population variance + +var =600 ; n=16 ; df=n-1; s2 = 670.81 ; alpha = 0.05 +chisq = s2*(n-1)/var +chisq +chi_critical1 = qchisq(alpha/2,df) +chi_critical2 = qchisq(alpha/2,df,lower.tail = F) +chi_critical = c(chi_critical1,chi_critical2) +chi_critical +pvalue = pchisq(chisq,df) +pvalue + +#Since pvalue>alpha, hence not significant + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.8.1/Ex7_8_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.8.1/Ex7_8_1.R new file mode 100644 index 00000000..c6ef8f05 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH7/EX7.8.1/Ex7_8_1.R @@ -0,0 +1,14 @@ +##Example 7.8.1 Pg.268 +##Test for ratio of two population variances + +s1 =30.62 ;s2 = 11.37; n1=6 ;n2=6; df1=n1-1; df2 = n2-1 ; alpha = 0.05 +f = s1^2/s2^2 +f +f_critical = qf(alpha,df1,df2,lower.tail = F) +f_critical +pvalue = pf(f,df1,df2,lower.tail = F) +pvalue + +#Since pvalue0.05, hence not significant +#Answer matches with minitab output + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH8/EX8.2.1/Ex8_2_1.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH8/EX8.2.1/Ex8_2_1.R new file mode 100644 index 00000000..06ac68d4 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH8/EX8.2.1/Ex8_2_1.R @@ -0,0 +1,23 @@ +##Example 8.2.1 Pg.318 +##One way ANOVA + +ven = c(26.72,28.58,29.71,26.95,10.97,21.97,14.35,32.21,19.19,30.92,10.42,35.49,36.84,25.03,33.59,33.74,18.02,22.27,26.10,20.89,29.44,14.86, + 16.47,25.19,37.45,45.08,25.22,22.11,33.01,31.20,26.50,32.77,8.70,25.90,29.80,37.63,21.69,21.49,18.11,31.50,27.36,21.33) +squ = c(37.42,56.46,51.91,62.73,4.55,39.17,38.44,40.92,58.93,61.88,49.54,64.35,82.49,38.54,39.53,37.57,25.71,23.97,13.82,42.21,35.88,10.54,2.97,41.89,23.94,49.81,30.71,50,87.50,68.99) +rrb = c(11.23,29.63,20.42,10.12,39.91,32.66,38.38,36.21,16.39,27.44,17.29,56.20,28.94,20.11,25.35,21.77,31.62,32.63,30.31,46.16,56.61,24.47,29.39,40.71,18.52,27.80,19.49,15.82,27.74,22.35,34.78,35.09,32.60,37.03,27,44.20,13.09,33.03,9.69,32.45,37.38,34.91,27.99,22.36,22.68,26.52,46.01,38.04,30.88,30.04,25.91,18.54,25.51) +nrb = c(44.33,76.86,4.45,55.01,58.21,74.72,11.84,139.09,69.01,94.61,48.35,37.65,66.36,72.48,87.09,26.34,71.24,90.38,50.86) + +selenium = c(ven,squ,rrb,nrb) +type = c(rep(1,length(ven)),rep(2,length(squ)),rep(3,length(rrb)),rep(4,length(nrb))) +type = factor(type,labels = c("ven","squ","rrb","nrb")) +dt = data.frame(type,selenium) +View(dt) + +anova <- aov(selenium~type) #anova model for selenium content and meat type +anova +summary(anova) + +#pvalue<0.05, hence significant +#Answers might slightly differ due to approximation + + diff --git a/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH8/EX8.2.2/Ex8_2_2.R b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH8/EX8.2.2/Ex8_2_2.R new file mode 100644 index 00000000..4797af05 --- /dev/null +++ b/Biostatistics:_Basic_Concepts_And_Methodology_For_The_Health_Sciences_by_Daniel_W._Wayne,_Chad_L._Cross/CH8/EX8.2.2/Ex8_2_2.R @@ -0,0 +1,29 @@ +##Example 8.2.2 Pg.325 +##One way ANOVA and Tukeys HSD + +ven = c(26.72,28.58,29.71,26.95,10.97,21.97,14.35,32.21,19.19,30.92,10.42,35.49,36.84,25.03,33.59,33.74,18.02,22.27,26.10,20.89,29.44,14.86, + 16.47,25.19,37.45,45.08,25.22,22.11,33.01,31.20,26.50,32.77,8.70,25.90,29.80,37.63,21.69,21.49,18.11,31.50,27.36,21.33) +squ = c(37.42,56.46,51.91,62.73,4.55,39.17,38.44,40.92,58.93,61.88,49.54,64.35,82.49,38.54,39.53,37.57,25.71,23.97,13.82,42.21,35.88,10.54,2.97,41.89,23.94,49.81,30.71,50,87.50,68.99) +rrb = c(11.23,29.63,20.42,10.12,39.91,32.66,38.38,36.21,16.39,27.44,17.29,56.20,28.94,20.11,25.35,21.77,31.62,32.63,30.31,46.16,56.61,24.47,29.39,40.71,18.52,27.80,19.49,15.82,27.74,22.35,34.78,35.09,32.60,37.03,27,44.20,13.09,33.03,9.69,32.45,37.38,34.91,27.99,22.36,22.68,26.52,46.01,38.04,30.88,30.04,25.91,18.54,25.51) +nrb = c(44.33,76.86,4.45,55.01,58.21,74.72,11.84,139.09,69.01,94.61,48.35,37.65,66.36,72.48,87.09,26.34,71.24,90.38,50.86) + +selenium = c(ven,squ,rrb,nrb) +type = c(rep(1,length(ven)),rep(2,length(squ)),rep(3,length(rrb)),rep(4,length(nrb))) +type = factor(type,labels = c("ven","squ","rrb","nrb")) +dt = data.frame(type,selenium) +View(dt) + +anova <- aov(selenium~type) #anova model for selenium content and meat type +anova +summary(anova) + +#pvalue<0.05, hence significant + +posthoc <- TukeyHSD(anova, "type", conf.level=0.95) +posthoc + +#Reject the null if pvalue p_value + diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH2/EX2.6/Ex2_6.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH2/EX2.6/Ex2_6.R new file mode 100644 index 00000000..15cff20a --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH2/EX2.6/Ex2_6.R @@ -0,0 +1,12 @@ +#pie chart +Levels_of_Risk<- c("Low","Average","High") +No_of_funds<- c(212,91,13) +data<- data.frame(Levels_of_Risk,No_of_funds) +Proportion<- data$No_of_funds/sum(No_of_funds) +Percent<- round(Proportion*100,digits=2) +data<- cbind(data,Proportion,Percent) +degree<- data$Proportion*360 +data<- cbind(data,degree) +lab<- paste(data$Levels_of_Risk,data$Percent) +lab<- paste(lab,"%") +pie(data$Percent,labels=lab) diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.1/Ex3_1.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.1/Ex3_1.R new file mode 100644 index 00000000..4d59b61a --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.1/Ex3_1.R @@ -0,0 +1,6 @@ +Cereal<- c("Kellogg's All Bran","Kellogg's Corn Flakes","Wheaties","NAture's Path Multigrain","Rice Krispies","Wheat Vanilla Almond","Mini Wheats") +Calories <- c(80,100,100,110,130,190,200) +No_of_Values<-length(Cereal) +sum_of_values<-sum(Calories) +Xbar<-sum_of_values/No_of_Values +Xbar diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.10/Ex3_10.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.10/Ex3_10.R new file mode 100644 index 00000000..a4916aba --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.10/Ex3_10.R @@ -0,0 +1,8 @@ +#ZScore = ((X-Xbar)/S) +# Xbar- mean, S- standard deviation +calories<- c(80,100,100,110,130,190,200) +Xbar<- mean(calories) +S <- sd(calories) +Z_score<- (calories - Xbar)/S +Z_score +data<- cbind(calories,Z_score) diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.2/Ex3_2.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.2/Ex3_2.R new file mode 100644 index 00000000..560a0b81 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.2/Ex3_2.R @@ -0,0 +1,4 @@ +#values taken from Ex3_1.R +Calories <- c(80,100,100,110,130,190,200) +Median<- median(Calories) +Median diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.3/Ex3_3.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.3/Ex3_3.R new file mode 100644 index 00000000..fba02184 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.3/Ex3_3.R @@ -0,0 +1,13 @@ +#Given data +failures<- c(1,3,0,3,26,2,7,4,0,2,3,3,6,3) +#mean +mean<- mean(failures) +#median +median <-median(failures) +# function for mode +getmode<- function(x){ + uniq<- unique(x) #unique() function used +uniq[which.max(tabulate(match(failures,uniq)))] #which.max() function used +} +mode<- getmode(failures) +mode #mode \ No newline at end of file diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.7/Ex3_7.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.7/Ex3_7.R new file mode 100644 index 00000000..ebdb2bd5 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.7/Ex3_7.R @@ -0,0 +1,5 @@ +# Range= X_largest - X_smallest +calories<- c(80,100,100,110,130,190,200) +Range<- max(calories)-min(calories) +Range +# the largest difference between any two number of calories is 120 diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.8/Ex3_8.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.8/Ex3_8.R new file mode 100644 index 00000000..1f54caa3 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.8/Ex3_8.R @@ -0,0 +1,15 @@ +#Variance = ((Xi-Xbar)^2)/(n-1) +#standard deviation = sqrt(variance) +calories<- c(80,100,100,110,130,190,200) +mean<- mean(calories) +mean +n<- 7 +S1<- calories - mean +S1 +S2 <- S1^2 +S2 +sum<-sum(S2) +Sample_variance <- sum/(n-1) +Sample_variance +Standard_deviation<- sqrt(Sample_variance) +Standard_deviation diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.9/Ex3_9.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.9/Ex3_9.R new file mode 100644 index 00000000..90cdac03 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH3/EX3.9/Ex3_9.R @@ -0,0 +1,18 @@ +#Coeffecient of variation CV=(S/Xbar)*100% +# S=Sample standard deviation, Xbar=Sample Mean +S_calories<- 46.9042 +Xbar_calories <- 130 # values can be found in EX 1 & 8 respectively +percent <- function(x, digits = 2, format = "f", ...) { + paste0(formatC(100 * x, format = format, digits = digits, ...), "%") +} +CV_calories<- (S_calories/Xbar_calories) +percent(CV_calories) +Sugar<- c(6,2,4,4,4,11,10) +Xbar_sugar <- mean(Sugar) +Xbar_sugar +S_sugar<- sd(Sugar) +S_sugar +CV_sugar<- (S_sugar/Xbar_sugar) +percent(CV_sugar) + + diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.10/Ex4_10.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.10/Ex4_10.R new file mode 100644 index 00000000..680facda --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.10/Ex4_10.R @@ -0,0 +1,17 @@ +# Bayes's Theorem : P (Bi|A) = P(Bi)*P(A|Bi) / P(B1)*P(A|B1)+P(B2)*P(A|B2)+...+P(Bn)*P(A|Bn) +event<- c("D","D.","T","T.") +# event D= has Disease +# event D.= does not have Disease +# event T= Test is positive +# event T.= Test is negative +p_D<- 0.03 #probability that the person has a disease + +p_D. <- 0.97 #probability that the person has a disease + +pT_D <- 0.9 #probablity of T given D + +pT_D. <- 0.02 #probability of T given not D + +pD_T <- (pT_D*p_D)/((pT_D*p_D)+(pT_D.*p_D.)) +pD_T <- round(pD_T ,digits = 3) +pD_T \ No newline at end of file diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.11/Ex4_11.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.11/Ex4_11.R new file mode 100644 index 00000000..37c981be --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.11/Ex4_11.R @@ -0,0 +1,7 @@ +#counting rule: No. of outcomes= K^n +outcomes<- function(k,n){ + return(k^n) + +} +outcomes(6,2) + diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.12/Ex4_12.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.12/Ex4_12.R new file mode 100644 index 00000000..83d15a0e --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.12/Ex4_12.R @@ -0,0 +1,9 @@ + #number of different outcomes- If there are K1 events on first trial, K2 events on second and so on, then the no.of possible outcomes is given by- + #(K1)(K2)...(Kn) + appetizer<- 5 + entrees<- 10 + beverages<- 3 + desserts<- 6 + Total_no_of_dinners<- appetizer*entrees*beverages* desserts + Total_no_of_dinners + diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.13/Ex4_13.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.13/Ex4_13.R new file mode 100644 index 00000000..f4fc6cf9 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.13/Ex4_13.R @@ -0,0 +1,7 @@ +#counting + +No_of_arrangements<- function(n) #n is no. of books +{ + return(factorial(n)) +} +No_of_arrangements(6) \ No newline at end of file diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.14/Ex4_14.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.14/Ex4_14.R new file mode 100644 index 00000000..b68b1e56 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.14/Ex4_14.R @@ -0,0 +1,11 @@ +#counting Rule (Permutation) + + +counting <- function(n, r){ + return( factorial(n) / factorial(n - r)) +} + +#have 6 elements, choosing 4 at a time +counting(6,4) + + diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.15/Ex4_15.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.15/Ex4_15.R new file mode 100644 index 00000000..7edd1721 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.15/Ex4_15.R @@ -0,0 +1,9 @@ +#counting Rule (COMBINATIONS) + + +counting <- function(n,r){ + return( factorial(n) / (factorial(n-r)* factorial(r))) +} + +#have 6 elements, choosing 4 at a time +counting(6,4) diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.3/Ex4_3.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.3/Ex4_3.R new file mode 100644 index 00000000..1c21bfcd --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.3/Ex4_3.R @@ -0,0 +1,13 @@ +# Computing Probability +# definitions +# A = purchased a TV with faster refresh rate +# A' = purchased a TV with faster refresh rate +# B = purchased streaming Box +# B' = did not purchase streaming Box +Television_Refresh_Rate <- c("Faster","Standard","Total") +Satisfaction_Yes<- c(64,176,240) +Satisfaction_No<- c(16,44,60) +Total<- c(80,220,300) +data<- cbind(Television_Refresh_Rate,Satisfaction_Yes,Satisfaction_No,Total) +p_faster_refresh_rate<- (Total[1]/Total[3]) +round(p_faster_refresh_rate,digits=3) diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.4/Ex4_4.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..8fa4db41 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,6 @@ +Television_Refresh_Rate <- c("Faster","Standard","Total") +media_box_Yes<- c(38,70,108) +media_box_No<- c(42,150,192) +Total<- c(80,220,300) +p_faster_refresh_and_media_box <- media_box_Yes[1]/Total[3] +round(p_faster_refresh_and_media_box,digits = 3) diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.5/Ex4_5.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..acdf2c42 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,5 @@ +p1<- 80/300 #Television had a faster refresh rate or purchased a media box +p2<- 108/300 #purchased a streaming media box +p3<- 38/300 #Television had a faster refresh rate and purchased a media box +p4<- p1+p2-p3 #Television had a faster refresh rate +p4 diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.8/Ex4_8.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.8/Ex4_8.R new file mode 100644 index 00000000..888dfa85 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH4/EX4.8/Ex4_8.R @@ -0,0 +1,11 @@ +# Determining Independence + +Television_Refresh_Rate <- c("Faster","Standard","Total") +Satisfaction_Yes<- c(64,176,240) +Satisfaction_No<- c(16,44,60) +Total<- c(80,220,300) +data<- cbind(Television_Refresh_Rate,Satisfaction_Yes,Satisfaction_No,Total) +p_satisfied_given_faster<- (Satisfaction_Yes[1]/Total[3])/(Total[1]/Total[3]) +p_satisfied<- Satisfaction_Yes[3]/Total[3] +p_satisfied_given_faster +p_satisfied \ No newline at end of file diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.1/Ex5_1.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.1/Ex5_1.R new file mode 100644 index 00000000..9d3c0275 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.1/Ex5_1.R @@ -0,0 +1,4 @@ +#probability of 3 tagged order form +p4<- dbinom(3, size=4,prob=0.1) #function dbinom() used + +p4 diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.2/Ex5_2.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.2/Ex5_2.R new file mode 100644 index 00000000..d714ce49 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.2/Ex5_2.R @@ -0,0 +1,9 @@ +#probability of 4 tagged order form +p4<- dbinom(4, size=4,prob=0.1) #function dbinom() used + +#probability of 3 tagged order form +p3<-dbinom(3, size=4,prob=0.1) +#probability of atleast three tagged order +p<- p3+p4 + +p diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.3/Ex5_3.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.3/Ex5_3.R new file mode 100644 index 00000000..2acd6626 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.3/Ex5_3.R @@ -0,0 +1,14 @@ +#probability of less than 3 tagged order form is: +#p3= p0+ p1+ p2 + + +#probability of 0 tagged order form +p0<-dbinom(0, size=4,prob=0.1) #function dbinom() used +#probability of 1 tagged order form +p1<-dbinom(1, size=4,prob=0.1) +#probability of 2 tagged order form +p2<-dbinom(2, size=4,prob=0.1) +#probability of less than three tagged order +p3<- p0+p1+p2 + +p3 diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.4.a/Ex5_4_a.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.4.a/Ex5_4_a.R new file mode 100644 index 00000000..d62fdc47 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.4.a/Ex5_4_a.R @@ -0,0 +1,12 @@ +#computing Binomial probablities +p3<- dbinom(3,size=3,prob=0.868) +p3 +p0<- dbinom(0,size=3,prob=0.868) +p0 +p2<- dbinom(2,size=3,prob=0.868) +p2 +#probablity of atleast two tagged form is +# p(X>=2) = P(X=2) + P(X=3) +p_atleast_2 <- p2+p3 +round(p_atleast_2,digits=4) + diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.4.b/Ex5_4_b.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.4.b/Ex5_4_b.R new file mode 100644 index 00000000..5d7b25cc --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.4.b/Ex5_4_b.R @@ -0,0 +1,9 @@ +# Mean and standard deviation in Binomial distribution : +# mean = n * p and sd = sqrt(n*p*q) +n<-3 +p<-0.868 +q<-(1-p) +mean<-n*p +mean +sd<- sqrt(n*p*q) +round(sd,digits=4) \ No newline at end of file diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.5/Ex5_5.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.5/Ex5_5.R new file mode 100644 index 00000000..0ebe8275 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH5/EX5.5/Ex5_5.R @@ -0,0 +1,9 @@ +#function ppoise() is used to calculate Poisson Probabilities +#P(X=0 | lambda =2.5) +x<-ppois(0, lambda=2.5) +round(x,digits=4) +x +#P(X=0 | lambda=2.5) +y<-ppois(0, lambda=2.5,lower=FALSE) +round(y,digits=4) +y \ No newline at end of file diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.1/7_1.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.1/7_1.R new file mode 100644 index 00000000..b387aa37 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.1/7_1.R @@ -0,0 +1,6 @@ + +#standard error of mean= sd(x)/sqrt(n) +n<- 25 +sd<- 15 +error<- sd/sqrt(n) +error diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.2/7_2.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.2/7_2.R new file mode 100644 index 00000000..13ab038f --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.2/7_2.R @@ -0,0 +1,6 @@ +#effect of sample size on standard error of mean +sd<-15 +n<-100 +error<- sd/sqrt(n) +error +#larger sample results in less variability in the sample of means from sample to sample diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.3/7_3.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.3/7_3.R new file mode 100644 index 00000000..2f6ee19a --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.3/7_3.R @@ -0,0 +1,9 @@ +#Effect of sample size n, on the clustering of Means is the sampling Distribution +# Z formula for sample means : z = (sample_mean - average)/(standard_dev/sqrt(sample_size)) +sample_mean<- 365 +avg<- 368 +standard_dev<-15 +sample_size<- 100 +standard_error_mean<- standard_dev/sqrt(sample_size) +z<- (sample_mean - avg)/standard_error_mean +z diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.4/7_4.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.4/7_4.R new file mode 100644 index 00000000..90072d0c --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH7/EX7.4/7_4.R @@ -0,0 +1,8 @@ +# X for sampling distribution of the mean -> X= sample_average + Z * (Standard_dev/sqrt(sample_size)) +sample_avg<- 368 +standard_dev <- 15 +sample_size<- 25 +Xl <- sample_avg + (-1.96)*(standard_dev/sqrt(sample_size)) +Xl # lower value of X +Xu <- sample_avg + (1.96)*(standard_dev/sqrt(sample_size)) +Xu #upper value of X diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.1/8_1.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.1/8_1.R new file mode 100644 index 00000000..93a5f488 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.1/8_1.R @@ -0,0 +1,12 @@ +#units of all values is in inches +# sample mean +a<-10.998 +#sample size +n<-100 +#standard deviation +s<-0.02 +error<- qnorm(0.975)*s/sqrt(n) +left<- a-error +right<- a+error +left #lower limit +right #upper limit \ No newline at end of file diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.2/8_2.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.2/8_2.R new file mode 100644 index 00000000..bc4e7aae --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.2/8_2.R @@ -0,0 +1,12 @@ +#units of all values is in inches +# sample mean +a<-10.998 +#sample size +n<-100 +#standard deviation +s<-0.02 +error<- qnorm(0.995)*s/sqrt(n) +left<- a-error +right<- a+error +left #lower limit +right #upper limit \ No newline at end of file diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.3/8_3.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.3/8_3.R new file mode 100644 index 00000000..bf3f82b5 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.3/8_3.R @@ -0,0 +1,18 @@ +# Confidence Interval to Estimate population mean : Population standard devition unknown and population normally distributed +# pop_mean +/- t*(sd/sqrt(n)) , df = n-1 +a<- c(73,19,16,64,28,28,31,90,60,56,31,56,22,18,45,48,17,17,17,91,92,63,50,51,69,16,17) +sample_mean<- mean(a) +mean +sd<- sd(a) + +n = 27 +df = n-1 +t = 2.0555 + + + +time_mean_up <- sample_mean - (t*(sd/sqrt(n))) +time_mean_up + +time_mean_low <- sample_mean + (t*(sd/sqrt(n))) +time_mean_low diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.4/Ex8_4.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.4/Ex8_4.R new file mode 100644 index 00000000..7e819dc3 --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH8/EX8.4/Ex8_4.R @@ -0,0 +1,11 @@ +#confidence Interval Estimate for the Population proportion +# p +- z*sqrt((p*p-1)/n) +X<- 35 #No. of Character having the characteristic +n<- 200 #sample size +z <-1.645 #critical value fromthe standardized normal distribution +p <- X / n #sample proportion +p +Pop_prop_upper<- p + z*sqrt((p*(1-p))/n) +Pop_prop_upper +Pop_prop_lower <-p - z*sqrt((p*(1-p))/n) +Pop_prop_lower diff --git a/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH9/EX9.6/Ex9_6.R b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH9/EX9.6/Ex9_6.R new file mode 100644 index 00000000..540eb79d --- /dev/null +++ b/Business_Statistics_:_A_First_Course_by_David_M._Levine,_Kathryn_A._Szabat,_David_F._Stephan,_P._K._Vishwanathan/CH9/EX9.6/Ex9_6.R @@ -0,0 +1,12 @@ +# z test of a population proportion : +# z = sample_prop - population_prop/sqrt(population_prop*q/n) + +n = 400 +x = 378 + sample_prop = x/n +population_prop = .909 +q = 1- population_prop + +# statistic value of z : +z1 = (sample_prop - population_prop)/sqrt((population_prop*q)/n) +z1 diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.1/Ex10_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.1/Ex10_1.R new file mode 100644 index 00000000..e9698289 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.1/Ex10_1.R @@ -0,0 +1,31 @@ +# z formula for the difference in two sample means : +# z = (samp_mean_1-samp_mean_2)-(pop_mean_1-pop_mean_2)/sqrt((sd1^2/n1)+(sd2^2/n2)) + +samp_mean_1 = 3352 +samp_mean_2 = 5727 +sd1 = 1100 +sd2 = 1700 +n1 = 87 +n2 = 76 + +# Observed value of Z : +z1 = ((samp_mean_1-samp_mean_2)-(0))/sqrt((sd1^2/n1)+(sd2^2/n2)) +z1 + +# Critical value of Z : +z = qnorm(.001, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) +z + +# sample critical : +s_c = (0)-(z*sqrt((sd1^2/n1)+(sd2^2/n2))) +s_c + +# The difference in sample means would need to be at least 704.23 +# to reject the null hypothesis. + +# The actual sample difference in this problem : +s_c = samp_mean_1-samp_mean_2 +s_c # which is considerably larger than the critical value of difference + +# Thus, with the critical value method also, the null hypothesis is rejected. + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.2/10_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.2/10_2.R new file mode 100644 index 00000000..1796c9af --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.2/10_2.R @@ -0,0 +1,15 @@ +# Confidence Interval to estimate difference in two population means : +# pop_mean_1-pop_mean_2 = (samp_mean_1-samp_mean_2) +/- (z*sqrt((sd1^2/n1)+(sd2^2/n2))) + +n1 = 50 +n2 = 50 +samp_mean_1 = 21.45 +samp_mean_2 = 24.6 +sd1 = 3.46 +sd2 = 2.99 +z = 1.96 +pmean_diff_1 = (samp_mean_1-samp_mean_2) + (z*sqrt((sd1^2/n1)+(sd2^2/n2))) +pmean_diff_1 + +pmean_diff_2 = (samp_mean_1-samp_mean_2) - (z*sqrt((sd1^2/n1)+(sd2^2/n2))) +pmean_diff_2 \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.3/Ex10_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.3/Ex10_3.R new file mode 100644 index 00000000..84b0abc3 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.3/Ex10_3.R @@ -0,0 +1,20 @@ +# t formula to test the difference in means assuming sd1,sd2 are equal : +#t = (samp_mean_1-samp_mean_2)-(pop_mean_1-pop_mean_2)/(sqrt((s1^2(n1-1))+(s2^2(n2-1))/n1+n2-2))*sqrt((1/n1)+(1/n2)) + +n1 = 46 +n2 = 26 +samp_mean_1 = 5.42 +samp_mean_2 = 5.04 +s1 = .58 +s2 = .49 +df = n1+n2-2 + +# Critical t value : +qt(.005, df, lower.tail = FALSE, log.p = FALSE) + +# Observed t value : +t = ((samp_mean_1-samp_mean_2)-0)/(sqrt(((s1^2*(n1-1))+(s2^2*(n2-1)))/(n1+n2-2))*sqrt((1/n1)+(1/n2))) +t + +# Because the observed value of is greater than the critical table value of the decision is to reject +# the null hypothesis \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.4/Ex10_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.4/Ex10_4.R new file mode 100644 index 00000000..2dc082f7 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.4/Ex10_4.R @@ -0,0 +1,25 @@ +# CONFIDENCE INTERVAL TO ESTIMATE difference in means ASSUMING THE POPULATION VARIANCES ARE UNKNOWN AND EQUAL : +n1 = 13 +n2 = 15 +samp_mean_1 = 4.35 +samp_mean_2 = 6.84 +s1 = 1.20 +s2 = 1.42 + +alpha = .025 +df = 26 + +t = qt(alpha, df, lower.tail = FALSE, log.p = FALSE) +t + +# p_m_diff = pop_mean_1-pop_mean_2 +s_diff = samp_mean_1-samp_mean_2 +b = sqrt(((s1^2*(n1-1))+(s2^2*(n2-1)))/(n1+n2-2)) +c = sqrt((1/n1)+(1/n2)) + + +p_m_diff_1 = s_diff - (t*b*c) +p_m_diff_1 + +p_m_diff_2 = s_diff + (t*b*c) +p_m_diff_2 \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.5/10_5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.5/10_5.R new file mode 100644 index 00000000..783bbc72 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.5/10_5.R @@ -0,0 +1,35 @@ +# t formula to test the Difference in Two Dependent Population : +# t = (mean_samp_diff - D )/(sd/sqrt(n)) +# df = n-1 +# D = mean_pop_diff, sd = sd_samp_diff, n = num_of_pairs, d= samp_diff_pair + + +Individual <- c(1,2,3,4,5,6,7) +Before <- c(32,11,21,17,30,38,14) +After <- c(39,15,35,13,41,39,22) +n = 7 + +for(i in 1:7){ + d = Before - After +} +print(d) +Individual <- cbind(Individual,Before,After,d) +Individual + +mean_samp_diff = sum(d)/n +mean_samp_diff +d1 = sum(d)/7 + +sd = sqrt((sum((d-mean_samp_diff)^2))/(n-1)) +sd + +D = 0 +t = (mean_samp_diff - D )/(sd/sqrt(n)) +t + +# Because the observed value of -2.54 is less than the critical, table value of -1.943 and the +# p-value (0.022) is less than alpha (.05), the decision is to reject the null hypothesis. + + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.6/10_6.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.6/10_6.R new file mode 100644 index 00000000..2da9a8ba --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.6/10_6.R @@ -0,0 +1,22 @@ +# Z formula to test the difference in Population Proportion : +# z = ((p1_c - p2_c)-(p1-p2)) / sqrt((p_c*q_c)*((1/n1)+(1/n2))) +# p_c =((n1*p1_c)+(n2*p2_c))/(n1+n2) +# q_c = 1 - p_c + +n1 = 100 +n2 = 95 +p1_c = .24 +p2_c = .41 + +p_c =((n1*p1_c)+(n2*p2_c))/(n1+n2) +p_c +q_c = 1 - p_c +q_c +# p1 - p2 = 0 + +z = ( (p1_c - p2_c) - (0) ) / sqrt( (p_c*q_c) * ( (1/n1) + (1/n2) ) ) +z + +# If a one-tailed test had been used,zc would have been z.01 = 2.33, +# and the null hypothesis would have been rejected. If alpha had been .05, +# zc would have been z. 025 = , and the null hypothesis would have been rejected. \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.7/Ex10_7.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.7/Ex10_7.R new file mode 100644 index 00000000..caa2ee01 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH10/EX10.7/Ex10_7.R @@ -0,0 +1,19 @@ +# F test for two Population Variance : +# F = s1^2/s2^2 +# df_num = v1 = n1-1 and df_deno = v2 = n2-1 + +# from given table we computed : +s1_sq = 5961428.6 +s2_sq = 737142.9 +n1 = 7 +n2 = 8 + +# critical F-value : +qf(.01, df1=n1-1, df2=n2-1, lower.tail = FALSE, log.p = FALSE) + +# Obseved F- value : +F = s1_sq/s2_sq +F + +# Because the observed value of F = 8.09 is greater than the table +# critical F value of 7.19, the decision is to reject the null hypothesis. diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.1/Ex11_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.1/Ex11_1.R new file mode 100644 index 00000000..7ed5de2a --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.1/Ex11_1.R @@ -0,0 +1,23 @@ +# One Way ANOVA SSE, SSc, SST values : +# SSC = sum(nj*(xj_b-x_b)^2) +# SSE = sum(sum((xij-xj_b)^2)) +# SST = sum(sum((xij-x_b)^2)) + +a <- c(29,27,30,27,28) +b <- c(32,33,31,34,30) +c <- c(25,24,24,25,26) +df <- data.frame(a,b,c) +df + +r = c(t(as.matrix(df))) # response data +r +f = c("a", "b", "c") # treatment levels +k = 3 # number of treatment levels +n = 5 + +tm = gl(k, 1, n*k, factor(f)) # matching treatments +tm + +av = aov(r ~ tm) +av +summary(av) diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.2/Ex11_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.2/Ex11_2.R new file mode 100644 index 00000000..b1e45f1b --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.2/Ex11_2.R @@ -0,0 +1,34 @@ +# TUKEYs HSD Test : HSD = q*sqrt(MSE/n) # q = critical value + +a <- c(2.46,2.41,2.43,2.47,2.46) +b <- c(2.38,2.34,2.31,2.40,2.32) +c <- c(2.51,2.48,2.46,2.49,2.44) +d <- c(2.49,2.47,2.48,2.46,2.44) +e <- c(2.56,2.57,2.53,2.55,2.55) +df <- data.frame(a,b,c,d,e) +df + + +r = c(t(as.matrix(df))) # response data +r +f = c("a", "b", "c","d","e") # treatment levels +k = 5 # number of treatment levels +n = 5 + +tm = gl(k, 1, n*k, factor(f)) # matching treatments +tm + +av = aov(r ~ tm) +av +b <- summary(av) +b + +# From above anova analysis we get MSE value : +MSE = 0.000618 +q = 5.29 +n = 5 +HSD = q*sqrt(MSE/n) +HSD + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.3/Ex11_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.3/Ex11_3.R new file mode 100644 index 00000000..2dde0b7d --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.3/Ex11_3.R @@ -0,0 +1,34 @@ +# Formula for computing Randomized Block Design for SSE, SSC, SSR, SST +# SSC = n*sum((xj_b-x_b)^2) +# SSR = C*sum((xi_b-x_b)^2) +# SSE = sum(sum((xij-xj_b-xi_b+x_b)^2)) +# SST = sum(sum((xij-x_b)^2)) + +a <- c(3.47,3.43,3.44,3.46,3.46,3.44) +b <- c(3.40,3.41,3.41,3.45,3.40,3.43) +c <- c(3.38,3.42,3.43,3.40,3.39,3.42) +d <- c(3.32,3.35,3.36,3.30,3.39,3.39) +e <- c(3.50,3.44,3.45,3.45,3.48,3.49) +df <- data.frame(a,b,c,d,e) +df + + +r = c(t(as.matrix(df))) # response data +r +f = c("a", "b", "c","d","e") # treatment levels +k = 5 # number of treatment levels +n = 6 + +blk = gl(n, k, k*n) # blocking factor +blk + +tm = gl(k, 1, n*k, factor(f)) # matching treatments +tm + +av = aov(r ~ tm + blk) +av +b <- summary(av) +b + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.4/Ex11_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.4/Ex11_4.R new file mode 100644 index 00000000..faeb7279 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH11/EX11.4/Ex11_4.R @@ -0,0 +1,38 @@ +# Two-Way ANOVA : + +Types_of_warehouses <- c("GM","GM","GM","GM","GM","GM","GM","GM","GM", + "Com","Com","Com","Com","Com","Com","Com","Com","Com", + "BS","BS","BS","BS","BS","BS","BS","BS","BS", + " CS"," CS"," CS"," CS"," CS"," CS"," CS"," CS"," CS") + + +Training_sessions <- c("A","A","A","B","B","B","C","C","C","A","A","A", + "B","B","B","C","C","C","A","A","A","B","B","B", + "C","C","C","A","A","A","B","B","B","C","C","C") + +Values <- c(3,4.5,4,2,2.5,2,2.5, 1,1.5,5,4.5,4,1,3,2.5,0,1.5,2,2.5,3,3.5,1,3, 1.5, + 3.5,3.5, 4,2,2,3,5, 4.5,2.5,4, 4.5, 5) + +df <- data.frame(Types_of_warehouses,Training_sessions,Values) +df + +av <- aov(Values~as.factor(Types_of_warehouses)*as.factor(Training_sessions),data= df) +av +summary(av) + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.1/Ex12_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.1/Ex12_1.R new file mode 100644 index 00000000..29e819ee --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.1/Ex12_1.R @@ -0,0 +1,17 @@ +# Slope of Regression line : + +no_of_beds <- c(23,29,29,35,42,46,50,54,64,66,76,78) +FTEs <- c(69,95,102,118,126,125,138,178,156,184,176,225) +Hospitals<-data.frame(no_of_beds,FTEs) +Hospitals + +# least squares equation of the regression line is : +lm( FTEs ~ no_of_beds, data=Hospitals) + +# y_c = 30.91 + 2.23 * x + + + + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.2/12_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.2/12_2.R new file mode 100644 index 00000000..4fa010bb --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.2/12_2.R @@ -0,0 +1,39 @@ +# Residual Analysis : + +Hospitals <- c(1,2,3,4,5,6,7,8,9,10,11,12) +x <- c(23,29,29,35,42,46,50,54,64,66,76,78) +y <- c(69,95,102,118,126,125,138,178,156,184,176,225) +for(i in 1:12){ + x_sq <- x*x +} +print(x_sq) + +for(i in 1:12){ + xy <- x*y +} +print(xy) + +x1 <- cbind(x,y,x_sq,xy) + +n = 12 + +b1 = ((sum(x*y))-((sum(x)*sum(y))/n))/((sum(x^2))-(sum(x)^2/n)) +b1 + +b0 = (sum(y)/n)-b1*(sum(x)/n) +b0 + +# y_c = 30.91 + 2.23 * x +y_c = b0 + b1*x +y_c +x1 <- cbind(x1,y_c) + +Residual <- y-y_c +Residual + +x1 <- cbind(x1,Residual) +View(x1) + +sum(Residual) + +hist(Residual) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.3/12_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.3/12_3.R new file mode 100644 index 00000000..e650388c --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.3/12_3.R @@ -0,0 +1,49 @@ +# Standard Error of Estimation : Se = sqrt(SSE/(n-2)) +# SSE = sum((y-y_c)^2) + +Hospitals <- c(1,2,3,4,5,6,7,8,9,10,11,12) +x <- c(23,29,29,35,42,46,50,54,64,66,76,78) +y <- c(69,95,102,118,126,125,138,178,156,184,176,225) +for(i in 1:12){ + x_sq <- x*x +} +print(x_sq) + +for(i in 1:12){ + xy <- x*y +} +print(xy) + +x1 <- cbind(x,y,x_sq,xy) + +n = 12 + +b1 = ((sum(x*y))-((sum(x)*sum(y))/n))/((sum(x^2))-(sum(x)^2/n)) +b1 + +b0 = (sum(y)/n)-b1*(sum(x)/n) +b0 + +# y_c = 30.91 + 2.23 * x +y_c = b0 + b1*x +y_c +x1 <- cbind(x1,y_c) + +Residual <- y-y_c +Residual + +x1 <- cbind(x1,Residual) + +for(i in 1:12){ + Residual_sq = Residual^2 +} +print(Residual_sq) + +x1 <- cbind(x1,Residual_sq) +View(x1) + +SSE = sum(Residual_sq) +SSE + +Se = sqrt(SSE/(n-2)) +Se \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.4/12_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.4/12_4.R new file mode 100644 index 00000000..6efc7773 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.4/12_4.R @@ -0,0 +1,55 @@ +# Coeficient of Determination : r_sq = 1 - (SSE/SS_yy) +# SS_yy = sum(y_sq)-(sum(y)^2/n) + +Hospitals <- c(1,2,3,4,5,6,7,8,9,10,11,12) +x <- c(23,29,29,35,42,46,50,54,64,66,76,78) +y <- c(69,95,102,118,126,125,138,178,156,184,176,225) +for(i in 1:12){ + x_sq <- x*x +} +print(x_sq) + +for(i in 1:12){ + xy <- x*y +} +print(xy) + +x1 <- cbind(x,y,x_sq,xy) + +n = 12 + +b1 = ((sum(x*y))-((sum(x)*sum(y))/n))/((sum(x^2))-(sum(x)^2/n)) +b1 + +b0 = (sum(y)/n)-b1*(sum(x)/n) +b0 + +# y_c = 30.91 + 2.23 * x +y_c = b0 + b1*x +y_c +x1 <- cbind(x1,y_c) + +Residual <- y-y_c +Residual + +x1 <- cbind(x1,Residual) + +for(i in 1:12){ + Residual_sq = Residual^2 +} +print(Residual_sq) + +x1 <- cbind(x1,Residual_sq) +View(x1) + +SSE = sum(Residual_sq) +SSE + +SS_yy = sum(y^2)-(sum(y)^2/n) +SS_yy + +r_sq = 1-(SSE/SS_yy) +r_sq + +# 0r r_sq = (b1^2 * SS_xx)/SS_yy + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.5/Ex12_5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.5/Ex12_5.R new file mode 100644 index 00000000..8ff207b9 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.5/Ex12_5.R @@ -0,0 +1,22 @@ +# t test for slope : + +no_of_beds <- c(23,29,29,35,42,46,50,54,64,66,76,78) +FTEs <- c(69,95,102,118,126,125,138,178,156,184,176,225) +Hospitals<-data.frame(no_of_beds,FTEs) +Hospitals + +# critical t value : +qchisq(.01,df = 10) + +# least squares equation of the regression line is : +a <- lm( FTEs ~ no_of_beds, data=Hospitals) +a # y_c = 30.91 + 2.23 * x +b <- summary(a) +b + +# observed t value : +b$coefficients[6] + + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.6/Ex12_6.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.6/Ex12_6.R new file mode 100644 index 00000000..bb65b59f --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.6/Ex12_6.R @@ -0,0 +1,19 @@ +# CONFIDENCE INTERVAL TO ESTIMATE E (yx) FOR A GIVEN VALUE OF x : +# y_c +/- t*Se*sqrt((1/n)+((x0-x_b)^2)/SS_xx) +# SS_xx = sum(x^2)-(sum(x)^2/n) + +no_of_beds <- c(23,29,29,35,42,46,50,54,64,66,76,78) +FTEs <- c(69,95,102,118,126,125,138,178,156,184,176,225) +Hospitals<-data.frame(no_of_beds,FTEs) +Hospitals + +a <- lm( FTEs ~ no_of_beds, data=Hospitals) +a + +data = data.frame(no_of_beds=40) +data + +predict(a, data, interval="confidence") + +predict(a, data, interval="predict") + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.7/Ex12_7.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.7/Ex12_7.R new file mode 100644 index 00000000..f1b10f56 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH12/EX12.7/Ex12_7.R @@ -0,0 +1,20 @@ +# Regression Analysis Example : + +Month <- c("January","Feburary","March","April","May","June","July","August") +Sales <- c(32569,32274,32583,32304,32149,32077,31989,31977) +Month_number <- c(1,2,3,4,5,6,7,8) +df <- data.frame(Month,Sales,Month_number) +df + +library("ggplot2") +ggplot(df, aes(x=Month, y=Sales)) + geom_point(size=1) + +# Regression Analysis: Sales versus Month +a <- lm(Sales~Month_number, data= df) +a +summary(a) + +# y_cap = 32,628.2 - 86.21*x : +x =10 +y_cap = 32628.2 - 86.21*x +y_cap \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH13/EX13.1/Ex13_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH13/EX13.1/Ex13_1.R new file mode 100644 index 00000000..563b19fe --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH13/EX13.1/Ex13_1.R @@ -0,0 +1,22 @@ +# Multiple Regression Model: + +Year <- c(1980,1982,1984,1986,1988,1990,1992,1994,1996,1998,2000,2002,2004,2006,2008) +Prime_Interest_rate <- c(15.26,14.85,12.04,8.33,9.32,10.01,6.25,7.15,8.27,8.35,9.23,4.67,4.34,7.96,5.09) +Unemp_rate <- c(7.1,9.7,7.5,7.0,5.5,5.6,7.5,6.1,5.4,4.5,4.0,5.8,5.5,4.6,5.8) +Personal_saving <- c(10.0,11.2,10.8,8.2,7.3,7.0,7.7,4.8,4.0,4.3,2.3,2.4,2.1,0.7,1.8) +df <- data.frame(Year,Prime_Interest_rate,Unemp_rate,Personal_saving) +df + +a <-lm(Prime_Interest_rate ~ Unemp_rate+Personal_saving,data=df) +a +summary(a) +anova(a) + +# y_cap = 7.4904 - 0.6725x1 + 0.9500x2 +# If the unemployment rate is 6.5 and the personal saving rate is 5.0, +# the predicted prime interest rate is 7.869%: +x1 = 6.5 +x2 = 5.0 +y_cap = 7.4904 - (0.6725)*(x1) + (0.9500)*(x2) +y_cap + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH13/EX13.2/Ex13_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH13/EX13.2/Ex13_2.R new file mode 100644 index 00000000..e87b711c --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH13/EX13.2/Ex13_2.R @@ -0,0 +1,19 @@ +# Multiple Regression Model: + +Year <- c(1980,1982,1984,1986,1988,1990,1992,1994,1996,1998,2000,2002,2004,2006,2008) +Prime_Interest_rate <- c(15.26,14.85,12.04,8.33,9.32,10.01,6.25,7.15,8.27,8.35,9.23,4.67,4.34,7.96,5.09) +Unemp_rate <- c(7.1,9.7,7.5,7.0,5.5,5.6,7.5,6.1,5.4,4.5,4.0,5.8,5.5,4.6,5.8) +Personal_saving <- c(10.0,11.2,10.8,8.2,7.3,7.0,7.7,4.8,4.0,4.3,2.3,2.4,2.1,0.7,1.8) +df <- data.frame(Year,Prime_Interest_rate,Unemp_rate,Personal_saving) +View(df) + +a <-lm(Prime_Interest_rate ~ Unemp_rate+Personal_saving,data=df) +a +s <-summary(a) +s +anova(a) + +pred <- predict(a) +resd <- s$residuals +data <- data.frame(pred,resd) +View(data) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH14/EX14.1/Ex14_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH14/EX14.1/Ex14_1.R new file mode 100644 index 00000000..0efc189f --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH14/EX14.1/Ex14_1.R @@ -0,0 +1,27 @@ +# Model Transformation : y = B0*x_B1 + E + +y_cost <- c(1.2,9.0,4.5,3.2,13.0,0.6,1.8,2.7) +x_weight <- c(450,20200,9060,3500,75600,175,800,2100) +y_cost <- data.frame(y_cost,x_weight) +y_cost + +# logy = log_B0 + B1*logx + E +log_xy <- log10(y_cost) +log_xy + +a <-lm(y_cost~x_weight,data=log_xy) +a +b <-summary(a) +b + +b0 <- b$coefficients[1] +b0 +b1 <- b$coefficients[2] +b1 + +logy_c = b0 + b1 * (sum(log_xy$x_weight)/8) +logy_c + +# antilog = 2.9644 +# y = (.055857)*x^.49606 + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.1.a/15_1_a.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.1.a/15_1_a.R new file mode 100644 index 00000000..63b49a04 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.1.a/15_1_a.R @@ -0,0 +1,34 @@ +# Moving average : + +Month <- c("January","February","March","April","May","June","July","August","September","October","November","December") +Shipments <- c(1056,1345,1381,1191,1259,1361,1110,1334,1416,1282,1341,1382) +Month <- cbind(Month,Shipments) +Month + +# The ???rst moving average is +first_four_Month_Moving_Average = sum(Shipments[1],Shipments[2],Shipments[3],Shipments[4])/4 +first_four_Month_Moving_Average +Second_four_Month_Moving_Average = sum(Shipments[5],Shipments[2],Shipments[3],Shipments[4])/4 +Second_four_Month_Moving_Average +Third_four_Month_Moving_Average = sum(Shipments[5],Shipments[6],Shipments[3],Shipments[4])/4 +Third_four_Month_Moving_Average +fourth_four_Month_Moving_Average = sum(Shipments[5],Shipments[6],Shipments[7],Shipments[4])/4 +fourth_four_Month_Moving_Average +fifth_four_Month_Moving_Average = sum(Shipments[5],Shipments[6],Shipments[7],Shipments[8])/4 +fifth_four_Month_Moving_Average +sixth_four_Month_Moving_Average = sum(Shipments[9],Shipments[6],Shipments[7],Shipments[8])/4 +sixth_four_Month_Moving_Average +seventh_four_Month_Moving_Average = sum(Shipments[9],Shipments[10],Shipments[7],Shipments[8])/4 +seventh_four_Month_Moving_Average +eight_four_Month_Moving_Average = sum(Shipments[9],Shipments[10],Shipments[11],Shipments[8])/4 +eight_four_Month_Moving_Average + +a = " " +b= " " +c = " " +d = " " +Average = rbind(a,b,c,d,first_four_Month_Moving_Average,Second_four_Month_Moving_Average,Third_four_Month_Moving_Average, + fourth_four_Month_Moving_Average,fifth_four_Month_Moving_Average,sixth_four_Month_Moving_Average, + seventh_four_Month_Moving_Average,eight_four_Month_Moving_Average) +Average + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.1.b/15_1_b.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.1.b/15_1_b.R new file mode 100644 index 00000000..8b8842f8 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.1.b/15_1_b.R @@ -0,0 +1,51 @@ +# Error in Moving Average : +# Moving average : + +Month <- c("January","February","March","April","May","June","July","August","September","October","November","December") +Shipments <- c(1056,1345,1381,1191,1259,1361,1110,1334,1416,1282,1341,1382) +Month <- cbind(Month,Shipments) +Month + +# The ???rst moving average is +first_four_Month_Moving_Average = sum(Shipments[1],Shipments[2],Shipments[3],Shipments[4])/4 +first_four_Month_Moving_Average +Second_four_Month_Moving_Average = sum(Shipments[5],Shipments[2],Shipments[3],Shipments[4])/4 +Second_four_Month_Moving_Average +Third_four_Month_Moving_Average = sum(Shipments[5],Shipments[6],Shipments[3],Shipments[4])/4 +Third_four_Month_Moving_Average +fourth_four_Month_Moving_Average = sum(Shipments[5],Shipments[6],Shipments[7],Shipments[4])/4 +fourth_four_Month_Moving_Average +fifth_four_Month_Moving_Average = sum(Shipments[5],Shipments[6],Shipments[7],Shipments[8])/4 +fifth_four_Month_Moving_Average +sixth_four_Month_Moving_Average = sum(Shipments[9],Shipments[6],Shipments[7],Shipments[8])/4 +sixth_four_Month_Moving_Average +seventh_four_Month_Moving_Average = sum(Shipments[9],Shipments[10],Shipments[7],Shipments[8])/4 +seventh_four_Month_Moving_Average +eight_four_Month_Moving_Average = sum(Shipments[9],Shipments[10],Shipments[11],Shipments[8])/4 +eight_four_Month_Moving_Average + +a = " " +b= " " +c = " " +d = " " +Average = rbind(a,b,c,d,first_four_Month_Moving_Average,Second_four_Month_Moving_Average,Third_four_Month_Moving_Average, + fourth_four_Month_Moving_Average,fifth_four_Month_Moving_Average,sixth_four_Month_Moving_Average, + seventh_four_Month_Moving_Average,eight_four_Month_Moving_Average) +Average + +a = " " +b= " " +c = " " +d = " " +Error_May = Shipments[5]-first_four_Month_Moving_Average +Error_June = Shipments[6]-Second_four_Month_Moving_Average +Error_July = Shipments[7]-Third_four_Month_Moving_Average +Error_Aug = Shipments[8]-fourth_four_Month_Moving_Average +Error_sep = Shipments[9]-fifth_four_Month_Moving_Average +Error_oct = Shipments[10]-sixth_four_Month_Moving_Average +Error_nov = Shipments[11]-seventh_four_Month_Moving_Average +Error_dec = Shipments[12]-eight_four_Month_Moving_Average +Error <- rbind(a,b,c,d,Error_May,Error_June,Error_July,Error_Aug,Error_sep,Error_oct,Error_nov,Error_dec) +Error +Month <- cbind(Month,Average,Error) +View(Month) diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.2/Ex15_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.2/Ex15_2.R new file mode 100644 index 00000000..550d4304 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.2/Ex15_2.R @@ -0,0 +1,29 @@ +# Weighted MOving Average : 3*l + 3*p + 3*b_p/6 + +Month <- c("January","February","March","April","May","June","July","August","September","October","November","December") +Shipments <- c(1056,1345,1381,1191,1259,1361,1110,1334,1416,1282,1341,1382) +Month <- data.frame(Month,Shipments) +Month +weights1 <- c(4,2,1,1) + +# install.packages("stats") +library(stats) + +f_weight_may <- weighted.mean(Shipments[4:1],weights1) +f_weight_june <- weighted.mean(Shipments[5:2],weights1) +f_weight_july <- weighted.mean(Shipments[6:3],weights1) +f_weight_aug <- weighted.mean(Shipments[7:4],weights1) +f_weight_sep <- weighted.mean(Shipments[8:5],weights1) +f_weight_oct <- weighted.mean(Shipments[9:6],weights1) +f_weight_nov <- weighted.mean(Shipments[10:7],weights1) +f_weight_dec <- weighted.mean(Shipments[11:8],weights1) +f_weights <- data.frame(f_weight_may,f_weight_june,f_weight_july,f_weight_aug, + f_weight_sep,f_weight_oct,f_weight_nov,f_weight_dec) +f_weights + +Shipments[5:12] - f_weights + +# We noticed that in this problem the errors obtained by using the 4-month weighted moving average +# were greater than most of the errors obtained by using an unweighted 4-month moving average +# in Ex15_1. + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.3/Ex15_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.3/Ex15_3.R new file mode 100644 index 00000000..9dc691af --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.3/Ex15_3.R @@ -0,0 +1,46 @@ +# EXPONENTIAL SMOOTHING : +Year <- c(1:16) +Total_units <- c(1193,1014,1200,1288,1457,1354,1477,1474,1617,1641,1569, + 1603,1705,1848,1956,2068) +data <- data.frame(Year,Total_units) +data + +library(ggplot2) +ggplot(data=data, aes(x=data$Year, y=data$Total_units, group=1)) + + geom_line(linetype = "dashed")+ + geom_point() + +# using exponential smoothing function i.e. ses() : +# install.package("forecast") +library(forecast) +# Forecast and error values for alpha = 0.2 : +f_a <- ses(Total_units, h = 8, alpha = 0.2, initial = "simple")[["fitted"]] +error_a <- ses(Total_units, h = 8, alpha = 0.2, initial = "simple")[["residuals"]] + +# Forecast and error values for alpha = 0.2 : +f_b <- ses(Total_units, h = 8, alpha = 0.5, initial = "simple")[["fitted"]] +error_b <- ses(Total_units, h = 8, alpha = 0.5, initial = "simple")[["residuals"]] + +# Forecast and error values for alpha = 0.2 : +f_c <- ses(Total_units, h = 8, alpha = 0.8, initial = "simple")[["fitted"]] +error_c <- ses(Total_units, h = 8, alpha = 0.8, initial = "simple")[["residuals"]] + +f_data <- data.frame(data,f_a,error_a,f_b,error_b,f_c,error_c) +View(f_data) + +# MAD and MSE values of alpha = 0.2, 0.5, 0.8 : +MAD_a <- sum(abs(error_a))/15 +MSE_a <- sum(abs(error_a^2))/15 + +MAD_b <- sum(abs(error_b))/15 +MSE_b <- sum(abs(error_b^2))/15 + +MAD_c <- sum(abs(error_c))/15 +MSE_c <- sum(abs(error_c^2))/15 + +val <- rbind(MAD_a,MSE_a,MAD_b,MSE_b,MAD_c,MSE_c) +val + + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.4/Ex15_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.4/Ex15_4.R new file mode 100644 index 00000000..bda3dbc4 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.4/Ex15_4.R @@ -0,0 +1,16 @@ +# Regression Trend Analysis Using Quadratic Models + +Year <- c(1991:2007) +Labour_force <- c(117.72,118.49,120.26,123.06,124.90,126.71,129.56,131.46,133.49,136.89,136.93,136.49,137.74,139.25,141.73,144.43,146.05) +Year_sq <- Year^2 +Year <- data.frame(Year,Labour_force,Year_sq) +Year +a <-lm(Labour_force~Year,data=Year) +a +anova(a) +ggplot(data = Year,aes(x=Year,y=Labour_force))+geom_point()+geom_smooth(method = "lm") + +b <-lm(Labour_force~.,data=Year) +b +anova(b) +ggplot(data = Year,aes(x=Year_sq,y=Labour_force))+geom_point()+geom_smooth(method = "lm") \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.5/Ex15_5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.5/Ex15_5.R new file mode 100644 index 00000000..b3c9a45e --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH15/EX15.5/Ex15_5.R @@ -0,0 +1,52 @@ +# LASPEYRES PRICE INDEX and PAASCHE PRICE INDEX : +year <- c(2008,2009) +p.Syrings <- c(6.70,6.95) +q.Syrings <- c(150,135) +p.Cotton <- c(1.35,1.45) +q.Cotton <- c(60,65) +p.Patient <- c(5.10,6.25) +q.Patient <- c(8,12) +p.ChildrenTylenol <- c(4.50,4.95) +q.ChildrenTylenol <- c(25,30) +p.Computerpaper <- c(11.95,13.20) +q.Computerpaper <- c(6,8) +p.Thermometer <- c(7.90,9.00) +q.Thermometer <- c(4,2) + +data <- data.frame(year,p.Syrings,q.Syrings,p.Cotton,q.Cotton,p.Patient,q.Patient, + p.ChildrenTylenol,q.ChildrenTylenol,p.Computerpaper,q.Computerpaper, + p.Thermometer,q.Thermometer) +data + +# Unweighted Aggregate Index for 2009 : +p_2009 <- sum(p.Syrings[2],p.Cotton[2],p.Patient[2],p.ChildrenTylenol[2],p.Computerpaper[2], + p.Thermometer[2]) +p_2008 <- sum(p.Syrings[1],p.Cotton[1],p.Patient[1],p.ChildrenTylenol[1],p.Computerpaper[1], + p.Thermometer[1]) +I = (p_2009/p_2008)*100 +I + +# Laspeyres Price Indices +# install.packages("micEcon") +# install.packages("micEconIndex") +library(micEconIndex) +library(micEcon) +a <- priceIndex(c("p.Syrings","p.Cotton","p.Patient","p.ChildrenTylenol","p.Computerpaper", + "p.Thermometer"), c("q.Syrings","q.Cotton","q.Patient","q.ChildrenTylenol", + "q.Computerpaper","q.Thermometer"),1,data) +a +I_2009_Laspeyres <- a[2]*100 +I_2009_Laspeyres + +# Paasche Price Indices +b <- priceIndex(c("p.Syrings","p.Cotton","p.Patient","p.ChildrenTylenol","p.Computerpaper", + "p.Thermometer"), c("q.Syrings","q.Cotton","q.Patient","q.ChildrenTylenol", + "q.Computerpaper","q.Thermometer"),1,data,"Paasche") +b +I_2009_Passache <- b[2]*100 +I_2009_Passache + + + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.1/Ex16_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.1/Ex16_1.R new file mode 100644 index 00000000..0b789306 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.1/Ex16_1.R @@ -0,0 +1,25 @@ +# CHI-SQUARE GOODNESS OF-FIT TEST : X_sq = sum((fo-fe)^2/fe) +# df = k-1-c +Month <- c("January","February","March","April","May","June","July","August","September","October","November","December") +fo <- c(1610,1585,1649,1590,1540,1397,1410,1350,1495,1564,1602,1655) + +# critical value of chi-square when alpha is 0.01 : +qchisq(.99, df=11) + + +fe <- sum(fo)/12 +for(i in 1:12){ + X = (fo-fe)^2/fe +} +print(X) + +# Observed chi-square value : +X_sq = sum(X) +X_sq + +Month <- cbind(Month,fo,fe,X) +Month + +# The observed value of chi-square is 74.37, greater than the critical table value i.e. 24.725, +# so the decision is to reject the null hypothesis. This problem provides enough +# evidence to indicate that the distribution of milk sales is not uniform. diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.2/Ex16_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.2/Ex16_2.R new file mode 100644 index 00000000..0d1485cd --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.2/Ex16_2.R @@ -0,0 +1,32 @@ +# Test data is whether in Poisson distributed : + +no_of_arrival <- c(0,1,2,3,4,5) +obs_freq <- c(7,18,25,17,12,5) + +# chi square value when alpha = 0.05 : +qchisq(.95,4) + +for(i in 1:6){ + arr_obs <- no_of_arrival*obs_freq +} +print(arr_obs) + +l = sum(arr_obs)/sum(obs_freq) +l # lambda + +# Expected probability using lamba and no_of_arrival : +exp_pb <- c(.1003,.2306,.2652,.2033,.1169,.0837) + +for(i in 0:5){ + exp_freq = sum(obs_freq)*exp_pb +} +print(exp_freq) + +no_of_arrival <- cbind(no_of_arrival,obs_freq,arr_obs,exp_pb,exp_freq) +no_of_arrival + +for(i in 0:5){ + X = (obs_freq-exp_freq)^2/exp_freq +} +print(X) +sum(X) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.3/Ex16_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.3/Ex16_3.R new file mode 100644 index 00000000..e9189259 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.3/Ex16_3.R @@ -0,0 +1,20 @@ +# CHI SQUARE GOODNESS OF FIT TEST example 2 : +p <- c("Milk","non-Milk") +fo <- c(115,435) +fe <- c(93.5,456.5) + +# critical value of chi-square : +qchisq(.95, df=1) + +X_1 = (fo[1]-fe[1])^2/fe[1] +X_1 + +X_2 = (fo[2]-fe[2])^2/fe[2] +X_2 + +# Observed value of chi-square : +X_sq = X_1 + X_2 +X_sq + +# This observed chi-square, 5.95, is greater than the critical chi-square value of 3.8415. +# The decision is to reject the null hypothesis. \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.4/Ex16_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.4/Ex16_4.R new file mode 100644 index 00000000..1bf23c3e --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH16/EX16.4/Ex16_4.R @@ -0,0 +1,21 @@ +# CHI-SQUARE TEST OF INDEPENDENCE : + +Age = matrix(c(26,95,18,41,40,20,24,13,32),nrow=3,ncol=3,byrow = TRUE) +dimnames(Age) = list(c("21-34","35-55",">55"),c("Coffee_tea ", "Soft_Drink", "Other")) +Age + +# chi-square expected value when alpha =.01 : +qchisq(.99,df=4) + +# The degrees of freedom are (3 - 1)(3 - 1) = 4, and the critical value is 13.2767. +# The decision rule is to reject the null hypothesis if the observed value of chisquare +# is greater than 13.2767. + + +# chi-square observed value : +# installed.pacakges("stats") +library(stats) +chisq.test(Age) + +# The observed value of chi-square, 59.41,is greater than the critical value, 13.2767, +# so the null hypothesis is rejected. diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.1/Ex17_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.1/Ex17_1.R new file mode 100644 index 00000000..48a19ce0 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.1/Ex17_1.R @@ -0,0 +1,24 @@ +# Mann-Whitney U test : + +Total_emp_comp <- c(18.75,19.80,20.10,20.75,21.64,21.90,22.36,22.96,23.45,23.88,24.12,24.85,25.30,25.50,26.19) +Rank <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) +Group <- c("H","H","H","H","E","H","H","H","E","E","E","E","E","E","E") +Total_emp_comp <- data.frame(Total_emp_comp,Rank,Group) +Total_emp_comp + +W1 = 1+2+3+4+6+7+8 +W1 +W2 = 5+9+10+11+12+13+14+15 +W2 +U1 = (7)*(8) + ((7)*(8))/2 - W1 +U1 +U2 = (7)*(8) + ((8)*(9))/2 - W2 +U2 + +# Using Wilcox test : +wilcox.test(Total_emp_comp ~ Group, data = Total_emp_comp,exact = FALSE) + +#Because U2 is the smaller value of U, we use U=3 as the test statistic for Table A.13. +# Because it is the smallest size, let n1=7; n2=8. + +# Because the p -value is less than a = .05, the null hypothesis is rejected. \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.2/Ex17_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.2/Ex17_2.R new file mode 100644 index 00000000..6cd6ad92 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.2/Ex17_2.R @@ -0,0 +1,28 @@ +#LARGE-SAMPLE FORMULAS MANN-WHITNEY U TEST : + +Value <- c(2.25,2.70,2.75,2.97,2.97,3.10,3.15,3.29,3.50,3.60,3.61,3.65,3.68,3.89,3.95, + 4.01,4.05,4.10,4.10,4.25,4.29,4.53,4.75,4.80,4.80,4.98,5.11,5.50,5.75,6.25) +Rank <- c(1,2,3,4.5,4.5,6,7,8,9,10,11,12,13,14,15,16,17,18.5,18.5,20,21,22,23,24.5,24.5,26,27,28,29,30) +Group <- c('V','R','V','V','V','V','V','V','R','V','V','R','V','R','R', + 'V','V','R','R','R','V','V','R','R','R','R','R','R','R','R') +Value <- data.frame(Value,Rank,Group) +Value + +W1 = 1 + 3 + 4.5 + 4.5 + 6 + 7 + 8 + 10 + 11 + 13 + 16 + 17 + 21 + 22 +W1 + +U = (14)*(16) + ((14)*(15))/2 - W1 +U + +U_u = ((14)*(16))/2 +U_u + +sd_u = sqrt(((14)*(16)*(31))/12) +sd_u + +# observed value +z = (U-U_u)/sd_u +z + +# Wilcox test : +wilcox.test(Value ~ Group, data = Value,exact = FALSE) diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.3/Ex17_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.3/Ex17_3.R new file mode 100644 index 00000000..2f27ce2e --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.3/Ex17_3.R @@ -0,0 +1,40 @@ +# WILCOXON MATCHEDPAIRS SIGNED RANK TEST : + +Worker <- c(1:20) +Before <- c(5,4,9,6,3,8,7,10,3,7,2,5,4,5,8,7,9,5,4,3) +After <- c(11,9,9,8,5,7,9,9,7,9,6,10,9,7,9,6,10,8,5,6) +d <- c(-6,-5,0,-2,-2,1,-2,1,-4,-2,-4,-5,-5,-2,-1,1,-1,-3,-1,-3) +Rank <- c(-19,-17,0,-9,-9,3.5,-9,3.5,-14.5,-9,-14.5,-17,-17,-9,-3.5,3.5,-3.5,-12.5,-3.5,-12.5) +Worker <- data.frame(Worker,Before,After,d,Rank) +Worker + +# test statistic z value : +qnorm(.99,lower.tail = FALSE) + +# T positive and negative using wilcox test function : +wilcox.test(Worker$Before, Worker$After, paired=TRUE) +wilcox.test(Worker$d, Worker$Rank, paired=TRUE) + +# T positive and negative using formula : +T_p <- 3.5+3.5+3.5 +T_p +T_n <- 19 + 17 + 9 + 9 + 9 + 14.5 + 9 + 14.5 + 17 + 17 + 9 + 3.5 + 3.5 + 12.5 + 3.5 + 12.5 +T_n + +T_min = min(T_p,T_n) +T_min + +n = 19 +T_mean = (n*(n+1))/4 +T_mean + +T_sd = sqrt((n*(n+1)*(2*n+1))/24) +T_sd + +# observed z value : +z = (T_min - T_mean)/T_sd +z + +# The observed z value (-3.41) is in the rejection region, so the analyst rejects the null hypothesis. +# The productivity is signi???cantly greater after the implementation of quality control +# at this company. \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.4/Ex17_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.4/Ex17_4.R new file mode 100644 index 00000000..bf4272c4 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.4/Ex17_4.R @@ -0,0 +1,29 @@ +# KRUSKAL-WALLIS TEST : + +Group_native <- c(8,5,7,11,9,6) +Group_water <- c(10,12,11,9,13,12) +Group_fertilizer <- c(11,14,10,16,17,12) +Group_water_fertilizer <- c(18,20,16,15,14,22) +Group <-data.frame(Group_native,Group_water,Group_fertilizer,Group_water_fertilizer) +Group + +# alpha = .01, critical value : +qchisq(.99,df=3) + +native<- Group$Group_native +water<- Group$Group_water +fertilizer<- Group$Group_fertilizer +water_fertilizer<- Group$Group_water_fertilizer +x1<-c(native,water,fertilizer,water_fertilizer) +x1 +g<- factor(rep(1:4, c(6,6,6,6)), + labels = c("native", + "water", + "fertilizer", + "water_fertilizer")) +kruskal.test(x1, g) + + +# The observed K value is 16.77 and the critical is 11.3449. +# Because the observed value is greater than the table value, the null hypothesis +# is rejected. There is a signi???cant difference in the way the trees grow \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.5/Ex17_5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.5/Ex17_5.R new file mode 100644 index 00000000..c5ac472e --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.5/Ex17_5.R @@ -0,0 +1,15 @@ +# FRIEDMAN TEST : + +Brand <- matrix(c(3,5,2,4,1,1,3,2,4,5,3,4,5,2,1,2,3,1,4,5,5,4,2,1,3,1,5,3,4,2,4,1,3,2,5, + 2,3,4,5,1,2,4,5,3,1,3,5,4,2,1), + nrow=10,ncol=5,byrow = TRUE) +Brand + +# Chi-square value, alpha =0.01 : +qchisq(.99,df=4) + +# observed value : +friedman.test(Brand) + +# Because the observed value of = 3.68 is not greater than the critical value, 13.2767, +# the researchers fail to reject the null hypothesis. \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.6/Ex17_6.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.6/Ex17_6.R new file mode 100644 index 00000000..53f37a01 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH17/EX17.6/Ex17_6.R @@ -0,0 +1,26 @@ +# SPEARMAN'S RANK CORRELATION : + +Crude_oil <- c(14.60,10.50,12.30,15.10,18.35,22.60,28.90,31.40,26.75) +Gasoline <- c(3.25,3.26,3.28,3.26,3.32,3.44,3.56,3.60,3.54) +Crude_rank <- c(3,1,2,4,5,6,8,9,7) +Gasoline_rank <- c(1,2.5,4,2.5,5,6,8,9,7) +d <- c(2,-1.5,-2,1.5,0,0,0,0,0) +d_sq <- c(4,2.25,4,2.25,0,0,0,0,0) +oil <- data.frame(Crude_oil,Gasoline,Crude_rank,Gasoline_rank,d,d_sq) +oil +d_sq_sum <- sum(d_sq) +d_sq_sum + +# Using cor.test : +# install.packages("stats") +library(stats) +cor.test(oil$Crude_oil, oil$Gasoline, method = "spearman") + +# using formula : +n = 9 +r_s <- 1 - ((6*d_sq_sum)/(n*(n^2-1))) +r_s + + +# A high positive correlation is computed between the price of a barrel of +# West Texas intermediate crude and a gallon of regular unleaded gasoline. diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.a/Ex2_1a.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.a/Ex2_1a.R new file mode 100644 index 00000000..6febdf29 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.a/Ex2_1a.R @@ -0,0 +1,28 @@ +# Class midpoints. + +Interest_rate <- c(7.29,7.23,7.11,6.78,7.47,6.69,6.77,6.57,6.80,6.88,6.98,7.16, + 7.30,7.24,7.16,7.03,6.90,7.16,7.40,7.05,7.28,7.31,6.87,7.68, + 7.03,7.17,6.78,7.08,7.12,7.31,7.40,6.35,6.96,7.29,7.16,6.97, + 6.96,7.02,7.13,6.84) + +summary(Interest_rate) + +low_val<- 6.30 +high_val <-7.70 +step_val <- 0.20 +x_breaks <- seq(low_val,high_val,step_val) +x_breaks +x_mid <- seq(low_val+step_val/2,high_val-step_val/2,step_val) +x_mid +x<-cut(Interest_rate,breaks = x_breaks,right=FALSE) +x +y<-table(x) +y + +df <- data.frame(y) +df + +# Class Mid point : +df$midpoint <- x_mid +View(df) + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.b/Ex2_1b.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.b/Ex2_1b.R new file mode 100644 index 00000000..6025df96 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.b/Ex2_1b.R @@ -0,0 +1,34 @@ +# Relative Frequency. + +Interest_rate <- c(7.29,7.23,7.11,6.78,7.47,6.69,6.77,6.57,6.80,6.88,6.98,7.16, + 7.30,7.24,7.16,7.03,6.90,7.16,7.40,7.05,7.28,7.31,6.87,7.68, + 7.03,7.17,6.78,7.08,7.12,7.31,7.40,6.35,6.96,7.29,7.16,6.97, + 6.96,7.02,7.13,6.84) + +summary(Interest_rate) + +low_val<- 6.30 +high_val <-7.70 +step_val <- 0.20 +x_breaks <- seq(low_val,high_val,step_val) +x_breaks +x_mid <- seq(low_val+step_val/2,high_val-step_val/2,step_val) +x_mid +x<-cut(Interest_rate,breaks = x_breaks,right=FALSE) +x +y<-table(x) +y + +df <- data.frame(y) +df + +# Class Mid point : +df$midpoint <- x_mid +df + +# Relative Frequency : +rf <- df$Freq/sum(df$Freq) +rf +df$relative_frequency <- rf +View(df) + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.c/Ex2_1c.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.c/Ex2_1c.R new file mode 100644 index 00000000..d89a1975 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.1.c/Ex2_1c.R @@ -0,0 +1,43 @@ +# Cumulative Frequency. + +Interest_rate <- c(7.29,7.23,7.11,6.78,7.47,6.69,6.77,6.57,6.80,6.88,6.98,7.16, + 7.30,7.24,7.16,7.03,6.90,7.16,7.40,7.05,7.28,7.31,6.87,7.68, + 7.03,7.17,6.78,7.08,7.12,7.31,7.40,6.35,6.96,7.29,7.16,6.97, + 6.96,7.02,7.13,6.84) + +summary(Interest_rate) + +low_val<- 6.30 +high_val <-7.70 +step_val <- 0.20 +x_breaks <- seq(low_val,high_val,step_val) +x_breaks +x_mid <- seq(low_val+step_val/2,high_val-step_val/2,step_val) +x_mid +x<-cut(Interest_rate,breaks = x_breaks,right=FALSE) +x +y<-table(x) +y + +df <- data.frame(y) +df + +# Class Mid point : +df$midpoint <- x_mid +df + +# Relative Frequency : +rf <- df$Freq/sum(df$Freq) +rf +df$relative_frequency <- rf +View(df) + +# Cumulative Frequency : +c<-cumsum(df$Freq) +df$cumulative_frequency <- c +n <- sum(df$Freq) +crf <- c/n +df$cumul <- crf +df$pie <- round(360*rf,1) +View(df) + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.2/2_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.2/2_2.R new file mode 100644 index 00000000..cb3d0c51 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.2/2_2.R @@ -0,0 +1,8 @@ +# Steam-and-leaf plot + +costs <- c(3.67,2.75,9.15,5.11,3.32,2.09,1.83,10.94,1.93,3.89, + 7.20,2.78,6.72,7.80,5.47,4.15,3.55,3.53,3.34,4.95, + 5.42,8.64,4.84,4.10,5.10,6.45,4.65,1.97,2.84,3.21 ) + + +stem(costs, scale = 1, width = 80, atom = 1e-08) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.3.a/2_3_a.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.3.a/2_3_a.R new file mode 100644 index 00000000..ad7062b9 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.3.a/2_3_a.R @@ -0,0 +1,21 @@ +# Bar Graph : + +Inventary_shrinkage <- c("Employee theft","Shoplifting","Administartive error","Vendor fraud") + +Annual_amount <- c(17918.6, 15191.9,7617.6,2553.6) + +data <- data.frame(Inventary_shrinkage,Annual_amount) + +Proportion <- data$Annual_amount/sum(data$Annual_amount) + +Percent <- Proportion*100 + +data <- cbind(data,Proportion,Percent) + +Degree <- data$Proportion*360 + +data<-cbind(data,Degree) + +library(ggplot2) + +ggplot(data,aes(x=data$Inventary_shrinkage,y=data$Annual_amount))+geom_bar(stat = "identity") diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.3.b/2_3_b.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.3.b/2_3_b.R new file mode 100644 index 00000000..30edf845 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.3.b/2_3_b.R @@ -0,0 +1,24 @@ +# Pie Chart : + +Inventary_shrinkage <- c("Employee theft","Shoplifting","Administartive error","Vendor fraud") + +Annual_amount <- c(17918.6, 15191.9,7617.6,2553.6) + +data <- data.frame(Inventary_shrinkage,Annual_amount) + +Proportion <- data$Annual_amount/sum(data$Annual_amount) + +Percent <- Proportion*100 + +data <- cbind(data,Proportion,Percent) + +Degree <- data$Proportion*360 + +data<-cbind(data,Degree) + +labls <- paste(data$Inventary_shrinkage,data$Percent,sep = " ") + +labls <- paste(labls,"%",sep="") + +pie(data$Percent, labels = labls) + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.4/2_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.4/2_4.R new file mode 100644 index 00000000..0f1093fd --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH2/EX2.4/2_4.R @@ -0,0 +1,15 @@ +# Scatter Plot : +Residential <- c(169635,155113,149410,175822,162706,134605,195028,231396,234955, + 266481,267063,263385,252745,228943,197526,232134,249757,274956, + 251937,281229,280748,297886,315757) + +Non_residential <- c(96497,115372,96407,129275,140569,145054,131289,155261,178925, + 163740,160363,164191,169173,167896,135389,120921,122222,127593, + 139711,153866,166754,177639,175048) + +home <- cbind(Residential,Non_residential) +View(home) + +# Scatter plot : +plot(Residential, Non_residential,xlab="Residential",ylab="Non-Residential") + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.a/3_1_a.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.a/3_1_a.R new file mode 100644 index 00000000..530df038 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.a/3_1_a.R @@ -0,0 +1,19 @@ +# Mode Example : + +getmode <- function(v) { + uniqv <- unique(v) + uniqv[which.max(tabulate(match(v, uniqv)))] +} + +Company <- c("Enterprise","Hertz","Natioanl/Alamo","Avis", "Dollar", "Budget","Advantage", + "U-save","Payless","ACE","Fox","Rent-A-Wreck","Traingle") + +Number_of_Cars_in_Service <- c(643000,327000,233000,204000,167000,144000,20000,12000,10000, + 9000,9000,7000,6000) + +data1 <- data.frame(Company,Number_of_Cars_in_Service) + +sort_data <- data1[order(-Number_of_Cars_in_Service),] + +result <- getmode(sort_data$Number_of_Cars_in_Service) +print(result) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.b/Ex3_1b.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.b/Ex3_1b.R new file mode 100644 index 00000000..8fe2be3a --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.b/Ex3_1b.R @@ -0,0 +1,13 @@ +# Median : + +Company <- c("Enterprise","Hertz","Natioanl/Alamo","Avis", "Dollar", "Budget","Advantage", + "U-save","Payless","ACE","Fox","Rent-A-Wreck","Traingle") + +Number_of_Cars_in_Service <- c(643000,327000,233000,204000,167000,144000,20000,12000,10000, + 9000,9000,7000,6000) + +data1 <- data.frame(Company,Number_of_Cars_in_Service) + +sort_data <- data1[order(-Number_of_Cars_in_Service),] + +median(sort_data$Number_of_Cars_in_Service) diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.c/Ex3_1c.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.c/Ex3_1c.R new file mode 100644 index 00000000..017bbd96 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.1.c/Ex3_1c.R @@ -0,0 +1,13 @@ +# Mean Example : + +Company <- c("Enterprise","Hertz","Natioanl/Alamo","Avis", "Dollar", "Budget","Advantage", + "U-save","Payless","ACE","Fox","Rent-A-Wreck","Traingle") + +Number_of_Cars_in_Service <- c(643000,327000,233000,204000,167000,144000,20000,12000,10000, + 9000,9000,7000,6000) + +data1 <- data.frame(Company,Number_of_Cars_in_Service) + +sort_data <- data1[order(-Number_of_Cars_in_Service),] + +mean(sort_data$Number_of_Cars_in_Service) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.2/Ex3_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.2/Ex3_2.R new file mode 100644 index 00000000..5f0f2700 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.2/Ex3_2.R @@ -0,0 +1,10 @@ +# Determine the 30th percentile of the following eight numbers : +data3 <- c(5,12,13,14,17,19,23,28) +N = 8 +P = 30 + +# 30th percentile value is : +a <- quantile(data3,c(.30)) +cat("30th percentile value is : ",a) + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.3/Ex3_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.3/Ex3_3.R new file mode 100644 index 00000000..8ccb1f86 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.3/Ex3_3.R @@ -0,0 +1,31 @@ +# Quartiles : + +Category <- c("Automotive","Personal Care","Entertainment & Media", + "Food","Drugs", "Electronics","Soft Drinks","Retail","Cleaners", + "Restaurants","Computers","Telephone","Financial", + "Beer Wine & Liquor","Candy","Toys") + +Ad_spending <- c(22195,19526,9538,7793,7707,4023,3916,3576,3571,3553,3247,2488, + 2433,2050,1137,699) + +advertise_age <- cbind(Category,Ad_spending) +View(advertise_age) + +N=16 + +# Q1 = P25 is found by : +i = 25/100*N +i + +#Q3 = P75 is solved by : +i1 =75/100*(N) +i1 + +# Quantile : +quantile(Ad_spending) + + + + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.5/3_5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.5/3_5.R new file mode 100644 index 00000000..0ccc4699 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.5/3_5.R @@ -0,0 +1,32 @@ +# Chebyshev's Theorem : + +avg_age = 28 +sd = 6 + +# Chebyshev's theorem states that at least (1 - 1)/k^2 proportion of the values are within +#(mean+k*sd). Because 80% of the values are within this range, let + +#1- (1/k^2) = .80 + +k = sqrt(1/(1-0.80)) +k + +# now for : +mean = 28 +sd = 6 + +# values are within +r1 = mean + k * sd +r1 #41.41 +r2 = mean - k * sd +r2 # 14.58 + +# Years of age or between 14.6 and 41.4 years old. + + + + + + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.6.a/3_6_a.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.6.a/3_6_a.R new file mode 100644 index 00000000..f407f8af --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.6.a/3_6_a.R @@ -0,0 +1,15 @@ +# Mean absolute deviation : + +x<- c(55,100,125,140,60) +n = 5 + +# a = abs(x - x_bar), where x_bar = sum(x)/n +a <- c(41,4,29,44,36) + +x <- cbind(x,a) +View(x) + +# MAD : +mean_dev <- sum(a)/n +mean_dev + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.6.b/Ex3_6b.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.6.b/Ex3_6b.R new file mode 100644 index 00000000..e9cd7405 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.6.b/Ex3_6b.R @@ -0,0 +1,20 @@ +# Variance and stanadard deviation : + +x<- c(55,100,125,140,60) +n = 5 + +# a = abs(x - x_bar), where x_bar = sum(x)/n +a <- c(41,4,29,44,36) + +# b = (x - x_bar)^2 +b <- c(1681,16,841,1936,1296) + +y <- cbind(x,a,b) +View(y) + +# Variance : +var(x) + +# standard deviation : +sd(x) + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.7/Ex3_7.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.7/Ex3_7.R new file mode 100644 index 00000000..3139a270 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH3/EX3.7/Ex3_7.R @@ -0,0 +1,52 @@ +# Mean, Median, Mode, Variance, and Standard deviation : + +class <- c("10-under-15","15-under-20","20-under-25","25-under-30","30-under-35", + "35-under-40","40-under-45","45-under-50") +freq <- c(6,22,35,29,16,8,4,2) +class <-data.frame(class,freq) +class + +# Mean of each intervals : +a <- mean(10:15) +b<-mean(15:20) +c<-mean(20:25) +d<-mean(25:30) +e<-mean(30:35) +f<-mean(35:40) +g<-mean(40:45) +h<-mean(45:50) +Mean <- rbind(a,b,c,d,e,f,g,h) +Mean + +# fM : +for(i in 1:8) +{ + fM <- freq * Mean +} +fM + +# group mean : +Group_mean <- sum(fM)/sum(freq) +Group_mean + +# Mean - group mean : +for(i in 1:8) +{ + Mean_grpmean <- Mean - Group_mean +} +Mean_grpmean + +# Square of Mean_grpmean : +Mean_grpmean_sq <- Mean_grpmean^2 +Mean_grpmean_sq + +# freq * Mean_grpmean_sq : +freq_Mean_grpmean_sq <- freq * Mean_grpmean_sq +freq_Mean_grpmean_sq + + +var <- sum(freq_Mean_grpmean_sq)/(sum(freq)-1) +var +sd <- sqrt(var) +sd + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.1/4_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.1/4_1.R new file mode 100644 index 00000000..8bdb2488 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.1/4_1.R @@ -0,0 +1,28 @@ +# Addition Law : P(F and P) = P(F) + P(P) - P(F or P) + +Type_of_position <- c("Managerial", "Professional","Technical","Clerical") +Sex_male <- c(8,31,52,9) +Sex_female <- c(3,13,17,22) +total_r <- c(11,44,69,31) +total_c <- c(" ",100,55,55) +Compny_HR_data <- cbind(Type_of_position,Sex_male,Sex_female,total_r) +Compny_HR_data <- rbind(Compny_HR_data,total_c) +View(Compny_HR_data) + +# F denote the event of female and P denote the event of professional worker + +# Probability of event of female : +Pb_F = sum(Sex_female)/sum(sum(Sex_female),sum(Sex_male)) +Pb_F + +# Probability of event of professional worker : +Pb_P = sum(Sex_male[2],Sex_female[2])/sum(sum(Sex_female),sum(Sex_male)) +Pb_P + +# Probability of female or Professional worker : +Pb_F_P = Sex_female[2]/sum(sum(Sex_female),sum(Sex_male)) +Pb_F_P + +# probability that the employee is female or a professional worker : +Pb_F_a_P <- Pb_F + Pb_P - Pb_F_P +Pb_F_a_P diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.11/4_11.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.11/4_11.R new file mode 100644 index 00000000..248e4b8c --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.11/4_11.R @@ -0,0 +1,17 @@ +# Independent Event : P(X|Y) = P(X) and P(Y|X) = P(Y) + +T1 <- c("A", "B","C") +D <- c(8,20,6) +E <- c(12,30,9) +total_r <- c(20,50,15) +total_c <- c(" ",34,51,85) +T1 <- cbind(T1,D,E,total_r) +T1 <- rbind(T1,total_c) +View(T1) + +# Check the ???rst cell in the matrix to ???nd whether P(A|D) = P(A) +Pb_A_D <- D[1]/sum(D) # P(A|D) +Pb_A_D + +P_A <- sum(D[1],E[1])/sum(total_r) +P_A # P(A) diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.12/4_12.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.12/4_12.R new file mode 100644 index 00000000..c84cd6fa --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.12/4_12.R @@ -0,0 +1,20 @@ +# Bayes's Rule : P (Xi|Y) = P(Xi)*P(Y|Xi) / P(X1)*P(Y|X1)+P(X2)*P(Y|X2)+...+P(Xn)*P(Y|Xn) + +Event <- c("A","B","C") +Prior <- c(.60,.30,.10) # P(Ei) +Conditional <- c(.40,.50,.70) # P(x|Ei) +Joint <- c(.24,.15,.07) # P(X and Ei) = P(Ei)*P(x|Ei) +Posterior <- c(.52,.33,.15) # P(X and Ei)/sum(P(X and Ei)) + +machine <- cbind(Event,Prior,Conditional,Joint,Posterior) +machine + +# Revised Probabilities : +machine_A <- Prior[1]* Conditional[1]/sum(Joint) +machine_A + +machine_B <- Prior[2]* Conditional[2]/sum(Joint) +machine_B + +machine_C <- Prior[3]* Conditional[3]/sum(Joint) +machine_C \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.3/4_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.3/4_3.R new file mode 100644 index 00000000..a13f2b0c --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.3/4_3.R @@ -0,0 +1,32 @@ +# Special Law of Addition : P (T and C) = P (T) + P (C) + +Type_of_position <- c("Managerial", "Professional","Technical","Clerical") +Sex_male <- c(8,31,52,9) +Sex_female <- c(3,13,17,22) +total_r <- c(11,44,69,31) +total_c <- c(" ",100,55,55) +Compny_HR_data <- cbind(Type_of_position,Sex_male,Sex_female,total_r) +Compny_HR_data <- rbind(Compny_HR_data,total_c) +View(Compny_HR_data) + +# T denote technical, C denote clerical, and P denote professional. + +# Probability of Technical position : +Pb_T = sum(Sex_male[3],Sex_female[3])/sum(sum(Sex_female),sum(Sex_male)) +Pb_T + +# Probability of Clerical position : +Pb_C = sum(Sex_male[4],Sex_female[4])/sum(sum(Sex_female),sum(Sex_male)) +Pb_C + +# Probability of professional position : +Pb_P = sum(Sex_male[2],Sex_female[2])/sum(sum(Sex_female),sum(Sex_male)) +Pb_P + +# probability that a worker is either technical or clerical is : +Pb_T_C = Pb_T + Pb_C +Pb_T_C + +# probability that a worker is either professional or clerical is : +Pb_P_C = Pb_P + Pb_C +Pb_P_C diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.5/4_5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.5/4_5.R new file mode 100644 index 00000000..9eab2ce7 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.5/4_5.R @@ -0,0 +1,19 @@ +# General Law of Multiplication : P (X or Y) = P(X)*P(Y|X) = P(Y)*P(X|Y) + +Total_emp = 140 +supervisor = 30 +Married_emp = 80 +Pb_S_M = .20 # P(S|M) i.e. married employees are supervisors + +# probability that the employee is married : +Pb_M = Married_emp/Total_emp +Pb_M + +# probability that the employee is married and is a supervisor : +Pb_M_s <- Pb_M * Pb_S_M +Pb_M_s + +# 11.43% of the 140 employees are married and are supervisors + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.6/Ex4_6.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.6/Ex4_6.R new file mode 100644 index 00000000..30edf2a7 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.6/Ex4_6.R @@ -0,0 +1,25 @@ +# General Law of Multiplication : + +Industry_type <- c("Finance_A", "Manufacturing_B","Communication_C") +Northeast_D <- c(.12,.15,.14) +Southeast_E <- c(.05,.03,.09) +Midwest_F <- c(.04,.11,.06) +West_G <- c(.07,.06,.08) +total_r <- c(.28,.35,.37) +total_c <- c(" ",.41,.17,.21,.21,1.00) +Industry_type <- cbind(Industry_type,Northeast_D,Southeast_E,Midwest_F,West_G,total_r) +Industry_type <- rbind(Industry_type,total_c) +View(Industry_type) + +# a.) P(Manufacturing_B and Southeast_E) : +P_B_E <- total_r[2]*(Southeast_E[2]/total_r[2]) +P_B_E + +# b.) P(West_G and Finance_A) : +P_G_A <- sum(Midwest_F) *(West_G[1]/sum(Midwest_F)) +P_G_A + +# c.) P(Manufacturing_B and Communication_C) : +P_B_C <- .0 +P_B_C # The matrix shows no intersection for these two events. +# Thus B and C are mutually exclusive. \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.8/4_8.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.8/4_8.R new file mode 100644 index 00000000..1d2cd671 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.8/4_8.R @@ -0,0 +1,23 @@ +# Special law of Mulyiplication : If X, Y are independent, P (X or Y) = P (X) * P (Y) + + +T1 <- c("A", "B","C") +D <- c(8,20,6) +E <- c(12,30,9) +total_r <- c(20,50,15) +total_c <- c(" ",34,51,85) +T1 <- cbind(T1,D,E,total_r) +T1 <- rbind(T1,total_c) +View(T1) + +# Probability of B : +Pb_B = sum(D[2],E[2])/sum(total_r) +Pb_B + +# Probability of D : +Pb_D = sum(D)/sum(total_r) +Pb_D + +# Probability of B and D is : +Pb_B_D = Pb_B * Pb_D +Pb_B_D \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.9/4_9.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.9/4_9.R new file mode 100644 index 00000000..bcaa977f --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH4/EX4.9/4_9.R @@ -0,0 +1,26 @@ +# Conditinal Probability : P (X|Y) = P(X or Y)/P(Y) = (P(X)*P(Y|X))/P(Y) + +Industry_type <- c("Finance_A", "Manufacturing_B","Communication_C") +Northeast_D <- c(.12,.15,.14) +Southeast_E <- c(.05,.03,.09) +Midwest_F <- c(.04,.11,.06) +West_G <- c(.07,.06,.08) +total_r <- c(.28,.35,.37) +total_c <- c(" ",.41,.17,.21,.21,1.00) +Industry_type <- cbind(Industry_type,Northeast_D,Southeast_E,Midwest_F,West_G,total_r) +Industry_type <- rbind(Industry_type,total_c) +View(Industry_type) + +#a.) P(Manufacturing_B | Midwest_F) = P(Manufacturing_B and Midwest_F)/P(Midwest_F) +Pb_B_F = Midwest_F[2]/sum(Midwest_F) +Pb_B_F + +#b.) P(West_G | Communication_C) = P(West_G and Communication_C)/P(Communication_C) +Pb_G_C = West_G[3]/sum(Northeast_D[3],Southeast_E[3],Midwest_F[3],West_G[3]) +Pb_G_C + +#c.) P(Northeast_D | Midwest_F) = P(Northeast_D and Midwest_F)/P(Midwest_F) +Pb_D_F = .00/sum(Midwest_F) +Pb_D_F + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.1/5_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.1/5_1.R new file mode 100644 index 00000000..d1f28752 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.1/5_1.R @@ -0,0 +1,41 @@ +# Variance and standard deviation of a Discrete Distribution : + +Prize <- c(1000,100,20,10,4,2,1,0) # x +Probability <- c(.00002,.00063,.00400,.00601,.02403,.08877,.10479,.77175) # P(x) + +# x * P(x) : +for(i in 1:8){ + x_Pb <- Prize*Probability # x * P(x) +} +print(x_Pb) + +# sum Of x * P(x) : +x_Pb_s <- sum(x_Pb) +x_Pb_s + + +# (x - x_Pb_s)^2 +for(j in 1:8){ + x_mean_sq <- (Prize - x_Pb_s)^2 +} +print(x_mean_sq) + + +# (x - x_Pb_s)^2 * P(x) : +for(j in 1:8){ + x_mean_sq_Pb <- (Prize - x_Pb_s)^2 * Probability +} +print(x_mean_sq_Pb) + +# sum of (x - x_Pb_s)^2 * P(x) : +x_mean_sq_Pb_s <- sum(x_mean_sq_Pb) +x_mean_sq_Pb_s + +Prize <- cbind(Prize,Probability,x_mean_sq,x_mean_sq_Pb) +View(Prize) + +# Variance and Standard deviation : +var <- x_mean_sq_Pb_s +var +sd <- sqrt(var) +sd \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.10/Ex5_10.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.10/Ex5_10.R new file mode 100644 index 00000000..1d10ebcb --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.10/Ex5_10.R @@ -0,0 +1,19 @@ +# Probability Example : + +p = .0003 +n= 10000 +l <- n*p +l +x<- c(7,8,9,10,11,12) + +# Binomial probability for x>5 : +b<-dbinom(x,n,p) +b +sum(b) + + +# Poission probability for x>5 : +p<-dpois(x,l) +p +sum(p) + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.11/Ex5_11.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.11/Ex5_11.R new file mode 100644 index 00000000..149f80df --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.11/Ex5_11.R @@ -0,0 +1,14 @@ +# Hypergeometric distribution : P(x) = ACx*(N-A)C(n-x)/NCn + +# N = size of the population, n = sample size, A = number of successes in the population, x = number of successes in the sample; sampling is done without replacement + +N = 18 +n = 3 +A = 12 + +# Using choose function : + +1-((choose(A,0)*choose((N-A),n))/choose(N,n)) + + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.2/5_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.2/5_2.R new file mode 100644 index 00000000..b74fb235 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.2/5_2.R @@ -0,0 +1,16 @@ +# Binomial Distribution : P(x) = nCx*p^x*q^n-x = n!/x!(n - x)! *p^x*q^n-x + +p =.65 +q = 1-p +n = 25 +x = 19 +x1 = 0:19 + +# Binomial Distribution through inbuild function in r : +bd <- dbinom(x,n,p) +bd + +# Binomial Distribution through formula : +bd <- (factorial(n)/(factorial(x)*factorial(n-x))) * (p^x) * (q^(n-x)) +bd + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.3/Ex5_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.3/Ex5_3.R new file mode 100644 index 00000000..cd9c6c47 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.3/Ex5_3.R @@ -0,0 +1,11 @@ +# Binomial Disribution ex 2 : + +p = .06 +q = .94 +n = 20 + +x <- c(0,1,2) +c<-choose(n,x)*(p^x) * (q^(n-x)) +c +sum(c) + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.5/Ex5_5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.5/Ex5_5.R new file mode 100644 index 00000000..347aaa6e --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.5/Ex5_5.R @@ -0,0 +1,14 @@ +# using Binomial Table : + +n = 20 +p = .10 +q = 1-p + +x <- c(0,1,2,3) +c<-choose(n,x)*(p^x) * (q^(n-x)) +c + +# Probability that fewer than four purchasers choose Oreos i.e. x<4 : +sum(c) # about 86.7% of the time fewer than four of the 20 will select Oreos + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.6/Ex5_6.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.6/Ex5_6.R new file mode 100644 index 00000000..573b8cd4 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.6/Ex5_6.R @@ -0,0 +1,19 @@ +# Mean and standard deviation in Binomial distribution : +# mean = n * p and sd = sqrt(n*p*q) + +n = 10 +p<-c(.10,.20,.30,.40) +q = 1-p + +# mean <- n*p +for(p1 in 1:4){ + mean = n*p +} +print(mean) + +pd<-pbinom(2,n,p) + + +p<-cbind(p,mean,pd) +p + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.7/5_7.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.7/5_7.R new file mode 100644 index 00000000..2bf2bd5a --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.7/5_7.R @@ -0,0 +1,41 @@ +# Poission formula : P(x) =lamda^x*e^-lamda/x! + +l <- 3.2 # lamda +# x>7 customers/4 minutes + +# through in build function of poission in r: +dpois(8,lambda = 3.2) # x=8 + +# x = 8 through formula : +x = 8 +pd_8 <- (l^x*exp(-l))/factorial(x) +pd_8 + +# x = 9 through formula : +x = 9 +pd_9 <- (l^x*exp(-l))/factorial(x) +pd_9 + +# x = 10 through formula : +x = 10 +pd_10 <- (l^x*exp(-l))/factorial(x) +pd_10 + +# x = 11 through formula : +x = 11 +pd_11 <- (l^x*exp(-l))/factorial(x) +pd_11 + +# x = 12 through formula : +x = 12 +pd_12 <- (l^x*exp(-l))/factorial(x) +pd_12 + +# x = 13 through formula : +x = 13 +pd_13 <- (l^x*exp(-l))/factorial(x) +pd_13 + +# Poission distribution for x>=8 +sum(pd_8,pd_9,pd_10,pd_11,pd_12,pd_13) + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.8/Ex5_8.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.8/Ex5_8.R new file mode 100644 index 00000000..d4117b76 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.8/Ex5_8.R @@ -0,0 +1,13 @@ +# Poisson distribution Example : +# Poission formula : P(x) =lamda^x*e^-lamda/x! + +l=3.2 +x = 10 +pd <- dpois(x,l,log=FALSE) +pd + +# probability of getting exactly 10 customers during an 8-minute interval +l1=6.4 +x1 = 10 +pd1 <- dpois(x1,l1,log=FALSE) +pd1 \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.9/Ex5_9.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.9/Ex5_9.R new file mode 100644 index 00000000..7675dcd7 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH5/EX5.9/Ex5_9.R @@ -0,0 +1,12 @@ +# using poission table : + +l <- 1.6 +x<- c(6,7,8,9) + + +# Poission probability for x>5 : +p<-dpois(x,l) +p +sum(p) + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.1/6_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.1/6_1.R new file mode 100644 index 00000000..a9f664e1 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.1/6_1.R @@ -0,0 +1,21 @@ +# Probabilities in Uniform Distribution : P(x) = x2-x1 / b-a where: a<=x1<=x2<=b + +b = 39 +a = 27 + +f_x = 1/(b-a) # f(x) +f_x + +u <- (a+b)/2 #mean +u + +sd <- (b-a)/sqrt(b-a) # standard deviation +sd + +# P(30 <= x <= 35) : +P = (35-30)/(39-27) +P + +# P(x<30) : +P1 = (30-27)/(39-27) +P1 \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.10/Ex6_10.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.10/Ex6_10.R new file mode 100644 index 00000000..d79fcd1d --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.10/Ex6_10.R @@ -0,0 +1,27 @@ +# Binomial distribution by using the normal distribution : + +p = .37 +n = 100 +q=1-p +mean1 = n*p +mean1 +sd = sqrt(n*p*q) +sd + +# range : +u = mean +3*(sd) +u +l = mean - 3*(sd) +l + +x = 26.5 +z=(x-mean)/sd +z + +# tail of the distribution : +.5000-.4850 + +x1 <- c(26:20) +b<-dbinom(x1,n,p) +b +sum(b) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.11/6_11.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.11/6_11.R new file mode 100644 index 00000000..6df2b6e5 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.11/6_11.R @@ -0,0 +1,16 @@ +# Exponential Distribution : f(x) = lambda * e^-lambda*x + +# Probability of right tail exponential distribution : P(x>=x0) = e^-lambda*x0 + +l = 1.38 # lambda +mean = 1/l +mean +x0 = .75 + +# P(x>=x0) : +P <- exp(-l*x0) +P + +# for x0 = 0.75, Probability < x0 : +Prob = 1-P +Prob \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.2/Ex6_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.2/Ex6_2.R new file mode 100644 index 00000000..5383ec29 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.2/Ex6_2.R @@ -0,0 +1,17 @@ +# MEAN AND STANDARD DEVIATION OF A UNIFORM DISTRIBUTION : + +u = 691 # mean +a = 200 +b = 1182 +x1 = 410 +x2 = 825 +sd <- (b-a)/sqrt(12) # standard deviation +sd + +# height of distribution : +f_x = 1/(b-a) # f(x) +f_x + +# probability that a randomly selected person pays between $410 and $825 annually for automobile insurance in the US: +p_x = (x2-x1)/(b-a) +p_x \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.3/Ex6_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.3/Ex6_3.R new file mode 100644 index 00000000..8cc4fe0a --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.3/Ex6_3.R @@ -0,0 +1,8 @@ +# Normal Curve distribution : + +mean = 494 +sd=100 +x =700 + +# probability of x greater than 700 : +pnorm(x, mean, sd, lower.tail=FALSE) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.4/Ex6_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.4/Ex6_4.R new file mode 100644 index 00000000..6da29b51 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.4/Ex6_4.R @@ -0,0 +1,18 @@ +# PROBABILITY OF A UNIFORM DISTRIBUTION + +x = 550 +mean = 494 +sd = 100 +lb =.2123 # probability of values between 550 and the mean +ub =.5000 # probability of values less than the mean + + +# using r function : +pnorm(x, mean, sd) + +# Or using normal formula : +z=(x-mean)/sd +z + +ub+lb # probability of values 550 + \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.5/Ex6_5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.5/Ex6_5.R new file mode 100644 index 00000000..22f3acf5 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.5/Ex6_5.R @@ -0,0 +1,14 @@ +# Probability of Normal Curve DISTRIBUTION : + +x = 600 +mean = 494 +sd = 100 +x1 = 300 + +a <- pnorm(x1, mean, sd, lower.tail=FALSE) +a +b <- pnorm(x, mean, sd, lower.tail=FALSE) +b + +# probability of a value between 300 and 600 : +a - b diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.6/Ex6_6.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.6/Ex6_6.R new file mode 100644 index 00000000..46163f98 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.6/Ex6_6.R @@ -0,0 +1,14 @@ +# PROBABILITY OF A UNIFORM DISTRIBUTION + +x = 350 +mean = 494 +sd = 100 +x1 = 450 + +a <- pnorm(x, mean, sd, lower.tail=FALSE) +a +b <- pnorm(x1, mean, sd, lower.tail=FALSE) +b + +# probability of a value between 350 and 450 : +a-b diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.7/Ex6_7.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.7/Ex6_7.R new file mode 100644 index 00000000..f8f9899b --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.7/Ex6_7.R @@ -0,0 +1,10 @@ +# MEAN OF A UNIFORM DISTRIBUTION + +x = 449 +z = 1.11 # value taken from z table +sd = 36 +# z = (x - mean)/sd + +mean = x - (z*sd) +mean + \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.8/Ex6_8.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.8/Ex6_8.R new file mode 100644 index 00000000..bceb43ee --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.8/Ex6_8.R @@ -0,0 +1,11 @@ +# Normal distribution using z value : + +mean = 3.58 +z = -0.46 # value taken from z table +sd = 1.04 +# z = (x - mean)/sd + +x = (z*sd) + mean +x + +# 67.72% of the daily average amount of solid waste per person weighs more than 3.10 pound. \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.9/6_9.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.9/6_9.R new file mode 100644 index 00000000..24ba6e5a --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH6/EX6.9/6_9.R @@ -0,0 +1,37 @@ +# binomial distribution problem by using the normal distribution : + +x = 12 +n = 25 +p = .40 +q = 1-p + +mean = n * p +mean + +sd = sqrt(n*p*q) +sd + +# test : mean +/- 3sd +test1 <- mean + 3*sd +test2 <- mean - 3*sd +test1 +test2 + +# test : 2.65 to 17.35 + +# z value at x = 12.5 +x = 12.5 +z = (x-mean)/sd +z + +# z value at x = 12.5 +x = 11.5 +z = (x-mean)/sd +z + +#z = 1.02 produces a probability of .3461. +# z = 0.61 produces a probability of .2291. + +# The difference in areas yields the following answer: +0.3461 - .2291 + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.1/Ex7_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.1/Ex7_1.R new file mode 100644 index 00000000..e4101e2c --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.1/Ex7_1.R @@ -0,0 +1,22 @@ +# Z formula for sample means : z = (sample_mean - average)/(standard_dev/sqrt(sample_size)) + +mean = 448 +sd = 21/sqrt(49) +n = 49 # sample size +# sample mean : 441 <= x_bar <= 446 +samplemean_l = 441 +samplemean_u = 446 + +a <-pnorm(samplemean_l, mean, sd, lower.tail=FALSE) +a +b <-pnorm(samplemean_u, mean, sd, lower.tail=FALSE) +b + + +# probability of a value being between z = -2.33 and -0.67 is : +prob = a - b +prob + +# The probability of a value being between z=2.33 and -0.67 is .2426; that is, +# there is a 24.26% chance of randomly selecting 49 hourly periods for +# which the sample mean is between 441 and 446 shoppers. diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.2/Ex7_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.2/Ex7_2.R new file mode 100644 index 00000000..a7b65208 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.2/Ex7_2.R @@ -0,0 +1,12 @@ +# Z formula for Sample mean of a finite population : +# z = (samplemean - population_mean)/(sd/sqrt(n))*(sqrt((N-n)/(N-1))) + +pop_mean = 37.6 # avg +pop_sd = 8.3 # sd +n = 45 # sample size +N = 360 # finite population +sample_mean = 40 + +sd = (pop_sd/sqrt(n))*(sqrt((N-n)/(N-1))) + +pnorm(sample_mean,pop_mean,sd,lower.tail=TRUE) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.3/Ex7_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.3/Ex7_3.R new file mode 100644 index 00000000..c774fa13 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH7/EX7.3/Ex7_3.R @@ -0,0 +1,12 @@ +# Z formula for Sample Proportion : +# z = (sample_proportion - population_prop)/sqrt((population_prop*q)/sample size) + +p = 0.10 # population_prop +sample_prop = 12/80 +n = 80 +q = 1-p + +sd = sqrt(p*q/n) + +# P(sample_prop >= .15) : +pnorm(sample_prop,p,sd,lower.tail=FALSE) \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.1/Ex8_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.1/Ex8_1.R new file mode 100644 index 00000000..5ec9f2bf --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.1/Ex8_1.R @@ -0,0 +1,13 @@ +# Confidence interval to Estimate Population mean : +# pop_mean +/- z*(sd/sqrt(n)) + +n = 44 +sample_mean = 10.455 +sd = 7.7 +z = 1.645 + +pop_mean_1 = sample_mean - (z*(sd/sqrt(n))) +pop_mean_1 + +pop_mean_2 = sample_mean + (z*(sd/sqrt(n))) +pop_mean_2 \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.2/8_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.2/8_2.R new file mode 100644 index 00000000..fa8d8ec5 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.2/8_2.R @@ -0,0 +1,14 @@ +# Confidence interval to Estimate Population mean using finite correction : +# (pop_mean) +/- (z*(sd/sqrt(n))*sqrt(N-n/N-1)) + +n = 50 +N = 800 +sample_mean = 34.30 +sd = 8 +z = 2.33 + +pop_mean_1 = sample_mean - (z*(sd/sqrt(n))*sqrt((N-n)/(N-1))) +pop_mean_1 + +pop_mean_2 = sample_mean + (z*(sd/sqrt(n))*sqrt((N-n)/(N-1))) +pop_mean_2 \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.3/Ex8_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.3/Ex8_3.R new file mode 100644 index 00000000..d6ac5377 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.3/Ex8_3.R @@ -0,0 +1,14 @@ +# Confidence Interval to Estimate population mean : Population standard devition unknown and population normally distributed +# pop_mean +/- t*(sd/sqrt(n)) , df = n-1 +a<- c(3,1,3,2,5,1,2,1,4,2,1,3,1,1) +n = 14 +df = n-1 +t = 3.012 +sd = 1.29 +sample_mean = 2.14 + +pop_mean_1 = sample_mean - (t*(sd/sqrt(n))) +pop_mean_1 + +pop_mean_2 = sample_mean + (t*(sd/sqrt(n))) +pop_mean_2 diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.4/8_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.4/8_4.R new file mode 100644 index 00000000..c8990641 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.4/8_4.R @@ -0,0 +1,15 @@ +# Confidence Interval to estimate Population Proportion : +# p = samp_prop +/- (z*sqrt(samp_prop*q/sample size) + +samp_prop = 0.51 +q = 1-samp_prop +z = 1.75 +n = 210 # sample size + +p_1 = samp_prop - (z*sqrt(samp_prop*q/n)) +p_1 + +p_2 = samp_prop + (z*sqrt(samp_prop*q/n)) +p_2 + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.5/Ex8_5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.5/Ex8_5.R new file mode 100644 index 00000000..ebc3ae56 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.5/Ex8_5.R @@ -0,0 +1,15 @@ +# Confidence Interval to estimate Population Proportion : +# p = samp_prop +/- (z*sqrt(samp_prop*q/sample size) + +samp_prop = 34/212 # sample size =212 and no. of jeans = 34 +q = 1-samp_prop +z = 1.645 +n = 212 # sample size + +p_1 = samp_prop - (z*sqrt(samp_prop*q/n)) +p_1 + +p_2 = samp_prop + (z*sqrt(samp_prop*q/n)) +p_2 + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.6/Ex8_6.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.6/Ex8_6.R new file mode 100644 index 00000000..3108e61d --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.6/Ex8_6.R @@ -0,0 +1,19 @@ + +# Confidence to estimate the Population Variance : +# var = ((n-1)*s^2)/(X(a/2))^2 or ((n-1)*s^2)/(X(1-a/2))^2 , df = n-1 + +s = 1.12 +n = 25 +df = n-1 + +a = qchisq(0.975, df=24) +a +b = qchisq(.025, df=24) +b + +var_1 = ((n-1)*s^2)/a +var_1 + +var_2 = ((n-1)*s^2)/b +var_2 + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.7/8_7.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.7/8_7.R new file mode 100644 index 00000000..7d113c3b --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.7/8_7.R @@ -0,0 +1,9 @@ +# Sample Size when Estimating Population mean : +# n = (z*sd/E)^2 + +E = 1 # error in estimating +z = 1.96 +sd = 5 + +n = (z*sd/E)^2 +n \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.8/8_8.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.8/8_8.R new file mode 100644 index 00000000..e828b1fb --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH8/EX8.8/8_8.R @@ -0,0 +1,10 @@ +# Sample size when estimating population proportion : +# n = z^2*p*q/E^2 + +E = .03 +p = .40 +z = 2.33 +q = 1-p + +n = z^2*p*q/E^2 +n \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.1/Ex9_1.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.1/Ex9_1.R new file mode 100644 index 00000000..b1463bdc --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.1/Ex9_1.R @@ -0,0 +1,20 @@ +# Formula to test Hypoyhesis about population mean : +# z = sample_mean - pop_mean/(sd/sqrt(n)) + +pop_mean = 4.30 +sample_mean = 4.156 +sd = .574 +n = 32 +a = .05 # alpha value + +# Calcultaed value of test statistic : +z1 = (sample_mean - pop_mean)/(sd/sqrt(n)) +z1 + +# Critical Z value associated with alpha = 0.05 : +z = qnorm(.05,lower.tail=TRUE) +z + +# critical sample mean : +sample_mean_c = (z * (sd/sqrt(n))) + pop_mean +sample_mean_c \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.2/Ex9_2.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.2/Ex9_2.R new file mode 100644 index 00000000..30337f8f --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.2/Ex9_2.R @@ -0,0 +1,19 @@ +# t test for population mean : +# t = (sample_mean - pop_mean) / (sd/sqrt(n)) , df = n-1 + +pop_mean = 471 +sample_mean = 498.78 +sd = 46.94 +n = 23 +alpha = 0.05 +df = n-1 + +# t-distribution function to calculate critical t-value using alpha and df: +qt(alpha, df, lower.tail = FALSE, log.p = FALSE) + +# Observed t valueusing sample mean and standard deviation : +t = (sample_mean - pop_mean) / (sd/sqrt(n)) +t + +# The observed t value of 2.84 is greater than the table t value of 1.717, +# so the business researcher rejects the null hypothesis. \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.3/Ex9_3.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.3/Ex9_3.R new file mode 100644 index 00000000..c6fb6321 --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.3/Ex9_3.R @@ -0,0 +1,20 @@ +# z test of a population proportion : +# z = sample_prop - population_prop/sqrt(population_prop*q/n) + +n = 550 +x = 115 +sample_prop = 115/550 +population_prop = .17 +q = 1- population_prop + +# test statistic value of z : +z1 = (sample_prop - population_prop)/sqrt((population_prop*q)/n) +z1 + +# critical value of z : +z = qnorm(.05,lower.tail=FALSE) +z + +# critical sample proportion : +sample_prop_c = z * sqrt(population_prop*q/n) + population_prop +sample_prop_c \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.4/Ex9_4.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.4/Ex9_4.R new file mode 100644 index 00000000..42796b2d --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.4/Ex9_4.R @@ -0,0 +1,29 @@ +# Test Hypothesis about a population variance : +# X^2 = (n-1)*s^2/var , df = n-1 + +var = 25 +n = 16 +s_sq = 28.0625 # sample variance +df = n-1 + +# Two tailed test and alpha = .10 it will be divided by 2 : +a <- .10/2 + +# we have two critical values of chi square : + +# 1st chi-sq value is a : +qchisq(a, df=15) + +# 2nd chi-sq is 1-a : +qchisq(1-a, df=15) + +# The decision rule is to reject the null hypothesis if the observed value +# of the test statistic is less than 7.26093 or greater than 24.9958. + +X_sq = ((n-1)*s_sq)/var +X_sq + +# This observed chi-square value is in the nonrejection region because +# chi_sq(.05)=7.26 < chi_sq(observed) = 16.83 < chi_sq(.95) = 24.9958. +# The company fails to reject the null hypothesis. The population variance +# of overtime hours per week is 25. diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.5/9-5.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.5/9-5.R new file mode 100644 index 00000000..83bed46c --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.5/9-5.R @@ -0,0 +1,11 @@ +# Z value for Type II error : z = sample_mean_c - pop_mean_1/(sd/sqrt(n)) + +sample_mean_c = 11.979 +pop_mean_1 = 11.96 +sd = .10 +n = 60 + +z = (sample_mean_c - pop_mean_1)/(sd/sqrt(n)) +z + + diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.6/Ex9_6.R b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.6/Ex9_6.R new file mode 100644 index 00000000..76f21ece --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/CH9/EX9.6/Ex9_6.R @@ -0,0 +1,26 @@ +# Z value for Type II error + +z_c = 1.96 +p = .40 +q =1-p +n = 250 +# z_c = (p_c-p)/sqrt(p*q/n) +p_c = z_c*sqrt((p*q)/n)+p +p_c +p_c1 = z_c*sqrt((p*q)/n)-p +p_c1 + +# z value on taking p_c = .46 and p = .36 : +p_c = .46 +p = .36 +z_c = (p_c-p)/sqrt(p*q/n) +z_c + +# z value on taking p_c = .34 and p = .36 : +p_c = .34 +p = .36 +z_c = (p_c-p)/sqrt(p*q/n) +z_c + +# The area associated with z = 3.29 is .4995.Combining this value with the .2454 obtained from the left side of the distribution in graph (b) yields the total probability of committing a Type II error: + .2454+.4994 \ No newline at end of file diff --git a/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/README.txt b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/README.txt new file mode 100644 index 00000000..af994a0c --- /dev/null +++ b/Business_Statistics_For_Contemporary_Decision_Making_by_Ken_Black/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Vibha Mehta +Course: B. Tech +Branch: Computer Science And Engineering +College/Institute/Organization: Techno India Njr Institute Of Technology + +About The Book + +Book: Business Statistics For Contemporary Decision Making +Author: Ken Black +Publisher: Wiley, Usa +Year Of Publication: 2010 +ISBN: 978-0470-40901-5 +Edition: 6 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Chemical_Simulation_by_Prof_Kannan/CH8/EX1.1/Ex8_1.R b/Chemical_Simulation_by_Prof_Kannan/CH8/EX1.1/Ex8_1.R new file mode 100644 index 00000000..e2684d17 --- /dev/null +++ b/Chemical_Simulation_by_Prof_Kannan/CH8/EX1.1/Ex8_1.R @@ -0,0 +1,9 @@ +"Consider a queueing model in which all customers have service times equal to 1, and where the times between successive customers are always +greater than 1 (for instance, the interarrival times could be uniformly distributed over (1, 2))." + +"Hence, as every arrival finds the system empty and every departure leaves it empty, we have:" +a0 = d0 = 1 +#an = proportion of customers that find n in the system when they arrive, and +#dn = proportion of customers leaving behind n in the system when they depart + +#However,P0 is not equal to 1, as the system is not always empty of customers. \ No newline at end of file diff --git a/Chemical_Simulation_by_Prof_Kannan/README.txt b/Chemical_Simulation_by_Prof_Kannan/README.txt new file mode 100644 index 00000000..a89c7ad5 --- /dev/null +++ b/Chemical_Simulation_by_Prof_Kannan/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Priyanka Bhagwat +Course: Ww +Branch: Physics +College/Institute/Organization: Lshksdlvdv + +About The Book + +Book: Chemical Simulation +Author: Prof Kannan +Publisher: Cdbcdvhb V +Year Of Publication: 1989 +ISBN: 47834 +Edition: 3 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.1/Ex10_1.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.1/Ex10_1.R new file mode 100644 index 00000000..59bfd43c --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.1/Ex10_1.R @@ -0,0 +1,11 @@ + +data <- iris +data$Species <- NULL + +clusters <- kmeans(data, 3) + +plot(data[c("Sepal.Length", "Sepal.Width","Petal.Length", "Petal.Width")], col=clusters$cluster) + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.2/Ex10_2.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.2/Ex10_2.R new file mode 100644 index 00000000..eadc4402 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.2/Ex10_2.R @@ -0,0 +1,53 @@ + +data <- c(1,2,3,8,9,10,25) + +clu1 <- c(1,2,3) + +clu2 <- c(8,9,10,25) + + +Mean_clu1 <- mean(clu1) + +Mean_clu2 <- mean(clu2) + + +su_mean1 <- sum((clu1-Mean_clu1)^2) + +su_mean2 <- sum((clu2-Mean_clu2)^2) + + +First_Total<-su_mean1+su_mean2 + +print("Variation within first partition") + +print(First_Total) + + + + +print("##################################################") + + + +data <- c(1,2,3,8,9,10,25) + +clu3 <- c(1,2,3,8) + +clu4 <- c(9,10,25) + + +Mean_clu3 <- mean(clu3) + +Mean_clu4 <- mean(clu4) + + +su_mean3 <- sum((clu3-Mean_clu3)^2) + +su_mean4 <- sum((clu4-Mean_clu4)^2) + + +sec_Total<-su_mean3+su_mean4 + +print("Variation within second partition") + +print(sec_Total) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.3/Ex10_3.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.3/Ex10_3.R new file mode 100644 index 00000000..215fd299 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.3/Ex10_3.R @@ -0,0 +1,21 @@ + + library(cluster) + +data(iris) + +print("Agglomerative Clustering") +agn_hiclu <- agnes(iris, metric = "manhattan", stand = TRUE) +print(agn_hiclu) +plot(agn_hiclu) + + + +print("#######################################################") + + + +data(iris) +print("Devisive Clustering") +divisive_clu <- diana(iris, metric = "manhattan", stand = TRUE) +print(divisive_clu) +plot(divisive_clu) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.4/Ex10_4.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.4/Ex10_4.R new file mode 100644 index 00000000..4ba853f3 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.4/Ex10_4.R @@ -0,0 +1,16 @@ +index <- sample(1:dim(iris)[1], 60) +newiris <- iris[index,] +newiris$Species <- NULL + +###Apply Hierarchical Clustering + +hier_clu <- hclust(dist(newiris), method="ave") +plot(hier_clu , hang = -1, labels=newiris$Species[index]) + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.7/Ex10_7.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.7/Ex10_7.R new file mode 100644 index 00000000..39fccd1d --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.7/Ex10_7.R @@ -0,0 +1,19 @@ + +library(dbscan) + +data(iris) + +iris <- as.matrix(iris[,1:4]) + +result_dbscan <- dbscan(iris, eps = .3, minPts = 3) + + +print(result_dbscan) + + +pairs(iris, col = result_dbscan$cluster + 1L) + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.8/Ex10_8.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.8/Ex10_8.R new file mode 100644 index 00000000..2643102c --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH10/EX10.8/Ex10_8.R @@ -0,0 +1,23 @@ + +library(dbscan) + +data(iris) + + + +result <- optics(iris[,1:4], eps = 10, minPts = 5) + + +###Componets of reachability +Com_reach <- as.reachability(result) + + +###plot(Com_reach, order_labels = TRUE) + + +dend <- as.dendrogram(Com_reach) + +plot(dend) + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.14/Ex11_14.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.14/Ex11_14.R new file mode 100644 index 00000000..4fdf1a16 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.14/Ex11_14.R @@ -0,0 +1,24 @@ +##install.packages("speccalt") + + +library(speccalt) +iris <- local.rbfdot(iris[,1:4]) +cluster1 <- speccalt(iris) # with automatic estimation +cluster2 <- speccalt(iris, 4) + + +View(cluster1) + +View(cluster2) + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.16/Ex11_16.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.16/Ex11_16.R new file mode 100644 index 00000000..eef68915 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.16/Ex11_16.R @@ -0,0 +1,26 @@ +###install.packages("igraph") + +library(igraph) + +graph <- make_full_bipartite_graph(2, 2, dir=TRUE, mode="all") + + +print(graph, v=TRUE) + + +plot(graph) + + + + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.19/Ex11_19.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.19/Ex11_19.R new file mode 100644 index 00000000..e4024124 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.19/Ex11_19.R @@ -0,0 +1,21 @@ + + +library(geosphere) +#geodesic distance +geo_dest<- geodesic(cbind(0,0), 2, 3) + +print(geo_dest) + + + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.21/Ex11_21.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.21/Ex11_21.R new file mode 100644 index 00000000..025234ff --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.21/Ex11_21.R @@ -0,0 +1,26 @@ + +hc <- hclust(dist(iris[,1:4])) + + +cutree(hc, k = 1:3) #k = 1 is trivial +cutree(hc, h = 100) + +## Compare the 2 and 10 grouping: +gra210 <- cutree(hc, k = c(2,10)) + + +plot(gra210) + + + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.23/Ex11_23.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.23/Ex11_23.R new file mode 100644 index 00000000..645ff1b2 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.23/Ex11_23.R @@ -0,0 +1,22 @@ + +library(SoftClustering) + +data(iris) + +Hardclu <- HardKMeans(iris[,1:4],2,2,10) + + +print(Hardclu) + + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.3/Ex11_3.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.3/Ex11_3.zip new file mode 100644 index 00000000..612023c0 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.3/Ex11_3.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.5/Ex11_5.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.5/Ex11_5.R new file mode 100644 index 00000000..db6f13cc --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.5/Ex11_5.R @@ -0,0 +1,7 @@ +library(FPDclustering) + + +Pro_clu <- PDclust(iris[,1:4], k = 2) + + +print(Pro_clu) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.7/Ex11_7.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.7/Ex11_7.R new file mode 100644 index 00000000..9cdc24e7 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH11/EX11.7/Ex11_7.R @@ -0,0 +1,31 @@ +###Install package install.packages("EMCluster") + + +library(EMCluster) +library(MASS) +library(Matrix) + + + +Dataset<- data.frame(Fi=c(4,3,9,14,18,21),se=c(10,3,6,8,11,7)) + + +d <- as.matrix(Dataset) + +emobj <- simple.init(d, nclass = 2) +emobj <- shortemcluster(d, emobj) + +emclu <- emcluster(d, emobj, assign.class = TRUE) +print(emclu) + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.1/Ex12_1.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.1/Ex12_1.R new file mode 100644 index 00000000..0e5e650d --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.1/Ex12_1.R @@ -0,0 +1,7 @@ +library(outliers) + + + +outliers<- outlier(iris[,1:4]) + +print(outliers) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.10/Ex12_10.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.10/Ex12_10.R new file mode 100644 index 00000000..6b696522 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.10/Ex12_10.R @@ -0,0 +1,7 @@ + +library(outliers) + +dataset <- c(24,28.9,28.9,29,29.1,29.1,29.2,29.2,29.3,29.4) +chisq.out.test(dataset ) +print(chisq.out.test(dataset, opposite=TRUE)) + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.12/Ex12_12.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.12/Ex12_12.R new file mode 100644 index 00000000..aecc89f8 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.12/Ex12_12.R @@ -0,0 +1,7 @@ +library(kmodR) + +d<- as.matrix(iris[,1:4]) + +print(kmod(d,k=3,l=10, i_max = 100)) + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.13/Ex12_13.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.13/Ex12_13.R new file mode 100644 index 00000000..6fd0c765 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.13/Ex12_13.R @@ -0,0 +1,7 @@ + + +d<- iris[,1:4] + +hist(as.matrix(d)) + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.14/Ex12_14.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.14/Ex12_14.R new file mode 100644 index 00000000..24d92253 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.14/Ex12_14.R @@ -0,0 +1,10 @@ +library(DMwR) + + + +d<- iris[,1:4] + +local_pro<- lofactor(d[,-5],10) + + +print(local_pro) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.15/Ex12_15.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.15/Ex12_15.R new file mode 100644 index 00000000..38d9bcb9 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.15/Ex12_15.R @@ -0,0 +1,17 @@ +library(DMwR) +library(lattice) +library(grid) + + + +d11<- iris[,1:4] + +d <- as.matrix(d11) + +density_scan<- dbscan(d, eps=1, minPts = 5) + + +print(density_scan) + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.16/Ex12_16.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.16/Ex12_16.R new file mode 100644 index 00000000..72020932 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.16/Ex12_16.R @@ -0,0 +1,18 @@ +library(DMwR) +library(lattice) +library(grid) + + + +dataset<- iris[,1:4] + +d <- as.matrix(dataset) + +dist<- kNNdist(d, k=4, search="kd") + +print(dist) + + +kNNdistplot(d, k=4) + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.18/Ex12_18.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.18/Ex12_18.R new file mode 100644 index 00000000..d9604e9d --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.18/Ex12_18.R @@ -0,0 +1,10 @@ +library(DMwR) + # Ignore class column "Species", which is a categorical column + +iris <- iris[,1:4] + +outlierslof <- lofactor(iris, k=2) + +outliers <- order(outlierslof, decreasing=T)[1:10] + +print(outliers) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.20/Ex12_20.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.20/Ex12_20.R new file mode 100644 index 00000000..5aa25133 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.20/Ex12_20.R @@ -0,0 +1,8 @@ +library(ldbod) + +dataset <- as.matrix(iris[,1:4]) + +local_den<- ldbod(dataset, k=3, nsub=50) + + +print(local_den) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.24/Ex12_24.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.24/Ex12_24.R new file mode 100644 index 00000000..dc7ba1f4 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.24/Ex12_24.R @@ -0,0 +1,7 @@ +library(HighDimOut) +library(ggplot2) + +result_SOD <- Func.SOD(data = iris[,1:4], k.nn = 10, k.sel = 5, alpha = 0.8) + +plot(result_SOD) + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.25/Ex12_25.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.25/Ex12_25.R new file mode 100644 index 00000000..02b3bce2 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.25/Ex12_25.R @@ -0,0 +1,13 @@ + + +###install.packages("abodOutlier") + + +library(abodOutlier) + +data(iris) + +Abodf<- abod(iris[,1:4], method = "randomized", n_sample_size = 5) + + +View(Abodf) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.7/Ex12_7.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.7/Ex12_7.R new file mode 100644 index 00000000..0842e283 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.7/Ex12_7.R @@ -0,0 +1,14 @@ +iris <- iris[,1:4] + + +kmeansClu <- kmeans(iris, centers=3) + + + +centersofclu <- kmeansClu$centers[kmeansClu$cluster, ] + +dist <- sqrt(rowSums((iris - centersofclu)^2)) + +outliers <- order(dist, decreasing=T)[1:10] + +print(outliers) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.8/Ex12_8.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.8/Ex12_8.R new file mode 100644 index 00000000..c5b524e1 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.8/Ex12_8.R @@ -0,0 +1,4 @@ +dataset <- c(24,28.9,28.9,29,29.1,29.1,29.2,29.2,29.3,29.4) + +mean(dataset) +print(sd(dataset)) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.9/Ex12_9.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.9/Ex12_9.R new file mode 100644 index 00000000..57e0b6d1 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH12/EX12.9/Ex12_9.R @@ -0,0 +1,8 @@ + +library(mvoutlier) + +data(iris) + + +aq.plot(iris[,1:4], alpha=0.1) + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.10/Ex2_10.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.10/Ex2_10.R new file mode 100644 index 00000000..1896551c --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.10/Ex2_10.R @@ -0,0 +1,9 @@ +Data <- c(30,36,47,50,52,52,56,60,63,70,70,110) + + +print("Interquartile Range") + + +print(IQR(Data)) + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.11/Ex2_11.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.11/Ex2_11.R new file mode 100644 index 00000000..2e276049 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.11/Ex2_11.R @@ -0,0 +1,5 @@ +Data <- data.frame(MG= c(30,36,47,50,52), CY=c(25,60,30,21,70)) + + +boxplot(Data,xlab = "Number of Cylinders",ylab = "Miles Per Gallon", main = "Summary of Mileage") + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.12/Ex2_12.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.12/Ex2_12.R new file mode 100644 index 00000000..ea6b1690 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.12/Ex2_12.R @@ -0,0 +1,10 @@ +Data <- c(30,36,47,50,52,52,56,60,63,70,70,110) + +print("variance") +print(var(Data)) + + +print("Standard Deviation") + +######"The answer provided in the textbook is 19.47" +print(sd(Data)) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.13/Ex2_13.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.13/Ex2_13.R new file mode 100644 index 00000000..f3744177 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.13/Ex2_13.R @@ -0,0 +1,6 @@ +Unit_price = c(40,43,47,74,75,78,115,117,120) +count_of_items_sold =c(275,300,250,360,515,540,320,270,350) + +qqplot(count_of_items_sold,Unit_price) + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.15/Ex2_15.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.15/Ex2_15.R new file mode 100644 index 00000000..8839b96e --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.15/Ex2_15.R @@ -0,0 +1,4 @@ +Unit_price = c(40,43,47,74,75,78,115,117,120) +count_of_items_sold =c(275,300,250,360,515,540,320,270,350) + +hist(Unit_price,breaks = seq(0, 800, by = 10)) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.18/Ex2_18.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.18/Ex2_18.R new file mode 100644 index 00000000..b81b2199 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.18/Ex2_18.R @@ -0,0 +1,22 @@ +Ja <- c(1,1,0,1,0,0,0) + +Jim <- c(1,1,1,0,0,0,0) + +ma <- c(0,1,1,1,0,1,0) + + + +Ja_Jim = (1+1)/(1+1+1) +print("Distance between Jack and Jim") + +print(Ja_Jim) + + +Ja_ma =(0+1)/(2+0+1) +print("Distance between Jack and mary") + +print(Ja_ma) + +Jim_ma =(1+2)/(1+1+2) +print("Distance between Jim and mary") +print(Jim_ma) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.19/Ex2_19.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.19/Ex2_19.R new file mode 100644 index 00000000..21efa10b --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.19/Ex2_19.R @@ -0,0 +1,16 @@ + +x1 <- c(1,2) + +x2 <- c(3,5) + +dif <- x2-x1 + +Euclidean<- sqrt(sum(dif^2)) +print("Euclidean distance") +print(Euclidean) + + +print("Manhattan Distance") +Manhattan <- sum(dif) + +print(Manhattan) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.20/Ex2_20.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.20/Ex2_20.R new file mode 100644 index 00000000..1501f8af --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.20/Ex2_20.R @@ -0,0 +1,13 @@ + +x1 <- c(1,2) + +x2 <- c(3,5) + +Supremum_Dis<- max(x2)-max(x1) + +print("supremum Distance") + +print(Supremum_Dis) + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.21/Ex2_21.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.21/Ex2_21.R new file mode 100644 index 00000000..d5f1a46f --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.21/Ex2_21.R @@ -0,0 +1,43 @@ + +test2 = c(3,1,2,3) + +obj_Id <- c(1,2,3,4) + + +dif <- obj_Id - test2 + +Euclidean<- sqrt(sum(dif^2)) +print("Euclidean distance") +print(Euclidean) + + + + +test2 = c(1,3) + +obj_Id <- c(2,4) + + +dif <- obj_Id - test2 + +Euclidean<- sqrt(sum(dif^2)) +print("Euclidean distance object 2 and 4") +print(Euclidean) + + + + + + + +test2 = c(3,3) + +obj_Id <- c(1,4) + + +dif <- obj_Id - test2 + +Euclidean<- sqrt(sum(dif^2)) +print("Euclidean distance of object 1 and 4") +print(Euclidean) + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.23/Ex2_23.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.23/Ex2_23.R new file mode 100644 index 00000000..9474a228 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.23/Ex2_23.R @@ -0,0 +1,23 @@ +x <- c(5,0,3,0,2,0,0,2,0,0) +y <- c(3,0,2,0,1,1,0,1,0,1) + + + +x_square<-sqrt(5^2+0^2+3^2+0^2+2^2+0^2+0^2+2^2+0^2+0^2) + + + +y_square<-sqrt(3^2+0^2+2^2+0^2+1^2+1^2+0^2+1^2+0^2+1^2) + + + + +Consine <- ((sum(x*y))/(x_square*y_square)) + + +##### Text Book answer is 0.94 +print(Consine) + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.6.1/Ex2_6.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.6.1/Ex2_6.R new file mode 100644 index 00000000..63298421 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.6.1/Ex2_6.R @@ -0,0 +1,5 @@ +Data <- c(30,36,47,50,52,52,56,60,63,70,70,110) + +print("Mean") + +print(paste("$",mean(Data))) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.7/Ex2_7.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.7/Ex2_7.R new file mode 100644 index 00000000..2f8f4c36 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.7/Ex2_7.R @@ -0,0 +1,3 @@ +Data <- c(30,36,47,50,52,52,56,60,63,70,70,110) +print("Median") +print(paste("$",median(Data))) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.8/Ex2_8.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.8/Ex2_8.R new file mode 100644 index 00000000..d5dc6428 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.8/Ex2_8.R @@ -0,0 +1,9 @@ +Data <- c(30,36,47,50,52,52,56,60,63,70,70,110) + +mode <- function(x) { + uni_value <- unique(x) + uni_value[which.max(tabulate(match(x, uni_value)))] +} + +print("Mode") +print(paste("$",mode(Data))) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.9/Ex2_9.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.9/Ex2_9.R new file mode 100644 index 00000000..e914a7b7 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH2/EX2.9/Ex2_9.R @@ -0,0 +1,13 @@ +Data <- c(30,36,47,50,52,52,56,60,63,70,70,110) + + +print("Mid range") + + +Mid_Range<- ((min(Data)+max(Data))/2) + +pr_mir<- Mid_Range + +print(paste("$",pr_mir)) + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.1/Ex3_1.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.1/Ex3_1.R new file mode 100644 index 00000000..67d97b6a --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.1/Ex3_1.R @@ -0,0 +1,8 @@ +Obs_fre <- c(250,50,200,1000) + +Exp_fre <-c(90,210,360,840) + +chi = sum((Obs_fre - Exp_fre)^2/(Exp_fre)) + + +print(chi) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.2/Ex3_2.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.2/Ex3_2.R new file mode 100644 index 00000000..809bfa97 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.2/Ex3_2.R @@ -0,0 +1,28 @@ +AllEle <- c(6,5,4,3,2) + +Hightech <-c(20,10,14,5,5) + + +E_AllEle <- sum(AllEle)/length(AllEle) + + +All<- paste("$",E_AllEle) + +print(All) + + + +E_Hightech <- sum(Hightech)/length(Hightech) + + +hi <-paste("$",E_Hightech) + +print(hi) + + +print("Covariance") + + +cov<- (sum(AllEle*Hightech)/length(AllEle))- (4*E_Hightech) + +print(cov) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.3/Ex3_3.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.3/Ex3_3.R new file mode 100644 index 00000000..d710269a --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.3/Ex3_3.R @@ -0,0 +1,4 @@ +AllEle <- c(1,1,5,5,5,5,5,8,8,10,10,10,10,12,14,14,14,15,15,15,15,15,15,18,18,18,18,18,18,18,18,20,20,20,20,20,20,20,21,21,21,21,25,25,25,25,25,28,28,30,30,30) + +hist(AllEle,main="Histogram for price", xlab="Price", ylab= "Count") + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.4/Ex3_4.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.4/Ex3_4.R new file mode 100644 index 00000000..2d7bed77 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.4/Ex3_4.R @@ -0,0 +1,9 @@ +Min <- 12000 +Max <- 98000 +Tra <- 73600 + + +Min_max_nor <- (Tra-Min)/(Max-Min) + +print("Min-Max Normalization") +print(Min_max_nor) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.5/Ex3_5.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.5/Ex3_5.R new file mode 100644 index 00000000..e50dc1dc --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.5/Ex3_5.R @@ -0,0 +1,9 @@ +Mean <- 54000 +std <- 16000 +Tra <- 73600 + + +Z_score_nor <- (Tra-Mean)/(std) + +print("Z-score Normalization") +print(Z_score_nor) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.6/Ex3_6.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.6/Ex3_6.R new file mode 100644 index 00000000..29db1d54 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH3/EX3.6/Ex3_6.R @@ -0,0 +1,20 @@ +decscale<- function (x) +{ + vect <- apply(abs(x), 2, max) + zvect <- ceiling(log10(vect)) + sc_fact <- 10^zvect + scale(x, center = TRUE, scale = sc_fact) +} + + +print(decscale(iris[,1:4])) + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.10/Ex4_10.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.10/Ex4_10.zip new file mode 100644 index 00000000..d06a5f48 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.10/Ex4_10.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.11/Ex4_11.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.11/Ex4_11.zip new file mode 100644 index 00000000..71b154f8 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.11/Ex4_11.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.13/Ex4_13.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.13/Ex4_13.zip new file mode 100644 index 00000000..3d19dfef Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.13/Ex4_13.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.3/Ex4_3.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.3/Ex4_3.R new file mode 100644 index 00000000..ecf0873e --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.3/Ex4_3.R @@ -0,0 +1,43 @@ + + +# Setup the dimension tables + + +Citytab <- data.frame(key=c("MY", "Ben", "TU", "HU", "GU"), + name=c("MYSORE", "Bengaluru", "Tumkur", "Hubballi", "Gulabarga"), + country=c("India", "India", "India", "India", "India")) + + +weektab <- data.frame(key=1:7, + desc=c("Mon", "Tue", "Wen", "Thu", "Fri", "Sat", "Sun")) + + +prodtab <- data.frame(key=c("Dal", "Sugar", "Rice"), price=c(50, 70, 40)) + + + +# Function to generate the Sales table + + +Totalsales <- function(Record_Size) { + + + location <- sample(Citytab$key, Record_Size, replace=T, prob=c(2,2,1,1,1)) + + week<- sample(weektab$key, Record_Size, replace=T) + + year <- sample(c(2017,2018), Record_Size, replace=T) + + product <- sample(prodtab$key, Record_Size, replace=T, prob=c(1, 5, 7)) + + sales <- data.frame(week=week, year=year, location=location, prod=product) +} + + + # create fact table of sales +Table_fact_sales <- Totalsales(100) + +print(Table_fact_sales) + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.4/Ex4_4.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..28085a19 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,100 @@ + + +# Setup the dimension tables + + +Citytab <- data.frame(key=c("MY", "Ben", "TU", "HU", "GU"), + name=c("MYSORE", "Bengaluru", "Tumkur", "Hubballi", "Gulabarga"), + country=c("India", "India", "India", "India", "India")) + + +weektab <- data.frame(key=1:7, + desc=c("Mon", "Tue", "Wen", "Thu", "Fri", "Sat", "Sun")) + + +prodtab <- data.frame(key=c("Dal", "Sugar", "Rice"), price=c(50, 70, 40)) + + + +# Function to generate the Sales table + + +Totalsales <- function(Record_Size) { + + + location <- sample(Citytab$key, Record_Size, replace=T, prob=c(2,2,1,1,1)) + + week<- sample(weektab$key, Record_Size, replace=T) + + year <- sample(c(2017,2018), Record_Size, replace=T) + + product <- sample(prodtab$key, Record_Size, replace=T, prob=c(1, 3, 2)) + + sales <- data.frame(week=week, year=year, location=location, product=product) +} + + + # create fact table of sales +Table_fact_sales <- Totalsales(20) + +print(Table_fact_sales) + + + + +Income <- tapply(Table_fact_sales$year, Table_fact_sales[,c("product", "week", "year")], FUN=function(x){return(sum(x))}) + + +print("Showing the cells of income") + +print(Income) + + +print("Slice") + +slice<- Income["Dal", "1",] + +print(slice) + + +print("Roll up") + +print(apply(Income, c("week", "year"), FUN=function(x) {return(sum(x, na.rm=TRUE))})) + + +print("Drill down") +print(apply(Income, c("week", "year", "product"), FUN=function(x) {return(sum(x, na.rm=TRUE))})) + + + +print("piot") +print(apply(Income, c("week", "year"), FUN=function(x) {return(sum(x, na.rm=TRUE))})) + +print(apply(Income, c("week", "product"), FUN=function(x) {return(sum(x, na.rm=TRUE))})) + + + +print("Dice") +print(Income[,c("1","2"),c("2017","2018")]) + + + + + + + + + + + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.6/Ex4_6.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.6/Ex4_6.R new file mode 100644 index 00000000..18c3f030 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.6/Ex4_6.R @@ -0,0 +1,49 @@ +library(sqldf) + +# dimension tables + + +Citytab <- data.frame(key=c("MY", "Ben", "TU", "HU", "GU"), + name=c("MYSORE", "Bengaluru", "Tumkur", "Hubballi", "Gulabarga"), + country=c("India", "India", "India", "India", "India")) + + +weektab <- data.frame(key=1:7, + desc=c("Mon", "Tue", "Wen", "Thu", "Fri", "Sat", "Sun")) + + +prodtab <- data.frame(key=c("Dal", "Sugar", "Rice"), price=c(50, 70, 40)) + + + +# Function to generate the Total Sales + + +Totalsales <- function(Record_Size) { + + + location <- sample(Citytab$key, Record_Size, replace=T, prob=c(2,2,1,1,1)) + + week<- sample(weektab$key, Record_Size, replace=T) + + year <- sample(c(2017,2018), Record_Size, replace=T) + + product <- sample(prodtab$key, Record_Size, replace=T, prob=c(1, 3, 2)) + + sales <- data.frame(week=week, year=year, location=location, product=product) +} + + + # create fact table of sales +Table_fact_sales <- Totalsales(20) + +###print(Table_fact_sales) + +print("Selecting Mysore location") + +sel<- sqldf("select * from Table_fact_sales where location = 'MY'") + +print(sel) + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.8/Ex4_8.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.8/Ex4_8.R new file mode 100644 index 00000000..14c76758 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.8/Ex4_8.R @@ -0,0 +1,10 @@ +library(sqldf) + +DataFrame <- data.frame(Seq = rep(10:20, each = 5),tra = rep(1:11,5)) + +SelQue <- sqldf("select Seq, tra from DataFrame +natural join (select Seq, avg(tra) as avg_tra from DataFrame group by Seq) +where tra> avg_tra") + + +print(SelQue) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.9/Ex4_9.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.9/Ex4_9.R new file mode 100644 index 00000000..c76937a2 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH4/EX4.9/Ex4_9.R @@ -0,0 +1,49 @@ +library(sqldf) + +# dimension tables + + +Citytab <- data.frame(key=c("MY", "Ben", "TU", "HU", "GU"), + name=c("MYSORE", "Bengaluru", "Tumkur", "Hubballi", "Gulabarga"), + country=c("India", "India", "India", "India", "India")) + + +weektab <- data.frame(key=1:7, + desc=c("Mon", "Tue", "Wen", "Thu", "Fri", "Sat", "Sun")) + + +prodtab <- data.frame(key=c("Dal", "Sugar", "Rice"), price=c(50, 70, 40)) + + + +# Function to generate the Total Sales + + +Totalsales <- function(Record_Size) { + + + location <- sample(Citytab$key, Record_Size, replace=T, prob=c(2,2,1,1,1)) + + week<- sample(weektab$key, Record_Size, replace=T) + + year <- sample(c(2017,2018), Record_Size, replace=T) + + product <- sample(prodtab$key, Record_Size, replace=T, prob=c(1, 3, 2)) + + sales <- data.frame(week=week, year=year, location=location, product=product) +} + + + # create fact table of sales +Table_fact_sales <- Totalsales(20) + +###print(Table_fact_sales) + +print("Selecting items group by Product") + +sel<- sqldf("select * from Table_fact_sales group by product") + +print(sel) + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.10/EX5_10.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.10/EX5_10.R new file mode 100644 index 00000000..09b09221 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.10/EX5_10.R @@ -0,0 +1,134 @@ +A <- c("a1","a1","a1","a2","a2") + +B <- c("b1","b2","b2","b1","b1") + +C <- c("c1","c1","c1","c1","c1") + + +D <- c("d1","d2","d1","d1","d1") + + +E <- c("e1","e1","e2","e2","e3") + +#####TID List########## + +print("Cuboid of AB") + +print("TID List of a1 and b1") +M1 <- which("a1" == A) +M2<- which("b1" == B) + +z1 <- Reduce(intersect, list(M1,M2)) + +print(length(z1)) + + +print("List size:") +print(length(z1)) + + +print("TID List of a1 and b2") + +M3 <- which("a1" == A) +M4<- which("b2" == B) + +z2 <- Reduce(intersect, list(M3,M4)) +print(z2) + +print("List size:") +print(length(z2)) + + +print("TID List of a2 and b1") + +M5 <- which("a2" == A) +M6<- which("b1" == B) + +z3 <- Reduce(intersect, list(M5,M6)) + +print(z3) + +print("List size:") +print(length(z3)) + +print("TID List of a2 and b2") + +M7 <- which("a2" == A) +M8<- which("b2" == B) + +z4 <- Reduce(intersect, list(M7,M8)) + +print(z4) + +print("List size:") +print(length(z4)) + + + +######################### + + + +print("Cuboid of DE") + +print("TID List of d1 and e1") +M11 <- which("d1" == D) +M12<- which("e1" == E) + +z11 <- Reduce(intersect, list(M11,M12)) + +print(length(z11)) + + +print("List size:") +print(length(z11)) + + +print("TID List of d1 and e2") +M13 <- which("d1" == D) +M14<- which("e2" == E) + +z12 <- Reduce(intersect, list(M13,M14)) + +print(length(z12)) + + +print("List size:") +print(length(z12)) + + + +print("TID List of d1 and e3") +M15 <- which("d1" == D) +M16<- which("e3" == E) + +z13 <- Reduce(intersect, list(M15,M16)) + +print(length(z13)) + + +print("List size:") +print(length(z13)) + + +print("TID List of d2 and e1") +M17 <- which("d2" == D) +M18<- which("e1" == E) + +z14 <- Reduce(intersect, list(M17,M18)) + +print(length(z14)) + + +print("List size:") +print(length(z14)) + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.11/EX5_11.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.11/EX5_11.R new file mode 100644 index 00000000..19b6640f --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.11/EX5_11.R @@ -0,0 +1,2 @@ + +print(cbind(TID=c(1,2,3,4,5),Item_count=c(5,3,8,5,2),SUM=c(70,10,20,40,30))) diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.14/Ex5_14.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.14/Ex5_14.zip new file mode 100644 index 00000000..33d539f2 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.14/Ex5_14.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.15/Ex5_15.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.15/Ex5_15.zip new file mode 100644 index 00000000..fefc0e7c Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.15/Ex5_15.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.16/Ex5_16.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.16/Ex5_16.zip new file mode 100644 index 00000000..9792f975 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.16/Ex5_16.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.9/EX5_9.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.9/EX5_9.R new file mode 100644 index 00000000..b2077586 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH5/EX5.9/EX5_9.R @@ -0,0 +1,137 @@ +A <- c("a1","a1","a1","a2","a2") + +B <- c("b1","b2","b2","b1","b1") + +C <- c("c1","c1","c1","c1","c1") + + +D <- c("d1","d2","d1","d1","d1") + + +E <- c("e1","e1","e2","e2","e3") + +#####TID List########## + +print("TID List of a1") +print(which("a1" == A)) + +print("TID List of a2") +print(which("a2" == A)) + +print("TID List of b1") +print(which("b1" == B)) + + +print("TID List of b2") +print(which("b2" == B)) + + + + +print("TID List of c1") +print(which("c1" == C)) + +print("TID List of d1") +print(which("d1" == D)) + + + +print("TID List of e1") +print(which("e1" == E)) + + +print("TID List e2") +print(which("e2" == E)) + + +print("TID List of e3") +print(which("e3" == E)) + +##### List Size############### + +a1 <-length(grep("a1", A)) + +print("List size of a1") +print(a1) + +a2 <-length(grep("a2", A)) + +print("List size of a2") + +print(a2) + +b1 <-length(grep("b1", B)) + + +print("List size of b1") +print(b1) + +b2 <-length(grep("b2", B)) + + +print("List size of b2") +print(b2) + + +c1 <-length(grep("c1", C)) + + +print("List size of c1") +print(c1) + + +d1 <-length(grep("d1", D)) + + +print("List size of d1") +print(d1) + + + + +d2 <-length(grep("d2", D)) + + +print("List size of d2") +print(d2) + + +e1 <-length(grep("e1", E)) + + +print("List size of e1") +print(e1) + + + +e2 <-length(grep("e2", E)) + + +print("List size of e2") +print(e2) + + + +e3 <-length(grep("e3", E)) + + +print("List size of e3") +print(e3) + + + + + + + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.2/Ex6_2.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.2/Ex6_2.zip new file mode 100644 index 00000000..10d95aad Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.2/Ex6_2.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.3/Ex6_3.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.3/Ex6_3.zip new file mode 100644 index 00000000..93819f7d Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.3/Ex6_3.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.4/Ex6_4.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.4/Ex6_4.zip new file mode 100644 index 00000000..2bf8a14c Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.4/Ex6_4.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.8/Ex6_8.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.8/Ex6_8.zip new file mode 100644 index 00000000..e0d7d2df Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.8/Ex6_8.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.9/EX6_9.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.9/EX6_9.R new file mode 100644 index 00000000..80c86fb5 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH6/EX6.9/EX6_9.R @@ -0,0 +1,13 @@ +library(arules) +Video <- c(4000,2000,3500,500) +Video_game <-c(4500,1500,3000,1000) + +cor <- sum((Video-Video_game)^2/Video_game) + + +print(cor) + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.1/EX7_1.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.1/EX7_1.R new file mode 100644 index 00000000..234d6e59 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.1/EX7_1.R @@ -0,0 +1,12 @@ +## Taken from arules package PDF +library(arules) + +data("Groceries") + +## Groceries contains a hierarchy stored in itemInfo + +Groceries_level2 <- aggregate(Groceries, by = "level2") + +inspect(Groceries_level2) + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.12/EX7_12.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.12/EX7_12.R new file mode 100644 index 00000000..bef535dd --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.12/EX7_12.R @@ -0,0 +1,20 @@ +library(arules) + +data("Adult") + +## find only frequent itemsets which do not contain small or large income + +items <- apriori(Adult, parameter = list(support= 0.001, conf=0.001, target="frequent")) + +close <-is.closed(items) + + +print(close) + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.13/EX7_13.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.13/EX7_13.R new file mode 100644 index 00000000..23176667 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.13/EX7_13.R @@ -0,0 +1,26 @@ +library(arules) + +data("Adult") + +sample <- sample(Adult, 10) + +## used Jaccard distance + +jaccard_dist <- dissimilarity(sample) + +hira_clu <- hclust(jaccard_dist , method = "ward.D2") + +plot(hira_clu, labels = FALSE, main = "Dendrogram") + + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.15/EX7_15.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.15/EX7_15.R new file mode 100644 index 00000000..03076fc2 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.15/EX7_15.R @@ -0,0 +1,28 @@ +library(arules) + +data("Adult") + +sample <- sample(Adult, 100) + + +sample1 <- apriori(Adult[1:50], parameter = list(support = 0.6)) +sample2 <- apriori(Adult[51:100], parameter = list(support = 0.6)) + + +combine_samples <- c(sample1, sample2) + + +print(duplicated(combine_samples)) + + + + + + + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.2/EX7_2.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.2/EX7_2.R new file mode 100644 index 00000000..5cc85467 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.2/EX7_2.R @@ -0,0 +1,14 @@ +library(arules) + +#### it demonstartes redundant rules and constraints (Example 7.8) + +data("Income") + + +Ass_rules <- apriori(Income, parameter = list(support = 0.5,conf=0.9)) + +inspect(rules[is.redundant(Ass_rules)]) + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.3/EX7_3.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.3/EX7_3.R new file mode 100644 index 00000000..b9ce4de3 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.3/EX7_3.R @@ -0,0 +1,16 @@ +library(arules) + + +### No rare Items in the dataset so I am showing other measure like significance of rules + + +data("Income") + + +Ass_rules <- apriori(Income, parameter = list(support = 0.5,conf=0.9)) + +interestMeasure(Ass_rules,measure = "hyperConfidence",transactions = Income) + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.6/EX7_6.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.6/EX7_6.R new file mode 100644 index 00000000..3057ad6f --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH7/EX7.6/EX7_6.R @@ -0,0 +1,18 @@ +library(arules) + + +### Complement Items from the dataset + + + +data("Adult") +rules <- apriori(Adult) + +InMe<- interestMeasure(rules, measure = "kulczynski",transactions = Adult) + + +print(InMe) + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.1/Ex8_1.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.1/Ex8_1.zip new file mode 100644 index 00000000..c6e49d2a Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.1/Ex8_1.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.10/Ex8_10.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.10/Ex8_10.R new file mode 100644 index 00000000..4c7a4e8d --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.10/Ex8_10.R @@ -0,0 +1,20 @@ +TP <- 90 + +FN <-210 + +FP <- 140 + +TN <- 9560 + + +Precision = TP/(TP+FP) + +print("Precision") + +print(Precision) + +Recall = TP/(TP+FN) + +print("Recall") + +print(Recall) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.11/Ex8_11.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.11/Ex8_11.R new file mode 100644 index 00000000..d190e95e --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.11/Ex8_11.R @@ -0,0 +1,15 @@ +library(ROCR) + +dataset<-data.frame(Pre=c(0.90,0.80,0.70,0.60,0.55,0.54,0.53,0.51,0.50,0.40),cls=c(1,1,0,1,1,0,0,0,1,0)) + + +predictions <- prediction(dataset$Pre, dataset$cls) + +model_perf <- performance(predictions,"tpr","fpr") + +plot(model_perf) + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.2/Ex8_2.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.2/Ex8_2.zip new file mode 100644 index 00000000..b4478da9 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.2/Ex8_2.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.3/Ex8_3.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.3/Ex8_3.zip new file mode 100644 index 00000000..aba985e4 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.3/Ex8_3.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.4/Ex8_4.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.4/Ex8_4.zip new file mode 100644 index 00000000..d4fa2a47 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.4/Ex8_4.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.6/Ex8_6.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.6/Ex8_6.zip new file mode 100644 index 00000000..044a41c8 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.6/Ex8_6.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.7/Ex8_7.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.7/Ex8_7.zip new file mode 100644 index 00000000..8b7cb698 Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.7/Ex8_7.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.8/Ex8_8.zip b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.8/Ex8_8.zip new file mode 100644 index 00000000..5b6ac66f Binary files /dev/null and b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.8/Ex8_8.zip differ diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.9/Ex8_9.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.9/Ex8_9.R new file mode 100644 index 00000000..acfca181 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH8/EX8.9/Ex8_9.R @@ -0,0 +1,19 @@ +TP <- 90 + +FN <-210 + +FP <- 140 + +TN <- 9560 + +Sensitivity= TP/(TP+FN) + +print("Sensitivity") + +print(Sensitivity) + +Specificity = TN/(FP+TN) + +print("Specificity") + +print(Specificity) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH9/EX9.1/Ex9_1.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH9/EX9.1/Ex9_1.R new file mode 100644 index 00000000..c2e3db53 --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH9/EX9.1/Ex9_1.R @@ -0,0 +1,25 @@ +### install.packages("neuralnet") + + +library(neuralnet) +library(MASS) +data <- Boston + + +## used learning rate 0.9 and one hidden layer + + + + +print(net.infert <- neuralnet(medv~nox+rm+age, learningrate = 0.9,data,hidden=1,act.fct="tanh")) + + + +prediction(net.infert) + + + + + + + diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH9/EX9.3/Ex9_3.R b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH9/EX9.3/Ex9_3.R new file mode 100644 index 00000000..87bdc07b --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/CH9/EX9.3/Ex9_3.R @@ -0,0 +1,30 @@ + + + +library(e1071) + + +C1 <- c(1,1,1,1,1,1,1) +C2 <- c(0,0,0,0,1,1,1) +C3 <- c(0,0,1,1,0,0,1) +C4 <- c(0,1,0,1,0,1,0) + +out <-c(0,0,0,1,0,1,0) + +Out1<-hamming.distance(C1, out) + +print(Out1) + + +Out2<-hamming.distance(C2, out) + +print(Out2) + +Out3<-hamming.distance(C3, out) + +print(Out3) + + +Out4<-hamming.distance(C4, out) + +print(Out4) \ No newline at end of file diff --git a/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/README.txt b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/README.txt new file mode 100644 index 00000000..c5f0f7bc --- /dev/null +++ b/Data_Mining:_Concepts_And_Techniques_by_Jiawei_Han,_Micheline_Kamber,_And_Jian_Pei/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Shankru Guggari +Course: Research Scholar +Branch: Computer Science And Engineering +College/Institute/Organization: Bms College Of Engineering, Bengaluru + +About The Book + +Book: Data Mining: Concepts And Techniques +Author: Jiawei Han, Micheline Kamber, And Jian Pei +Publisher: Morgan Kaufmann, Usa +Year Of Publication: 2011 +ISBN: 9780123814791 +Edition: 3 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.1/ex10_1.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.1/ex10_1.R.zip new file mode 100644 index 00000000..2e4fe7b8 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.1/ex10_1.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.10/ex10_10.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.10/ex10_10.R.zip new file mode 100644 index 00000000..097556ce Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.10/ex10_10.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.12/ex10_12.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.12/ex10_12.R new file mode 100644 index 00000000..84e204a9 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.12/ex10_12.R @@ -0,0 +1,5 @@ +c<-c(1,2,3,4,4,6) +r<-c(62,78,70,90,93,103) +mo<-lm(r ~ c) +mo +summary(mo) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.13/ex10_13.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.13/ex10_13.R.zip new file mode 100644 index 00000000..f5bc82aa Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.13/ex10_13.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.14/ex10_14.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.14/ex10_14.R new file mode 100644 index 00000000..2064299b --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.14/ex10_14.R @@ -0,0 +1,5 @@ +c<-c(1,2,3,4,4,6) +r<-c(62,78,70,90,93,103) +mo<-lm(r~c) +mo +predict(mo,interval = "prediction", level = 0.95) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.15/ex10_15.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.15/ex10_15.R new file mode 100644 index 00000000..51bcede4 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.15/ex10_15.R @@ -0,0 +1,7 @@ +gpa<-c(3.2,2.7,2.5,3.4,2.2) +x<-c(22,27,24,28,23) +sbs<-c(550,570,525,670,490) +dt<-data.frame("Student"=c("a","b","c","d","e"),"GPA"=gpa,"Age"=x,"State board scores"=sbs) +mo<-lm(dt$State.board.scores ~ dt$GPA +dt$Age) +mo +summary(mo) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.16/ex10_16.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.16/ex10_16.R new file mode 100644 index 00000000..51bcede4 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.16/ex10_16.R @@ -0,0 +1,7 @@ +gpa<-c(3.2,2.7,2.5,3.4,2.2) +x<-c(22,27,24,28,23) +sbs<-c(550,570,525,670,490) +dt<-data.frame("Student"=c("a","b","c","d","e"),"GPA"=gpa,"Age"=x,"State board scores"=sbs) +mo<-lm(dt$State.board.scores ~ dt$GPA +dt$Age) +mo +summary(mo) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.17/ex10_17.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.17/ex10_17.R new file mode 100644 index 00000000..51bcede4 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.17/ex10_17.R @@ -0,0 +1,7 @@ +gpa<-c(3.2,2.7,2.5,3.4,2.2) +x<-c(22,27,24,28,23) +sbs<-c(550,570,525,670,490) +dt<-data.frame("Student"=c("a","b","c","d","e"),"GPA"=gpa,"Age"=x,"State board scores"=sbs) +mo<-lm(dt$State.board.scores ~ dt$GPA +dt$Age) +mo +summary(mo) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.2/ex10_2.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.2/ex10_2.R.zip new file mode 100644 index 00000000..87de7b81 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.2/ex10_2.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.3/ex10_3.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.3/ex10_3.R.zip new file mode 100644 index 00000000..95f69d1d Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.3/ex10_3.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.4/ex10_4.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.4/ex10_4.R.zip new file mode 100644 index 00000000..b93ec271 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.4/ex10_4.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.5/ex10_5.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.5/ex10_5.R.zip new file mode 100644 index 00000000..2d9e64ee Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.5/ex10_5.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.6/ex10_6.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.6/ex10_6.R.zip new file mode 100644 index 00000000..03644ddb Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.6/ex10_6.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.7/ex10_7.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.7/ex10_7.R.zip new file mode 100644 index 00000000..64d5814c Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.7/ex10_7.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.8/ex10_8.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.8/ex10_8.R.zip new file mode 100644 index 00000000..7d195f4b Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.8/ex10_8.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.9/ex10_9.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.9/ex10_9.R.zip new file mode 100644 index 00000000..2e0ab294 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH10/EX10.9/ex10_9.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.1/ex11_1.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.1/ex11_1.R new file mode 100644 index 00000000..a87e5fc1 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.1/ex11_1.R @@ -0,0 +1,2 @@ +o<-c(32,28,16,14,10) +chisq.test(o) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.2/ex11_2.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.2/ex11_2.R.zip new file mode 100644 index 00000000..eda6e794 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.2/ex11_2.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.3/ex11_3.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.3/ex11_3.R.zip new file mode 100644 index 00000000..fd85cd7f Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.3/ex11_3.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.4/ex11_4.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.4/ex11_4.R.zip new file mode 100644 index 00000000..4da5ad2b Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.4/ex11_4.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.5/ex11_5.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.5/ex11_5.R new file mode 100644 index 00000000..8b599db4 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.5/ex11_5.R @@ -0,0 +1,7 @@ +u<-c(15,12,8,8,15,9,6,8,7) +m<-matrix(u,ncol=3,byrow = TRUE) +colnames(m)<-c("no college", "four year degree", "advanced college") +rownames(m)<-c("Urban","Suburban","Rural") +m<-as.table(m) +m +chisq.test(m) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.6/ex11_6.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.6/ex11_6.R new file mode 100644 index 00000000..b1227344 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.6/ex11_6.R @@ -0,0 +1,7 @@ +u<-c(10,9,8,13,16,12) +m<-matrix(u,ncol=3,byrow = TRUE) +colnames(m)<-c("low", "moderate", "high") +rownames(m)<-c("Male","Female") +m<-as.table(m) +m +chisq.test(m) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.7/ex11_7.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.7/ex11_7.R new file mode 100644 index 00000000..9ae8f266 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH11/EX11.7/ex11_7.R @@ -0,0 +1,7 @@ +u<-c(10,7,4,90,93,96) +m<-matrix(u,ncol=3,byrow = TRUE) +colnames(m)<-c("Airline 1", "Airline 2", "Airline 3") +rownames(m)<-c("Yes","No") +m<-as.table(m) +m +chisq.test(m) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.1/ex12_1.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.1/ex12_1.R new file mode 100644 index 00000000..f1ba8496 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.1/ex12_1.R @@ -0,0 +1,6 @@ +x<-data.frame("meal"=c(10,12,9,15,13),"exercise"=c(6,8,3,0,2),"diet"=c(5,9,12,8,4)) +mo<-c(x$meal,x$exercise,x$diet) +gr<-factor(rep(letters[1:3],each = 5)) +fit=aov(formula = mo ~ gr) +anova(fit) + diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.2/ex12_2.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.2/ex12_2.R new file mode 100644 index 00000000..c50a779c --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.2/ex12_2.R @@ -0,0 +1,5 @@ +x<-data.frame("tp"=c(7,14,32,19,10,11),"mf"=c(10,1,1,0,11,1),"bv"=c(1,12,1,9,1,11)) +mo<-c(x$tp,x$mf,x$bv) +gr<-factor(rep(letters[1:3],each = 6)) +fit=aov(formula = mo ~ gr) +anova(fit) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.3/ex12_3.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.3/ex12_3.R new file mode 100644 index 00000000..9f1e0d4e --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.3/ex12_3.R @@ -0,0 +1,10 @@ +me<-c(10,12,9,15,13) +ex<-c(6,8,3,0,2) +di<-c(5,9,12,8,4) +l<-c(me,ex,di) +fa<-factor(rep(c("meat","exercise","diet"),15)) +pr=factor(rep(1:15, rep(3, 15))) +d<-data.frame(l,fa,pr) +fml<- aov(d$l ~ d$fa + d$pr, data = d) +library(DescTools) +ScheffeTest(x=fml) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.4/ex12_4.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.4/ex12_4.R new file mode 100644 index 00000000..fd85cd24 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.4/ex12_4.R @@ -0,0 +1,9 @@ +me<-c(10,12,9,15,13) +ex<-c(6,8,3,0,2) +di<-c(5,9,12,8,4) +l<-c(me,ex,di) +fa<-factor(rep(c("meat","exercise","diet"),15)) +pr=factor(rep(1:15, rep(3, 15))) +d<-data.frame(l,fa,pr) +a1<- aov(d$l ~ d$fa + d$pr) +TukeyHSD(x=a1,"d$fa", conf.level=0.95) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.5/ex12_5.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.5/ex12_5.R new file mode 100644 index 00000000..9572c161 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH12/EX12.5/ex12_5.R @@ -0,0 +1,7 @@ +ss<-c(26.7,25.2,32.3,32.8,28.6,29.3,26.1,24.2) +gas<-factor(c("reg","reg","ho","ho","reg","reg","ho","ho")) +auto<-factor(c("tw","tw","tw","tw","fw","fw","fw","fw")) +dat<-data.frame("value"=ss,"Gas"=gas,"Automobile"=auto) +dat +results<-lm(dat$value ~ dat$Gas + dat$Automobile + dat$Gas*dat$Automobile, data=dat) +anova(results) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.1/ex13_1.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.1/ex13_1.R new file mode 100644 index 00000000..cafd0490 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.1/ex13_1.R @@ -0,0 +1,4 @@ +x<-c(18,43,40,16,22,30,29,32,37,36,39,34,39,45,28,36,40,34,39,52) +a=0.05 +SIGN.test(x) +#package BSDA to be downloaded for SIGN.test \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.10/ex13_10.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.10/ex13_10.R new file mode 100644 index 00000000..699a6c30 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.10/ex13_10.R @@ -0,0 +1,5 @@ +d<-c(18, 36, 19, 22, 25, 44, 23, 27, 27, 35, 19, 43, 37, 32, 28, 43, 46, 19, 20, 22) +runs.test(d) +l<-paste("Since there are 9 runs between 5 and 15, the null hypothesis is not rejected.") +l +#snpar package to be downloaded for runs.test \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.2/ex13_2.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.2/ex13_2.R.zip new file mode 100644 index 00000000..a5df3d86 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.2/ex13_2.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.3/ex13_3.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.3/ex13_3.R new file mode 100644 index 00000000..82817b84 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.3/ex13_3.R @@ -0,0 +1,4 @@ +x<-c(3,0,5,4,2,4,3,5,2,1) +y<-c(2,1,4,0,1,3,1,3,2,3) +SIGN.test(x,y) +#package BSDA to be downloaded for SIGN.test \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.4/ex13_4.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.4/ex13_4.R.zip new file mode 100644 index 00000000..3062383e Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.4/ex13_4.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.5/ex13_5.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.5/ex13_5.R.zip new file mode 100644 index 00000000..572bb2cf Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.5/ex13_5.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.6/ex13_6.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.6/ex13_6.R new file mode 100644 index 00000000..213e1da5 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.6/ex13_6.R @@ -0,0 +1,4 @@ +a<-c(4.7,3.2,5.1,5.2,5.0) +b<-c(5.3,6.4,7.3,6.8,7.2) +c<-c(6.3,8.2,6.2,7.1,6.6) +kruskal.test(list(a,b,c)) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.7/ex13_7.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.7/ex13_7.R.zip new file mode 100644 index 00000000..4fb45cb4 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH13/EX13.7/ex13_7.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.1/ex2_1.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.1/ex2_1.R new file mode 100644 index 00000000..86b0f060 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.1/ex2_1.R @@ -0,0 +1,4 @@ +a<-c("A","B","B","AB","O","O","B","AB","B","B","B","O","A","O","A","O","O","O","AB","AB","A","O","B","A","O") +results<-table(a) +results +results/length(a)*100 \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.10/ex2_10.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.10/ex2_10.R new file mode 100644 index 00000000..e71abc57 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.10/ex2_10.R @@ -0,0 +1,4 @@ +damage<-c(2.8, 3.3, 3.4, 5.0, 8.5) +ts(damage, start=2001, end= 2005) +names(damage)<-c("2001", "2002", "2003", "2004", "2005") +plot.ts(damage,xlab="Year",ylab="Damage(in millions)") \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.11/ex2_11.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.11/ex2_11.R new file mode 100644 index 00000000..c1f87ca0 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.11/ex2_11.R @@ -0,0 +1,7 @@ +snacks<-c(11.200, 8.200, 4.300, 3.800, 2.500) +food<-c("Potato chips", "Tortilla chips", "Pretzels", "Popcorn", "Snack Nuts") +pct <- round(snacks/sum(snacks)*100, digits = 1)# round off to one decimal place +pct +food <- paste(food,"(", pct, ")") +food <- paste(food,"%",sep="") +pie(snacks, labels=food, main="Amount of food eaten during super bowl") \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.12/ex2_12.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.12/ex2_12.zip new file mode 100644 index 00000000..2e38aa19 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.12/ex2_12.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.13/ex2_13.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.13/ex2_13.zip new file mode 100644 index 00000000..a40b2861 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.13/ex2_13.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.14/ex2_14.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.14/ex2_14.zip new file mode 100644 index 00000000..25700f91 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.14/ex2_14.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.15/ex2_15.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.15/ex2_15.zip new file mode 100644 index 00000000..cda47832 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.15/ex2_15.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.2/ex2_2.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.2/ex2_2.R new file mode 100644 index 00000000..55acd1cc --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.2/ex2_2.R @@ -0,0 +1,13 @@ +mpg<-c(112,110,107,116,120,100,118,112,108,113,127,117,114,110,120,120,116,115,121,117,134,118,118,113,105,118,122,117,120,110,105,114,118,119,118,110,114,122,111,112,109,105,106,104,114,112,109,110,111,114) +H = max(mpg) +L = min(mpg) +cat("Maximum value is: ", H) +cat("Minimum value is: ", L) +Range = H - L +cat("Range is: ", Range) +cat("\n") +breaks= seq(99.5,134.5, by=5) +mpg.div=cut(mpg, breaks, right=TRUE) +mpg.freq=table(mpg.div) +table<-data.frame(mpg.freq) +table diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.3/ex2_3.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.3/ex2_3.R new file mode 100644 index 00000000..9f97d83c --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.3/ex2_3.R @@ -0,0 +1,19 @@ +mpg<-c(12, 17, 12, 14, 16, 18, 16, 18, 12, 16, 17, 15, 15, 16, 12, 15, 16, 16, 12, 14, 15, 12, 15, 15, 19, 13, 16, 18, 16, 14) +H = max(mpg) +L = min(mpg) +cat("Maximum value is: ", H) +cat("\n") +cat("Minimum value is: ", L) +cat("\n") +Range = H - L +cat("Range is: ", Range) +cat("\n") +breaks= seq(12, 20, by=1) +mpg.div=cut(mpg, breaks, right=FALSE) +mpg.freq=table(mpg.div) +table<-data.frame(mpg.freq) +table +#for cumulative frequency +mpg.cumfreq = cumsum(mpg.freq) +tbl<-data.frame(mpg.cumfreq) +tbl diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.4/ex2_4.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.4/ex2_4.R new file mode 100644 index 00000000..3b4b57bf --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.4/ex2_4.R @@ -0,0 +1,7 @@ +temp<-c(112, 100, 127, 120, 134, 118, 105, 110, 109, 112, 110, 118, 117, 116, 118, 122, 114, 114, 105, 109, 107, 112, 114, 115, 118, 117, 118, 122, 106, 110, 116, 108, 110, 121, 113, 120, 119, 111, 104, 111, 120, 113, 120, 117, 105, 110, 118, 112, 114, 114) +H = max(temp) +L = min(temp) +Range = H - L +Width = ceiling(Range/7) +#though the question specifies lower limit as 99.5 and upper limit as 134.5, the considered upper and lower limits are 100 and 135 +hist(temp,main="Histogram of Recorded Temparatures",xlab="temparature",border="red",col="yellow",xlim=c(100,135),las=1,breaks=Width) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.5/ex2_5.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.5/ex2_5.R new file mode 100644 index 00000000..50ec54ed --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.5/ex2_5.R @@ -0,0 +1,8 @@ +temp<-c(112, 100, 127, 120, 134, 118, 105, 110, 109, 112, 110, 118, 117, 116, 118, 122, 114, 114, 105, 109, 107, 112, 114, 115, 118, 117, 118, 122, 106, 110, 116, 108, 110, 121, 113, 120, 119, 111, 104, 111, 120, 113, 120, 117, 105, 110, 118, 112, 114, 114) +H = max(temp) +L = min(temp) +Range = H - L +Width = ceiling(Range/7) +#using package "mosaic" +library(mosaic) +freqpoly(temp) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.6/ex2_6.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.6/ex2_6.R new file mode 100644 index 00000000..4d30e6f4 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.6/ex2_6.R @@ -0,0 +1,10 @@ +temp<-c(112, 100, 127, 120, 134, 118, 105, 110, 109, 112, 110, 118, 117, 116, 118, 122, 114, 114, 105, 109, 107, 112, 114, 115, 118, 117, 118, 122, 106, 110, 116, 108, 110, 121, 113, 120, 119, 111, 104, 111, 120, 113, 120, 117, 105, 110, 118, 112, 114, 114) +H = max(temp) +L = min(temp) +Range = H - L +Width = ceiling(Range/7) +#installed package agricolae +library(agricolae) +#since the histogram division is from 100 to 135, ther is a shift in the ogive curve, when compared with the original +temp.h=hist(temp,main="Histogram of Recorded Temparatures",xlab="temparature",border="red",col="yellow",xlim=c(100,135),las=1,breaks=7) +ogive.freq(temp.h, xlab="temparature", ylab="relative cumulative frequency") \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.7/ex2_7.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.7/ex2_7.R new file mode 100644 index 00000000..669c7643 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.7/ex2_7.R @@ -0,0 +1,14 @@ +fr<-c(6,11,11,17,17,17,22,22,22,22,22,27,27,27,27,32,32,32,37,37) +H=40.5 +L=5.5 +Range = H - L +Width = ceiling(Range/7) +#though the question specifies lower limit as 99.5 and upper limit as 134.5, the considered upper and lower limits are 100 and 135 +fr.h=hist(fr,main="Histogram of Recorded Temparatures",xlab="temparature",border="red",col="yellow",xlim=c(5,41),las=1,breaks=Width) +fr.h +#using package "mosaic" +library(mosaic) +freqpoly(fr) +library(agricolae) +ogive.freq(fr.h, xlab="miles", ylab="relative cumulative frequency") +#install package "agricolae" \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.8/ex2_8.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.8/ex2_8.R new file mode 100644 index 00000000..90799eac --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.8/ex2_8.R @@ -0,0 +1,4 @@ +#bar plot construction +amount<-c(728, 344, 141, 72) +barplot(amount, main="Expenditure of a first year college student", xlab="expenditure", ylab="amount", names.arg =c("electronics", "dorm decor", "clothing", "shoes"), border="green") +barplot(amount, main="Expenditure of a first year college student", xlab="expenditure", ylab="amount", names.arg =c("electronics", "dorm decor", "clothing", "shoes"), border="green", horiz=TRUE) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.9/ex2_9.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.9/ex2_9.R new file mode 100644 index 00000000..2e4df245 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH2/EX2.9/ex2_9.R @@ -0,0 +1,5 @@ +tp<-c(2.9, 4.3, 6, 3.8, 5.8) +names(tp)<-c("Indiana","Oklahoma","Florida","Maine","Pennysylvania") +#install package qcc that contains pareto chart +library(qcc) +pareto.chart(tp, xlab="States", ylab="Number of Turnpikes", main="Turnpike Distribution", col="blue") diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.1/ex3_1.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.1/ex3_1.zip new file mode 100644 index 00000000..4b53badd Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.1/ex3_1.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.10/ex3_10.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.10/ex3_10.zip new file mode 100644 index 00000000..b6f92796 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.10/ex3_10.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.11/ex3_11.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.11/ex3_11.zip new file mode 100644 index 00000000..5b9756de Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.11/ex3_11.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.12/ex3_12.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.12/ex3_12.zip new file mode 100644 index 00000000..94d6685d Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.12/ex3_12.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.13/ex3_13.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.13/ex3_13.zip new file mode 100644 index 00000000..b1338301 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.13/ex3_13.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.14/ex3_14.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.14/ex3_14.zip new file mode 100644 index 00000000..0e85a673 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.14/ex3_14.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.15/ex3_15.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.15/ex3_15.zip new file mode 100644 index 00000000..5da6762c Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.15/ex3_15.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.16/ex3_16.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.16/ex3_16.zip new file mode 100644 index 00000000..47cdc9eb Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.16/ex3_16.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.17/ex3_17.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.17/ex3_17.zip new file mode 100644 index 00000000..14e24230 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.17/ex3_17.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.18/ex3_18.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.18/ex3_18.zip new file mode 100644 index 00000000..799ce921 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.18/ex3_18.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.19/ex3_19.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.19/ex3_19.zip new file mode 100644 index 00000000..113e6a8a Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.19/ex3_19.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.2/ex3_2.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.2/ex3_2.zip new file mode 100644 index 00000000..366da90e Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.2/ex3_2.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.20/ex3_20.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.20/ex3_20.zip new file mode 100644 index 00000000..a2597b48 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.20/ex3_20.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.21/ex3_21.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.21/ex3_21.zip new file mode 100644 index 00000000..4d947b90 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.21/ex3_21.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.22/ex3_22.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.22/ex3_22.zip new file mode 100644 index 00000000..6e52b37f Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.22/ex3_22.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.23/ex3_23.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.23/ex3_23.zip new file mode 100644 index 00000000..0bb5efaf Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.23/ex3_23.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.24/ex3_24.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.24/ex3_24.zip new file mode 100644 index 00000000..eac627d1 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.24/ex3_24.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.25/ex3_25.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.25/ex3_25.zip new file mode 100644 index 00000000..0d8e6912 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.25/ex3_25.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.26/ex3_26.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.26/ex3_26.zip new file mode 100644 index 00000000..42833ba6 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.26/ex3_26.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.27/ex3_27.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.27/ex3_27.zip new file mode 100644 index 00000000..acd2d9b6 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.27/ex3_27.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.28/ex3_28.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.28/ex3_28.zip new file mode 100644 index 00000000..ddc5dcb9 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.28/ex3_28.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.29/ex3_29.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.29/ex3_29.zip new file mode 100644 index 00000000..d9931915 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.29/ex3_29.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.3/ex3_3.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.3/ex3_3.zip new file mode 100644 index 00000000..ca18cf1b Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.3/ex3_3.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.30/ex3_30.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.30/ex3_30.zip new file mode 100644 index 00000000..6e3366ce Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.30/ex3_30.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.31/ex3_31.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.31/ex3_31.zip new file mode 100644 index 00000000..072f0a1d Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.31/ex3_31.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.32/ex3_32.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.32/ex3_32.zip new file mode 100644 index 00000000..81fdb0aa Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.32/ex3_32.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.33/ex3_33.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.33/ex3_33.zip new file mode 100644 index 00000000..badbabbc Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.33/ex3_33.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.34/ex3_34.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.34/ex3_34.zip new file mode 100644 index 00000000..ff3edbb4 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.34/ex3_34.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.35/ex3_35.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.35/ex3_35.zip new file mode 100644 index 00000000..74717fa0 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.35/ex3_35.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.36/ex3_36.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.36/ex3_36.zip new file mode 100644 index 00000000..bfe1b287 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.36/ex3_36.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.37/ex3_37.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.37/ex3_37.zip new file mode 100644 index 00000000..b2deb184 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.37/ex3_37.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.38/ex3_38.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.38/ex3_38.zip new file mode 100644 index 00000000..61f8caf0 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.38/ex3_38.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.39/ex3_39.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.39/ex3_39.zip new file mode 100644 index 00000000..d77b53c4 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.39/ex3_39.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.4/ex3_4.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.4/ex3_4.zip new file mode 100644 index 00000000..dd9d72a4 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.4/ex3_4.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.5/ex3_5.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.5/ex3_5.zip new file mode 100644 index 00000000..495bb839 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.5/ex3_5.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.6/ex3_6.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.6/ex3_6.zip new file mode 100644 index 00000000..5b743872 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.6/ex3_6.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.7/ex3_7.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.7/ex3_7.zip new file mode 100644 index 00000000..c796472c Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.7/ex3_7.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.8/ex3_8.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.8/ex3_8.zip new file mode 100644 index 00000000..b7108748 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.8/ex3_8.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.9/ex3_9.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.9/ex3_9.zip new file mode 100644 index 00000000..14ca2fd8 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH3/EX3.9/ex3_9.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.11/ex4_11.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.11/ex4_11.zip new file mode 100644 index 00000000..56e688ac Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.11/ex4_11.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.12/ex4_12.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.12/ex4_12.zip new file mode 100644 index 00000000..3daaf191 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.12/ex4_12.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.13/ex4_13.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.13/ex4_13.zip new file mode 100644 index 00000000..81359a60 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.13/ex4_13.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.14/ex4_14.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.14/ex4_14.zip new file mode 100644 index 00000000..aefde72a Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.14/ex4_14.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.17/ex4_17.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.17/ex4_17.R new file mode 100644 index 00000000..21b307df --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.17/ex4_17.R @@ -0,0 +1,4 @@ +dough<-c(3,4,5) #glazed,jelly and chocolate doughnuts respectively +pr<-(dough[3]+dough[1])/sum(dough) +n<-paste("the answer is",round(pr,digits=2)) +n diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.18/ex4_18.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.18/ex4_18.zip new file mode 100644 index 00000000..bd5bdf84 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.18/ex4_18.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.19/ex4_19.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.19/ex4_19.zip new file mode 100644 index 00000000..8a91cf13 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.19/ex4_19.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.20/ex4_20.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.20/ex4_20.zip new file mode 100644 index 00000000..f78b9235 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.20/ex4_20.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.21/ex4_21.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.21/ex4_21.R new file mode 100644 index 00000000..1afe223f --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.21/ex4_21.R @@ -0,0 +1,8 @@ +designation<-c(8,5) +gender<-c(10,3) +repnf<-7 +reppf<-3 +repnm<-designation[1]-repnf +pr<-(designation[1]+gender[2]-repnm)/sum(designation) +n<-paste("The probability that selected staff is",round(pr, digits=2)) +n \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.22/ex4_22.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.22/ex4_22.R new file mode 100644 index 00000000..810d5a2a --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.22/ex4_22.R @@ -0,0 +1,6 @@ +p1<-0.32 +p2<-0.09 +p3<-0.06 +pr<-p1+p2-p3 +n<-paste("probability of having an accident while intoxicated or driving is",pr) +n \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.23/ex4_23.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.23/ex4_23.zip new file mode 100644 index 00000000..769f4571 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.23/ex4_23.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.24/ex4_24.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.24/ex4_24.zip new file mode 100644 index 00000000..7c3b4d4a Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.24/ex4_24.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.25/ex4_25.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.25/ex4_25.zip new file mode 100644 index 00000000..12c86cc4 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.25/ex4_25.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.26/ex4_26.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.26/ex4_26.zip new file mode 100644 index 00000000..efd96f13 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.26/ex4_26.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.27/ex4_27.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.27/ex4_27.R new file mode 100644 index 00000000..fc57ee17 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.27/ex4_27.R @@ -0,0 +1,4 @@ +pr<-0.09 +ne<-3 +lbs<-paste("The probability is",(pr^ne)) +lbs \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.28/ex4_28.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.28/ex4_28.R new file mode 100644 index 00000000..94442a7f --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.28/ex4_28.R @@ -0,0 +1,8 @@ +c1=5 +c2=16 +c3=32 +t=c1+c2+c3 +c21=c2-1 +p=(c2/t)*(c21/(t-1)) +l<-paste("the probability that both will have occurred in 2004 is",p) +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.29/ex4_29.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.29/ex4_29.R new file mode 100644 index 00000000..94d59fb2 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.29/ex4_29.R @@ -0,0 +1,4 @@ +a=0.53 +h=0.27 +l<-paste("the probability that both will have occurred in 2004 is",a*h) +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.30/ex4_30.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.30/ex4_30.R new file mode 100644 index 00000000..7a8b8ed0 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.30/ex4_30.R @@ -0,0 +1,8 @@ +l<-paste("Probability of getting three jacks is",(4/52)*(3/51)*(2/50)) +l +l<-paste("Probability of getting an ace, a king, and a queen in order is",(4/52)*(4/51)*(4/50)) +l +l<-paste("Probability of getting a club, a spade, and a heart in order is",(13/52)*(13/51)*(13/50)) +l +l<-paste("Probability of getting three clubs is",(13/52)*(12/51)*(11/50)) +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.42/ex4_42.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.42/ex4_42.R new file mode 100644 index 00000000..a2a4e4c4 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.42/ex4_42.R @@ -0,0 +1,2 @@ +l<-paste("There are",factorial(5),"different possible rankings") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.43/ex4_43.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.43/ex4_43.R new file mode 100644 index 00000000..c63094a6 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.43/ex4_43.R @@ -0,0 +1,4 @@ +n=5 +r=3 +l<-paste("There are",factorial(n)/factorial(n-r),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.44/ex4_44.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.44/ex4_44.R new file mode 100644 index 00000000..3c4d505f --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.44/ex4_44.R @@ -0,0 +1,4 @@ +n=8 +r=3 +l<-paste("There are",factorial(n)/factorial(n-r),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.45/ex4_45.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.45/ex4_45.R new file mode 100644 index 00000000..16e3e5a0 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.45/ex4_45.R @@ -0,0 +1,4 @@ +n=9 +r=2 +l<-paste("There are",factorial(n)/factorial(n-r),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.47/ex4_47.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.47/ex4_47.R new file mode 100644 index 00000000..d81c66de --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.47/ex4_47.R @@ -0,0 +1,4 @@ +n=4 +r=2 +l<-paste("There are",choose(n,r),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.48/ex4_48.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.48/ex4_48.R new file mode 100644 index 00000000..fce76bfb --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.48/ex4_48.R @@ -0,0 +1,4 @@ +n=8 +r=3 +l<-paste("There are",choose(n,r),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.49/ex4_49.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.49/ex4_49.R new file mode 100644 index 00000000..27ae91fb --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.49/ex4_49.R @@ -0,0 +1,6 @@ +n1=5 +n2=7 +r1=2 +r2=3 +l<-paste("There are",choose(n1,r1)*choose(n2,r2),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.5/ex4_5.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.5/ex4_5.zip new file mode 100644 index 00000000..5f919b45 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.5/ex4_5.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.50/ex4_50.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.50/ex4_50.R new file mode 100644 index 00000000..9fc24e89 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.50/ex4_50.R @@ -0,0 +1,6 @@ +n1=4 +n2=52 +r1=4 +r2=5 +l<-paste("Probability is",48*choose(n1,r1)/choose(n2,r2)) +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.a/ex4_51a.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.a/ex4_51a.R new file mode 100644 index 00000000..81801617 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.a/ex4_51a.R @@ -0,0 +1,8 @@ +n1=4 +n2=20 +n3=24 +r1=2 +r2=2 +r3=4 +l<-paste("There are",choose(n1,r1)*choose(n2,r2)/choose(n3,r3),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.b/ex4_51b.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.b/ex4_51b.R new file mode 100644 index 00000000..9a8bb20d --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.b/ex4_51b.R @@ -0,0 +1,6 @@ +n1=20 +n2=24 +r1=4 +r2=4 +l<-paste("There are",choose(n1,r1)/choose(n2,r2),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.c/ex4_51c.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.c/ex4_51c.R new file mode 100644 index 00000000..f12d9801 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.c/ex4_51c.R @@ -0,0 +1,4 @@ +n1=24 +r1=4 +l<-paste("There are",1/choose(n1,r1),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.d/ex4_51d.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.d/ex4_51d.R new file mode 100644 index 00000000..65410884 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.51.d/ex4_51d.R @@ -0,0 +1,6 @@ +n1=20 +n2=24 +r1=4 +r2=4 +l<-paste("There are",1-(choose(n1,r1)/choose(n2,r2)),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.52/ex4_52.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.52/ex4_52.R new file mode 100644 index 00000000..5749d79b --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.52/ex4_52.R @@ -0,0 +1,8 @@ +n1=6 +n2=8 +n3=14 +r1=1 +r2=1 +r3=2 +l<-paste("There are",choose(n1,r1)*choose(n2,r2)/choose(n3,r3),"different ways") +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.6/ex4_6.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.6/ex4_6.zip new file mode 100644 index 00000000..470d12b0 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.6/ex4_6.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.7/ex4_7.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.7/ex4_7.zip new file mode 100644 index 00000000..e7413925 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.7/ex4_7.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.8/ex4_8.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.8/ex4_8.zip new file mode 100644 index 00000000..1ef841c7 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.8/ex4_8.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.9/ex4_9.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.9/ex4_9.zip new file mode 100644 index 00000000..545479dd Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH4/EX4.9/ex4_9.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.1/ex5_1.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.1/ex5_1.zip new file mode 100644 index 00000000..1e3b04d5 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.1/ex5_1.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.10/ex5_10.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.10/ex5_10.R new file mode 100644 index 00000000..6b3bf0a3 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.10/ex5_10.R @@ -0,0 +1,7 @@ +out<-c(3,4,5) +pr<-c(2/5,1/5,2/5) +mea<-weighted.mean(out,pr) +v<-round(sum(out*out*pr),digits=1)-(round(mea,digits=1)*round(mea,digits=1)) +sd<-round(sqrt(v),digits=1) +n<-paste("the variance and standard deviation of the probability distribution is",round(v,digits=1),"and",sd,"respectively") +n \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.11/ex5_11.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.11/ex5_11.R new file mode 100644 index 00000000..8a192e47 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.11/ex5_11.R @@ -0,0 +1,12 @@ +out<-c(0,1,2,3,4) +pr<-c(0.18, 0.34, 0.23, 0.21, 0.04) +mea<-weighted.mean(out,pr) +v<-round(sum(out*out*pr),digits=1)-(round(mea,digits=1)*round(mea,digits=1)) +sd<-round(sqrt(v),digits=1) +round(v,digits=1) +n<-paste("the variance and standard deviation of the probability distribution is",round(v,digits=1),"and",sd,"respectively") +n +k=2 +ct<-round(mea,digits=1)+(k*round(sd,digits=1)) +f<-paste("Most calls will be accomodated by",round(ct),"phone lines") +f \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.12/ex5_12.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.12/ex5_12.R new file mode 100644 index 00000000..bd29a3c9 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.12/ex5_12.R @@ -0,0 +1,5 @@ +gain<-c(350,-1)#win and lose +pr<-c(0.001,0.999) +e<-weighted.mean(gain,pr) +n<-paste("the expectation of the event is",e) +n \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.13/ex5_13.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.13/ex5_13.R new file mode 100644 index 00000000..71e157ea --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.13/ex5_13.R @@ -0,0 +1,5 @@ +gain<-c(98,48,23,8,-2)#win and lose +pr<-c(0.002,0.002,0.002,0.002,0.992) +e<-weighted.mean(gain,pr) +n<-paste("the expectation of the event is",e) +n diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.14/ex5_14.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.14/ex5_14.R new file mode 100644 index 00000000..96d04ada --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH5/EX5.14/ex5_14.R @@ -0,0 +1,15 @@ +principle<-c(5000) +r1<-c(0.04) +r2<-c(0.025) +dr1<-c(0.02) +dr2<-c(0.01) +a<-((principle*r1)*(1-dr1))-(principle*dr1) +b<-((principle*r2)*(1-dr2))-(principle*dr2) +a +b +if (a>b) + s<-paste("Bond X brings more returns") +if(ar2){lb<-paste(max(g),"is a outliner"); +lb}else{print("no outliner")} diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.12/ex6_12.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.12/ex6_12.R new file mode 100644 index 00000000..4a58c028 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.12/ex6_12.R @@ -0,0 +1,12 @@ +g<-c(81,148,152,135,151,152,159,142,34,162,130,162,163,143,67,112,70) +#since the formula for skewness in the inbuilt is not the same as in textbook, using manual methods +sk=3*(mean(g)-median(g))/sd(g) +l<-paste("Skewness is",round(sk,3)) +l +iqr<-IQR(g,type = 2) +q1<-quantile(g,0.25,type = 2) +q3<-quantile(g,0.75, type = 2) +r1=q1-(1.5*iqr) +r2=q3+(1.5*iqr) +if(max(g)>r2){lb<-paste(max(g),"is a outliner"); +lb}else{print("no outliner")} diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.13/ex6_13.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.13/ex6_13.R.zip new file mode 100644 index 00000000..b40b5d45 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.13/ex6_13.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.14/ex6_14.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.14/ex6_14.R.zip new file mode 100644 index 00000000..5fb3528b Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.14/ex6_14.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.15/ex6_15.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.15/ex6_15.R new file mode 100644 index 00000000..e395e61d --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.15/ex6_15.R @@ -0,0 +1,10 @@ +x=224 +m=218.4 +s=25 +n=40 +z1=(x-m)/s +l<-paste("the probability that a person selected at random consumes less than 224 pounds per year is",round(pnorm(z1)*100,1),"%") +l +z2=(x-m)/(s/sqrt(n)) +l<-paste("the probability that the mean of a sample of 40 individuals is less than 224 pounds per year is",round(pnorm(z2)*100,1),"%") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.16/ex6_16.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.16/ex6_16.R.zip new file mode 100644 index 00000000..500d4fbf Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.16/ex6_16.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.17/ex6_17.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.17/ex6_17.R.zip new file mode 100644 index 00000000..6fa9b5b5 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.17/ex6_17.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.18/ex6_18.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.18/ex6_18.R.zip new file mode 100644 index 00000000..836ed401 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.18/ex6_18.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.19/ex6_19.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.19/ex6_19.R.zip new file mode 100644 index 00000000..406a28cb Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.19/ex6_19.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.2/ex6_2.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.2/ex6_2.R.zip new file mode 100644 index 00000000..d84ae08d Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.2/ex6_2.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.3/ex6_3.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.3/ex6_3.R.zip new file mode 100644 index 00000000..125ba84e Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.3/ex6_3.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.a/ex6_4a.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.a/ex6_4a.R.zip new file mode 100644 index 00000000..64fc1c0f Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.a/ex6_4a.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.b/ex6_4b.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.b/ex6_4b.R.zip new file mode 100644 index 00000000..bbdcd8f2 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.b/ex6_4b.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.c/ex6_4c.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.c/ex6_4c.R.zip new file mode 100644 index 00000000..b7e25332 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.4.c/ex6_4c.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.6/ex6_6.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.6/ex6_6.R.zip new file mode 100644 index 00000000..a0e14069 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.6/ex6_6.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.7/ex6_7.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.7/ex6_7.R new file mode 100644 index 00000000..74025dbb --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.7/ex6_7.R @@ -0,0 +1,12 @@ +X1=27 +X2=31 +X3=30.2 +m=28 +sd=2 +z3=round((X3-m)/sd,2) +z1=round((X1-m)/sd,2) +g<-paste(round((1-pnorm(z3))*100,2),"% is the probability that a randomly selected household generates More than 30.2 pounds per month") +g +z2=round((X2-m)/sd,2) +g<-paste(round((pnorm(z2)-pnorm(z1))*100,2),"% is the probability that a randomly selected household generates between 27 and 31 pounds of newspapers per month") +g \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.8/ex6_8.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.8/ex6_8.R.zip new file mode 100644 index 00000000..a1b520cd Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH6/EX6.8/ex6_8.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.1/ex7_1.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.1/ex7_1.R new file mode 100644 index 00000000..3b0cfdc3 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.1/ex7_1.R @@ -0,0 +1,8 @@ +m=54 +z=round(qnorm(0.975),2) +z +s=6 +n=50 +x=round((z*s)/sqrt(n),2) +l<-paste("Hence one can say with 95% confidence that the interval between",m-x,"and",m+x,"days does contain the population mean, based on a sample of 50 automobiles.") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.10/ex7_10.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.10/ex7_10.R new file mode 100644 index 00000000..484173a3 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.10/ex7_10.R @@ -0,0 +1,8 @@ +n=1721 +p=0.159 +q=1-p +z=round(qnorm(0.975),2) +lo=round((p-(z*sqrt(p*q/n)))*100,1) +hi=round((p+(z*sqrt(p*q/n)))*100,1) +l<-paste("Hence, you can be 95% confident that the true percentage is between",lo,"and",hi,"%") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.11/ex7_11.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.11/ex7_11.R new file mode 100644 index 00000000..7053e1f7 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.11/ex7_11.R @@ -0,0 +1,7 @@ +z=round(qnorm(0.975),2) +E=0.02 +p=0.40 +q=1-p +n=p*q*((z/E)^2) +l<-paste("Minimum sample space required is",round(n)) +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.12/ex7_12.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.12/ex7_12.R new file mode 100644 index 00000000..33b21a59 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.12/ex7_12.R @@ -0,0 +1,10 @@ +z=round(qnorm(0.951),2) +E=0.05 +p=0.50 +q=1-p +n=p*q*((z/E)^2) +if(n>round(n)) + n=n+1 +l<-paste("Minimum sample space required is",round(n)) +l + diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.13/ex7_13.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.13/ex7_13.R.zip new file mode 100644 index 00000000..e92d5141 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.13/ex7_13.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.14/ex7_14.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.14/ex7_14.R new file mode 100644 index 00000000..2c09392b --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.14/ex7_14.R @@ -0,0 +1,10 @@ +n=20 +s=1.6 +Xr=round(qchisq(0.975,19),2) +Xl=round(qchisq(0.025,19),2) +lo=(n-1)*(s^2)/Xr +lo=sqrt(lo) +hi=(n-1)*(s^2)/Xl +hi=sqrt(hi) +l<-paste("Hence, you can be 95% confident that the true standard deviation for the nicotine content of all cigarettes manufactured is between",round(lo,1),"and",round(hi,1),"milligrams based on a sample of 20 cigarettes.") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.15/ex7_15.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.15/ex7_15.R new file mode 100644 index 00000000..266064b6 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.15/ex7_15.R @@ -0,0 +1,11 @@ +n=10 +m<-c(59, 54, 53, 52, 51, 39, 49, 46, 49, 48) +s=sd(m) +Xr=round(qchisq(0.95,9),3) +Xl=round(qchisq(0.05,9),3) +lo=(n-1)*(s^2)/Xr +lo=sqrt(lo) +hi=(n-1)*(s^2)/Xl +hi=sqrt(hi) +l<-paste("Hence, you can be 90% confident that the true standard deviation price of all single-day ski lift tickets of the population is between",round(lo,2),"and",round(hi,2),"dollars on a sample of 10 nationwide ski resorts.") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.2/ex7_2.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.2/ex7_2.R new file mode 100644 index 00000000..905e03ed --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.2/ex7_2.R @@ -0,0 +1,7 @@ +m=5.6 +z=round(qnorm(0.995),2) +s=0.8 +n=30 +x=round((z*s)/sqrt(n),1) +l<-paste(" one can be 99% confident that the mean age of all primary vehicles is between",m-x,"and",m+x,"years, based on 30 vehicles.") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.3/ex7_3.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.3/ex7_3.R new file mode 100644 index 00000000..0671db1d --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.3/ex7_3.R @@ -0,0 +1,10 @@ +da<-c(12.23, 16.56, 4.39, 2.89, 1.24, 2.17, 13.19, 9.16, 1.42, 73.25, 1.91, 14.64, 11.59, 6.69, 1.06, 8.74, 3.17, 18.13, 7.92, 4.78, 16.85, 40.22, 2.42, 21.58, 5.01, 1.47, 12.24, 2.27, 12.77, 2.76) +m=round(mean(da),2) +s=round(sd(da),2) +c=0.9 +a=1-c +z=round(qnorm(0.951),2) +n=30 +x=round((z*s)/sqrt(n),3) +l<-paste("Hence, one can be 90% confident that the population mean of the assets of all credit unions is between",m-x,"and",m+x,"based on a sample of 30 credit unions") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.4/ex7_4.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.4/ex7_4.R new file mode 100644 index 00000000..dd41e6f0 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.4/ex7_4.R @@ -0,0 +1,9 @@ +c=0.99 +a=1-c +s=4.38 +z=round(qnorm(0.995),2) +z +E=2 +ss=(z*s/E)^2 +l<-paste("to be 99% confident that the estimate is within 2 feet of the true mean depth, the scientist needs at least a sample of",round(ss),"measurements.") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.5/ex7_5.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.5/ex7_5.R new file mode 100644 index 00000000..9ca7f1f1 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.5/ex7_5.R @@ -0,0 +1 @@ +round(qt(0.975,21),2) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.6/ex7_6.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.6/ex7_6.R new file mode 100644 index 00000000..69fe893f --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.6/ex7_6.R @@ -0,0 +1,9 @@ +t=round(qt(0.975,9),3) +c=0.95 +s=0.78 +n=10 +m=7.1 +lo=round(m-(t*(s/sqrt(n))),2) +hi=round(m+(t*(s/sqrt(n))),2) +l<-paste("Therefore, one can be 95% confident that the population mean is between",lo,"and",hi,"inches") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.7/ex7_7.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.7/ex7_7.R new file mode 100644 index 00000000..94c0bd33 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.7/ex7_7.R @@ -0,0 +1,8 @@ +t=qt(0.995,6) +s=1610.3 +n=7 +m=7041.4 +lo=round(m-(t*(s/sqrt(n)))) +hi=round(m+(t*(s/sqrt(n)))) +l<-paste("Therefore, one can be",c*100,"confident that the population mean is between",lo,"and",hi) +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.8/ex7_8.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.8/ex7_8.R.zip new file mode 100644 index 00000000..fed0cc40 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.8/ex7_8.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.9/ex7_9.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.9/ex7_9.R new file mode 100644 index 00000000..1ebbdc37 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH7/EX7.9/ex7_9.R @@ -0,0 +1,9 @@ +x=60 +n=500 +p=round((x/n),2) +q=1-p +z=round(qnorm(0.951),2) +lo=round((p-(z*sqrt(p*q/n)))*100,1) +hi=round((p+(z*sqrt(p*q/n)))*100,1) +l<-paste("Hence, you can be 90% confident that the percentage of applicants who are men is between",lo,"and",hi,"%") +l \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.10/ex8_10.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.10/ex8_10.R.zip new file mode 100644 index 00000000..f6bb9a8e Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.10/ex8_10.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.11/ex8_11.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.11/ex8_11.R.zip new file mode 100644 index 00000000..bb7a2c86 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.11/ex8_11.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.12/ex8_12.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.12/ex8_12.R.zip new file mode 100644 index 00000000..0676b6c0 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.12/ex8_12.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.13/ex8_13.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.13/ex8_13.R new file mode 100644 index 00000000..a5ebf9e0 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.13/ex8_13.R @@ -0,0 +1,2 @@ +g<-c(60, 56, 60, 55, 70, 55, 60, 55) +t.test(g, mu=60, conf.level = 0.9) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.14/ex8_14.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.14/ex8_14.R.zip new file mode 100644 index 00000000..590cbd1c Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.14/ex8_14.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.15/ex8_15.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.15/ex8_15.R.zip new file mode 100644 index 00000000..916ea1de Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.15/ex8_15.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.16/ex8_16.R.zip b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.16/ex8_16.R.zip new file mode 100644 index 00000000..ae2eedd7 Binary files /dev/null and b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.16/ex8_16.R.zip differ diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.17/ex8_17.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.17/ex8_17.R new file mode 100644 index 00000000..1981bb44 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.17/ex8_17.R @@ -0,0 +1,11 @@ +mu=0.60 +n=200 +x=128 +p=x/n +q=1-mu +c=1.96 +z=(p-mu)/sqrt(mu*q/n) +if((z>-c)&&(z-c)&&(zc2) + l<-paste("Null hypothesis rejected") +l +m1=x-(c2*s/sq) +m2=x+(c2*s/sq) +p<-paste("confidence interval is between",round(m1,1),"and",round(m2,1)) +p \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.31/ex8_31.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.31/ex8_31.R new file mode 100644 index 00000000..7f5fa42e --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH8/EX8.31/ex8_31.R @@ -0,0 +1,16 @@ +mu1=200 +n=10 +x=198.2 +s=3.3 +sq=round(sqrt(n),4) +z=(x-mu1)*sq/s +c2=round(-qt(0.025,9),3) +c1=-round(-qt(0.025,9),3) +if(z>c1 || zc2 || zc1 || z0) + l<-paste("Since the confidence interval does not contain zero, the decision is to reject the null hypothesis, which agrees with the previous result.")else + l<-paste("Hypothesis accepted") +p +l diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.4/ex9_4.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.4/ex9_4.R new file mode 100644 index 00000000..a4afdcbb --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.4/ex9_4.R @@ -0,0 +1,16 @@ +c1=-round(qt(0.975,7),3) +c1 +c2=round(qt(0.975,7),3) +s1=38*38 +s2=12*12 +n1=8 +n2=10 +x1=191 +x2=199 +z=(x1-x2)/sqrt(s1/n1 + s2/n2) +z +if(z>c2 || z0) + l<-paste("Since 0 is contained in the interval, the decision is to not reject the null hypothesis")else + l<-paste("Hypothesis rejected") +p +l +#qf doesn't give the exact answer as in the tb \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.6/ex9_6.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.6/ex9_6.R new file mode 100644 index 00000000..39838f7a --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.6/ex9_6.R @@ -0,0 +1,3 @@ +X1<-c(210,230,182,205,262,253,219,216) +X2<-c(219,236,179,204,270,250,222,216) +t.test(X1,X2,paired = TRUE,alternative = "less") \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.7/ex9_7.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.7/ex9_7.R new file mode 100644 index 00000000..873f8439 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.7/ex9_7.R @@ -0,0 +1,3 @@ +X1<-c(210,235,208,190,172,244) +X2<-c(190,170,210,188,173,228) +t.test(X1,X2, paired = TRUE) diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.8/ex9_8.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.8/ex9_8.R new file mode 100644 index 00000000..ca99c08c --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.8/ex9_8.R @@ -0,0 +1,6 @@ +n=6 +mu=0 +c=2.015 +X1<-c(210,235,208,190,172,244) +X2<-c(190,170,210,188,173,228) +t.test(X1,X2, paired = TRUE, conf.level = 0.90) \ No newline at end of file diff --git a/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.9/ex9_9.R b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.9/ex9_9.R new file mode 100644 index 00000000..836467e1 --- /dev/null +++ b/Elementary_Statistics:_A_Step_By_Step_Approach_by_Allan_G._Bluman/CH9/EX9.9/ex9_9.R @@ -0,0 +1,15 @@ +x1=12 +n1=34 +x2=17 +n2=24 +p1=x1/n1 +p2=x2/n2 +p=(x1+x2)/(n1+n2) +q=1-p +c1=round(qnorm(0.975),2) +c2=-round(qnorm(0.975),2) +z=round((p1-p2)/sqrt(p*q*(1/n1+1/n2)),1) +if(z>c1 || zY=c*X+a------>Y=0.66*X+23.66 + +#Equation of line regressiono of X on Y +e=lm(X~Y) +f=summary(e)$coefficients[1,1] +f # Intercept +g=summary(e)$coefficients[2,1] +g # Slope +#From the above, we can get the equation of X on Y +#Equation--->X=g*Y+f------>X=0.545*Y+30.36 + +#Calculating the value +x=0.545*70+30.36 +x # Answer little vary due to rounding off \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.2/EX11_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.2/EX11_2.R new file mode 100644 index 00000000..9be3de29 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.2/EX11_2.R @@ -0,0 +1,15 @@ +#Page number-11.10 +#Example number--11.2 + +a=matrix(c(8,40,-10,-18),nrow=2,ncol=2) +b=matrix(c(-66,214),nrow=2,ncol=1) +r=solve(a,b) +r +x=r[1,1] +y=r[2,1] +byx=8/10 #Regression coefficient of Y on X +bxy=18/40 #Regression coefficient of X on Y +z=sqrt(byx*bxy) +z +s.dy=solve(1/5,4/5) +s.dy #Standard deviation of Y \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.3/EX11_3.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.3/EX11_3.R new file mode 100644 index 00000000..1631359e --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.3/EX11_3.R @@ -0,0 +1,30 @@ +#Page number-11.11 +#Example number--11.3 + +kolkata=c(65,2.5) +mumbai=c(67,3.5) +type=c("Average Price","Standard Deviation") +q=data.frame(type,kolkata,mumbai) +q + +x=q[1,2]; x +s.dx=q[2,2]; s.dx #Standard deviation of x +y=q[1,3]; y +s.dy=q[2,3]; s.dy #Standard deviation of y + +slope=0.8*3.5/2.5 +intercept=67+0.8*65*3.5/2.5 +#From the above, we can get the equation of Y on X +#Equation--->Y=slope*X+intercept + +#Calculating the value +Y=67+0.8*3.5/2.5*(70-65) +Y + + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.6/EX11_6.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.6/EX11_6.R new file mode 100644 index 00000000..605aa8b9 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.6/EX11_6.R @@ -0,0 +1,17 @@ +#Page number-11.14 +#Example number--11.6 + +obs=c(seq(1,10,1)) +X=c(1,1,2,2,3,3,4,5,6,7) +Y=c(2,7,7,10,8,12,10,14,11,14) +data.frame(obs,X,Y,X^2,X^3,X^4,X*Y,X^2*Y) + +a=matrix(c(10,34,154,34,154,820,154,820,4774),nrow=3,ncol=3) +b=matrix(c(95,377,1849),nrow=3,ncol=1) +t=solve(a,b) +t +#From the above, we can get the equation +#Equation---> Y= 1.80 + 3.48*X - 0.2689*X^2 + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.7/EX11_7.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.7/EX11_7.R new file mode 100644 index 00000000..eac33d86 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH11/EX11.7/EX11_7.R @@ -0,0 +1,18 @@ +#Page number-11.15 +#Example number--11.7 + +obs=c(seq(1,8,1)) +X=c(1,2,3,4,5,6,7,8) +Y=c(1.0,1.2,1.8,2.5,3.6,4.7,6.6,9.1) +U=log(Y) +data.frame(obs,X,Y,U,X*U,X^2) + +a=matrix(c(8,36,36,204),nrow=2,ncol=2) +b=matrix(c(3.7393,22.7385),nrow=2,ncol=1) +t=solve(a,b) +t +#Taking antilog +b=0.1408 +d=0.6821 + +#Equation-----> Y= 0.6821* (1.38)^X diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.7/EX12_7.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.7/EX12_7.R new file mode 100644 index 00000000..ef9be967 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.7/EX12_7.R @@ -0,0 +1,12 @@ +#Page number--12.31 +#Example number--12.7 + +r12=0.77 +r13=0.72 +r23=0.52 + +r12.3=(r12-r13*r23)/sqrt((1-r13^2)*(1-r23^2)) +r12.3 +R1.23=sqrt((r12^2+r13^2-2*r12*r13*r23)/(1-r23^2)) +R1.23 + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.8/EX12_8.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.8/EX12_8.R new file mode 100644 index 00000000..9b34d1a5 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.8/EX12_8.R @@ -0,0 +1,41 @@ +#Page number--12.32 +#Example number--12.8 + +s.d1=2 +s.d2=3 +s.d3=3 +r12=0.7 +r21=0.7 +r13=0.5 +r31=0.5 +r23=0.5 +r32=0.5 + +#Part (i) +r23.1=(r23-r21*r31)/sqrt((1-r21^2)*(1-r31^2)) +r23.1 +#Part (ii) +R1.23=sqrt((r12^2+r13^2-2*r12*r13*r23)/(1-r23^2)) +R1.23 +#Part (iii) +r12.3=0.6 +r13.2=0.2425 +s.d1.3=2*sqrt(1-r13^2);s.d1.3 +s.d2.3=3*sqrt(1-r23^2);s.d2.3 +s.d1.2=2*sqrt(1-r12^2);s.d1.2 +s.d3.2=3*sqrt(1-r23^2);s.d3.2 +b12.3=r12.3*s.d1.3/s.d2.3;b12.3 +b13.2=r13.2*s.d1.2/s.d3.2;b13.2 + +#Part (iv) +w=matrix(c(1,r12,r13,r12,1,r23,r13,r23,1),nrow=3,ncol=3) +det(w) +w1=matrix(c(1,r23,r23,1),nrow=2,ncol=2) +det(w1) +s.d1.23=2*sqrt(det(w)/det(w1));s.d1.23 + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.9/EX12_9.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.9/EX12_9.R new file mode 100644 index 00000000..d5d9778d --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH12/EX12.9/EX12_9.R @@ -0,0 +1,21 @@ +#Page number--12.33 +#Example number--12.9 + +r12=0.8 +r21=0.8 +r13=-0.4 +r31=-0.4 +r23=-0.56 +r32=-0.56 + +w=matrix(c(1,r12,r13,r12,1,r23,r13,r23,1),nrow=3,ncol=3) +det(w) +w11=matrix(c(1,r23,r23,1),nrow=2,ncol=2) +det(w11) +w12=matrix(c(r21,r31,r23,1),nrow=2,ncol=2) +det(w12)*-1 +w13=r23*r12-r13 +w13 + +#Required equation +#0.686/4.42*(X1-28.02)-0.576/1.10*(X2-4.91)-0.048/85*(X3-594) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.11/EX13_11.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.11/EX13_11.R new file mode 100644 index 00000000..1118f0f8 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.11/EX13_11.R @@ -0,0 +1,23 @@ +#Page number--13.13 +#Example number--13.11 + +#Part (i) +N=1000 +A=470;B=620;AB=320 +k=AB-A*B/N +if (k>0) print("A and B are positively associated") + +#Part (ii) +A=490;AB=294;i=570;iB=380 +N=A+i +B=AB+iB +k=AB-A*B/N +if (k<0) print("A and B are negatively associated") + +#Part (iii) +AB=256;iB=768;Aj=48;ij=144 +A=AB+Aj +B=AB+iB +N=AB+Aj+iB+ij +k=AB-A*B/N +if (k<0) print("A and B are independent") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.12/EX13_12.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.12/EX13_12.R new file mode 100644 index 00000000..e200464d --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.12/EX13_12.R @@ -0,0 +1,28 @@ +#Page number--13.14 +#Example number--13.12 + +#A:: Dark eye-colour of father +#B:: Dark eye-colour of son + +AB=50;Aj=79;iB=89;ij=782 + +Q=(AB*ij-Aj*iB)/(AB*ij+Aj*iB) #Yule's Coefficient of Association +Q + +A=AB+Aj;A +B=AB+iB;B +i=iB+ij;i +j=Aj+ij;j +N=A+i +N +AB0=A*B/N;round(AB0) +Aj0=A*j/N;round(Aj0) +iB0=i*B/N;round(iB0) +ij0=i*j/N;round(ij0) + + + + + + + \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.14/EX13_14.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.14/EX13_14.R new file mode 100644 index 00000000..59d131f2 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.14/EX13_14.R @@ -0,0 +1,27 @@ +#Page number--13.15 +#Example number--13.14 + +#A:: Boys +#i:: Girls +#B:: Successful candidates +#j:: Failed candidates + +N=800 +Aj=80;iB=260 +AB=380;ij=80 +Attributes=c("B","j") +A=c(380,80) +i=c(260,80) +Total=c(A[1]+i[1],A[2]+i[2]) +data.frame(Attributes,A,i,Total) + +Q=(AB*ij-Aj*iB)/(AB*ij+Aj*iB) #Yule's Coefficient of Association +Q + +sprintf("The coeficient shows positive association of a low degree between success and failure") + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.15/EX13_15.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.15/EX13_15.R new file mode 100644 index 00000000..e8855575 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.15/EX13_15.R @@ -0,0 +1,26 @@ +#Page number--13.15 +#Example number--13.15 + +#A:: Majority +#i:: Minority +#B:: Regular players +#j:: Not Regular players + +i=250+200+150 +sprintf("No. of minority students: %d",i) +A=120+100+80 +sprintf("No. of major students: %d",A) +iB=200+150+90 +sprintf("No. of minor regular players: %d",iB) +AB=48+30+12 +sprintf("No. of major regular players: %d",AB) + +Aj=A-AB;Aj +ij=i-iB;ij + +Q=(AB*ij-Aj*iB)/(AB*ij+Aj*iB) #Yule's Coefficient of Association +Q + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.2/EX13_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.2/EX13_2.R new file mode 100644 index 00000000..8c9ba34f --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH13/EX13.2/EX13_2.R @@ -0,0 +1,16 @@ +#Page number--13.5 +#Example number--13.2 + +ABi=738;AjC=225;Aji=1196 +kBC=204;kBi=1762;kjC=171; +kji=21842 +ABC=149 + +A=ABC+ABi+AjC+Aji;A +B=ABC+ABi+kBC+kBi;B +C=ABC+AjC+kBC+kjC;C +AB=ABC+Aji;AB # Answer is wrong in the example +AC=ABC+AjC;AC +BC=ABC+kBC;BC + +N=ABC+ABi+AjC+Aji+kBC+kBi+kjC+kji;N \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.1/EX14_1.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.1/EX14_1.R new file mode 100644 index 00000000..3d3e6041 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.1/EX14_1.R @@ -0,0 +1,19 @@ +#Page number--14.12 +#Example number--14.1 + +n=9000 +X=3240 + +#H0::That die is unbiased +#Probability of success +P=1/6+1/6 +Q=1-P +#H1::That die is baised + +Z=(X-n*P)/sqrt(n*P*Q) + +#Probability limits +p=3240/9000;q=1-p +ll=p-3*sqrt(p*q/n) +ul=p+3*sqrt(p*q/n) +sprintf("Probability of getting 3 or 4 certainly lies between %f and %f",round(ll,3),round(ul,3)) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.10/EX14_10.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.10/EX14_10.R new file mode 100644 index 00000000..1ae50671 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.10/EX14_10.R @@ -0,0 +1,17 @@ +#Page number--14.19 +#Example number--14.10 + +n1=1000;p1=800/1000;q1=1-p1 +n2=1200;p2=800/1200;q2=1-p2 + +#H0: P1=P2 +#H1: P1>P2 (Right-tailed test) + +p=(n1*p1+n2*p2)/(n1+n2);p +q=1-p + +z=abs((p1-p2)/sqrt(p*q*(1/n1+1/n2))) +z +if(z>1.96) print("H0 hypothesis is rejected") +sprintf("There is significant decrease in consuption of tea after increase in excise duty") + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.15/EX14_15.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.15/EX14_15.R new file mode 100644 index 00000000..6a88a7fe --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.15/EX14_15.R @@ -0,0 +1,16 @@ +#Page number--14.22 +#Example number--14.15 + +n1=400;p1=300/400;q1=1-p1 +n2=500;p2=300/500;q2=1-p2 + +#H0: P1=P2 +#H1: P1!=P2 (two tailed test) + +p=(n1*p1+n2*p2)/(n1+n2);p +q=1-p +s.e.p1p2=sqrt(p*q*1/(n1+n2)*500/400) +s.e.p1p2 +z=(p-p1)/s.e.p1p2 +abs(z) # Answer is wrong in the book +sprintf("H0 is rejected") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.18/EX14_18.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.18/EX14_18.R new file mode 100644 index 00000000..7a6c8647 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.18/EX14_18.R @@ -0,0 +1,21 @@ +#Page number--14.26 +#Example number--14.18 + +#H0: u=30.5 +#H1: u<30.5 (Left-tailed test) + +AgeLastBirthday=c("16-20","21-25","26-30","31-35","36-40") +f=c(12,22,20,30,16) +midx=c((16+20)/2,(25+21)/2,(26+30)/2,(31+35)/2,(36+40)/2) +d=(midx-28)/5 +a=f*d +b=f*d^2 +data.frame(AgeLastBirthday,f,midx,d,a,b) + +u=30.5 +x=28+5*16/100 +s=5*sqrt(164/100-(16/100)^2) + +z=abs((x-u)/sqrt(s^2/100)) +z +if(z>1.645) print("Reject H0 hypothesis") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.2/EX14_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.2/EX14_2.R new file mode 100644 index 00000000..4987d9e9 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.2/EX14_2.R @@ -0,0 +1,13 @@ +#Page number--14.13 +#Example number--14.2 + +n=500 +X=65 +p=X/n #Proportion on Number of bad pineapples +q=1-p +#S.E of proportion +s.e=sqrt(p*q/n) +#Probability limits +ll=p-3*sqrt(p*q/n) +ul=p+3*sqrt(p*q/n) +sprintf("Percentage of bad pineapples in the consignment between %f and %f",round(ll,3),round(ul,3)) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.26/EX14_26.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.26/EX14_26.R new file mode 100644 index 00000000..4e650387 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.26/EX14_26.R @@ -0,0 +1,15 @@ +#Page number--14.31 +#Example number--14.26 + +n1=400;n2=400 +x1=250;x2=220 +s.d1=40;s.d2=55 + +#H0::u1=u2 +#H1::u1!=u2 (two tailed test) + +z=abs((x1-x2)/sqrt(40^2/400+55^2/400)) +z +if(z>3) print("H0 rejected") +sprintf("Expenditure of two population of shoppers in market A and B differ significantly") + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.28/EX14_28.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.28/EX14_28.R new file mode 100644 index 00000000..d33fb356 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.28/EX14_28.R @@ -0,0 +1,21 @@ +#Page number--14.32 +#Example number--14.28 + +n1=250;n2=400 +x1=120;x2=124 +s.d1=12;s.d2=14 +s.e.x1x2=sqrt(s.d1^2/n1+s.d2^2/n2) +s.e.x1x2 + +#H0::u1=u2 +#H1::u1!=u2 (two tailed test) + +z=(x1-x2)/s.e.x1x2 +z +if(z>3) print("H0 rejected") +sprintf("There is significant difference between sample means") + +#|u1-u2| limits +ll=abs(x1-x2)-2.58*s.e.x1x2 #lower limit +ul=abs(x1-x2)+2.58*s.e.x1x2 #upper limit +sprintf("|u1-u2| varies between %f and %f",ll,ul) diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.30/EX14_30.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.30/EX14_30.R new file mode 100644 index 00000000..faa762e5 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.30/EX14_30.R @@ -0,0 +1,23 @@ +#Page number--14.34 +#Example number--14.30 + +n1=1000;n2=1200 +x1=67.42;x2=67.25 +s.d1=2.58;s.d2=2.5 + +#Part (i) +#H0::u1=u2 +#H1::u1!=u2 (two tailed test) + +z=abs((x1-x2)/sqrt(s.d1^2/n1+s.d2^2/n2)) +z +if(z<1.96) print("H0 accepted") +sprintf("There is no significant difference between sample means") + +#Part (ii) +s.e.s1s2=sqrt(s.d1^2/(2*n1)+s.d2^2/(2*n2)) +s.e.s1s2 +z=(s.d1-s.d2)/s.e.s1s2 +z +if(z<1.96) print("H0 accepted") +sprintf("The sample standard deviation do not differ significantly") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.4/EX14_4.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.4/EX14_4.R new file mode 100644 index 00000000..f09a24e8 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.4/EX14_4.R @@ -0,0 +1,17 @@ +#Page number--14.13 +#Example number--14.4 + +n=1000 +X=540 +p=X/n # Sample proportion of rice eaters +#H0::Wheat and rice are equally popular +# Population proportion of rice eaters in Maharashtra +P=0.5 +Q=1-P + +Z=(p-P)/sqrt(P*Q/n) + +#At 1% level of significance +if(Z<2.532) +sprintf("Hence, H0 hypothesis accepted") +sprintf("Rice and wheat are equally popular in Maharashtra State") diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.6/EX14_6.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.6/EX14_6.R new file mode 100644 index 00000000..ca956ff6 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.6/EX14_6.R @@ -0,0 +1,8 @@ +#Page number--14.14 +#Example number--14.6 + +P=0.95 +p=40/200 +q=1-p +n=p*q*3.8416/0.0025 +round(n) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.7/EX14_7.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.7/EX14_7.R new file mode 100644 index 00000000..e044a927 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH14/EX14.7/EX14_7.R @@ -0,0 +1,16 @@ +#Page number--14.16 +#Example number--14.7 + +#H1: P1!=P2 (two tailed test) +n1=400 +n2=600 +X1=200;X2=325 +p1=X1/n1 +p2=X2/n2 + +p=(n1*p1+n2*p2)/(n1+n2) +q=1-p + +z=abs((p1-p2)/sqrt(p*q*(1/n1+1/n2))) +z +if(z<1.96) print("Mean and women do not differ on flyover proposal") diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.12/EX15_12.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.12/EX15_12.R new file mode 100644 index 00000000..2e080389 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.12/EX15_12.R @@ -0,0 +1,17 @@ +#Page number--15.27 +#Example number--15.12 + +digits=c(seq(0,9,1)) +f=c(1026,1107,997,966,1075,933,1107,972,964,853) # Observed Frequency +m=sum(f)/length(f) # Mean +e=rep(m,10) # Expected Frequency +a=(f-e)^2 +b=round(a/e,3) +data.frame(digits,f,e,a,b) + +#H0 is null hypothesis +x=sum(b) +x + +sprintf("H0 may be rejected") +sprintf("The digits are not uniformly distributed in the directory") diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.14/EX15_14.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.14/EX15_14.R new file mode 100644 index 00000000..fa1f7116 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.14/EX15_14.R @@ -0,0 +1,23 @@ +#Page number--15.29 +#Example number--15.14 + +#Probability of male birth +p=1/2 +#Probability of female birth +q=1/2 +n_m_b=c(seq(0,4,1)) +f=c(32,178,290,236,64) # Number of families +e=c() +for (i in n_m_b){ + e[i+1]=800*choose(4,i)*p^4 # Frequency of male birth +} +a=(f-e)^2 +b=round(a/e,3) +data.frame(n_m_b,f,e,a,b) + +#H0 is null hypothesis +x=sum(b) +x + +sprintf("H0 may be rejected") +sprintf("Male and female births are not equally probable") diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.15/EX15_15.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.15/EX15_15.R new file mode 100644 index 00000000..fdc95bca --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.15/EX15_15.R @@ -0,0 +1,16 @@ +#Page number--15.30 +#Example number--15.15 + +x=c(seq(0,6,1)) +f=c(275,72,30,7,5,2,1) # Observed Frequency +m=sum(f*x)/sum(f) #Mean +# Expected Frequency +e=c(242.1,0.482*242.1,0.241*116.69,0.482/3*28.12,0.482/4*4.51,0.482/5*0.544,0.482/6*0.052) +a=(f-e)^2 +b=round(a/e,3) +data.frame(x,f,e,a,b) + +x=sum(b) +x # Aswer here is wrong in the book + +sprintf("Poisson distribution is not good to fit to the given data") diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.18/EX15_18.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.18/EX15_18.R new file mode 100644 index 00000000..fe9afe06 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.18/EX15_18.R @@ -0,0 +1,16 @@ +#Page number--15.34 +#Example number--15.18 + +Class=c("Male employed","Male unemployed","Female employed","Female unemployed") +f=c(1480,5720,120,680) # Observed Frequency +e=c(7200*1600/8000,7200-1440,1600-1440,6400-5760) # Expected Frequency +a=(f-e)^2 +b=round(a/e,2) +data.frame(Class,f,e,b) + +#H0 is null hypothesis +x=sum(b) +x + +sprintf("H0 may be rejected") +sprintf("Appointment is based on the basis of sex") diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.20/EX15_20.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.20/EX15_20.R new file mode 100644 index 00000000..25df875d --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.20/EX15_20.R @@ -0,0 +1,23 @@ +#Page number--15.36 +#Example number--15.20 + +E86=126*200/300 +E60=93*200/300 +E44=69*200/300 + +Researcher=c("X","Y") +bavg=c(E86,126-E86) # Below Average +avg=c(E60,93-E60) # Average +aavg=c(E44,69-E44) # Above Average +genius=c(200-192,12-8) +data.frame(Researcher,bavg,avg,aavg,genius) + +f=c(86,60,44,10,40,33,25,2) +e=c(84,62,46,8,42,31,23,4) +a=(f-e)^2 +b=round(a/e,3) +data.frame(f,e,a,b) + +x=sum(b[1:6]) +x +sprintf("No difference in sampling techniques used by two researchers") diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.9/EX15_9.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.9/EX15_9.R new file mode 100644 index 00000000..d52074c3 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH15/EX15.9/EX15_9.R @@ -0,0 +1,18 @@ +#Page number--15.25 +#Example number--15.9 + +X=c(2.5,2.3,2.4,2.3,2.5,2.7,2.5,2.6,2.6,2.7,2.5) +m=sum(X)/length(X) # Mean +a=round(X-m,2) +b=a^2 +data.frame(X,m,a,b) + +#Null Hypothesis +H0=0.16 +#Alternative Hypothesis +#H1>0.16 +x=sum(b)/H0 +x + +sprintf("H0 may be accepted") +sprintf("The data are consistent with the hypothesis that the precision of the instrument is 0.16") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.10/EX16_10.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.10/EX16_10.R new file mode 100644 index 00000000..914799fc --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.10/EX16_10.R @@ -0,0 +1,35 @@ +#Page number--16.18 +#Example number--16.10 + +n1=12 +n2=15 +#H0::Null Hypothesis ------> No significant difference in mean of weight in diet A and B +#H1::Alternative Hypothesis----->ux!=uy (two-tailed) + +#Diet A +x1=c(25,32,30,34,24,14,32,24,30,31,35,25) +m1=sum(x1)/n1 # Mean +m1 +a1=x1-m1 +b1=a1^2 +data.frame(x1,a1,b1) + +#Diet B +x2=c(44,34,22,10,47,31,40,30,32,35,18,21,35,29,22) +m2=sum(x2)/n2 # Mean +m2 +a2=x2-m2 +b2=a2^2 +data.frame(x2,a2,b2) + +s2=(sum(b2)+sum(b1))/(n1+n2-2) +t=abs((m1-m2)/sqrt(s2*(1/n1+1/n2))) +t + +sprintf("H0 is accepted") +sprintf("Two diets do not differ significantly ") + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.12/EX16_12.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.12/EX16_12.R new file mode 100644 index 00000000..0a7cae00 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.12/EX16_12.R @@ -0,0 +1,43 @@ +#Page number--16.20 +#Example number--16.12 + +# SAILORS +X=c(63,65,68,69,71,72) +A=68 +d=X-A +a=sum(d^2) +data.frame(X,d,d^2) + +# SOLDIERS +Y=c(61,62,65,66,69,69,70,71,72,73) +B=66 +D=Y-B +b=sum(D^2) +data.frame(Y,D,D^2) + +mx=A + sum(d)/6;mx # Mean +p=a-(sum(d))^2/6;p + +my=B + sum(D)/10;my # Mean +q=b-(sum(D))^2/10;q + +S2=(1/(6+10-2))*(p+q) +S2 + +t=(mx-my)/sqrt(S2*(1/6+1/10)) +t + +sprintf("Null hypothesis can be retained") +sprintf("The sailors are on the average taller than the soilders.") + + + + + + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.15/EX16_15.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.15/EX16_15.R new file mode 100644 index 00000000..a1fc02ef --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.15/EX16_15.R @@ -0,0 +1,63 @@ +#Page number--16.22 +#Example number--16.15 + +# Part (i) +# Food A +X=c(49,53,51,52,47,50,52,53) +A=50 +d=X-A +a=sum(d^2) +data.frame(X,d,d^2) + +# Food B +Y=c(52,55,52,53,50,54,54,53) +B=52 +D=Y-B +b=sum(D^2) +data.frame(Y,D,D^2) + +mx=A + sum(d)/8;mx # Mean +p=a-(sum(d))^2/8;p + +my=B + sum(D)/8;my # Mean +q=b-(sum(D))^2/8;q + +S2=(1/(8+8-2))*(p+q) +S2 + +t=(mx-my)/sqrt(S2*(1/8+1/8)) +t + +sprintf("Null hypothesis rejected") +sprintf("Food B is superior to Food A") + +# Part (ii) +X +Y +d=X-Y +data.frame(X,Y,d,d^2) + +n=length(X) +md=sum(d)/n +md +S2=1/(n-1)*(sum(d^2)-(sum(d))^2/n) +S2 + +t= abs(md/sqrt(S2/n)) +round(t,3) + +sprintf("Food B is superior to Food A") + + + + + + + + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.18/EX16_18.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.18/EX16_18.R new file mode 100644 index 00000000..97a8ba06 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.18/EX16_18.R @@ -0,0 +1,25 @@ +#Page number--16.25 +#Example number--16.18 + +#H0::Null Hypothesis ------>p=0 +#H0::The value of r=0.2 is not significant + +r=0.2 +n=625 +t=r*sqrt(n-2)/sqrt(1-r^2) +t + +sprintf("Null hypothesis is rejected") +sprintf("The sample correlation is significant of correlation in the population.") + +#95% confidence limits +ll=r - 1.96*(1-r^2)/sqrt(n) # lower limit +ll +ul=r + 1.96*(1-r^2)/sqrt(n) # upper limit +ul + +#99% confidence limits +ll=r - 2.58*(1-r^2)/sqrt(n) # lower limit +round(ll,3) +ul=r + 2.58*(1-r^2)/sqrt(n) # upper limit +ul diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.26/EX16_26.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.26/EX16_26.R new file mode 100644 index 00000000..6f3e315a --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.26/EX16_26.R @@ -0,0 +1,14 @@ +#Page number--16.38 +#Example number--16.26 + +n1=8 +n2=10 +dx=84.4 +dy=102.6 +SX2=dx/(n1-1);SX2 +SY2=dy/(n2-1);SY2 + +F=SX2/SY2 +F + +if(F<3.29) print("H0 may be accepted") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.27/EX16_27.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.27/EX16_27.R new file mode 100644 index 00000000..5549fb76 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.27/EX16_27.R @@ -0,0 +1,26 @@ +#Page number--16.38 +#Example number--16.27 + +n1=10 +n2=12 +mx=15 +my=14 +dx=90 +dy=108 + +# F-Test +SX2=dx/(n1-1);SX2 +SY2=dy/(n2-1);SY2 + +F=SX2/SY2 +F + +if(F<2.90) print("H0 of equality of populatin may be accepted") + +# T-Test +S2=1/(n1+n2-2)*(dx+dy) +S2 +t=(mx-my)/sqrt(S2*(1/n1+1/n2)) +t + +sprintf("Samples have been drawn from the same normal population") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.6/EX16_6.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.6/EX16_6.R new file mode 100644 index 00000000..3a40709c --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.6/EX16_6.R @@ -0,0 +1,14 @@ +#Page number--16.13 +#Example number--16.6 + +n=22 +x=153.7 +s=17.2 +u=146.3 + +#H0::Null Hypothesis ------> the advertising campaign is successful +#H1::Alternative Hypothesis--->u>146.3 (Right tail) + +t=(x-u)/sqrt(s^2/(n-1)) +t # Answer of value of t is wrong +sprintf("H0 is rejected") diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.7/EX16_7.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.7/EX16_7.R new file mode 100644 index 00000000..fcc729c0 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH16/EX16.7/EX16_7.R @@ -0,0 +1,23 @@ +#Page number--16.14 +#Example number--16.7 + +n=10 +u=100 +#H0::Null Hypothesis ------> mean IQ of 100 in the population u=100 +#H1::Alternative Hypothesis--->u!=100 + +x=c(70,120,110,101,88,83,95,98,107,100) +m=sum(x)/n #Mean +m +a=x-m +b=a^2 +data.frame(x,a,b) +s2=sum(b)/9 +s2 +t=abs((m-u)/sqrt(s2/n)) +t +sprintf("H0 is accepted") + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.1/EX2_1.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.1/EX2_1.R new file mode 100644 index 00000000..22beb6ea --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.1/EX2_1.R @@ -0,0 +1,23 @@ +#PAGE NUMBER--2.8 +#Example number--2.1 + +#Part (a) +x=c(1,2,3,4,5,6,7) +f=c(5,9,12,17,14,10,6) # frequency +fx=f*x +a=data.frame(x,y,fx) +a +mean=(sum(fx))/sum(y) +mean + + + +#Part (b) +Marks=c("0-10","10-20","20-30","30-40","40-50","50-60") +mid=c((0+10)/2,(10+20)/2,(20+30)/2,(30+40)/2,(40+50)/2,(50+60)/2) # mid values +f=c(12,18,27,20,17,6) # frequency +fx=f*mid +b=data.frame(Marks,mid,f,fx) +b +mean=(sum(fx))/sum(f) +mean \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.12/EX2_12.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.12/EX2_12.R new file mode 100644 index 00000000..4944e190 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.12/EX2_12.R @@ -0,0 +1,12 @@ +#PAGE NUMBER--2.21 +#Example number--2.12 + +Class_Interval=c("0-10","10-20","20-30","30-40","40-50","50-60","60-70","70-80") +f=c(5,8,7,12,28,20,10,10) +data.frame(Class_Interval,f) + +a=max(f) +sprintf("Maximum frequence: %d",a) +sprintf("Modal class is 40-50") +Mode= 40 + 10*(28-12)/(2*28-12-20) +round(Mode,2) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.15/EX2_15.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.15/EX2_15.R new file mode 100644 index 00000000..38c136da --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.15/EX2_15.R @@ -0,0 +1,14 @@ +#PAGE NUMBER--2.25 +#Example number--2.15 + +# G'=(x1'*x2*.....xn)^1/n +# G'=(x1*x2*.....xn)1/n * (x1'/x1)^1/n +# G'=G* (x1'/x1)^1/n + +G=16.2 +n=10 +x1=12.9 +x_1=21.9 +c_G.M=G*(x_1/x1)^(1/10) # Corrected G.M +c_G.M + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.17/EX2_17.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.17/EX2_17.R new file mode 100644 index 00000000..c73b5ae7 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.17/EX2_17.R @@ -0,0 +1,18 @@ +#PAGE NUMBER--2.27 +#Example number--2.17 + +#Average speed + +avg.s=function(){ + #let the distance between home and college is x kms. + x=1 + #speed from home to college + a=x/10 + #speed from college to home + b=x/15 + AverageSpeed=2*x/(a+b) + sprintf("Your average speed is: %s",AverageSpeed) +} +avg.s() + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.18/EX2_18.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.18/EX2_18.R new file mode 100644 index 00000000..4d6d7a5a --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.18/EX2_18.R @@ -0,0 +1,32 @@ +#PAGE NUMBER--2.27 +#Example number--2.18 + +#Part (a) +#Average price +avg.p=function(){ + #Number of varities of milk + n=4 + #Prices of milk sold at different varities + a=c(8,10,12,15) + #Average price + AveragePrice=1/((1/n)*(1/a[n-3]+1/a[n-2]+1/a[n-1]+1/a[n])) + sprintf("Your average price is: %s",AveragePrice) +} +avg.p() + + +#Part (b) +quality=c("A","B","C") +p.p.p=c(1.00,1.50,2.00) #price per pencil +m.s=c(50,30,20) #money spent +fr.distr=data.frame(quality,p.p.p,m.s) +fr.distr +n.e=sum(m.s) #net value +p.p= sum(m.s / p.p.p) #number of pencils purchased +Averagep.p.p = n.e/p.p #Average price per pencil +Averagep.p.p + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.19/EX2_19.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.19/EX2_19.R new file mode 100644 index 00000000..7c00c3e7 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.19/EX2_19.R @@ -0,0 +1,13 @@ +#PAGE NUMBER--2.28 +#Example number--2.19 + +speed=c(60,25,350,25) +distance=c(900,3000,400,15) +wx=round(distance/speed,2) +data.frame(speed,distance,wx) + +avg.sp= sum(distance)/sum(wx) #Average Speed + +#Answer is little varying as of rounding off + +avg.sp \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.2/EX2_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.2/EX2_2.R new file mode 100644 index 00000000..f3a2e67e --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.2/EX2_2.R @@ -0,0 +1,14 @@ +#PAGE NUMBER--2.10 +#Example number--2.2 + +A=28 +h=8 +Class_Interval=c("0-8","8-16","16-24","24-32","32-40","40-48") +mid=c((0+8)/2,(8+16)/2,(16+24)/2,(24+32)/2,(32+40)/2,(40+48)/2) +f=c(8,7,16,24,15,7) # frequency +d=(mid-A)/h +fd=f*d +a=data.frame(Class_Interval,mid,f,d,fd) +a +mean=A + h* sum(fd)/sum(f) +mean \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.20/EX2_20.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.20/EX2_20.R new file mode 100644 index 00000000..1e77bdf0 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.20/EX2_20.R @@ -0,0 +1,24 @@ +#PAGE NUMBER--2.29 +#Example number--2.20 + +x=seq(0,8,1) +f=c(1,9,26,59,72,52,29,7,1) +cf=cumsum(f) +data.frame(x,f,cf) + +sum(f)/2 +sprintf("Cumulative frequence just greater than 128 is 167") +sprintf("So, Median = 4") + +Q1=sum(f)/4;Q1 +sprintf("Cumulative frequence just greater than 64 is 95") +sprintf("So, Q1 = 3") +Q3=3*sum(f)/4;Q3 +sprintf("Cumulative frequence just greater than 192 is 219") +sprintf("So, Q3 = 5") +D4=4*sum(f)/10;D4 +sprintf("Cumulative frequence just greater than 102.4 is 167") +sprintf("So, D4 = 4") +P27=27*sum(f)/100;P27 +sprintf("Cumulative frequence just greater than 69.12 is 95") +sprintf("So, P27 = 3") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.21/EX2_21.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.21/EX2_21.R new file mode 100644 index 00000000..dcbd2906 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.21/EX2_21.R @@ -0,0 +1,28 @@ +#PAGE NUMBER--2.29 +#Example number--2.21 + +m_m_t=c(0,10,20,30,40,50) # marks more than +n_o_c=c(500,460,400,200,100,30) # number of candidates +Class_interval=c("0-10","10-20","20-30","30-40","40-50","50 Above") +f=c(500-460,460-400,400-200,200-100,100-30,30) +cf=cumsum(f) +data.frame(m_m_t,n_o_c,Class_interval,f,cf) + +sum(f)/4 +sprintf("Cumulative frequence just greater than 125 is 300") +sprintf("So, the corresponding class is 20-30") +Q1= 20 + 10/200*(125-100) +Q1 + +3*sum(f)/10 +sprintf("Cumulative frequence just greater than 150 is 300") +sprintf("So, the corresponding class is 20-30") +D3= 20 + 10/200*(150-100) +D3 + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.23/EX2_23.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.23/EX2_23.R new file mode 100644 index 00000000..f6dfb249 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.23/EX2_23.R @@ -0,0 +1,28 @@ +#PAGE NUMBER--2.31 +#Example number--2.23 + +m.g=c("0-10","10-20","20-30","30-40","40-50","50-60","60-70") #Marks Group +f=c(4,8,11,15,12,6,3) +l.c.f=cumsum(f) #Less than cumulative frequency +m.c.f=rev(cumsum(rev(f))) +data.distr=data.frame(m.g,f,l.c.f,m.c.f) #More than cumulative frequency +data.distr +#For lower quartile (Q1) +N=sum(f) +Q1=20+10/11*(N/4-l.c.f[2]) +Q1 +#For middle quartile (Q2) +Q2=30+10/15*(N/2-l.c.f[3]) #Median +Q2 +#For upper quartile (Q3) +Q3=40+10/12*(3*N/4-l.c.f[4]) +Q3 +x=seq(10,70,10) +plot(x,l.c.f,xlab="MARKS",ylab="No. of Students",main="Cumulative frequency curve",col="red") +sp=spline(x,l.c.f,n=20) +plot(x,m.c.f,xlab="MARKS",ylab="No. of Students",main="Cumulative frequency curve",col="red") +spl=spline(x,m.c.f,n=20) +lines(spl,col="blue") +lines(sp,col="green") +locator() + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.24/EX2_24.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.24/EX2_24.R new file mode 100644 index 00000000..d32e404e --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.24/EX2_24.R @@ -0,0 +1,33 @@ +#PAGE NUMBER--2.33 +#Example number--2.24 + +marks=c("0-10","10-20","20-30","30-40","40-50","50-60","60-70") +n.o.s=c(6,5,8,15,7,6,3) +mid=seq(5,65,10) +d=(mid-35)/10 +fd=n.o.s*d +mean=35+10*(sum(fd))/sum(n.o.s) +l.c.f=cumsum(n.o.s) +a=abs(mid-mean) +b=n.o.s*a +fr.distr=data.frame(marks,mid,n.o.s,d,fd,a,b,l.c.f) +fr.distr + +#Part (i) +N=sum(n.o.s) +Q1=20+10*(N/4-11)/8 +Q1 #Q1 is deviated because they have taken N/4=12.75 which is 12.5 +Q3=40+10/7*(3*N/4-34) +Q3 #Q3 is deviated because they have taken N/4=12.75 which is 12.5 + +QD=(Q3-Q1)/2 +sprintf("Quartile Deviation is : %s",QD) + +#Part (ii) +MD=sum(b)/N +MD + + + + + \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.26/EX2_26.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.26/EX2_26.R new file mode 100644 index 00000000..c07d602b --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.26/EX2_26.R @@ -0,0 +1,17 @@ +#PAGE NUMBER--2.38 +#Example number--2.26 + +A=55 +h=10 +Age_group=c("20-30","30-40","40-50","50-60","60-70","70-80","80-90") +mid=c((20+30)/2,(30+40)/2,(40+50)/2,(50+60)/2,(60+70)/2,(70+80)/2,(80+90)/2) +f=c(3,61,132,153,140,51,2) +d=(mid-A)/h +fd=f*d +fd2=fd*d + +mean= A + h*sum(fd)/sum(f) +mean + +s.d=sqrt(100*(765/542-0.028^2)) +s.d # Standard Deviation diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.27/EX2_27.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.27/EX2_27.R new file mode 100644 index 00000000..a2d03139 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.27/EX2_27.R @@ -0,0 +1,19 @@ +#PAGE NUMBER--2.39 +#Example number--2.27 + +n=200 +mean=40 +s.d=15 + +s_x=n*mean +s_x # sum of xi +s_x2=n*(15^2+1600) +s_x2 # sum of xi^2 + +c_s_x= s_x-34-53+43+35 +corrected_mean=c_s_x/n +corrected_mean + +c_s_x2= s_x2-34^2-53^2+43^2+35^2 +corrected_s.d= sqrt(c_s_x2/n - corrected_mean^2) +corrected_s.d # corrected Standard deviation diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.28/EX2_28.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.28/EX2_28.R new file mode 100644 index 00000000..619370c7 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.28/EX2_28.R @@ -0,0 +1,37 @@ +#PAGE NUMBER--2.39 +#Example number--2.28 + +d=seq(-4,3,1) +f=c(2,5,7,13,21,16,8,3) +fd=f*d +fd2=fd*d +data.frame(fd,fd2) + +mean=21.9 +s.d2=63.9725 +h=round(sqrt(solve(193/75-(-9/75)^2,s.d2))) +h +A= 21.9 + 9*5/75 +A + +# Mid value=(x1+x2)/2=A +# Magnitude of class= x1-x2=h +a=matrix(c(1,-1,1,1),nrow=2,ncol=2) +b=matrix(c(A*2,h),nrow=2,ncol=1) +t=solve(a,b) +t +x1=t[1,1];x1 +x2=t[2,1];x2 + +# So the classes obtained +class_interval=c("0-5","5-10","10-15","15-20","20-25","25-30","30-35","35-40") +mid=c((0+5)/2,(5+10)/2,(10+15)/2,(15+20)/2,(20+25)/2,(25+30)/2,(30+35)/2,(35+40)/2) +data.frame(d,mid,class_interval,f) + + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.29/EX2_29.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.29/EX2_29.R new file mode 100644 index 00000000..c5c5d808 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.29/EX2_29.R @@ -0,0 +1,17 @@ +#PAGE NUMBER--2.40 +#Example number--2.29 + +N=250 +n1=100 +x1=15 +s.d1=3 +n2=250-n1 +mean=15.6 +s.d=sqrt(13.44) + +x2=solve(150,N*mean-1500) +x2 +d1=x1-mean;d1 +d2=x2-mean;d2 +s.d2=sqrt(solve(150,N*13.44-n1*9.36-n2*0.16)) +s.d2 \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.3/EX2_3.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.3/EX2_3.R new file mode 100644 index 00000000..8279b9d5 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.3/EX2_3.R @@ -0,0 +1,17 @@ +#PAGE NUMBER--2.11 +#Example number--2.3 + +x1=5200 +x2=4200 +x=5000 +#we know that combined mean----> x=(a1*x1+a2*x2)/(a1+a2) +#we will find the ratio of a1/a2 +#let us name it as ------> a +a=(x-x2)/(x1-x) +#by comparing a numerator and denominator we get a1=800 and a2=200 +a1=x-x2;a1 +a2=x1-x;a2 +m.p=a1*100/(a1+a2) +f.p=a2*100/(a1+a2) +sprintf("Percentage of male employee: %s",m.p) +sprintf("Percentage of female employee: %s",f.p) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.34/EX2_34.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.34/EX2_34.R new file mode 100644 index 00000000..8b6fa4af --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.34/EX2_34.R @@ -0,0 +1,45 @@ +#PAGE NUMBER--2.44 +#Example number--2.34 + +# Part(i) +# Firm A: +n1=500 # Number of wagers +x1=186 # Average daily wage +t_w_p1=n1*x1 # Total wages paid +t_w_p1 + +# Firm B: +n2=600 # Number of wagers +x2=175 # Average daily wage +t_w_p2=n2*x2 # Total wages paid +t_w_p2 + +sprintf("Firm B has larger wage bill") + +# Part(ii) +s.d1=sqrt(81) # Standard Deviation of A +s.d2=sqrt(100) # Standard Deviation of B +c.vA=100*s.d1/x1 +c.vA +c.vB=100*s.d2/x2 +c.vB + +sprintf("Firm B has greater variability in individual wages") + +# Part(iii) +a_d_w= (n1*x1 + n2*x2)/(n1 + n2) # Average daily wages +a_d_w +d1=x1-a_d_w +d2=x2-a_d_w +c.v= 1/(n1 + n2) * (n1*(81+d1^2) + n2*(100+d2^2)) +c.v + + + + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.35/EX2_35.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.35/EX2_35.R new file mode 100644 index 00000000..46620d2d --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.35/EX2_35.R @@ -0,0 +1,30 @@ +#PAGE NUMBER--2.48 +#Example number--2.35 + +A=4 +U1=-1.5 +U2=17 +U3=-30; U4=108 +u2= U2-U1^2; u2 +u3= U3-3*U2*U1+2*U1^3; u3 +u4= U4-4*U3*U1+6*U2*U1^2 -3*U1^4; u4 + +b1=u3^2/u2^3 +b1 +b2=u4/u2^2 +b2 +mean= A + U1 +mean + +# Taking A=0, we get the first moment about origin +U1=2.5 +U2= u2+U1^2; U2 +U3= u3+3*u2*U1+U1^3; U3 +U4= u4+4*u3*U1+6*u2*U1^2+U1^4; U4 + +# Taking A=2, we get the first moment about x=2 +U1=2.5-2 +U2= u2+U1^2; U2 +U3= u3+3*u2*U1+U1^3; U3 +U4= u4+4*u3*U1+6*u2*U1^2+U1^4; U4 + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.36/EX2_36.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.36/EX2_36.R new file mode 100644 index 00000000..9f754441 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.36/EX2_36.R @@ -0,0 +1,29 @@ +#PAGE NUMBER--2.49 +#Example number--2.36 + +x=seq(0,8,1) +f=c(1,8,28,56,70,56,28,8,1) +d=x-4 +fd=f*d +fd2=fd*d +fd3=fd2*d +fd4=fd3*d +data.frame(x,f,d,fd,fd2,fd3,fd4) + +# Moments about point x=4 +U1=sum(fd)/sum(f); U1 +U2=sum(fd2)/sum(f); U2 +U3=sum(fd3)/sum(f); U3 +U4=sum(fd4)/sum(f); U4 + +# Moments about mean +u1=0 +u2= U2-U1^2; u2 +u3= U3-3*U2*U1+2*U1^3; u3 +u4= U4-4*U3*U1+6*U2*U1^2 -3*U1^4; u4 + +b1=u3^2/u2^3 +b1 +b2=u4/u2^2 +b2 + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.4/EX2_4.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.4/EX2_4.R new file mode 100644 index 00000000..5285a4f6 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.4/EX2_4.R @@ -0,0 +1,44 @@ +#PAGE NUMBER--2.12 +#Example number--2.4 + +Age_Group=c("20-25","25-30","30-35","35-40","40-45","45-50","50-55","55-60","60-65") +n_o_p=c(30,160,210,180,145,105,70,60,40) # Number of persons +data.frame(Age_Group,n_o_p) + +N=1000 + +# Part(i) +a=15/100*N +sprintf("Number of persons to be retrenched from the lower group: %d", a) +sprintf("30 people from 20-25 age group") +sprintf("%d people from 25-30 age group", a-30) + +# Part(ii) +b=45/100*N +sprintf("Number of persons to be absorbed in other branches: %d", b) +Age_Group1=c("25-30","30-35","35-40","40-45") +n_o_p1=c(160-120,210,180,b-(40+210+180)) +data.frame(Age_Group1,n_o_p1) + +# Part(iii) +c=10/100*N +sprintf("Number of persons to retire: %d", c) + +Age_Group2=c("40-45","45-50","50-55") +n_o_p2=c(145-20,105,70) # Number of persons +data.frame(Age_Group2,n_o_p2) + +A=47.5 +h=5 +mid=c((40+45)/2,(45+50)/2,(50+55)/2) +d=(mid-A)/h;d +fd=n_o_p2*d +data.frame(Age_Group2,mid,n_o_p2,d,fd) +mean=A + h* sum(fd)/sum(n_o_p2) +round(mean) + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.40/EX2_40.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.40/EX2_40.R new file mode 100644 index 00000000..d760a03f --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.40/EX2_40.R @@ -0,0 +1,36 @@ +#PAGE NUMBER--2.51 +#Example number--2.40 + +N=250 +x=54 +s.d=3 +b1=0; b2=3 + +#Wrong observation---> 64 and 50 Correct observation---> 62 and 52 +#Part (i) +ux=N*x +cx=ux - (64+50) + (62+52) +cx +cm=cx/N # Corrected mean +cm + +# Part (ii) +ux2=N*s.d^2; ux2 +cx2=ux2 -((64-54)^2+(50-54)^2)+((62-54)^2+(52-54)^2); cx2 +cs.d=round(sqrt(cx2/N),2) # Corrected Standard Deviation +cs.d + +# Part (iii) +u3=b1*u2^3; u3 +ux3=N*u3; ux3 +cx3=0 -((64-54)^3+(50-54)^3)+((62-54)^3+(52-54)^3); cx3 # Answer here is wrong +cu3=cx3/N; cu3 +cb1=(cu3)^2/(cx2/N)^3; round(cb1) + +# Part (iv) +u4=b2*9^2 +ux4= N*u4; ux4 +cx4= ux4 - ((64-54)^4+(50-54)^4)+((62-54)^4+(52-54)^4); cx4 +cu4=cx4/N; cu4 +cb2= cu4/(cx2/N)^2; cb2 + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.42/EX2_42.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.42/EX2_42.R new file mode 100644 index 00000000..89163f98 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.42/EX2_42.R @@ -0,0 +1,19 @@ +#PAGE NUMBER--2.55 +#Example number--2.42 + +mean=10 +u2=16 +s.d=sqrt(16) +y1=1 +b1=4 + +# First four moments about origin +U1=mean +U2=u2 + U1^2; U2 +u3=s.d^3; u3 +U3= u3 + 3*U2*U1 -2*U1^3; U3 +u4= b1*u2^2; u4 # here we have to take value of b1, written wrong in book + +U4= u4 + 4*U3*U1 - 6*U2*U1^2 + 3*U1^4; U4 # plus,minus signs are not correct in the book + +sprintf("The distribution is leptokurtic") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.43/EX2_43.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.43/EX2_43.R new file mode 100644 index 00000000..caafe398 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.43/EX2_43.R @@ -0,0 +1,53 @@ +#PAGE NUMBER--2.56 +#Example number--2.43 + +A=135 +h=10 +Scores=c("50-60","60-70","70-80","80-90","90-100","100-110","110-120","120-130", +"130-140","140-150","150-160","160-170","170-180","180-190","190-200", +"200-210","210-220","220-230") +f=c(1,0,0,1,1,2,1,0,4,4,2,5,10,11,4,1,1,2) +mid=c((50+60)/2,(60+70)/2,(70+80)/2,(80+90)/2,(90+100)/2,(100+110)/2, +(110+120)/2,(120+130)/2,(130+140)/2,(140+150)/2,(150+160)/2,(160+170)/2, +(170+180)/2,(180+190)/2,(190+200)/2,(200+210)/2,(210+220)/2,(220+230)/2) +d=(mid-A)/h +fd=f*d +fd2=fd*d +fd3=fd2*d +fd4=fd3*d +data.frame(Scores,mid,f,d,fd,fd2,fd3,fd4) + +# Raw Moments of variable d about origin +U1=sum(fd)/sum(f); U1 +U2=sum(fd2)/sum(f); U2 +U3=sum(fd3)/sum(f); U3 +U4=sum(fd4)/sum(f); U4 + +# Central Moments of variable X +u2= (U2-U1^2)*h^2; u2 +u3= (U3-3*U2*U1+2*U1^3)*h^3; u3 +u4= (U4-4*U3*U1+6*U2*U1^2 -3*U1^4)*h^4; u4 + +# Sheppard's Corrections for Moments + +u2b=u2-h^2/12; u2b +u3b=u3; u3b +u4b=u4 - h^2/2*u2 + 7/240*h^4; u4b + +# Moment coefficient of skewness +y1= u3/(u2)^(3/2); y1 + +# Moment coefficient of kurtosis +b2= u4/u2^2; b2 + +sprintf("The distribution is leptokurtic") + + + + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.6/EX2_6.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.6/EX2_6.R new file mode 100644 index 00000000..3d5fe98d --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.6/EX2_6.R @@ -0,0 +1,10 @@ +#PAGE NUMBER--2.15 +#Example number--2.6 + +x=c(1,2,3,4,5,6,7,8,9) +f=c(8,10,11,16,20,25,15,9,6) +cf=cumsum(f) +data.frame(x,f,cf) +sum(f)/2 +sprintf("Cumulative frequence just greater than 60 is 65") +sprintf("So, Median = 5") \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.7/EX2_7.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.7/EX2_7.R new file mode 100644 index 00000000..f4012c87 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.7/EX2_7.R @@ -0,0 +1,15 @@ +#PAGE NUMBER--2.16 +#Example number--2.7 + +Wages=c("2000-3000","3000-4000","4000-5000","5000-6000","6000-7000") +n_o_e=c(3,5,20,10,5) # Number of employees +cf=cumsum(n_o_e) +data.frame(Wages,n_o_e,cf) + +sum(n_o_e)/2 +sprintf("Cumulative frequence just greater than 21.5 is 28") +sprintf("So, the median class is 4000-5000") + +median= 4000 + 1000/20*(21.5-8) +median + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.8/EX2_8.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.8/EX2_8.R new file mode 100644 index 00000000..9c196fe0 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.8/EX2_8.R @@ -0,0 +1,14 @@ +#PAGE NUMBER--2.17 +#Example number--2.8 + +Wages_hours=c("Below 3.005","3.005-4.505","4.505-6.005","6.005-7.505","7.505-9.005","9.005 Above") +f=c(0.05*3000,580,0.3*3000,500,0.2*3000,3000-2730) +cf=cumsum(f) +data.frame(Wages_hours,f,cf) + +sum(f)/2 +sprintf("Cumulative frequence just greater than 1500 is 1630") +sprintf("So, the median class is 4.505-6.005") + +median= 4.505 + 1.5/900*(1500-730) +round(median,2) diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.9/EX2_9.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.9/EX2_9.R new file mode 100644 index 00000000..043ae9d2 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH2/EX2.9/EX2_9.R @@ -0,0 +1,24 @@ +#PAGE NUMBER--2.17 +#Example number--2.9 + +variable=c("10-20","20-30","30-40","40-50","50-60","60-70","70-80") +f=c(12,30,NA,65,NA,25,18) +data.frame(variable,f) + +# Let frequency of 30-40 be f1 +# Let frequency of 50-60 be f1 +# sum of f1+f2= q +q=229-(12+30+65+25+18) +#Solving the equation----> 46=40+(114.5-12-30-f1)/65*10 +f1=round(solve(10,335)) +f1 +f2=q-f1 +f2 + + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH20/EX20.1/EX20_1.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH20/EX20.1/EX20_1.R new file mode 100644 index 00000000..07d1e506 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH20/EX20.1/EX20_1.R @@ -0,0 +1,16 @@ +#Page number--20.8 +#Example number--20.1 + +x=seq(0,4,1) +e=x-2 +y=c(1,1.8,3.3,4.5,6.3) +q=e +y0=y*e +data.frame(x,e,y,q,y0) + +b0=sum(y)/length(x) +b0 +b1=sum(y0)/sum(e^2) +b1 +#WE get the following equation +# y = 1.33*x + 0.72 \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH20/EX20.2/EX20_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH20/EX20.2/EX20_2.R new file mode 100644 index 00000000..7521aac3 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH20/EX20.2/EX20_2.R @@ -0,0 +1,21 @@ +#Page number--20.9 +#Example number--20.2 + +x=seq(0.5,3,0.5) +e=4*x-7 +y=c(72,110,158,214,290,380) +q=e +q2=c(5,-1,-4,-4,-1,5) +y0=y*q +y1=y*q2 +data.frame(x,e,y,q,q2,y0,y1) + +b0=sum(y)/length(x) +b0 +b1=sum(y0)/sum(e^2) +b1 +b2=sum(y1)/sum(q2^2) +b2 + +#WE get the following equation +# y = 106.32*x^2 - 128.04*x + 83.08 \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.2/EX3_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.2/EX3_2.R new file mode 100644 index 00000000..3844d21a --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.2/EX3_2.R @@ -0,0 +1,39 @@ +#Page number--3.7 +#Example number--3.2 +#LOAD PACKAGE---->prob + +s=rolldie(2) +s + +#Part (a) +subset(s,X1==X2) +p=nrow(subset(s,X1==X2))/nrow(s) +sprintf("Probability that the two dice show the same number: %f",p) + +#Part (b) +subset(s,X1==6) +p=nrow(subset(s,X1==6))/nrow(s) +sprintf("Probability that the first die show 6: %f",p) + +#Part (c) +subset(s,X1+X2==8) +p=nrow(subset(s,X1+X2==8))/nrow(s) +sprintf("Probability that the total of numbers on the die is 8: %f",p) + +#Part (d) +subset(s,X1+X2>8) +p=nrow(subset(s,X1+X2>8))/nrow(s) +sprintf("Probability that the total of numbers on the die is more than 8: %f",p) + +#Part (e) +subset(s,X1+X2==13) +p=nrow(subset(s,X1+X2==13))/nrow(s) +sprintf("Probability : %f",p) +sprintf("This is an impossible event") + +#Part (f) +sprintf("This is a certain event.") +sprintf("Probability : 1") + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.24/EX3_24.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.24/EX3_24.R new file mode 100644 index 00000000..ba0f0566 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.24/EX3_24.R @@ -0,0 +1,25 @@ +#Page number--3.36 +#Example number--3.24 + +letters + +n=length(letters) + +#Part (i) +#Probability that the letter choosen is vowel +n1=length(c("a","e","i","o","u")) +p=n1/n +sprintf("Probability: %f",p) + +#Part (ii) +#Probability that the letter preceeds m and is vowel +n2=length(c("a","e","i")) +p=n2/n +sprintf("Probability: %f",p) + +#Part (iii) +#Probability that the letter follows m and is vowel +n3=length(c("o","u")) +p=n3/n +sprintf("Probability: %f",p) + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.29/EX3_29.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.29/EX3_29.R new file mode 100644 index 00000000..dbd7702e --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.29/EX3_29.R @@ -0,0 +1,13 @@ +#Page number--3.38 +#Example number--3.29 + +#Probability of rolling die=P(n) +#P(n)is proportional to n +#P(n)=kn +#We know that-----> P(1)+P(2)+P(3)+P(4)+P(5)+P(6)=1 +#k(1+2+3+4+5+6)=1 +k=solve(21,1) +#We need to find probability of an odd number appearing on top +#P(1)+P(3)+(5) +p=1*k+3*k+5*k +sprintf("Probability : %f",p) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.3/EX3_3.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.3/EX3_3.R new file mode 100644 index 00000000..01e00182 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.3/EX3_3.R @@ -0,0 +1,32 @@ +#Page number--3.8 +#Example number--3.3 + +# Part(a) +N=5*4 +sprintf("Total number of cases: %d",N) +#Part(i) +# there are 12 cases--->(1,2),(1,3),(1,4),(1,5),(3,1),(3,2),(3,4),(3,5),(5,1),(5,2),(5,3),(5,4) +a=12/20 +sprintf("Probability that the first digit drawn is odd: %f",a) +#Part(ii) +# there are 12 cases--->(2,1),(3,1),(4,1),(5,1),(1,3),(2,3),(4,3),(5,3),(1,5),(2,5),(3,5),(4,5) +b=12/20 +sprintf("Probability that the second digit drawn is odd: %f",b) +#Part(iii) +# there are 6 cases--->(1,3),(1,5),(3,1),(3,5),(5,1),(5,3) +c=6/20 +sprintf("Probability that the first and second digit drawn are odd: %f",c) + +# Part(b) +n=25 +#Number which are multiple of 5-----> 5,10,15,20,25 +d.f.c= 5+3 # Distinct favourable cases +d=d.f.c/n +sprintf("Required Probability: %f",d) + +#Number which are multiple of 3-----> 3,6,9,12,15,18,21,24 +d.f.c= 8+3-1 # Distinct favourable cases +e=d.f.c/n +sprintf("Required Probability: %f",e) + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.30/EX3_30.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.30/EX3_30.R new file mode 100644 index 00000000..b88d63a8 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.30/EX3_30.R @@ -0,0 +1,26 @@ +#Page number--3.39 +#Example number--3.30 +#LOAD PACKAGE---prob + +s=rolldie(2) + +#S denotes sum of faces of two die + +#Part (a) +subset(s,X1+X2>8) +#Sample Space +#S=9-------->(3,6),(6,3),(4,5)(5,4) +#S=10------->(4,6),(6,4),(5,5) +#S=11------->(5,6),(6,5) +#S=12------->(6,6) +p=nrow(subset(s,X1+X2==9))/nrow(s)+nrow(subset(s,X1+X2==10))/nrow(s)+nrow(subset(s,X1+X2==11))/nrow(s)+nrow(subset(s,X1+X2==12))/nrow(s) +sprintf("Probability that sum greater than 8: %f",p) + +#Part(b) +subset(s,X1+X2==7 | X1+X2==11) +#Sample Space +#S=7-------->(1,6),(6,1),(2,5),(5,2),(3,4),(4,3) +#S=11------->(5,6),(6,5) +p1=nrow(subset(s,X1+X2==7))/nrow(s)+nrow(subset(s,X1+X2==11))/nrow(s) +sprintf("Required Probability : %f",1-p1) + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.37/EX3_37.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.37/EX3_37.R new file mode 100644 index 00000000..4aa1b094 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.37/EX3_37.R @@ -0,0 +1,31 @@ +#Page number--3.41 +#Example number--3.37 +#LOAD PACKAGE---->prob + +s=cards() +s + +#A= Probability that the card drawn is king +#B= Probability that the card drawn is heart +#C= Probability that the card drawn is red card +A=nrow(subset(s,rank=="K"))/nrow(s) +B=nrow(subset(s,suit=="Heart"))/nrow(s) +C=(nrow(s)/2)/nrow(s) #Total red cards=26(i.e. half of deck) +#D=Probability that the card drawn is king of hearts +#E=Probability that the card drawn is heart +#F=Probability that the card drawn is red king +#G=Probability that the card drawn is king of hearts +D=1/nrow(s) +E=13/nrow(s) +F=2/nrow(s) +G=1/nrow(s) +#P=Probability that the card drawn is KING OR HEART OR RED CARD +P=A+B+C-D-E-F+G +P + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.4/EX3_4.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.4/EX3_4.R new file mode 100644 index 00000000..74b211f9 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH3/EX3.4/EX3_4.R @@ -0,0 +1,53 @@ +#Page number--3.9 +#Example number--3.4 + +#Preparing Combination function +comb=function(n,r){ + return (factorial(n)/(factorial(r)*factorial(n-r))) +} + +s=cards() + +#Part (i) +subset(s, rank=="K" | rank=="J" | rank=="Q" | rank=="A") +#there are 4 King, 4 Jack, 4 Queen, 4 Ace ---> we need to select one from each +#total there are 52 cards +p=(comb(4,1)*comb(4,1)*comb(4,1)*comb(4,1))/comb(52,4) +sprintf("Probability: %f",p) + +#Part (ii) +subset(s, rank=="K" | rank=="Q" ) +#there are 4 kings, 4 queens ----> we need to select two from each +#total there are 52 cards +p=(comb(4,2)*comb(4,2))/comb(52,4) +sprintf("Probability: %f",p) + +#Part (iii) +#There are 26 black cards and 26 red cards ----> we need to select two from each +#total there are 52 cards +p=(comb(26,2)*comb(26,2))/comb(52,4) +sprintf("Probability: %f",p) + +#Part (iv) +subset(s, suit=="Diamond" | suit=="Heart" ) +#there are 13 heart, 13 diamonds ----> we need to select two from each +#total there are 52 cards +p=(comb(13,2)*comb(13,2))/comb(52,4) +sprintf("Probability: %f",p) + +#Part (v) +#4 cards can be from each suit +#total 52 cards +p=(comb(13,1)*comb(13,1)*comb(13,1)*comb(13,1))/comb(52,4) +sprintf("Probability: %f",p) + + + + + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.1/EX4_1.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.1/EX4_1.R new file mode 100644 index 00000000..ffdb63b0 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.1/EX4_1.R @@ -0,0 +1,32 @@ +#Page number--4.6 +#Example number--4.1 + +#There are 3 factories-->X,Y,Z +#Product produced respectively--->3n,n,n +#Where n is constant, let suppose n=1 +n=1 +#E1,E2,E3 denotes event to the item produced in X,Y,Z +#A be the event that item is deffective +PE1=3*n/(3*n+n+n) +PE2=n/(5*n) +PE3=n/(5*n) +#GIVEN------->P(A|E1)=P(A|E3)=0.03 AND P(A|E2)=0.05 +P.AE1=0.03 #P(A|E1) +P.AE3=0.03 #P(A|E3) +P.AE2=0.05 #P(A|E2) + +#Part (i) +PA=PE1*P.AE1+PE2*P.AE2+PE3*P.AE3 +PA +sprintf("The required probability is: %f ",PA) + + +#Part (ii) +#Using bayes rule +P.E1A=(PE1*P.AE1)/PA #P(E1|A) +P.E2A=(PE2*P.AE2)/PA #P(E2|A) +P.E3A=(PE3*P.AE3)/PA #P(E3|A) +sprintf("The required probabilities are: %f ,%f ,%f",P.E1A,P.E2A,P.E3A) + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.10/EX4_10.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.10/EX4_10.R new file mode 100644 index 00000000..40c9c0d6 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.10/EX4_10.R @@ -0,0 +1,25 @@ +#Page number--4.11 +#Example number--4.10 + +#E--------->They get same answer +#E1-------->Both A and B solve correctly +#E2-------->Exactly one of them sovles correctly +#E3-------->No one sovles correctly + + +PE1=1/6*1/8 +PE2=1/6*7/8+5/6*1/8 +PE3=5/6*7/8 + +P.EE1=1 #P(E|E1) +P.EE2=0 #P(E|E2) +P.EE3=1/525 #P(E|E3) + +PE=PE1*P.EE1+PE2*P.EE2+PE3*P.EE3 + +#Using bayes rule +P.E1E=(PE1*P.EE1)/PE #P(E1|E) +sprintf("The required probability is: %f ",P.E1E) + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.16/EX4_16.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.16/EX4_16.R new file mode 100644 index 00000000..8842b2f7 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.16/EX4_16.R @@ -0,0 +1,32 @@ +#Page number--4.15 +#Example number--4.16 + +#E------------->The referee observes plus sign +#E1,E2--------->Wrote plus or minus sign +#E3,E4--------->Plus signed not changed, Plus sign was changed exactly twice + +PE1=1/3 +PE2=1-PE1 + +#A1,A2,A3---->B,C,D change sign on slip +PA1=2/3;PA2=2/3;PA3=2/3 +PA1b=1/3;PA2b=1/3;PA3b=1/3 #P(Ai) bar + +PE3=(1/3)^3 +PE4=PA1*PA2*PA3b+PA1*PA2b*PA3+PA1b*PA2*PA3 + +P.EE1=PE3+PE4 #P(E|E1) +sprintf("The required probability is: %f ",P.EE1) + +#E5,E6--------->Minus sign change once, Minus sign change thrice +PE5=PA1*PA2b*PA3b+PA1b*PA2*PA3b+PA1b*PA2b*PA3 +PE6=PA1*PA2*PA3 +P.EE2=PE5+PE6 #P(E|E2) +sprintf("The required probability is: %f ",P.EE2) + +P.E1E=(PE1*P.EE1)/(PE1*P.EE1+PE2*P.EE2) #P(E1|E) +sprintf("The FINAL probability is: %f ",P.E1E) + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.18/EX4_18.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.18/EX4_18.R new file mode 100644 index 00000000..310f82a3 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.18/EX4_18.R @@ -0,0 +1,28 @@ +#Page number--4.17 +#Example number--4.18 + +#E------------->Event of drawing a white ball from the second urn in the fiest draw +#E0,E1,E2,E3,E4------>Drawing of (0,4),(1,3),(2,2),(3,1),(4,0) white and black balls + +PE0=choose(5,4)/choose(10,4) +PE1=choose(5,1)*choose(5,3)/choose(10,4) +PE2=choose(5,2)*choose(5,2)/choose(10,4) +PE3=choose(5,3)*choose(5,1)/choose(10,4) +PE4=choose(5,4)/choose(10,4) +P.EE0=0 #P(E|E0) +P.EE1=1/4 #P(E|E1) +P.EE2=2/4 #P(E|E2) +P.EE3=3/4 #P(E|E3) +P.EE4=4/4 #P(E|E4) + +#C-------->Future event + +P.CE0E=0 #P(C|intersection(E0,E)) +P.CE1E=0 #P(C|intersection(E1,E)) +P.CE2E=1/3 #P(C|intersection(E2,E)) +P.CE3E=2/3 #P(C|intersection(E3,E)) +P.CE4E=3/3 #P(C|intersection(E4,E)) + +P.CE=(PE0*P.EE0*P.CE0E+PE1*P.EE1*P.CE1E+PE2*P.EE2*P.CE2E+PE3*P.EE3*P.CE3E+PE4*P.EE4*P.CE4E)/(PE0*P.EE0+PE1*P.EE1+PE2*P.EE2+PE3*P.EE3+PE4*P.EE4) +sprintf("The required probability is: %f ",P.CE) + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.2/EX4_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.2/EX4_2.R new file mode 100644 index 00000000..ef92af25 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.2/EX4_2.R @@ -0,0 +1,23 @@ +#Page number--4.7 +#Example number--4.2 + +#A------------->Introduction to co-education +#E1,E2,E3------>Chatterji,Ayangar,Singh selected as principal + +PE1=4/9 +PE2=2/9 +PE3=3/9 +P.AE1=0.3 #P(A|E1) +P.AE2=0.5 #P(A|E2) +P.AE3=0.8 #P(A|E3) + +#Part (i) +PA=PE1*P.AE1+PE2*P.AE2+PE3*P.AE3 +sprintf("The required probability is: %f ",PA) + +#Part (ii) +#Using bayes rule +P.E3A=(PE3*P.AE3)/PA #P(E3|A) +sprintf("The required probability is: %f ",P.E3A) + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.20/EX4_20.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.20/EX4_20.R new file mode 100644 index 00000000..ca0987b2 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.20/EX4_20.R @@ -0,0 +1,18 @@ +#Page number--4.19 +#Example number--4.20 + +#A------------->Getting a red face in each of 1st n throws +#E1,E2,E3------>Event that Die A is used, Die B is used, Getting a red face + +#Part (i) +P.E3E1=4/6 #P(E3|E1) +P.E3E2=2/6 #P(E3|E2) + +PE1=1/2;PE2=1/2 + +PE3=PE1*P.E3E1+PE2*P.E3E2 +sprintf("The probability of getting a red face in any throw: %f ",PE3) + +#Part (ii) +#Using the Law Of Succession +sprintf("The probability of getting a red face at the 3rd throw when 1st two gave red faces: %f ", (1/2+1)/(1/2+2)) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.3/EX-4_3.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.3/EX-4_3.R new file mode 100644 index 00000000..db73d2ff --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.3/EX-4_3.R @@ -0,0 +1,24 @@ +#Page number--4.7 +#Example number--4.3 + +#X,Y,Z---->managers +#E1,E2,E3------>Are the events of becoming X,Y,Z managers + +PE1=4/9 +PE2=2/9 +PE3=1/3 +P.AE1=0.3 #P(A|E1) +P.AE2=0.5 #P(A|E2) +P.AE3=0.8 #P(A|E3) + +#Part (i) +PA=PE1*P.AE1+PE2*P.AE2+PE3*P.AE3 +PA +sprintf("The probability that Bonus scheme is introduced: %f ",PA) + +#Part (ii) +#Using bayes rule +P.E1A=(PE1*P.AE1)/PA #P(E1|A) +sprintf("The probability that X will be manager: %f ",P.E1A) + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.4/EX4_4.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.4/EX4_4.R new file mode 100644 index 00000000..5b09e658 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.4/EX4_4.R @@ -0,0 +1,24 @@ +#Page number--4.8 +#Example number--4.4 + +#A------------->Output is defective +#E1,E2,E3------>Output produced by machines I,II,III + +PE1=3000/10000 +PE2=2500/10000 +PE3=4500/10000 +P.AE1=0.01 #P(A|E1) +P.AE2=0.012 #P(A|E2) +P.AE3=0.02 #P(A|E3) + +PA=PE1*P.AE1+PE2*P.AE2+PE3*P.AE3 +PA +sprintf("The probability that output is deffective: %f ",PA) + + +#Using bayes rule +P.E1A=(PE1*P.AE1)/PA #P(E1|A) +P.E2A=(PE2*P.AE2)/PA #P(E2|A) +P.E3A=(PE3*P.AE3)/PA #P(E3|A) +sprintf("The probabilities of machine I,II,III are: %f ,%f ,%f",P.E1A,P.E2A,P.E3A) + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.9/EX4_9.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.9/EX4_9.R new file mode 100644 index 00000000..517e9dfb --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH4/EX4.9/EX4_9.R @@ -0,0 +1,22 @@ +#Page number--4.11 +#Example number--4.9 + +#E------------->Drawing a white ball from second vessel +#E1,E2,E3,E4------>Transfer of (0,4),(1,3),(2,2),(3,1) white and black balls + +PE1=choose(5,4)/choose(8,4) +PE2=choose(3,1)*choose(5,3)/choose(8,4) +PE3=choose(3,2)*choose(5,2)/choose(8,4) +PE4=choose(3,3)*choose(5,1)/choose(8,4) +P.EE1=0 #P(E|E1) +P.EE2=1/4 #P(E|E2) +P.EE3=2/4 #P(E|E3) +P.EE4=3/4 #P(E|E4) + +PE=PE1*P.EE1+PE2*P.EE2+PE3*P.EE3+PE4*P.EE4 + +#Using bayes rule +P.E4E=(PE4*P.EE4)/PE #P(E4|E) +sprintf("The required probability is: %f ",P.E4E) + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.1/EX5_1.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.1/EX5_1.R new file mode 100644 index 00000000..29955b4d --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.1/EX5_1.R @@ -0,0 +1,61 @@ +#Page number--5.6 +#Example number--5.1 + +# Constructing Quadratic Formula +result <- function(a,b,c){ + if(delta(a,b,c) > 0){ # first case D>0 + x_1 = (-b+sqrt(delta(a,b,c)))/(2*a) + x_2 = (-b-sqrt(delta(a,b,c)))/(2*a) + result = c(x_1,x_2) + } + else if(delta(a,b,c) == 0){ # second case D=0 + x = -b/(2*a) + } + else {"There are no real roots."} # third case D<0 +} + +# Constructing delta +delta<-function(a,b,c){ + b^2-4*a*c +} + +#Values of X +x=c(0,1,2,3,4,5,6,7) +#Respective probabilities +px=c("0","k","2k","2k","3k","k^2","2k^2","7k^2+k") + +data.frame(x,px) + +#Part(i) +#We know that total probability =1 +#k+2k+2k+3k+k^2+2k^2+7k^2+k=1-------------->We get 10*k^2+9*k-1=0 +a=result(10,9,-1) +a +#Since, k cannot be negative +k=a[1] +k +#Substituting values of k in p(x), we get +px=c(0,k,2*k,2*k,3*k,k^2,2*k^2,7*k^2+k) + +b=data.frame(x,px) +b + +#Part (ii) +#Evaluate P(X<6) +PX6=sum(b[1:6,2]) +sprintf("The probability X<6 is: %f",PX6) +sprintf("The probability X>=6 is: %f",1-PX6) +P0X5=sum(b[2:5,2]) +sprintf("The probability 0cubature +# Constructing Quadratic Formula +result <- function(a,b,c){ + if(delta(a,b,c) > 0){ # first case D>0 + x_1 = (-b+sqrt(delta(a,b,c)))/(2*a) + x_2 = (-b-sqrt(delta(a,b,c)))/(2*a) + result = c(x_1,x_2) + } + else if(delta(a,b,c) == 0){ # second case D=0 + x = -b/(2*a) + } + else {"There are no real roots."} # third case D<0 +} + +# Constructing delta +delta<-function(a,b,c){ + b^2-4*a*c +} + + +#Total probability = 1 +integrand=function(x){x*(2-x)} +a=integrate(integrand,lower=0,upper=2) +a +y0=1/1.333 + +u1d=(3*2^2)/(3*4) #Mean +u2d=(3*2^3)/(4*5) +u3d=(3*2^4)/(5*6) +u4d=(3*2^5)/(6*7) +#Variance +#u2=u2d-u1d^2 +u2=6/5-1 +#u3=u3d-3*u2d*u1d+2*u1d^3 +u3=8/5-3*6/5*1+2 +#u4=u4d-4*u3d*u1d+6*u2d*u1d^2-3*u1d^4 +u4=16/7-4*8/5*1+6*6/5*1-3*1 +beta1=u3^2/u2^3 +beta1 +beta2=u4/u2^2 +beta2 +#Since beta1 =0, symmetrical distribution +#Mean deviation about mean +integrand=function(x){3/4*(1-x)*x*(2-x)} +f1=integrate(integrand,lower=0,upper=1) +f1 +integrand=function(x){3/4*(x-1)*x*(2-x)} +f2=integrate(integrand,lower=1,upper=2) +f2 +#Mean deviation abt mean=f1+f2 +M=0.1875+0.1875 + +#Harmonic Mean +integrand=function(x){3/4*(2-x)} +a=integrate(integrand,lower=0,upper=2) +a +H.M=3/2 + +#Median +#integrand=function(x){3/4*x*(2-x)} +#integrate(integrand,lower=0,upper=M)=1/2 +#Solving above integral we get quadratic equation----->(M-1)*(M^2-2*M-2)=0 +b=result(1,-2,-2) +b +#Other solution of b +b=1 +#Since, M lying in [0,2] +sprintf("The median is: %f", b) + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.13/EX5_13.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.13/EX5_13.R new file mode 100644 index 00000000..ceb86977 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.13/EX5_13.R @@ -0,0 +1,33 @@ +#Page number--5.18 +#Example number--5.13 + +#Mean +integrand=function(x){x*(3+2*x)/18} +a1=integrate(integrand,lower=2,upper=4) +a1 +u1d=83/27 + +integrand=function(x){x^2*(3+2*x)/18)} +a2=integrate(integrand,lower=2,upper=4) +a1 +u2d=88/9 + +#Varience +v=u2d-u1d^2 + +#Standard Deviation +s.d=sqrt(v) + +#Mean Deviation +integrand=function(x){(83/27-x)*(3+2*x)/18} +f1=integrate(integrand,lower=2,upper=83/27) +f1 +integrand=function(x){(x-83/27)*(3+2*x)/18} +f2=integrate(integrand,lower=83/27,upper=4) +f2 +#Mean deviation=f1+f2 +M.D=0.247264+0.247264 + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.19/EX5_19.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.19/EX5_19.R new file mode 100644 index 00000000..3273b3f6 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.19/EX5_19.R @@ -0,0 +1,32 @@ +#Page number--5.21 +#Example number--5.19 + +#Part (i) +integrand=function(x){100/x^2} +a=integrate(integrand,lower=100,upper=150) +a +#Probability that tubes be replaced in first 150 hrs. +p=(1/3)^3 + +#Part (ii) +#Probability that none of tubes be replaced in first 150 hrs. +p=(1-1/3)^3 + +#Part (iii) +#Probability that tube last more than 150 but less than 200 hrs. +integrand=function(x){100/x^2} +a1=integrate(integrand,lower=150,upper=200) +a1 +integrand=function(x){100/x^2} +a2=integrate(integrand,lower=150,upper=Inf) +a2 +#a1=0.1666667 a2=0.6666667 +p=0.1666667/0.6666667 + +#Part (iv) +#Maximum number of tubes +n=log(0.5)/log(0.6667) +n + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.2/EX5_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.2/EX5_2.R new file mode 100644 index 00000000..ee50cbed --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.2/EX5_2.R @@ -0,0 +1,22 @@ +#Page number--5.7 +#Example number--5.2 + +x=c(1,2,3,4,5) +px=c() +i=1 +while(i<=5){ + px[i]=i/15 + i=i+1 +} +a=data.frame(x,px) +a + +#Part (i) +PX12=sum(a[1:2,2]) +sprintf("The probability X=1 or X=2 is: %f",PX12) + +#Part (ii) +P=a[2,2]/(1-a[1,2]) +sprintf("The required probability is: %f",P) + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.22/EX5_22.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.22/EX5_22.R new file mode 100644 index 00000000..bde27198 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.22/EX5_22.R @@ -0,0 +1,23 @@ +#Page number--5.24 +#Example number--5.22 + +#Part (i) +#P(X<=10) +integrand=function(x){1/20*exp(-x/20)} +a=integrate(integrand,lower=0,upper=10) +a + +#Part (ii) +#P(16<=X<=24) +integrand=function(x){1/20*exp(-x/20)} +a1=integrate(integrand,lower=16,upper=24) +a1 + +#Part (iii) +#P(X>=30) +integrand=function(x){1/20*exp(-x/20)} +a3=integrate(integrand,lower=30,upper=Inf) +a3 + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.24/EX5_24.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.24/EX5_24.R new file mode 100644 index 00000000..e13a2b32 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.24/EX5_24.R @@ -0,0 +1,38 @@ +#Page number--5.27 +#Example number--5.24 +#LOAD PACKAGE---->ploynom + +#Part (i) +integrand=function(x){6*x*(1-x)} +a=integrate(integrand,lower=0,upper=1) +a +sprintf("The function p.d.f") + +#Part (ii) +#The expression is +#0, if x<=0 +#(3*x^2-2*x^3), if 01 + +#Part (iii) +integrand=function(x){6*x*(1-x)} +a1=integrate(integrand,lower=1/3,upper=1/2) +a1 +integrand=function(x){6*x*(1-x)} +a2=integrate(integrand,lower=1/3,upper=2/3) +a2 +#a1=0.2407407 a2=0.4814815 +p=0.2407407/0.4814815 +p #Answer may vary because of rounding off values + +#Part (iv) +#integrand=function(x){6*x*(1-x)} +#integrate(integrand,lower=0,upper=k)=integrate(integrand,lower=k,upper=1) +#Solving above integral we get cubic equation----->4k^3-6k^2+1=0 +options(digits=16) +library(polynom) +p=polynomial(c(4,-6,0,1)) +solve(p) +sprintf("The only admissible value of k=1/2") + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.3/EX5_3.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.3/EX5_3.R new file mode 100644 index 00000000..9db1f18d --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.3/EX5_3.R @@ -0,0 +1,18 @@ +#Page number--5.7 +#Example number--5.3 +#LOAD PACKAGE----->prob + +s=rolldie(2) +s +X=c(1,2,3,4,5,6,7,8,9,10,11,12) +a=0 +for(i in 1:12){ + a[i]=nrow(subset(s,X1+X2==i))/nrow(s) +} +#Probability chart +plot(X,a,type="h",xlim=c(0,12),ylim=c(0,0.17),ylab="Prob.",xlab="Sum of two faces") + +#Cummulative probability distribution +FX=c(sum(a[1]),sum(a[1:2]),sum(a[1:3]),sum(a[1:4]),sum(a[1:5]),sum(a[1:6]),sum(a[1:7]),sum(a[1:8]),sum(a[1:9]),sum(a[1:10]),sum(a[1:11]),sum(a[1:12])) +data.frame(X,FX) + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.4/EX5_4.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.4/EX5_4.R new file mode 100644 index 00000000..2c2b9f9b --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.4/EX5_4.R @@ -0,0 +1,58 @@ +#Page number--5.8 +#Example number--5.4 +#LOAD PACKAGE---->prob + +s=tosscoin(3) +s +#For number of heads +X=c(3,2,2,1,2,1,1,0) +#For number of head runs +Y=c(1,1,0,0,1,0,0,0) +#For length of head runs +Z=c(3,2,0,0,2,0,0,0) +U=X+Y +V=X*Y +data.frame(X,Y,Z,U,V) + +#Part (i) +#Probability distribution of X +P3=1/8;P2=3/8;P1=3/8;P0=1/8 +x=seq(0,3,1) +px=c(P3,P2,P1,P0) +plot(x,px,type="h",xlim=c(0,3),ylim=c(0,0.4),ylab="Prob.",xlab="Number of heads") +points(0:3,px,pch=16,cex=2) + +#Part (ii) +#Probability distribution of Y +P1=3/8;P0=5/8 +y=seq(0,1,1) +py=c(P1,P0) +plot(y,py,type="h",xlim=c(0,1),ylim=c(0,0.7),ylab="Prob.",xlab="Number of heads runs") +points(0:1,py,pch=16,cex=2) + +#Part (iii) +#Probability distribution of Z +P3=1/8;P2=2/8;P1=0;P0=5/8 +z=seq(0,3,1) +pz=c(P0,P1,P2,P3) +plot(z,pz,type="h",xlim=c(0,3),ylim=c(0,0.7),ylab="Prob.") +points(0:3,pz,pch=16,cex=2) + +#Part (iv) +#Probability distribution of U +P4=1/8;P3=2/8;P2=1/8;P1=3/8;P0=1/8 +u=seq(0,4,1) +pu=c(P2,P1,P0,P3,P4) +plot(u,pu,type="h",xlim=c(0,4),ylim=c(0,0.4),ylab="Prob.") +points(0:4,pu,pch=16,cex=2) + +#Part (v) +#Probability distribution of V +P3=1/8;P2=2/8;P1=0;P0=5/8 +v=seq(0,3,1) +pv=c(P0,P1,P2,P3) +plot(v,pv,type="h",xlim=c(0,3),ylim=c(0,0.7),ylab="Prob.") +points(0:3,pv,pch=16,cex=2) + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.5/EX5_5.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.5/EX5_5.R new file mode 100644 index 00000000..601d03ae --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH5/EX5.5/EX5_5.R @@ -0,0 +1,43 @@ +#Page number--5.13 +#Example number--5.5 + +# Constructing Quadratic Formula +result <- function(a,b,c){ + if(delta(a,b,c) > 0){ # first case D>0 + x_1 = (-b+sqrt(delta(a,b,c)))/(2*a) + x_2 = (-b-sqrt(delta(a,b,c)))/(2*a) + result = c(x_1,x_2) + } + else if(delta(a,b,c) == 0){ # second case D=0 + x = -b/(2*a) + } + else {"There are no real roots."} # third case D<0 +} + +# Constructing delta +delta<-function(a,b,c){ + b^2-4*a*c +} + +#Part (i) +#Checking f(x) is p.d.f or not +integrand=function(x) {6*x*(1-x)} +a=integrate(integrand,lower=0,upper=1) +a +sprintf("f(x) is p.d.f") + +#Part (ii) +#Determining b +#integrand=function(x) {6*x*(1-x)} +#integrate(integrand,lower=0,upper=b) = integrate(integrand,lower=b,upper=1) +#Solving above integral we get quadratic equation----->(2*b-1)(2*b^2-2*b-1)=0 +b=result(2,-2,-1) +b +#Other solution of b +b=1/2 +#Since, probability cannot be negative or greater than 1 +sprintf("The onle real value of b: %f", b) + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.1/EX6_1.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.1/EX6_1.R new file mode 100644 index 00000000..2b853d86 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.1/EX6_1.R @@ -0,0 +1,16 @@ +#Page number--6.11 +#Example number--6.1 + +x=c(-3,6,9) +px=c(1/6,1/2,1/3) +a=data.frame(x,px) +a +#E(X) +EX=sum(a[1:3,1]*a[1:3,2]) +EX +#E(X^2) +EX2=sum((a[1:3,1])^2*a[1:3,2]) +EX2 +#E(2X+1)^2=4*E(X^2)+4*E(X)+1 +EX3=4*EX2+4*EX+1 +EX3 diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.2/EX6_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.2/EX6_2.R new file mode 100644 index 00000000..f58284ac --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.2/EX6_2.R @@ -0,0 +1,20 @@ +#Page number--6.11 +#Example number--6.2 +#LOAD PACKAGE---->prob + +s=rolldie(2,makespace=TRUE) +s + +#Part (a) +#E(X) +EX=sum(1/6*seq(1,6,,)) +EX + +#Part (b) +#Probability distribution on basis on sum of two faces of die +x=c(seq(2,12,1)) +px=c(1/36,2/36,3/36,4/36,5/36,6/36,5/36,4/36,3/36,2/36,1/36) +a=data.frame(x,px) +a +EX=sum(a[1:11,1]*a[1:11,2]) +EX diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.29/EX6_29.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.29/EX6_29.R new file mode 100644 index 00000000..d105f368 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.29/EX6_29.R @@ -0,0 +1,34 @@ +#Page number--6.36 +#Example number--6.29 +#LOAD PACKAGE---->prob + +s=rolldie(2) +s + +x=c(1,2,3,4,5,6) +y1=c(1/36,0,0,0,0,0) +y2=c(1/36,2/36,0,0,0,0) +y3=c(1/36,1/36,3/36,0,0,0) +y4=c(1/36,1/36,1/36,4/36,0,0) +y5=c(1/36,1/36,1/36,1/36,5/36,0) +y6=c(1/36,1/36,1/36,1/36,1/36,6/36) +Marginal_Totals_y=c(1/36,3/36,5/36,7/36,9/36,11/36) +Marginal_Totals_x=c(6/36,6/36,6/36,6/36,6/36,6/36) +a=data.frame(y1,y2,y3,y4,y5,y6,Marginal_Totals_x,Marginal_Totals_y) +a + +EY=1*1/36+2*3/36+3*5/36+4*7/36+5*9/36+6*11/36 +EY +EY2=1^2*1/36+2^2*3/36+3^2*5/36+4^2*7/36+5^2*9/36+6^2*11/36 +EY2 +VY=EY2-EY^2 +VY +EX1=6/36*(1+2+3+4+5+6) +EX1 +EX1Y=(1*1/36+2*1/36+3*1/36+4*1/36+5*1/36+6*1/36)+(4*2/36+6*1/36+8*1/36+10*1/36+12*1/36)+(9*3/36+12*1/36+15*1/36+18*1/36)+(16*4/36+20*1/36+24*1/36)+(25*5/36+30*1/36)+36*6/36 +EX1Y +COV=EX1Y-EX1*EY +COV + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.3/EX6_3.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.3/EX6_3.R new file mode 100644 index 00000000..9b41f1c1 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.3/EX6_3.R @@ -0,0 +1,19 @@ +#Page number--6.12 +#Example number--6.3 +#LOAD PACKAGE---->prob + +s=tosscoin(4) +s + +n.o.h=c(4,3,3,3,3,2,2,2,2,2,2,1,1,1,1,0) +data.frame(s,n.o.h) +PX0=1/6;PX1=4/16;PX2=6/16;PX3=4/16;PX4=1/16 + +#Probability Distribution +x=c(0,1,2,3,4) +px=c(PX0,PX1,PX2,PX3,PX4) +data.frame(x,px) +EX=sum(x*px) +EX + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.30/EX6_30.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.30/EX6_30.R new file mode 100644 index 00000000..1c0f6824 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.30/EX6_30.R @@ -0,0 +1,35 @@ +#Page number--6.37 +#Example number--6.30 + +#Part (i) +EY=-1*2+0*6+1*2 +EY +EX=-1*2+0*4+1*4 +EX + +#Part (ii) +EXY=-1*-1*0+0*-1*1+1*-1*1+0*-1*2+0*0*2+0*1*2+1*-1*0+1*0*1+1*1*1 +EXY +COV=EXY-EX*EY +COV + +#Part (iii) +EY2=-1^2*0.2+0*0.6+1^2*0.2 +EY2 +VY=EY2-EY^2 +VY +EX2=-1^2*0.2+0*0.4+1^2*0.4 +EX2 +VX=EX2-EX^2 +VX + +#Part (iv) +PXY=0.2/0.6 #P(X=-1|Y=0) +PXY=0.2/0.6 #P(X=0|Y=0) +PXY=0.2/0.6 #P(X=1|Y=0) + +#Part (v) +EYX=-1*0+0*2+1*0 +EYX2=1*0+0*2+0 +VYX=EYX2-EYX^2 +VYX diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.4/EX6_4.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.4/EX6_4.R new file mode 100644 index 00000000..44fe3545 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.4/EX6_4.R @@ -0,0 +1,14 @@ +#Page number--6.13 +#Example number--6.4 + +PX0=choose(3,2)/choose(10,2) +PX1=choose(7,1)*choose(3,1)/choose(10,2) +PX2=choose(7,2)/choose(10,2) + +x=c(0,1,2) +px=c(PX0,PX1,PX2) +#Probability Distribution +a=data.frame(x,px) +a +EX=sum(x*px) +EX diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.5/EX6_5.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.5/EX6_5.R new file mode 100644 index 00000000..fe70af24 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH6/EX6.5/EX6_5.R @@ -0,0 +1,12 @@ +#Page number--6.13 +#Example number--6.5 + +Event=c("Lucky number","Special lucky no.","Other numbers") +Favourable=c("5,10,15","0","1,2,3,4,6,7,8,9,11,12,13,14,16,17,18,19") +px=c(3/20,1/20,16/20) +Player_Gain=c((20-10)*px[1],(50-10)*px[2],-10*px[3]) +a=data.frame(Event,Favourable,px,Player_Gain) +a +EX=sum(a[1:3,4]) +EX +if(EX!=0){print("Game is not fair")} diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.12/EX7_12.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.12/EX7_12.R new file mode 100644 index 00000000..888a4606 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.12/EX7_12.R @@ -0,0 +1,18 @@ +#Page number--7.31 +#Example number--7.12 + +#S be total number of successes +n=600 #Number of times die thrown +p=1/6;q=5/6 +ES=n*p +VS=n*p*q + +#Using Chebychev's inequality +#P{|S-ES|=1-1/k^2 #s.d--->Standard deviation +#P{100-k*sqrt(500/6)=1-1/k^2 +#comparing lower limit with 80 +k=solve(sqrt(500/6),20) +k +#P{80<=S<=120} +P=1-1/k^2 +sprintf("Probabilities of getting 80 to 120 sixes: %f",P) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.13/EX7_13.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.13/EX7_13.R new file mode 100644 index 00000000..dd70e9c9 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.13/EX7_13.R @@ -0,0 +1,11 @@ +#Page number--7.32 +#Example number--7.13 + +#By proof of Bernoulli's law of large numbers +#P{|X/n-p|prob + +s=rolldie(2) +s + +#From above table we find that +X=c(seq(2,12,1)) +cases=c("(1,1)","(1,2),(2,1)","(1,3),(3,1),(2,2)","(1,4),(4,1),(2,3),(3,2)","(1,5),(5,1),(2,4),(4,2),(3,3)","(1,6),(6,1),(2,5),(5,2),(3,4),(4,3)","(2,6),(6,2),(3,5),(5,3),(4,4)","(3,6),(6,3),(4,5),(5,4)","(4,6),(6,4),(5,5)","(5,6),(6,5)","(6,6)") +prob=c(1/36,2/36,3/36,4/36,5/36,6/36,5/36,4/36,3/36,2/36,1/36) +a=data.frame(X,cases,prob) +a +EX=sum(X*prob) +EX +EX2=sum(X^2*prob) +EX2 +VarX=EX2-EX^2 +VarX +#By Chebychev's inequality +P=(35/6)/9 +P +#Actual Probability +P1=1-(4+5+6+5+4)/36 +P1 \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.19/EX7_19.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.19/EX7_19.R new file mode 100644 index 00000000..0fcdb220 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH7/EX7.19/EX7_19.R @@ -0,0 +1,17 @@ +#Page number--7.34 +#Example number--7.19 + +EX=(1+2+3+4+5+6)/6 +EX +EX2=(1^2+2^2+3^2+4^2+5^2+6^2)/6 +EX2 +VarX=EX2-EX^2 +VarX +#By Chebychev's inequality +k=2.5 +#P{|X2.5} 0){ # first case D>0 + x_1 = (-b+sqrt(delta(a,b,c)))/(2*a) + x_2 = (-b-sqrt(delta(a,b,c)))/(2*a) + result = c(x_1,x_2) + } + else if(delta(a,b,c) == 0){ # second case D=0 + x = -b/(2*a) + } + else {"There are no real roots."} # third case D<0 +} + +# Constructing delta +delta<-function(a,b,c){ + b^2-4*a*c +} + +#Probability Distribution +#P=choose(6,x)*(p)^x*(1-p)^6-x +#9*P(X=4)=P(X=2) +#Solving above equation +#We get quadratic equation---->8*p^2+2*p-1=0 +a=result(8,2,-1) +a +#Probability cannot be negative +sprintf("p : %f",a[1]) diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.12/EX8_12.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.12/EX8_12.R new file mode 100644 index 00000000..14b652ec --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.12/EX8_12.R @@ -0,0 +1,16 @@ +#Page number--8.11 +#Example number--8.12 + +# Mean +M=4 + +#Variance +Var=4/3 + +q=Var/M +p=1-q +n=M/p + +# P(X>=1) = 1 - P(X=0) +P=1-q^6 +P diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.2/EX8_2.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.2/EX8_2.R new file mode 100644 index 00000000..6b1327db --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.2/EX8_2.R @@ -0,0 +1,12 @@ +#Page number--8.5 +#Example number--8.2 +n=5 +#Probability A wins the game +p=3/5 +q=1-p +#Probability of getting A wins +#P=choose(5,x)*(3/5)^x*(2/5)^(5-x) +#Probability of getting 3 wins +P=(choose(5,3)*2**2+choose(5,4)*3*2+1*3^2*1)*3^3/5^5 +P + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.21/EX8_21.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.21/EX8_21.R new file mode 100644 index 00000000..a3514ab8 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.21/EX8_21.R @@ -0,0 +1,19 @@ +#Page number--8.19 +#Example number--8.21 + +n=5 +N=4096 +#Probability of success throw 4,5,6 +p=1/2 +q=1-p +#Probability distribution +#P=choose(12,x)*(1/2)^x*(1/2)^(12-x) +#f(x)=choose(12,x) +success=c(0,1,2,3,4,5,6,7,8,9,10,11,12) +Expected_Frequency=c() +for(i in success){ + Expected_Frequency[i+1]=choose(12,i) +} +data.frame(success,Expected_Frequency) +Total=sum(Expected_Frequency) +Total \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.22/EX8_22.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.22/EX8_22.R new file mode 100644 index 00000000..08e48d75 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.22/EX8_22.R @@ -0,0 +1,59 @@ +#Page number--8.20 +#Example number--8.22 + +n=7 +N=128 +#CASE 1: When the coin is unbaised +p=1/2 +q=p +x=c(seq(0,7,1)) +f=c(7,6,19,35,30,23,7,1) +fx=f*x +#a=(n-x)/(x+1) +a=c() +for(i in x){ + a[i+1]=(n-i)/(i+1) +} +#b=(n-x)/(x+1)*p/q +b=c() +for(i in x){ + b[i+1]=(n-i)/(i+1)*p/q +} +Expected_Frequency=c(1,1*7,7*3,21*5/3,35*1,35*3/5,21*1/3,7*1/7) +data.frame(x,f,fx,a,b,Expected_Frequency) + +#CASE 2: When nature of coin is not known +mean=433/128 +p=mean/n +q=1-p +p/q +x=c(seq(0,7,1)) +#a=(n-x)/(x+1) +a=c() +for(i in x){ + a[i+1]=(n-i)/(i+1) +} +#b=(n-x)/(x+1)*p/q +b=c() +for(i in x){ + b[i+1]=(n-i)/(i+1)*p/q +} +Expected_Frequency=c(1.2593,1.259*6.546,2.805*8.243,1.558*23.129,0.935*36.05,.5611*33.715,.3117*18.918,.1336*5.897) +data.frame(x,f,fx,a,b,Expected_Frequency,round(Expected_Frequency)) + +#Part (iii) +f=c(128*.0625*.1663,8.591,128*.283,128*.184,128*.260,128*.146,128*.043,128*.0056) +data.frame(x,f,round(f)) +Total=sum(round(f)) +Total #Note that total is wrong in the book + + + + + + + + + + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.3/EX8_3.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.3/EX8_3.R new file mode 100644 index 00000000..587f01e4 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.3/EX8_3.R @@ -0,0 +1,14 @@ +#Page number--8.6 +#Example number--8.3 +n=6 +#Probability of correct distinction between coffee +p=3/4 +q=1-p +#Probability of getting x correct distinction between coffee +#P=choose(6,x)*(3/4)^x*(1/4)^(6-x) +#Probability of getting atleast 5 correct distinction between coffee +P=choose(6,5)*(3/4)**5*(1/4)+choose(6,6)*(3/4)^6 +P +#Probability that the claim is rejected +Q=1-P +Q diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.33/EX8_33.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.33/EX8_33.R new file mode 100644 index 00000000..566b6103 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.33/EX8_33.R @@ -0,0 +1,11 @@ +#Page number--8.35 +#Example number--8.33 + +#For poisson distribution +#Part (i) +a=dpois(0,1.5) +sprintf("Proportion of days on which neither car is used: %f",a) + +#Part (ii) +b=ppois(2,1.5,lower=FALSE) +sprintf("Proportion on which some demand is refused: %f",b) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.34/EX8_34.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.34/EX8_34.R new file mode 100644 index 00000000..b3ba94ae --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.34/EX8_34.R @@ -0,0 +1,10 @@ +#Page number--8.35 +#Example number--8.34 + +n=4000 +#Probability of loss of both eyes +p=10/100000 +#For poisson distribution +lambda=n*p +a=ppois(3,lambda,lower=FALSE) +sprintf("Probability that more than 3 will collect the policy: %f",a) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.37/EX8_37.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.37/EX8_37.R new file mode 100644 index 00000000..a7b7c183 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.37/EX8_37.R @@ -0,0 +1,8 @@ +#Page number--8.37 +#Example number--8.37 + +lambda=390/520 +lambda +#For poisson distribution +a=dpois(0,lambda) +sprintf("Sample of 5 pages with no error: %f",a^5) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.4/EX8_4.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.4/EX8_4.R new file mode 100644 index 00000000..6d828062 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.4/EX8_4.R @@ -0,0 +1,12 @@ +#Page number--8.6 +#Example number--8.4 +n=8 +#Probability of getting answer correct +p=1/3 +q=1-p +#Probability of getting x answer correct +#P=choose(8,x)*(1/3)^x*(2/3)^(8-x) +#Probability of getting 6 answer correct +P=choose(8,6)*(1/3)^6*(2/3)^2+choose(8,7)*(1/3)^7*(2/3)+choose(8,8)*(1/3)^8 +P + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.41/EX8_41.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.41/EX8_41.R new file mode 100644 index 00000000..f48a3a18 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.41/EX8_41.R @@ -0,0 +1,8 @@ +#Page number--8.38 +#Example number--8.41 + +lambda=2 +#For poisson distribution +a=dpois(1,lambda) +b=dpois(2,lambda) +sprintf("Required probability: %f",a+b) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.55/EX8_55.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.55/EX8_55.R new file mode 100644 index 00000000..3f173b1d --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.55/EX8_55.R @@ -0,0 +1,19 @@ +#Page number--8.46 +#Example number--8.55 + +n_m_p=c(0,1,2,3,4) #Number of mistakes per page +n_o_p=c(109,65,22,3,1) #Number of pages +data.frame(n_m_p,n_o_p) + +#Poission distribution parameter +lambda=sum(n_m_p*n_o_p)/200 +lambda +Expected_Frequency=c() +a=c() +for(i in n_m_p){ + a[i+1]=dpois(i,lambda) +} +for(i in n_m_p){ + Expected_Frequency[i+1]=200*a[i+1] +} +data.frame(n_m_p,Expected_Frequency,round(Expected_Frequency)) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.56/EX8_56.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.56/EX8_56.R new file mode 100644 index 00000000..cc091db8 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.56/EX8_56.R @@ -0,0 +1,16 @@ +#Page number--8.46 +#Example number--8.56 + +lambda=2/5 +n_o_e=c(0,1,2,3,4) #Number of errors +prob=c() +for(i in n_o_e){ + prob[i+1]=dpois(i,lambda) +} +Expected_Frequency=c() +for(i in n_o_e){ + Expected_Frequency[i+1]=1000*prob[i+1] +} +data.frame(n_o_e,prob,Expected_Frequency,round(Expected_Frequency)) + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.57/EX8_57.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.57/EX8_57.R new file mode 100644 index 00000000..c36a4c8b --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.57/EX8_57.R @@ -0,0 +1,21 @@ +#Page number--8.47 +#Example number--8.57 + +n_o_d=c(0,1,2,3,4,5,6,7,8) #Number of doddens +o_f=c(56,156,132,92,37,22,4,0,1) #Observed frequency +data.frame(n_o_d,o_f) +Mean=sum(n_o_d*o_f)/500 +lambda=Mean +a=c() +for(i in n_o_d){ + a[i+1]=lambda/(i+1) +} +prob=c() +for(i in n_o_d){ + prob[i+1]=dpois(i,lambda) +} +Expected_Frequency=c() +for(i in n_o_d){ + Expected_Frequency[i+1]=500*prob[i+1] +} +data.frame(n_o_d,a,prob,Expected_Frequency,round(Expected_Frequency)) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.6/EX8_6.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.6/EX8_6.R new file mode 100644 index 00000000..b55a5326 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.6/EX8_6.R @@ -0,0 +1,25 @@ +#Page number--8.7 +#Example number--8.6 +n=10 +#Probability that old machine need adjustment +p1=1/11 +q1=1-p +#Probability that new machine need adjustment +p2=1/21 +q2=1-p +#Probability that x old machine need adjustment +#P=choose(3,x)*(1/11)^x*(10/11)^(3-x) +#Probability that x new machine need adjustment +#P=choose(7,x)*(1/21)^x*(20/21)^(7-x) + +#Part (i) +#Probability that 2 old machine and no new machine need adjustment +P=choose(3,2)*(1/11)^2*(10/11)*(20/21)^7 +P + +#Part (ii) +#Probability that no old machine and 2 new machine need adjustment +Q=(10/11)^3*choose(7,2)*(1/21)^2*(20/21)^5 +Q + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.63/EX8_63.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.63/EX8_63.R new file mode 100644 index 00000000..6886138c --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.63/EX8_63.R @@ -0,0 +1,19 @@ +#Page number--8.54 +#Example number--8.63 + +n_o_c=c(0,1,2,3,4,5) #Number of cells +f=c(213,128,37,18,3,1) #frequency +Mean=sum(n_o_c*f)/400 +u2=sum(f*n_o_c^2)/400 +u2 +Var=u2-Mean^2 +p=0.6825/0.8117 +q=1-p +r=round(p*0.6825/q) +a=c(p^4,0.5738*0.5,2.5*0.1592*0.2869,2*0.1592*0.1142,7/4*0.1592*0.0364,8/5*0.1592*0.0101) +Expected_Frequency=c() +for(i in n_o_c){ + Expected_Frequency[i+1]=400*a[i+1] +} +round(Expected_Frequency) + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.7/EX8_7.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.7/EX8_7.R new file mode 100644 index 00000000..32c745a5 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.7/EX8_7.R @@ -0,0 +1,22 @@ +#Page number--8.8 +#Example number--8.7 + +#Probability of hitting target +p=1/4 +q=1-p +#Probability that x hits in 7 shots +#P=choose(7,x)*(1/4)^x*(3/4)^7-x + +#Part (i) +#Probability of hitting atleast 2 hits +P=1-(choose(7,0)*(1/4)^0*(3/4)^7-0+choose(7,1)*(1/4)^1*(3/4)^(7-1)) +P + +#Part (ii) +#Probability of atleast 1 hit in n shots +p=solve(log(3/4),log(1/3)) +p +round(p) +sprintf("The required number of shots: %d",round(p)) + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.9/EX8_9.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.9/EX8_9.R new file mode 100644 index 00000000..bd30ac26 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH8/EX8.9/EX8_9.R @@ -0,0 +1,12 @@ +#Page number--8.9 +#Example number--8.9 + +n=5 +p1=0.4096 +p2=0.2048 +#Probability distribution +#P=choose(5,x)*(p)^x*(1-p)^(5-x) +#p1=choose(5,1)*(p)^1*(1-p)^(5-1) +#p2=choose(5,2)*(p)^x*(1-p)^(5-2) +#The ratio of p1 and p2 +sprintf("The parameter p is: %f",solve(5,1)) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.1/EX9_1.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.1/EX9_1.R new file mode 100644 index 00000000..7f3fd9ed --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.1/EX9_1.R @@ -0,0 +1,36 @@ +#Page number--9.14 +#Example number--9.1 +#Load Package-->cubature + +library(cubature) +N=1000 +u=79.945 +s.d=5.545 +class=c("Below 60","60-65","65-70","70-75","75-80","80-85","85-90","90-95","95-100","100 and over") +l_c_b=c(-Inf,60,65,70,75,80,85,90,95,100) +z=c() +for(i in c(seq(1,10,1))){ + z[i]=(l_c_b[i]-u)/s.d +} +z +#Equation of normal curve +#f(x)=1000/sqrt(2*pi)*exp(-1/2*((x-u)/s.d)^2) +oZ=c() +for(i in c(seq(1,10,1))){ + # define the integrated function + f <- function(x){exp(-x^2/2)} + a=adaptIntegrate(f, lowerLimit =-Inf, upperLimit =z[i]) + oZ[i]=1/sqrt(2*pi)*a$integral +} +oZ +deltaZ=c(0.000112,0.002914,0.031044,0.147870,0.322050,0.319300,0.144072,0.029792,0.002733,NA) +Expected_Frequency=c() +for(i in c(seq(1,10,1))){ + Expected_Frequency[i]=N*deltaZ[i] +} + +data.frame(class,l_c_b,z,oZ,deltaZ,Expected_Frequency,round(Expected_Frequency)) +Total=sum(round(Expected_Frequency[1:9])) +Total + + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.12/EX9_12.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.12/EX9_12.R new file mode 100644 index 00000000..c6f4cd3f --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.12/EX9_12.R @@ -0,0 +1,24 @@ +#Page number--9.22 +#Example number--9.12 + +#P(X<25)=0.1003 +p1=0.1003 +#P(X<70)=0.8997 +p2=0.8997 +#When X=25, Z=(25-u)/s.d=-z1 +#When X=70, Z=(70-u)/s.d=z2 + +#P(080)=0.04 +#When X=75, Z=(75-u)/s.d=z1 +#When X=80, Z=(80-u)/s.d=z2 + +#P(080)=0.05 +#When X=30, Z=(30-u)/s.d=-z1 +#When X=80, Z=(80-u)/s.d=z2 + +#P(0P(43.5=44) +sum(dbinom(44:100,100,0.4)) +#P(X=44) +dbinom(44,100,0.4) + +sprintf("We can see that both Normal and Binomial Distribution are close to each other") + diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.21/EX9_21.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.21/EX9_21.R new file mode 100644 index 00000000..998f95fd --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.21/EX9_21.R @@ -0,0 +1,31 @@ +#Page number--9.31 +#Example number--9.21 +#Load Package-->cubature + +library(cubature) + +mean=1 +variance=4/3 +#mean=(a+b)/2=1 +#b+a=2 +#variance=(b-a)^2/12=4/3 +#b-a=4 + +#Solving two variables equation +x=matrix(c(1,-1,1,1),nrow=2,ncol=2) +y=matrix(c(2,4),nrow=2,ncol=1) +z=solve(x,y) +z + +p=1/4 # -1cubature + +library(cubature) + +#P(X>=20) + +fx=1/30 # 05)=1-P(|X-30|<=5) +P=1-2*0.3413 +P \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.5/EX9_5.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.5/EX9_5.R new file mode 100644 index 00000000..db3fb0be --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.5/EX9_5.R @@ -0,0 +1,25 @@ +#Page number--9.17 +#Example number--9.5 + +Mean=662 +s.d=32 #Standard Deviation + +#Part (i) +P1=pnorm(Inf,662,4)-pnorm(700,662,32) +sprintf("Probability that plots has a yield over 700 kilos : %f",P1) +#Batch off 1000 plots +sprintf("Expected number of plots with yield over 700 kilos: %f",as.integer(1000*P1)) + +#Part (ii) +P2=pnorm(650,662,32) +sprintf("Probability that plots has a yield less than 650 kilos : %f",P2) +#Batch off 1000 plots +sprintf("Expected number of plots with yield less than 650 kilos: %f",as.integer(1000*P2)) +#Answer vary due to rounding of values + +#Part (iii) +#P(X>x1)=100/1000 +p=100/1000 +z1=1.28 #From Normal Table +x1=662+32*z1 +sprintf("Best 100 plots have yield: %f kilos",x1) diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.7/EX9_7.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.7/EX9_7.R new file mode 100644 index 00000000..e474bbb5 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.7/EX9_7.R @@ -0,0 +1,31 @@ +#Page number--9.18 +#Example number--9.7 + +Mean=1000 +s.d=200 #Standard Deviation + +#Part (i) +P1=pnorm(800,1000,200) +sprintf("Probability that bulb fail in less than 800 hrs.: %f",P1) +#Total number of bulbs=10000 +sprintf("Expected number of bulb fail in less than 800 hrs.: %f",round(10000*P1)) + +#Part(ii) +P2=pnorm(1200,1000,200)-pnorm(800,1000,200) +sprintf("Expected number of bulb fail in 800-1200hrs.: %f",as.integer(10000*P2)) +x=seq(0,2000,length=200) +y=dnorm(x,1000,200) +plot(x,y,type="l") +x=seq(800,1200,length=100) +y=dnorm(x,1000,200) +polygon(c(800,x,1200),c(0,y,0),col="red") +#Part (a) +#Taking value of z1 from Normal Tables +z1=1.28 +x1=1000-200*z1 +x1 +#Part (b) +#Taking value of z1 from Normal Tables +z2=1.28 +x2=1000+200*z1 +x2 \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.8/EX9_8.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.8/EX9_8.R new file mode 100644 index 00000000..33a463b1 --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.8/EX9_8.R @@ -0,0 +1,10 @@ +#Page number--9.20 +#Example number--9.8 + +Mean=65 +s.d=5 #Standard Deviation + +P1=pnorm(Inf,65,5)-pnorm(70,65,5) +sprintf("Probability that marks are over 70: %f",P1) +#3 students selected at random, exactly 2 will get more than 70 +choose(3,2)*P1^2*(1-P1) \ No newline at end of file diff --git a/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.9/EX9_9.R b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.9/EX9_9.R new file mode 100644 index 00000000..ba00c81e --- /dev/null +++ b/Fundamentals_Of_Mathematical_Statistics_by_S.c._Gupta,_V.k._Kapoor/CH9/EX9.9/EX9_9.R @@ -0,0 +1,25 @@ +#Page number--9.20 +#Example number--9.9 + +#Part (a) +Y1=log(1.202) +Y2=log(7.92) +#For Y1=0.08 +z1=(0.08-4)/2 +#For Y2=7.92 +z2=(7.92-4)/2 +#P(0.080.05){ + cat( "Since the p-value is greater than .05, the null hypothesis that the mean mileage is the same for all 3 brands of gasoline cannot be rejected. ") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.3.b/Ex10_3b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.3.b/Ex10_3b.R new file mode 100644 index 00000000..06bc8606 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.3.b/Ex10_3b.R @@ -0,0 +1,23 @@ +Xijold<-matrix(c(220, 251, 226, 246, 260, 244, 235, 232, 242, 225, 252, 272, 250, 238, 256),nrow = 3,ncol = 5,byrow = TRUE) +Xij = Xijold - 220; +m=3; +n=5; +Xidot = matrix(0,3,1); +for (i in 1:m){ + for (j in 1:n){ + Xidot[i]=Xidot[i] + Xij[i,j] + } +} +Xidot = Xidot/n; +Xdotdot = sum(Xidot)/m; +SSb=0; +for (i in 1:m){ + SSb = SSb + (Xidot[i]-Xdotdot)^2 +} +SSb = SSb*n; +Xijsquared = Xij^2; +SSW = sum(Xijsquared) - (m*n*(Xdotdot^2)) - SSb; +sigma1 = SSW/((n*m)-m); +sigma2 = SSb/(m-1); +TS = sigma2/sigma1; +cat("Value of the test statistic is",TS) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.3.c/Ex10_3c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.3.c/Ex10_3c.R new file mode 100644 index 00000000..2924ac14 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.3.c/Ex10_3c.R @@ -0,0 +1,31 @@ +Xij<-matrix(c(3.2, 3.4, 3.3, 3.5, 3.4, 3.0, 3.7, 3.3, 2.8, 2.6, 3.0, 2.7),nrow = 3,ncol = 4,byrow = TRUE) +Xi = matrix(0,3,1); +n= 4; +m=3; +for (i in 1:3){ + for (j in 1:4){ + Xi[i]= Xi[i] + Xij[i,j] + } +} +Xi = Xi/n; +SSW= 0; +for (i in 1:3){ + for (j in 1:4){ + SSW = SSW + ((Xij[i,j]-Xi[i])^2) + } +} +sigma1 = SSW/((n*m)-m); +Xdotdot = sum(Xi)/m; +new = (Xi - Xdotdot)^2; +SSb= n*sum(new); +sigma2 = SSb/(m-1); +TS = sigma2/sigma1; +cat("Value of the test statistic is",TS) +pvalue = 1 - pf(TS,m-1, ((n*m)-m) ); +cat("The p-value is",pvalue) +C = 3.95; #from table A5 +W = C*sqrt(SSW/(9*4)); +W +cat("Mean1 - Mean2 lies between ", Xi[1]-Xi[2]-W ,"and ", Xi[1]-Xi[2]+W) +cat("Mean1 - Mean3 lies between ", Xi[1]-Xi[3]-W ,"and ", Xi[1]-Xi[3]+W) +cat("Mean2 - Mean3 lies between ", Xi[2]-Xi[3]-W ,"and ", Xi[2]-Xi[3]+W) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.4.b/Ex10_4b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.4.b/Ex10_4b.R new file mode 100644 index 00000000..7baf6d42 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.4.b/Ex10_4b.R @@ -0,0 +1,22 @@ +X<-matrix(c(75, 73, 60, 70, 86, 78, 71, 64, 72, 90, 80, 69, 62, 70, 85, 73, 67, 63, 80, 92),nrow = 4,ncol = 5,byrow = TRUE) +Xidot = matrix(0,4,1); +for (i in 1:4){ + for (j in 1:5){ + Xidot[i]=Xidot[i] + X[i,j] + } +} +Xidot = Xidot/5; +Xjdot = matrix(0,5,1); +for (j in 1:5){ + for (i in 1:4){ + Xjdot[j]=Xjdot[j] + X[i,j] + } +} +Xjdot = Xjdot/4; +Xdotdot = sum(Xidot)/4; +meanhat = Xdotdot; +alphahat = Xidot - meanhat; +betahat = Xjdot - meanhat; +cat("The estimator of the mean is",meanhat) +cat("The alphas are-",alphahat) +cat("The betas are-",betahat) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.5.a/Ex10_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.5.a/Ex10_5a.R new file mode 100644 index 00000000..3b8794b9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH10/EX10.5.a/Ex10_5a.R @@ -0,0 +1,41 @@ +X<-matrix(c(53, 35, 31, 37, 40, 43, 36, 34, 17, 21, 30, 18, 47, 37, 17, 31, 45, 26, 55, 31, 17, 23, 43, 37, 40, 32, 19, 26, 45, 37, 52, 42, 20, 27, 26, 32, 39, 28, 21, 21, 36, 28, 40, 32, 21, 21, 36, 35),nrow =8,ncol = 6, byrow = TRUE) +m= 8; +n = 6; +Xidot = matrix(0,8,1); + +for (i in 1:8){ + for (j in 1:6){ + Xidot[i]=Xidot[i] + X[i,j] + } +} +Xidot = Xidot/6; +Xjdot = matrix(0,6,1); + +for (j in 1:6){ + for (i in 1:8){ + Xjdot[j]=Xjdot[j] + X[i,j] + } +} + +Xjdot = Xjdot/8; +Xdotdot = sum(Xidot)/8; +new = (Xidot - Xdotdot)^2; +SSr = n*sum(new); +new1 = (Xjdot - Xdotdot)^2; +SSc = m*sum(new1); +SSe = 0; +for (i in 1:m){ + for (j in 1:n){ + SSe = SSe + (X[i,j]-Xidot[i]-Xjdot[j]+ Xdotdot)^2 + } +} + +N =(m-1)*(n-1) +TS1 = SSr*N/((m-1)*SSe) +TS2 = SSc*N/((n-1)*SSe) +pvaluec = 1- pf(TS1, m-1, N) +pvaluer = 1- pf(TS2, n-1, N) +cat("The value of the F-statistic for testing that there is no row effect is",TS1) +cat("The p-value for testing that there is no row effect is",pvaluec) +cat("The value of the F-statistic for testing that there is no column effect is",TS2) +cat("The p-value for testing that there is no column effect is",pvaluer) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.a/Ex11_2a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.a/Ex11_2a.R new file mode 100644 index 00000000..9e1d2500 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.a/Ex11_2a.R @@ -0,0 +1,25 @@ +X<-c(90, 100, 87, 96, 101, 86, 119, 118, 121, 114, 113, 106) +pi= matrix(1,12,1); +pi= pi/12; +new = X^2; +npi= sum(X)*pi; +T = sum(new); +T = T/npi; +T = T - sum(X); +cat("When there are 12 regions") +cat("The test statistic is",T[1]) +pvalue = 1- pchisq(T[1], 11); +cat("The pvalue is ",pvalue) + +X<-c(277, 283, 358, 333) +pi= matrix(1,4,1); +pi= pi/4; +new = X^2; +npi= sum(X)*pi; +T = sum(new); +T = T/npi; +T = T - sum(X); +cat("When there are 4 regions") +cat("The test statistic is",T[1]) +pvalue = 1- pchisq(T[1], 3); +cat("The pvalue is ",pvalue) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.b/Ex11_2b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.b/Ex11_2b.R new file mode 100644 index 00000000..2810168b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.b/Ex11_2b.R @@ -0,0 +1,14 @@ +X<-c(3, 6, 9, 7, 5) +p<-c(0.15, 0.25, 0.35, 0.20, 0.05) +T= 0; +n3=sum(X); +np = p*n3; +Xsqu = (X-np)^2; +cat(Xsqu); +XT = Xsqu/np; +T = sum(XT); + +cat("The test statistic is",T) +pvalue = 1- pchisq(T[1], 4) +cat("The pvalue is ",pvalue) +cat("Thus, the hypothesis would not be rejected at 5% level of significance") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.d/Ex11_2d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.d/Ex11_2d.R new file mode 100644 index 00000000..2463f7b1 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.2.d/Ex11_2d.R @@ -0,0 +1,18 @@ +X<-c(3, 3, 5, 18, 4, 7) +p<-c(0.1, 0.1, 0.05, 0.4, 0.2, 0.15) +psimu = 0.1843 +num= 10000; +T= 0; +n=sum(X); +np = n*p; +Xsqu = X^2; +for (i in 1:6){ + T = T + (Xsqu[i]/np[i]) +} +T = T - sum(X) + +cat("The test statistic is",T[1]) +pvalue = 1- pchisq(T[1], 5); +int1 = psimu - (1.645*sqrt(psimu*(1-psimu)/num)); +int2 = psimu + (1.645*sqrt(psimu*(1-psimu)/num)); +cat("With 90% confidence p-value lies between ",int1,"and",int2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.3.a/Ex11_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.3.a/Ex11_3a.R new file mode 100644 index 00000000..bd52aa9a --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.3.a/Ex11_3a.R @@ -0,0 +1,38 @@ +Y<-c(8, 0, 0, 1, 3, 4, 0, 2, 12, 5, 1, 8, 0, 2, 0, 1, 9, 3, 4, 5, 3, 3, 4, 7, 4, 0, 1, 2, 1, 2) +weeks = 30; +lamda = sum(Y)/weeks; +p = matrix(0,5,1); +p[1] = ppois(0, lamda); +p[2] = ppois(1, lamda) - p[1]; +p[3] = ppois(3, lamda) - ppois(1, lamda); +p[4] = ppois(5, lamda) - ppois(3, lamda); +p[5] = 1 - ppois(5, lamda); + +X = matrix(0,5,1); +for (i in 1:30){ + if(Y[i]==0){ + X[1] = X[1] +1; + } else if(Y[i]==1){ + X[2] = X[2] +1; + } else if(Y[i]==2){ + X[3] = X[3] +1; + } else if(Y[i]==3){ + X[3] = X[3] +1; + } else if(Y[i]==4){ + X[4] = X[4] +1; + } else if(Y[i]==5){ + X[4] = X[4] +1; + } else if(Y[i]>5){ + X[5] = X[5] +1; + } +} + +T= 0; +npi = weeks * p; +for (i in 1:5){ + T = T + ((X[i]-npi[i])^2)/npi[i] +} +cat("T is",T) +pvalue = 1- pchisq(T, 3) +cat("The p-value is",pvalue) +cat("Hypothesis of an underlying poisson distribution is rejected") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.4.a/Ex11_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.4.a/Ex11_4a.R new file mode 100644 index 00000000..e4b66d77 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.4.a/Ex11_4a.R @@ -0,0 +1,34 @@ +Nij<-matrix(c(68, 56, 32, 52, 72, 20),nrow = 2,ncol = 3,byrow = TRUE) +n= sum(Nij); +Ni = matrix(0,2,1); +Mj = matrix(0,3,1); +for (i in 1:2){ + for (j in 1:3){ + Ni[i] = Ni[i] + Nij[i,j] + } +} +for (j in 1:3){ + for (i in 1:2){ + Mj[j] = Mj[j] + Nij[i,j] + } +} +NM = matrix(1,2,3); +for (i in 1:2){ + for (j in 1:3){ + NM[i,j]= Ni[i]*Mj[j] + } +} +NM= NM/n; +TS = 0 +for (i in 1:2){ + for (j in 1:3){ + TS = TS + ((Nij[i,j]-NM[i,j])^2)/NM[i,j] + } +} +cat("The test statistic is",TS) +compare = pchisq(2, 0.95, 0.05) +if(TS>compare){ + cat("The null hypothesis is rejected at the 5% level of significance") + } else { + disp("The null hypothesis is accepted at the 5% level of significance") + } \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.4.b/Ex11_4b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.4.b/Ex11_4b.R new file mode 100644 index 00000000..2a27a802 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.4.b/Ex11_4b.R @@ -0,0 +1,30 @@ +Nij<-matrix(c(10, 12, 6, 7, 10, 24, 9, 10, 13, 20, 7, 10),nrow = 3,ncol = 4,byrow = TRUE) +n= sum(Nij); +Ni = matrix(0,3,1); +Mj = matrix(0,4,1); +for (i in 1:3){ + for (j in 1:4){ + Ni[i] = Ni[i] + Nij[i,j] + } +} +for (j in 1:4){ + for (i in 1:3){ + Mj[j] = Mj[j] + Nij[i,j] + } +} +NM = matrix(1,3,4); +for (i in 1:3){ + for (j in 1:4){ + NM[i,j]= Ni[i]*Mj[j] + } +} +NM= NM/n; +TS = 0 +for (i in 1:3){ + for (j in 1:4){ + TS = TS + ((Nij[i,j]-NM[i,j])^2)/NM[i,j] + } +} +cat("The test statistic is",TS) +pvalue = 1- pchisq(TS, 6) +cat("the hypothesis that the machine that causes a breakdown is independent of the shift on which the breakdown occurs is accepted.") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.5.a/Ex11_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.5.a/Ex11_5a.R new file mode 100644 index 00000000..0475a157 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.5.a/Ex11_5a.R @@ -0,0 +1,38 @@ +Nij<-matrix(c(62, 14, 9938, 19986),nrow = 2,ncol = 2,byrow = TRUE) +n= sum(Nij); +Ni = matrix(0,2,1); +Mj = matrix(0,2,1); +for (i in 1:2){ + for (j in 1:2){ + Ni[i] = Ni[i] + Nij[i,j] + } +} +Ni +for (j in 1:2){ + for (i in 1:2){ + Mj[j] = Mj[j] + Nij[i,j] + } +} + +NM = matrix(1,2,2); +for (i in 1:2){ + for (j in 1:2){ + NM[i,j]= Ni[i]*Mj[j] + } +} +NM= NM/n; +NM +TS = 0 +for (i in 1:2){ + for (j in 1:2){ + TS = TS + ((Nij[i,j]-NM[i,j])^2)/NM[i,j] + } +} +cat("The test statistic is",TS) +compare = pchisq(1, 0.99, 0.01) +compare +if(TS>compare){ + cat("The null hypothesis is rejected at the 1% level of significance"); +} else{ + cat("The null hypothesis is accepted at the 1% level of significance"); +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.5.b/Ex11_5b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.5.b/Ex11_5b.R new file mode 100644 index 00000000..8e218dc9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.5.b/Ex11_5b.R @@ -0,0 +1,40 @@ +Nij<-matrix(c(28, 30, 58, 55, 472, 470, 442, 445),nrow = 2,ncol = 4,byrow = TRUE) +n= sum(Nij); +Ni = matrix(0,2,1); +Mj = matrix(0,4,1); +for (i in 1:2){ + for (j in 1:4){ + Ni[i] = Ni[i] + Nij[i,j] + } +} +for (j in 1:4){ + for (i in 1:2){ + Mj[j] = Mj[j] + Nij[i,j] + } +} +NM = matrix(1,2,4); +for (i in 1:2){ + for (j in 1:4){ + NM[i,j]= Ni[i]*Mj[j] + } +} +NM= NM/n; + +TS = 0 +for (i in 1:2){ + for (j in 1:4){ + TS = TS + ((Nij[i,j]-NM[i,j])^2)/NM[i,j] + } +} +cat("The test statistic is",TS) + +compare = pchisq(3, 0.99, 0.01) +pvalue = 1- pchisq(TS, 3) +cat("The p-value is",pvalue) + +compare +if(TS>compare){ + cat("The null hypothesis is rejected at the 1% level of significance"); +} else{ + cat("The null hypothesis is accepted at the 1% level of significance"); +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.6.a/Ex11_6a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.6.a/Ex11_6a.R new file mode 100644 index 00000000..5a3cb0f0 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH11/EX11.6.a/Ex11_6a.R @@ -0,0 +1,11 @@ +X<-c(66, 72, 81, 94, 112, 116, 124, 140, 145, 155); +D= 0.4831487; +n= 10; +Dgiven = 1.480; +Dstar = (sqrt(n) + 0.12 + (0.11/sqrt(n)))*D; +cat("Dstar is ",Dstar); +if(Dstar>Dgiven){ + cat("Null hypothesis is rejected at 2.5% level of significance") + } else{ + cat("Null hypothesis is accepted at 2.5% level of significance") + } \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.2.a/Ex12_2a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.2.a/Ex12_2a.R new file mode 100644 index 00000000..2947b2ac --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.2.a/Ex12_2a.R @@ -0,0 +1,9 @@ +n= 200; +v = 120; +p =0.5; +if(v < (n/2)){ + pvalue = 2*pbinom(v, n, p) +} else{ + pvalue = 2*pbinom(n-v, n, p) +} +cat("Pvalue is ",pvalue) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.2.b/Ex12_2b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.2.b/Ex12_2b.R new file mode 100644 index 00000000..4d553376 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.2.b/Ex12_2b.R @@ -0,0 +1,7 @@ +n= 80; +v = 28; +p =0.5; + +pvalue = pbinom(v, n, p); +cat("Pvalue is ",pvalue); +cat("Thus, the null hypothesis that the median income is less than or equal to $90,000 is rejected") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.3.b/Ex12_3b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.3.b/Ex12_3b.R new file mode 100644 index 00000000..4ebafd6d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.3.b/Ex12_3b.R @@ -0,0 +1,20 @@ +n =4; +mo = 2; +X<-c(4.2, 1.8, 5.3, 1.7) +t =3; #value of the test statistic (Ex12_3a) +tstar= min(t, (n*(n+1)/2) - t); +P = matrix(0,4,4); +P[1,1]= 0.5; +P[1,2] = 1; +P[1,3] = 1; +P[1,4] = 1; +for (i in 2:4){ + for (j in 1:4){ + if (j-i <1) { + P[i,j] = 0.5*P[i-1, j] + } else{ + P[i,j] = 0.5*(P[i-1,j-i]+P[i-1,j]) + } + } +} +P \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.3.c/Ex12_3c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.3.c/Ex12_3c.R new file mode 100644 index 00000000..881fa147 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.3.c/Ex12_3c.R @@ -0,0 +1,18 @@ +n =20; +t =142; +tstar= min(t, (n*(n+1)/2) - t); +P = matrix(1,20,tstar+1); +P[1,1]= 0.5; +P[1,2] = 1; +for (i in 2:20){ + for (j in 1:(tstar+1)){ + if (j-i <1){ + P[i,j] = 0.5*P[i-1, j] + } else{ + P[i,j] = 0.5*(P[i-1,j-i]+P[i-1,j]) + } + } + } +pvalue= 2*P[20,tstar+1]; +cat("Pvalue is",pvalue) +cat("Thus the hypothesis that the population distribution is symmetric about 0 is accepted at the alpha = 10% level of significance") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.a/Ex12_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.a/Ex12_4a.R new file mode 100644 index 00000000..2ca9aad1 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.a/Ex12_4a.R @@ -0,0 +1,17 @@ +X<-c(65.2, 67.1, 69.4, 78.2, 74, 80.3) +Y<-c(59.4, 72.1, 68, 66.2, 58.5) +Z = append(X,Y) +Z = sort(Z); +n= length(X); +q = length(Z) +T = 0; +for (i in 1:n){ + test = X[i]; + for (j in 1:q){ + if(test== Z[j]){ + T = T+ j; + } + } +} + +cat("The test statistic is ",T) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.b/Ex12_4b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.b/Ex12_4b.R new file mode 100644 index 00000000..203d68c3 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.b/Ex12_4b.R @@ -0,0 +1,31 @@ +prob <- function(N, M, K) { + if(N==1 & M==0){ + if(K >0){ + cat(result = 1) + } else { + cat(result =0) + } + } else if (N==0 & M==1){ + if(K <0){ + cat(result = 0) + } else { + cat(result =1) + } + } else if (N==0 & M==0 &K==0){ + cat(result =1) + } else{ + cat(result = (prob(N-1, M, K-N-M)*(N/(N+M))) + (prob(N, M-1, K)*(M/(N+M)))) + } +} + +pval <- function(n,m,t) { + result = 2*min(prob(n,m,t), 1-prob(n,m,t-1)); +} + +'> pval(2,1,3) +001 +Error: C stack usage 19923984 is too close to the limit + +C:\Program Files\RStudio\bin>rstudio.exe --max-ppsize=5000000000 + +' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.c/Ex12_4c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.c/Ex12_4c.R new file mode 100644 index 00000000..6a61e516 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.c/Ex12_4c.R @@ -0,0 +1,33 @@ +prob <- function(N, M, K) { + if(N==1 & M==0){ + if(K >0){ + cat(result = 1) + } else { + cat(result =0) + } + } else if (N==0 & M==1){ + if(K <0){ + cat(result = 0) + } else { + cat(result =1) + } + } else if (N==0 & M==0 &K==0){ + cat(result =1) + } else{ + cat(result = (prob(N-1, M, K-N-M)*(N/(N+M))) + (prob(N, M-1, K)*(M/(N+M)))) + } +} + +pval <- function(n,m,t) { + result = 2*min(prob(n,m,t), 1-prob(n,m,t-1)); +} + +'> pval(2,1,3) +001 +Error: C stack usage 19923984 is too close to the limit + +C:\Program Files\RStudio\bin>rstudio.exe --max-ppsize=5000000000 + +' +'> pval(5,6,21) +Error: C stack usage 19923984 is too close to the limit' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.d/Ex12_4d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.d/Ex12_4d.R new file mode 100644 index 00000000..29aa8c81 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.d/Ex12_4d.R @@ -0,0 +1,32 @@ +prob <- function(N, M, K) { + if(N==1 & M==0){ + if(K >0){ + cat(result = 1) + } else { + cat(result =0) + } + } else if (N==0 & M==1){ + if(K <0){ + cat(result = 0) + } else { + cat(result =1) + } + } else if (N==0 & M==0 &K==0){ + cat(result =1) + } else{ + cat(result = (prob(N-1, M, K-N-M)*(N/(N+M))) + (prob(N, M-1, K)*(M/(N+M)))) + } +} + +pval <- function(n,m,t) { + result = 2*min(prob(n,m,t), 1-prob(n,m,t-1)); +} + +'> pval(9,13,72) +001 +Error: C stack usage 19923984 is too close to the limit + +C:\Program Files\RStudio\bin>rstudio.exe --max-ppsize=5000000000 + +' + diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.e/Ex12_4e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.e/Ex12_4e.R new file mode 100644 index 00000000..310d05f5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.4.e/Ex12_4e.R @@ -0,0 +1,16 @@ +n1 =5; +m1= 6; + +t1 =21; +num1 = n1*(n1+m1+1)/2; +d1=abs(t1 - num1); +val = d1/sqrt(n1*m1*(n1+m1+1)/12); +pval = 2*(1- pnorm(val, 0,1)) +cat("The p-value for eg 12.4a is",pval) +n2 =9; +m2= 13; +t2 =72; +d2=abs(t2 - n2*(n2+m2+1)/2); +val = d2/sqrt(n2*m2*(n2+m2+1)/12); +pval = 2*(1-pnorm(val, 0,1)); +cat("The p-value for eg 12.4d is",pval) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.5.a/Ex12_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.5.a/Ex12_5a.R new file mode 100644 index 00000000..ab1c73b4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.5.a/Ex12_5a.R @@ -0,0 +1,33 @@ +fact <- function(num) { + if(num<=0){ + result= 1 + } else { + result = factorial(num) + } +} + +proba <- function(n,m,k) { + if(k%%2==0){ + k=k/2; + result = 2*fact(m-1)*fact(n-1)*fact(n)*fact(m)/(fact(k-1)^2*fact(m-k)*fact(n-k)*fact(n+m)); + } else { + k = (k-1)/2; + result = fact(m-1)*fact(n-1)*fact(n)*fact(m)/(fact(k-1)*fact(k)*fact(m-k)*fact(n-k-1)*fact(n+m)) + fact(m-1)*fact(n-1)*fact(n)*fact(m)/(fact(k-1)*fact(k)*fact(m-k-1)*fact(n-k)*fact(n+m)); + } +} + + +r1 = 20; +n1 = 20; +m1=10; +ans1 =0; +for (i in 1:19){ + ans1 =ans1 + proba(n1,m1,i); +} +if(ans1<0.5){ + pvalue1 = 2*ans1; +} else { + pvalue1 = 2*(1-ans1); +} + +cat("P-value is",pvalue1) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.5.c/Ex12_5c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.5.c/Ex12_5c.R new file mode 100644 index 00000000..97f02fe3 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH12/EX12.5.c/Ex12_5c.R @@ -0,0 +1,10 @@ +u = 61; +sigma = 5.454; +r =75; +val = pnorm((r-u)/sigma, 0,1) +if(val>0.5){ + pvalue = 2*(1-val) +} else{ + pvalue = 2*val +} +cat("P-value is",pvalue) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.2.a/Ex13_2a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.2.a/Ex13_2a.R new file mode 100644 index 00000000..b5b6a750 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.2.a/Ex13_2a.R @@ -0,0 +1,17 @@ +X<-c(3.01, 2.97, 3.12, 2.99, 3.03, 3.02, 3.10, 3.14, 3.09, 3.20) +Y<-seq(1,10,1) +u = 3; +sigma = 0.1; +n=4; +ucl = u + (3*sigma/sqrt(n)); +lcl = u - (3*sigma/sqrt(n)); +Z<-seq(0.1,10,0.1) +P= matrix(1,1,100) +Q= matrix(1,1,100) +P =P*ucl; +Q =Q*lcl; +plot(Y, X) +plot(Z, P) +plot(Z, Q) +cat('ucl is',ucl) +cat('lcl is',lcl) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.2.b/Ex13_2b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.2.b/Ex13_2b.R new file mode 100644 index 00000000..f4ab3f7a --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.2.b/Ex13_2b.R @@ -0,0 +1,12 @@ +Xbar<-c(3.01, 2.97, 3.12, 2.99, 3.03, 3.02, 3.10, 3.14, 3.09, 3.20) +S<-c(0.12, 0.14, 0.08, 0.11, 0.09, 0.08, 0.15, 0.16, 0.13, 0.16) +c<-c(0.7978849, 0.8862266, 0.9213181, 0.9399851, 0.9515332, 0.9593684, 0.9650309, 0.9693103, 0.9726596) +n=4; +Xbarbar= mean(Xbar); +Sbar =mean(S); +lcl = Xbarbar - (3*Sbar/(sqrt(n)*c(n-1))); +ucl = Xbarbar + (3*Sbar/(sqrt(n)*c(n-1))); +u = Xbarbar; +sigma= Sbar/c[n-1]; +prob = pnorm(3.1, u, sigma) - pnorm(2.9, u, sigma); +cat("Percentage of the items that will meet the specifications is",prob*100) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.3.a/Ex13_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.3.a/Ex13_3a.R new file mode 100644 index 00000000..43f55d30 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.3.a/Ex13_3a.R @@ -0,0 +1,32 @@ +Xbar<-c(35.1, 33.2, 31.7, 35.4, 34.5, 36.4, 35.9, 38.4, 35.7, 27.2, 38.1, 37.6, 38.8, 34.3, 43.2, 41.3, 35.7, 36.3, 35.4, 34.6) +S<-c(4.2, 4.4, 2.5, 3.2, 2.6, 4.5, 3.4, 5.1, 3.8, 6.2, 4.2, 3.9, 3.2, 4, 3.5, 8.2, 8.1, 4.2, 4.1, 3.7) +c<-c(0.7978849, 0.8862266, 0.9213181, 0.9399851, 0.9515332, 0.9593684, 0.9650309, 0.9693103, 0.9726596) +Y<-seq(1,20,1) +n =5; +Z<-seq(0.1,20,0.1) +Xbarbar = mean(Xbar); +Sbar = mean(S); +lclX = Xbarbar - (3*Sbar/(sqrt(n)*c[n-1])); +uclX = Xbarbar + (3*Sbar/(sqrt(n)*c[n-1])); +val1 = 1/c[n-1] +val1 = val1^2; +val1 = val1 - 1; +val = sqrt(val1); +ucls = Sbar*(1+(3*val)); +lcls = Sbar*(1-(3*val)); +plot(Y, Xbar) +P<-matrix(1,1, 200) +Q<-matrix(1,1, 200) +P= P*lclX; +Q=Q*uclX; +cat('UCL(X)=',uclX) +cat('LCL(X)=',lclX) +plot(Z, P) +plot(Z, Q,main = 'Control Chart for X') +cat('UCL(S)=',uclX) +cat('LCL(S)=',lclX) +plot(Y, S) +P= P*lcls/lclX; +Q=Q*ucls/uclX; +plot(Z, P) +plot(Z, Q,main = 'Control Chart for S') \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.4.a/Ex13_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.4.a/Ex13_4a.R new file mode 100644 index 00000000..d1baa636 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.4.a/Ex13_4a.R @@ -0,0 +1,23 @@ +defect<-c(6, 5, 3, 0, 1, 2, 1, 0, 2, 1, 1, 3, 2, 0, 1, 1, 0, 2, 1, 2) +F<-c(0.12, 0.10, 0.06, 0.00, 0.02, 0.04, 0.02, 0.00, 0.04, 0.02, 0.02, 0.06, 0.04, 0.00, .02, 0.02, 0.00, 0.04, 0.02, 0.04) +total = 1000; +Fbar = sum(defect)/total; +n=50; +val = sqrt(Fbar*(1-Fbar)/n); +lcl = Fbar - (3*val); +ucl = Fbar + (3*val); +cat("LCL is" ,lcl) +cat("UCL is",ucl) +for (i in 1:20){ + if( F[i]>ucl | F[i] ucl){ + total = total - X[i] + num= num -1 + } +} +Xbar = total/num +lcl = Xbar - 3*sqrt(Xbar); +ucl = Xbar + 3*sqrt(Xbar); +cat("After recomputation") +cat("UCL is",ucl) +cat("LCL is",lcl) +total = total - X[4] +num = num-1; +cat("Xbar is",Xbar) +cat(" is",X[4]) +Xbar = total/num +lcl = Xbar - 3*sqrt(Xbar); +ucl = Xbar + 3*sqrt(Xbar); +cat("After second recomputation") +cat("UCL is",ucl); +cat("LCL is",lcl); +cat("It appears that the process is in control with mean",Xbar); + +'The mean after the second recomputation is incoreectly calculated in the textbook. It should be +((17*84.41)-111 )/16 = 82.748 whereas the value given in the book is 82.56. The values of UCL and LCL +change accordingly.' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.b/Ex13_6b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.b/Ex13_6b.R new file mode 100644 index 00000000..56d3d66d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.b/Ex13_6b.R @@ -0,0 +1,16 @@ +X<-c(48, 52, 70, 62, 57, 81, 56, 59, 77, 82, 78, 80, 74, 82, 68, 84) +u = 62; +n = 4; +sigma = 24; +alpha = 0.25; +W = matrix(0,17); +W[1] = 60; +for (i in 2:17){ + W[i] = (0.25*X[i-1]) + (0.75*W[i-1]) +} +cat("The values of W are",W) +val = 3*sigma*sqrt(alpha/(n*(2-alpha))); +lcl = u- val; +ucl = u+ val; +cat("LCL is",lcl) +cat("UCL is",ucl) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.c/Ex13_6c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.c/Ex13_6c.R new file mode 100644 index 00000000..06a38988 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.c/Ex13_6c.R @@ -0,0 +1,30 @@ +X<-c(9.617728, 10.25437, 9.867195, 10.79338, 10.60699, 10.48396, 13.33961, 9.462969, 10.14556, 11.66342, 11.55484, 11.26203, 12.31473, 9.220009, 11.25206, 10.48662, 9.025091, 9.693386, 11.45989, 12.44213, 11.18981, 11.56674, 9.869849, 12.11311, 11.48656) +t<-seq(1,26,1) +alpha = 2/9; +val = 9.915051 - (alpha*9.617728); +val = val/(1-alpha); +cat("val is",val) +u = 10; +n = 5; +sigma = 2; + +W = matrix(0,26) +W[1] = 10.; +for (i in 2:26){ + W[i] = (alpha*X[i-1]) + ((1-alpha)*W[i-1]) +} +cat("The values of W are",W) +val = 3*sigma*sqrt(alpha/(n*(2-alpha))); +lcl = u- val; +ucl = u+ val; +cat("LCL is",lcl) +cat("UCL is",ucl) +plot(t,W,xlab ="t",ylab = "W") +nlcl = matrix(1,1, 26) +nlcl= nlcl* lcl; +lines(t,nlcl) +nucl = matrix(1, 1, 26); +nucl= nucl * ucl; +lines(t,nucl) + +'The asymptpotic lines for UCL and LCL have been plotted ' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.d/Ex13_6d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.d/Ex13_6d.R new file mode 100644 index 00000000..8dba9dcd --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH13/EX13.6.d/Ex13_6d.R @@ -0,0 +1,21 @@ +X<-c(29, 33, 35, 42, 36, 44, 43, 45) +u =30; +sig = 8; +d =0.5; +B =5; +Y = X - u - (d*sig); +S = matrix(0,9); +S[1] =0; +for (i in 2:9){ + S[i]= max(S[i-1] + Y[i-1], 0) +} +cat("S is",S) +cl = B*sig; +cat(cl) +answer =100; +for ( i in 1:9){ + if(S[i]>cl){ + answer = i + } +} +cat("The mean has increased after observing the ",answer-1," subgroup average") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.a/Ex14_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.a/Ex14_3a.R new file mode 100644 index 00000000..428ad7d5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.a/Ex14_3a.R @@ -0,0 +1,14 @@ +total =50; +failure = 15; +alpha = 0.05; +t =525; +val1 = qchisq(alpha/2,2*failure) +val2 = qchisq(1-alpha/2,2*failure) + +int1 = 2*t/val1; +int2 = 2*t/val2; +cat("The 95% confidence interval is",int2,"to",int1) + +'The confidence interval is from 22.35 to 62.17 whereas solution in R is 22.35 to 62.53 +because of the difference in the value of chi-square(0.975, 30). +The textbook says the value is 16.89 whereas R calculates its value as 16.79' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.b/Ex14_3b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.b/Ex14_3b.R new file mode 100644 index 00000000..654299e8 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.b/Ex14_3b.R @@ -0,0 +1,5 @@ +t = 1800; +theta = 150; +r =20; +pvalue = 1 - pchisq(2*r,2*t/theta) +cat("P-value is ",pvalue) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.c/Ex14_3c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.c/Ex14_3c.R new file mode 100644 index 00000000..234943b1 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.c/Ex14_3c.R @@ -0,0 +1,12 @@ +T = 500; +alpha = 0.05; +r = 10; +val1 = qchisq(1-alpha/2, 2*r) +val2 = qchisq(alpha/2, 2*r) +int1= 2*T/val1; +int2= 2*T/val2; +cat("The 95% confidence interval is",int1,"to",int2) + +'The confidence interval is from 29.27 to 103.52 whereas solution in R is 29.265774 to +104.26683 because of the difference in the value of chi-square(0.975, 30). +The textbook says the value is 9.66 whereas scilab calculates its value as 9.5907774 ' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.d/Ex14_3d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.d/Ex14_3d.R new file mode 100644 index 00000000..88896884 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.d/Ex14_3d.R @@ -0,0 +1,9 @@ +r = 30; +T = 600; +theta = 25; +val1 = pchisq(2*T/theta,2*r) +val2 = 1 - pchisq(2*T/theta,2*(r+1)) +val2 +pvalue = min(val1, val2); +cat("The pvalue is",pvalue) +cat("H0 would be accepted when the significance level is 0.10") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.e/Ex14_3e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.e/Ex14_3e.R new file mode 100644 index 00000000..ea56d6d4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.3.e/Ex14_3e.R @@ -0,0 +1,8 @@ +X<-c(5, 7, 6.2, 8.1, 7.9, 15, 18, 3.9, 4.6, 5.8) +Y<-c(3, 3.2, 4.1, 1.8, 1.6, 2.7, 1.2, 5.4, 10.3, 1.5) +t = sum(X)+sum(Y); +R =10; +a = 20; +b = 2; +estimate = (R+b)/(a+t); +cat("Bayes estimate of lambda is",estimate) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.4.a/Ex14_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.4.a/Ex14_4a.R new file mode 100644 index 00000000..63bdfa82 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH14/EX14.4.a/Ex14_4a.R @@ -0,0 +1,10 @@ +Xlife = 420; +Ylife = 510; +Xnum= 10; +Ynum =15; +ts = Xlife*Ynum/(Ylife*Xnum); +cat( "The value of the test statistic is",ts) +val = pf(ts, Xnum, Ynum) +pvalue = 2*(1-val); +cat("The p-value is",pvalue) +cat("We cannot reject H0"); \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.2.a/Ex2_2a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.2.a/Ex2_2a.R new file mode 100644 index 00000000..9ef65b07 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.2.a/Ex2_2a.R @@ -0,0 +1,5 @@ +starting_salary<-c(47, 48, 49 ,50 ,51, 52, 53, 54, 56, 57, 60) +frequency <-c(4, 1 ,3 ,5 ,8 ,10, 0 ,5 ,2, 3, 1) +total = sum(frequency) +relative_frequency = frequency/total +cat("The relative frequencies are ",relative_frequency) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.2.b/Ex2_2b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.2.b/Ex2_2b.R new file mode 100644 index 00000000..4f2d78b3 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.2.b/Ex2_2b.R @@ -0,0 +1,6 @@ +slices<-c(42, 50, 32, 55, 9 ,12) +lbls<-c("Lung ", "Breast ", "Colon ", "Prostate ", "Melanoma ", "Bladder ") +pct <- round(slices/sum(slices)*100) +lbls <- paste(lbls, pct) # add percents to labels +lbls <- paste(lbls,"%",sep="") # ad % to labels +pie(slices,labels = lbls, col=rainbow(length(lbls)),main="Pie Chart") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.a/Ex2_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.a/Ex2_3a.R new file mode 100644 index 00000000..37869ee0 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.a/Ex2_3a.R @@ -0,0 +1,4 @@ +scores<-c(284, 280, 277, 282, 279, 285, 281, 283, 278, 277) +new_scores=(scores - 280) +final_mean = mean(new_scores)+ 280 +cat("Final Mean = ", final_mean) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.b/Ex2_3b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.b/Ex2_3b.R new file mode 100644 index 00000000..493e34a0 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.b/Ex2_3b.R @@ -0,0 +1,6 @@ +age<-c(15, 16, 17, 18, 19, 20) +frequencies<-c(2, 5, 11, 9 ,14, 13) +product = age*frequencies +total_people = sum(frequencies) +mean_age = sum(product)/total_people +cat("The sample mean of the ages is",mean_age) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.c/Ex2_3c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.c/Ex2_3c.R new file mode 100644 index 00000000..a276a66f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.c/Ex2_3c.R @@ -0,0 +1,12 @@ +age<-c(15, 16, 17, 18, 19, 20) +frequencies<-c(2, 5, 11, 9 ,14 ,13) +final_age = matrix(0,1,length(age)) +i=1 +for (j in 1:6){ + for (k in 1:frequencies[j]){ + final_age[i] = age[j] + i = i +1 + } +} +final_median = median(final_age) +final_median \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.d/Ex2_3d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.d/Ex2_3d.R new file mode 100644 index 00000000..4b793776 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.d/Ex2_3d.R @@ -0,0 +1,6 @@ +germ_free_mice<-c(158, 192, 193, 194, 195, 202, 212, 215, 229, 230, 237, 240, 244, 247, 259, 301, 301, 321, 337, 415 ,434 ,444 ,485 ,496 ,529 ,537, 624, 707 ,800) +conventional_mice<-c(159, 189, 191, 198, 235 ,245, 250, 256, 261, 265, 266 ,280 ,343 ,356, 383, 403, 414 ,428 ,432) +cat("Sample mean for germ-free mice is ",mean(germ_free_mice)) +cat("Sample median for germ-free mice is ",median(germ_free_mice)) +cat("Sample mean for conventional mice is ",mean(conventional_mice)) +cat("Sample mean for conventional mice is ",median(conventional_mice)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.e/Ex2_3e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.e/Ex2_3e.R new file mode 100644 index 00000000..9abe776d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.e/Ex2_3e.R @@ -0,0 +1,23 @@ +value<-c(1, 2, 3, 4, 5, 6) +frequencies<-c(9, 8 ,5 ,5, 6 ,7) +final_value = matrix(0,1,length(value)) +i=1 +for (j in 1:6){ + for (k in 1:frequencies[j]){ + final_value[i] = value[j] + i = i +1 + } +} +product = value*frequencies; +product +sum(product) + +total_value = sum(frequencies); +mean_value = sum(product)/total_value #the answer in the textbook is incorrect +which(frequencies==max(frequencies)) +m1= max(frequencies); +n= which(frequencies==max(frequencies)) + +cat("The sample mean is",mean_value) +cat("The median is",median(final_value)) +cat("The mode is",value[n]) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.f/Ex2_3f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.f/Ex2_3f.R new file mode 100644 index 00000000..e3cb3541 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.f/Ex2_3f.R @@ -0,0 +1,4 @@ +A <-c(3, 4, 6, 7, 10) +B <-c(-20, 5 ,15 ,24) +cat("The sample variance of A is",var(A)) +cat("The sample variance of B is",var(B)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.g/Ex2_3g.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.g/Ex2_3g.R new file mode 100644 index 00000000..82b6b763 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.g/Ex2_3g.R @@ -0,0 +1,3 @@ +accidents<-c(22, 22, 26, 28, 27, 25 ,30, 29, 24) +new_accidents = accidents - 22 +cat("The variance of the number of accidents is",var(new_accidents)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.h/Ex2_3h.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.h/Ex2_3h.R new file mode 100644 index 00000000..8da23fd6 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.h/Ex2_3h.R @@ -0,0 +1,5 @@ +population<-c(7333253, 3448613, 2731743, 1702086, 1524249, 1151977, 1048949 ,1022830 ,998905, 992038, 816884, 752279, 734676, 702979, 665070, 635913, 617044 ,614289 ,579307, 567094, 547727 ,520947 ,514013, 504505, 493559) +cat("The sample 10 percentile is",quantile(population, .10)) +cat("The sample 50 percentile is",quantile(population, .50)) +cat("The sample 80 percentile is",quantile(population, .80)) +cat("The median is",median(population)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.i/Ex2_3i.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.i/Ex2_3i.R new file mode 100644 index 00000000..b7e2bf07 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.3.i/Ex2_3i.R @@ -0,0 +1,2 @@ +noise<-c(82, 89, 94, 110, 74, 122, 112, 95, 100, 78, 65, 60, 90 ,83 ,87 ,75 ,114 ,85 ,69 ,94 ,124 ,115 ,107 ,88 ,97 ,74 ,72 ,68 ,83 ,91 ,90 ,102, 77, 125, 108 ,65) +cat("The quartiles are",quantile(noise)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.4.a/Ex2_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.4.a/Ex2_4a.R new file mode 100644 index 00000000..80bab46d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.4.a/Ex2_4a.R @@ -0,0 +1,5 @@ +cars<-c(448162, 404192, 368327, 318308, 272122, 260486, 249128, 234936, 218540, 207977) +interval1 = mean(cars) - (1.5*sd(cars)); +interval2 = mean(cars) + (1.5*sd(cars)); +data = 100*5/9; +cat("Atleast 55.55% of the data lies in the interval",interval1 ,"to",interval2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.5.a/Ex2_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.5.a/Ex2_5a.R new file mode 100644 index 00000000..9b1e044a --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.5.a/Ex2_5a.R @@ -0,0 +1,4 @@ +data<-c(90, 91 ,94 ,83 ,85 ,85 ,87 ,88 ,72, 74, 74, 75, 77, 77, 78, 60, 62 ,63, 64, 66, 66, 52 ,55 ,55 ,56 ,58 ,43, 46) +cat("According to the empirical rule 68% of the data lies between",mean(data)-sd(data),"and",mean(data)+sd(data)) +cat("95% of the data lies between",mean(data)-(2*sd(data)),"and",mean(data)+(2*sd(data))) +cat("99.7% of the data lies between", mean(data)-(3*sd(data)),"and",mean(data)+(3*sd(data))) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.6.a/Ex2_6a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.6.a/Ex2_6a.R new file mode 100644 index 00000000..0edc122d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.6.a/Ex2_6a.R @@ -0,0 +1,14 @@ +temp<-c(24.2, 22.7 ,30.5, 28.6, 25.5, 32.0, 28.6, 26.5, 25.3, 26.0, 24.4 ,24.8 ,20.6, 25.1, 21.4, 23.7, 23.9, 25.2, 27.4, 28.3 ,28.8 ,26.6) +defects<-c(25, 31 ,36 ,33 ,19 ,24 ,27 ,25 ,16 ,14 ,22 ,23 ,20 ,25 ,25 ,23 ,27 ,30 ,33 ,32 ,35, 24) +temp_new = temp- mean(temp) +defects_new = defects - mean(defects) +num=0 +s1 =0; +s2=0; +for (i in 1:22){ + num = num + (temp_new[i]*defects_new[i]) + s1 = s1 + (temp_new[i]*temp_new[i]) + s2 = s2 + (defects_new[i]*defects_new[i]) +} +coefficient = num/sqrt(s1*s2) +coefficient \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.6.b/Ex2_6b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.6.b/Ex2_6b.R new file mode 100644 index 00000000..f0fdd7fb --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH2/EX2.6.b/Ex2_6b.R @@ -0,0 +1,14 @@ +year<-c(12, 16, 13, 18, 19 ,12, 18, 19, 12, 14) +pulserate<-c(73, 67, 74, 63 ,73 ,84 ,60 ,62, 76, 71) +year_new = year- mean(year) +pulserate_new = pulserate - mean(pulserate) +num=0 +s1 =0 +s2=0 +for (i in 1:10){ + num = num + (year_new[i]*pulserate_new[i]) + s1 = s1 + (year_new[i]*year_new[i]) + s2 = s2 + (pulserate_new[i]*pulserate_new[i]) +} +coefficient = num/sqrt(s1*s2) +coefficient \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.4.a/Ex3_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.4.a/Ex3_4a.R new file mode 100644 index 00000000..88e37d06 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.4.a/Ex3_4a.R @@ -0,0 +1,5 @@ +cigarette = 0.28; +cigar = 0.07; +cigar_and_cigarette = 0.05 ; +cigar_or_cigarette = cigarette + cigar - cigar_and_cigarette; +cat((1-cigar_or_cigarette)*100 ,"% of the males smoke neither cigar nor cigarette") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.a/Ex3_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.a/Ex3_5a.R new file mode 100644 index 00000000..ce7a6e2d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.a/Ex3_5a.R @@ -0,0 +1,7 @@ +white_balls= 6; +black_balls = 5; +total = white_balls + black_balls; +probability_whiteandblack = white_balls*black_balls/(total*(total-1)); +probability_blackandwhite = white_balls*black_balls/(total*(total-1)); +reqd_probability = probability_whiteandblack + probability_blackandwhite; +cat("Thus, the required probability is",reqd_probability) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.b/Ex3_5b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.b/Ex3_5b.R new file mode 100644 index 00000000..b07e809d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.b/Ex3_5b.R @@ -0,0 +1,6 @@ +maths = 4; +chemistry = 3; +history = 2; +language = 1; +total_arrangements = factorial(4)*factorial(maths)*factorial(chemistry)*factorial(history)*factorial(language); +cat("The total number of possible arrangements is ",total_arrangements) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.c/Ex3_5c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.c/Ex3_5c.R new file mode 100644 index 00000000..0a6e1f2f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.c/Ex3_5c.R @@ -0,0 +1,6 @@ +men = 6; +women = 4; +cat("No of different rankings possible is",factorial(men+women)) +women_top4 = factorial(women)*factorial(men); +prob = women_top4/factorial(men+women); +cat("Probability that women receive the top 4 scores is",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.d/Ex3_5d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.d/Ex3_5d.R new file mode 100644 index 00000000..75581678 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.d/Ex3_5d.R @@ -0,0 +1,7 @@ +men = 6; +women = 9; +reqd_size =5; +total =factorial(men+women)/(factorial(reqd_size)*factorial(men+women-reqd_size)); +given_committee = factorial(men)*factorial(women)/(factorial(3)*factorial(2)*factorial(men-3)*factorial(women-2)); +prob = given_committee/total; +cat("Probability that the committee consists of 3 men and 2 women is",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.f/Ex3_5f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.f/Ex3_5f.R new file mode 100644 index 00000000..f292dea2 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.5.f/Ex3_5f.R @@ -0,0 +1,21 @@ +black_p = 6; +white_p = 6; +pair = 2; +total_p = black_p + white_p; + +total_pairs = 1; +while(total_p >0){ + total_pairs = total_pairs*factorial(total_p)/(factorial(pair) * factorial(total_p - pair) ) + total_p = total_p -2 +} +total_pairs= total_pairs/factorial(6); +black_pairs = 1; +while(black_p >0){ + black_pairs = black_pairs*factorial(black_p)/((factorial(pair) * factorial(black_p - pair) )) + black_p = black_p -2 +} +black_pairs= black_pairs/factorial(3); +white_pairs = black_pairs; +allowed_pairs = black_pairs * white_pairs; +probb = allowed_pairs/ total_pairs; +cat(" Probability that a random pairing will not result in any of the white and black players rooming together is ",probb) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.a/Ex3_6a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.a/Ex3_6a.R new file mode 100644 index 00000000..fc635180 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.a/Ex3_6a.R @@ -0,0 +1,4 @@ +defective =5; +partially_defective = 10; +acceptable = 25; +cat("The required probability is",acceptable/(acceptable+partially_defective)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.b/Ex3_6b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.b/Ex3_6b.R new file mode 100644 index 00000000..43cb7410 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.b/Ex3_6b.R @@ -0,0 +1,5 @@ +prob_bb = 0.25; +prob_bg = 0.25; +prob_gb = 0.25; +prob_gg = 0.25; +cat("Probability that both are boys is",prob_bb/(prob_bg+prob_gb+prob_bb)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.c/Ex3_6c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.c/Ex3_6c.R new file mode 100644 index 00000000..5765f357 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.6.c/Ex3_6c.R @@ -0,0 +1,3 @@ +prob_phoenix = 0.3; +prob_manager = 0.6; +cat("Probability that Perez will be a Phoenix branch office manager is",prob_phoenix*prob_manager) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.a/Ex3_7a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.a/Ex3_7a.R new file mode 100644 index 00000000..a1ab7fc2 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.a/Ex3_7a.R @@ -0,0 +1,5 @@ +accident_prone= 0.4; +nonaccident_prone= 0.2; +pop_accident = 0.3; +prob = pop_accident*accident_prone + (1-pop_accident)*nonaccident_prone; +cat("The required probability is ",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.b/Ex3_7b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.b/Ex3_7b.R new file mode 100644 index 00000000..f8087e46 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.b/Ex3_7b.R @@ -0,0 +1,6 @@ +accident_prone= 0.4; +nonaccident_prone= 0.2; +pop_accident = 0.3; +prob_of_accident = pop_accident*accident_prone + (1-pop_accident)*nonaccident_prone; +prob = pop_accident * accident_prone /prob_of_accident; +cat("The required probability is",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.c/Ex3_7c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.c/Ex3_7c.R new file mode 100644 index 00000000..0be51ac6 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.c/Ex3_7c.R @@ -0,0 +1,3 @@ +m = 5; +p =1/2; +cat("The required probability is", (m*p)/(1+((m-1)*p))) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.d/Ex3_7d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.d/Ex3_7d.R new file mode 100644 index 00000000..09fe00f4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.d/Ex3_7d.R @@ -0,0 +1,5 @@ +detect_present = 0.99; +detect_notpresent = 0.01; +pop_disease = 0.005; +prob = detect_present*pop_disease/((detect_present*pop_disease) +(detect_notpresent*(1-pop_disease)) ) ; +cat("The required probability is",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.e/Ex3_7e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.e/Ex3_7e.R new file mode 100644 index 00000000..f58010af --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.e/Ex3_7e.R @@ -0,0 +1,5 @@ +criminal_char = 0.9 +convinced= 0.6; +pop_char = 0.2; +prob = (convinced*criminal_char) /((convinced*criminal_char) + (pop_char*(1-convinced))); +cat("The required probability is",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.f/Ex3_7f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.f/Ex3_7f.R new file mode 100644 index 00000000..270e4384 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.7.f/Ex3_7f.R @@ -0,0 +1,8 @@ +alpha1 = 0.4; +plane_in_region1 = 1/3; +plane_in_region2 = 1/3; +plane_in_region3 = 1/3; +prob1 = (alpha1*plane_in_region1)/((alpha1*plane_in_region1)+ 1*plane_in_region2 + 1*plane_in_region3); +prob2 = (1*plane_in_region2)/((alpha1*plane_in_region1)+ 1*plane_in_region2 + 1*plane_in_region3); +cat("The probability that the planes is in region 1 given that the search of region 1 did not uncover it ",prob1) +cat("The probability that the planes is in region 2/3 given that the search of region 1 did not uncover it ",prob2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.8.a/Ex3_8a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.8.a/Ex3_8a.R new file mode 100644 index 00000000..7cf1f5cc --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH3/EX3.8.a/Ex3_8a.R @@ -0,0 +1,3 @@ +prob_A = 4/52; +prob_H = 13/52; +cat("P(AH) is",prob_A*prob_H) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.1.a/Ex4_1a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.1.a/Ex4_1a.R new file mode 100644 index 00000000..ff93fa45 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.1.a/Ex4_1a.R @@ -0,0 +1,30 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) + +#First we set up the sample space with the rolldie function +S <- rolldie(2, makespace = TRUE) +#Next, we add random variables U and V with the addrv function. +S <- addrv(S, FUN = max, invars = c("X1", "X2"), name = "U") +S <- addrv(S, FUN = sum, invars = c("X1", "X2"), name = "V") +head(S) +UV <- marginal(S, vars = c("U", "V")) +xtabs(round(probs, 3) ~ U + V, data = UV) +marginal(UV, vars = "U") +marginal(UV, vars = "V") + +temp <- xtabs(probs ~ U + V, data = UV) +rowSums(temp) +colSums(temp) +colSums(temp) + +' +data = sample(1:6,10000000,replace=TRUE)+sample(1:6,10000000,replace=TRUE) +table(data)/length(data) +sum(table(data)/length(data)) + +table(sample(1:6,10000000,replace=TRUE))/length(sample(1:6,10000000,replace=TRUE)) +' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.1.c/Ex4_1c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.1.c/Ex4_1c.R new file mode 100644 index 00000000..f9490de4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.1.c/Ex4_1c.R @@ -0,0 +1,15 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) + +" +F(x) = 0 -- { x <= 0} +F(x) = 1 - exp(-x^2) -- {x >0} + +P{X>1} = ? +" +P = 1 - (1 - exp(-(1^2))) +P \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.2.a/Ex4_2a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.2.a/Ex4_2a.R new file mode 100644 index 00000000..b56e68a5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.2.a/Ex4_2a.R @@ -0,0 +1,11 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) + +P1 = 1/2 +P2 = 1/3 +P3 = 1 - P1 - P2 +P3 \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.2.b/Ex4_2b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.2.b/Ex4_2b.R new file mode 100644 index 00000000..3a4006a7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.2.b/Ex4_2b.R @@ -0,0 +1,17 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) + + +integrand <- function(x) {(4*(x) - 2*(x^2))} +R = integrate(integrand,lower = 0,upper = 2) +C = 1/R$value +C + +# P {X>1} +integrand <- function(x) {C*(4*(x) - 2*(x^2))} +P = integrate(integrand,lower = 1,upper = 2) +P \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.a/Ex4_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.a/Ex4_3a.R new file mode 100644 index 00000000..a596ddd9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.a/Ex4_3a.R @@ -0,0 +1,20 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) + + +p_0_0 = (length(combn(5, 3))/3)/(length(combn(12, 3))/3) +p_0_1 = (length(combn(4, 1))/1)*(length(combn(5, 2))/2)/(length(combn(12, 3))/3) +p_0_1 = (length(combn(4, 2))/2)*(length(combn(5, 1))/1)/(length(combn(12, 3))/3) +p_0_3 = (length(combn(4, 3))/3)/(length(combn(12, 3))/3) +p_1_0 = (length(combn(3, 1))/1)*(length(combn(5, 2))/2)/(length(combn(12, 3))/3) +p_1_1 = (length(combn(3, 1))/1)*(length(combn(4, 1))/1)*(length(combn(5, 1))/1)/(length(combn(12, 3))/3) +p_1_2 = (length(combn(3, 1))/1)*(length(combn(4, 2))/2)/(length(combn(12, 3))/3) +p_2_0 = (length(combn(3, 2))/2)*(length(combn(5, 1))/1)/(length(combn(12, 3))/3) +p_2_1 = (length(combn(3, 2))/2)*(length(combn(4, 1))/1)/(length(combn(12, 3))/3) +p_3_0 = (length(combn(3, 3))/3)/(length(combn(12, 3))/3) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.b/Ex4_3b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.b/Ex4_3b.R new file mode 100644 index 00000000..3946e321 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.b/Ex4_3b.R @@ -0,0 +1,39 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +' +library(discreteRV) +d<-RV(c("Boy","Girl"),odds=c(0.5,0.5)) +e<-RV(c("0","1","2","3"),odds = c(0.15,0.20,0.35,0.3)) +f<-joint(d,e) +probs(f) +' + +#P{B=0,G=0} = P{no children} +P = .15 +P +#P{B=0,G=1} = P{1 Girl and total of 1 child} = P{1 child} P{1 girl | 1 child} +P = .20 * (1/2) +P +#P{B=0,G=2} = P{2 Girls and total of 2 children} = P{2 children} P{2 girls | 2 children} +P = .35*(1/2)^2 +P +#P{B=0,G=3} = P{3 Girls and total of 3 children} = P{3 children} P{3 girls | 3 children} +P = .3*(1/2)^3 +P +#P{B=1,G=0} = P{1 Boy and total of 1 child} = P{1 child} P{1 boy | 1 child} +P = .2*(1/2) +P +#P{B=1,G=1} = P{1 Boy, 1Girl and total of 2 children} = P{2 children} P{1 boy | 2 children} +P = .35*.5 +#P = .35*((1/2)^2+(1/2)^2) +P +#P{B=1,G=2} = P{1 Boy, 2Girls and total of 3 children} = P{2 children} P{2 Girls | 2 children + 1 boy|1 child} +P = .3*((1/2)^3+(1/2)^2) +P \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.c/Ex4_3c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.c/Ex4_3c.R new file mode 100644 index 00000000..0f3ba4cb --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.c/Ex4_3c.R @@ -0,0 +1,48 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) +#1 +fun0 = function(x,y,z) { exp(-x)*exp(-2*y)*z } +fun01 <- function(z) { + integrate(function(y) { + sapply(y, function(y) { + integrate(function(x) fun0(x,y,z), 1, Inf)$value + }) + }, 0, 1)$value +} + +fun01(2) +#(1-exp(-2))*exp(-1) + +#2 +fun0 = function(x,y,z) { exp(-x)*exp(-2*y)*z } +fun01 <- function(z) { + integrate(function(y) { + sapply(y, function(y) { + integrate(function(x) fun0(x,y,z), 0, y)$value + }) + }, 0, Inf)$value +} + +fun01(2) + + +' +library(cubature) +f <-function(x) 2*exp(-x[1])*exp(-2*x[2]) +adaptIntegrate(f,lowerLimit = c(1,0),upperLimit = c(Inf,1)) + +require(pracma) +f <- function(x, y) 2*exp(-x)*exp(-2*y) +quad2d(f, 0, 1, 1, Inf) + +http://stackoverflow.com/questions/23901682/double-integration-in-r-with-additional-argument +' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.d/Ex4_3d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.d/Ex4_3d.R new file mode 100644 index 00000000..8332775c --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.d/Ex4_3d.R @@ -0,0 +1,26 @@ +#install.packages("IPSUR") +#install.packages("prob") +#install.packages("discreteRV") +#install.packages("pracma") +#install.packages("cubature") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + +fun0 = function(x,y,a) { exp(-x)*exp(-y) } +fun01 <- function(z) { + integrate(function(y) { + sapply(y, function(y) { + integrate(function(x) fun0(x,y,z), 0, a*y)$value + }) + }, 0, Inf)$value +} + +fun01(1) +fun01(2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.e/Ex4_3e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.e/Ex4_3e.R new file mode 100644 index 00000000..8ed450d6 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.e/Ex4_3e.R @@ -0,0 +1,16 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + +#P{X1 = 1,X2 = 2, X3 = 0} +P = 0.20*0.10*0.30 + + diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.f/Ex4_3f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.f/Ex4_3f.R new file mode 100644 index 00000000..22d071fb --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.f/Ex4_3f.R @@ -0,0 +1,26 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + +#P{G=1} = 0.3875 +C = 0.3875 +#P{B=0|G=1}=((P{B=0,G=1})/(P{G=1})) +P = 0.1/C +P +#P{B=1|G=1} +P = .175/C +P +#P{B=2|G=1} +P = .1125/C +P +#P{B=3|G=1} +P = 0 +P \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.g/Ex4_3g.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.g/Ex4_3g.R new file mode 100644 index 00000000..9afc1b93 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.3.g/Ex4_3g.R @@ -0,0 +1,31 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + +#P(0,0) +P_0_0 = .4 +#P(0,1) +P_0_1 = .2 +#P(1,0) +P_1_0 = .1 +#P(1,1) +P_1_1 = .3 + +#P{Y = 1} = P(0,1) + #P(1,1) +P_Y = P_0_1 + P_1_1 + +#P{X = 0|Y=1} = P(0,1)/P{Y=1} +P1 = P_0_1 / P_Y +P1 + +#P{X = 1|Y=1} = P(1,1)/P{Y=1} +P2 = P_1_1 / P_Y +P2 \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.4.a/Ex4_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.4.a/Ex4_4a.R new file mode 100644 index 00000000..43b2cd28 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.4.a/Ex4_4a.R @@ -0,0 +1,16 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +S <- rolldie(1, makespace = TRUE) +Ex = sum(S$X1*S$probs) +Ex \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.4.d/Ex4_4d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.4.d/Ex4_4d.R new file mode 100644 index 00000000..b92ca43f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.4.d/Ex4_4d.R @@ -0,0 +1,16 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +integrand <- function(x) {x / 1.5} +R = integrate(integrand,lower = 0,upper = 1.5) +R \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.a/Ex4_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.a/Ex4_5a.R new file mode 100644 index 00000000..4e86199e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.a/Ex4_5a.R @@ -0,0 +1,20 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +# P {X} +PY0 = .2 +PY1 = .5 +PY2 = .3 +# E[X^2] = E[Y] = Y0 * PY0 + Y1 * PY1 + Y2 * PY0 +E = 0 * PY0 + 1 * PY1 + 4 * PY2 +E \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.b/Ex4_5b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.b/Ex4_5b.R new file mode 100644 index 00000000..8b75d109 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.b/Ex4_5b.R @@ -0,0 +1,15 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +integrand <- function(x) {x*(1/3)*(x^(-2/3))} +R = integrate(integrand,lower = 0,upper = 1) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.c/Ex4_5c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.c/Ex4_5c.R new file mode 100644 index 00000000..2a0f1930 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.c/Ex4_5c.R @@ -0,0 +1,20 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +# P {X} +P0 = .2 +P1 = .5 +P2 = .3 +# E[X^2] = X0^2*P0 + X1^2*P1 + X2^2*P2 +E = (0^2)*P0 + (1^2)*P1 + (2^2)*P2 +E \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.d/Ex4_5d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.d/Ex4_5d.R new file mode 100644 index 00000000..b635158b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.d/Ex4_5d.R @@ -0,0 +1,15 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +integrand <- function(x) {x^(3)} +R = integrate(integrand,lower = 0,upper = 1) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.e/Ex4_5e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.e/Ex4_5e.R new file mode 100644 index 00000000..f2c8ae90 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.e/Ex4_5e.R @@ -0,0 +1,20 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +profits <-c(10,20,40) +probs <- c(.2,.8,.3) +E1 = profits[1]*probs[1]+0*(1-probs[1]) +E2 = profits[2]*probs[2]+0*(1-probs[2]) +E3 = profits[3]*probs[3]+0*(1-probs[3]) +E = E1 + E2 + E3 +E \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.g/Ex4_5g.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.g/Ex4_5g.R new file mode 100644 index 00000000..8fd87134 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.5.g/Ex4_5g.R @@ -0,0 +1,15 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +EX = 20 * (1 - (19/20)^10) +EX \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.6.a/Ex4_6a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.6.a/Ex4_6a.R new file mode 100644 index 00000000..fffb03ec --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.6.a/Ex4_6a.R @@ -0,0 +1,19 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +S <- rolldie(1, makespace = TRUE) +Ex = sum(S$X1*S$probs) +Ex2 = sum((S$X1)^2*S$probs) +Ex2 +Varx = Ex2 - (Ex)^2 +Varx \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.7.a/Ex4_7a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.7.a/Ex4_7a.R new file mode 100644 index 00000000..bc061a51 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.7.a/Ex4_7a.R @@ -0,0 +1,20 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + +S <- rolldie(1, makespace = TRUE) +Ex = sum(S$X1*S$probs) +Ex2 = sum((S$X1)^2*S$probs) +Ex2 +Varx = Ex2 - (Ex)^2 +Varx +Varx10 = 10 * Varx +Varx10 \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.7.b/Ex4_7b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.7.b/Ex4_7b.R new file mode 100644 index 00000000..ba9c54ba --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.7.b/Ex4_7b.R @@ -0,0 +1,17 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + +Var = .5 * (1 - .5) +Var + +Var10 = 10 * Var +Var10 \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.9.a/Ex4_9a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.9.a/Ex4_9a.R new file mode 100644 index 00000000..5b49fdf8 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH4/EX4.9.a/Ex4_9a.R @@ -0,0 +1,24 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +#read(IPSUR) +library(prob) +#read(prob) +#install.packages("combinat") +library(combinat) +library(discreteRV) +require(pracma) +library(cubature) + + +# Markov +# P {X > 75} +meanX = 50 +P = meanX / 75 +P + +#Chebyshev +# P {|X - 50| > = 10 } < = (SigmaX^2 / 10^2) +VarX = 25 +P = 1 - (VarX / 10^2) +P \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.a/Ex5_1a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.a/Ex5_1a.R new file mode 100644 index 00000000..97327601 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.a/Ex5_1a.R @@ -0,0 +1,7 @@ +#Probability that the package will have to be replaced +library(IPSUR) +P = 1 - choose(10,0)*(0.01)^0*(0.99)^10-choose(10,1)*(0.01)^1*(0.99)^9 +P +#Probability that exactly one of the three packages will be returned +PP = choose(3,1)*P*(1-P)^2 +PP \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.b/Ex5_1b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.b/Ex5_1b.R new file mode 100644 index 00000000..c4b0d65b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.b/Ex5_1b.R @@ -0,0 +1,7 @@ +library(IPSUR) +#The probability that a child recieves the blue eyed gene from both parents +Pblue = (1/2)*(1/2) +Pblue +#the probability that exactly two of them have blue eye color +P = choose(4,2)*(1/4)^2*(3/4)^2 +P \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.e/Ex5_1e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.e/Ex5_1e.R new file mode 100644 index 00000000..74828e0f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.e/Ex5_1e.R @@ -0,0 +1,10 @@ +library(IPSUR) +install.packages("binom") +library(binom) +pbinom(q = 0, size = 6,prob = 0.4) +pbinom(q = 1, size = 6,prob = 0.4) - pbinom(q = 0, size = 6,prob = 0.4) +pbinom(q = 2, size = 6,prob = 0.4) - pbinom(q = 1, size = 6,prob = 0.4) +pbinom(q = 3, size = 6,prob = 0.4) - pbinom(q = 2, size = 6,prob = 0.4) +pbinom(q = 4, size = 6,prob = 0.4) - pbinom(q = 3, size = 6,prob = 0.4) +pbinom(q = 5, size = 6,prob = 0.4) - pbinom(q = 4, size = 6,prob = 0.4) +pbinom(q = 6, size = 6,prob = 0.4) - pbinom(q = 5, size = 6,prob = 0.4) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.f/Ex5_1f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.f/Ex5_1f.R new file mode 100644 index 00000000..ef775332 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.1.f/Ex5_1f.R @@ -0,0 +1,2 @@ +pbinom(q = 70, size = 100,prob = 0.75) - pbinom(q = 69, size = 100,prob = 0.75) +pbinom(q = 70, size = 100,prob = 0.75) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.a/Ex5_2a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.a/Ex5_2a.R new file mode 100644 index 00000000..23223ab7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.a/Ex5_2a.R @@ -0,0 +1,4 @@ +#P{X>=1} = 1 - P{X = 0} +1-ppois(0,3) +#Or +1-dpois(0,3) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.b/Ex5_2b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.b/Ex5_2b.R new file mode 100644 index 00000000..d947768f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.b/Ex5_2b.R @@ -0,0 +1 @@ +ppois(1,1) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.c/Ex5_2c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.c/Ex5_2c.R new file mode 100644 index 00000000..96403ab5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.c/Ex5_2c.R @@ -0,0 +1 @@ +ppois(2,3.2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.d/Ex5_2d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.d/Ex5_2d.R new file mode 100644 index 00000000..a4072b03 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.d/Ex5_2d.R @@ -0,0 +1,8 @@ +#Proportion of days have less than 3 claims +ppois(2,5) + +dpois(4,lambda = 5) + +#the probability that 3 of the next 5 days will have claims is +library(IPSUR) +choose(5,3) *(dpois(4,lambda = 5))^3 *(1-dpois(4,lambda = 5))^2 \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.f/Ex5_2f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.f/Ex5_2f.R new file mode 100644 index 00000000..e1280cb1 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.2.f/Ex5_2f.R @@ -0,0 +1,2 @@ +i<-seq(0, 3, 1) +sum(dpois(i,8)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.a/Ex5_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.a/Ex5_3a.R new file mode 100644 index 00000000..1aca39a6 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.a/Ex5_3a.R @@ -0,0 +1 @@ +dhyper(4, m = 15, n = 5, k = 6)+dhyper(5, m = 15, n = 5, k = 6)+dhyper(6, m = 15, n = 5, k = 6) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.b/Ex5_3b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.b/Ex5_3b.R new file mode 100644 index 00000000..ba8997a1 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.b/Ex5_3b.R @@ -0,0 +1,8 @@ +hyper <- function(N, M, n, i) { + factorial(N)*factorial(M)*factorial(n)*factorial(N+M-n)/(factorial(i)*factorial(N-i)*factorial(n-i)*factorial(M-n+i)*factorial(N+M)) +} + +r= 50 +n=100 +X=25 +cat("Estimate of the number of animals in the region is",r*n/X) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.c/Ex5_3c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.c/Ex5_3c.R new file mode 100644 index 00000000..3f2819a4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.3.c/Ex5_3c.R @@ -0,0 +1,9 @@ +bino <- function(n, k, p) { + factorial(n)*(p^k)*((1-p)^(n-k))/(factorial(k)*factorial(n-k)) +} + +condprob <- function(n,k,p,i) { + bino(n,i,p)*bino(m,k-i,p)/bino(n+m,k, p); +} + +#The function condprob will give P{X=i|X+Y=k} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.a/Ex5_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.a/Ex5_4a.R new file mode 100644 index 00000000..6be57071 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.a/Ex5_4a.R @@ -0,0 +1,18 @@ +beta = 10 +alpha = 0 +#a +a = 2 +b = 9 +(b-a)/(beta-alpha) +#b +a = 1 +b = 4 +(b-a)/(beta-alpha) +#c +a = 0 +b = 5 +(b-a)/(beta-alpha) +#d +a = 6 +b = 10 +(b-a)/(beta-alpha) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.b/Ex5_4b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.b/Ex5_4b.R new file mode 100644 index 00000000..7d18493b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.b/Ex5_4b.R @@ -0,0 +1,15 @@ +beta = 30 +alpha = 0 +#a +a1 = 10 +b1 = 15 +a2 = 25 +b2 = 30 +(b1-a1)/(beta-alpha)+(b2-a2)/(beta-alpha) + +#b +a1 = 0 +b1 = 3 +a2 = 15 +b2 = 18 +(b1-a1)/(beta-alpha)+(b2-a2)/(beta-alpha) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.c/Ex5_4c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.c/Ex5_4c.R new file mode 100644 index 00000000..e6e6d4e2 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.4.c/Ex5_4c.R @@ -0,0 +1,5 @@ +I0 = 10^-6 +a = 5 +integrand <- function(x) {0.5*exp(a*x)} +R = integrate(integrand,lower = 1,upper = 3) +(I0*R$value)-I0 \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.a/Ex5_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.a/Ex5_5a.R new file mode 100644 index 00000000..dcc1c952 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.a/Ex5_5a.R @@ -0,0 +1,6 @@ +#a +pnorm(11,3,sqrt(16)) +#b +1-pnorm(-1,3,sqrt(16)) +#c +pnorm(7,3,sqrt(16))-pnorm(2,3,sqrt(16)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.b/Ex5_5b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.b/Ex5_5b.R new file mode 100644 index 00000000..6b613323 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.b/Ex5_5b.R @@ -0,0 +1,4 @@ +#a +pnorm(-1.5) +#b +1-pnorm(2.5) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.c/Ex5_5c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.c/Ex5_5c.R new file mode 100644 index 00000000..0d656284 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.c/Ex5_5c.R @@ -0,0 +1,6 @@ +mu = 6 +sigma = 1 +#a +E = 3*(mu^2+sigma^2) #ref page 169 +#b +1-pnorm(sqrt(40),mu,sigma) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.d/Ex5_5d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.d/Ex5_5d.R new file mode 100644 index 00000000..e73d0ae5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.5.d/Ex5_5d.R @@ -0,0 +1,4 @@ +#a +1-pnorm(25,24.16,sqrt(19.22)) +#b +1-pnorm(3,0,sqrt(19.22)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.a/Ex5_6a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.a/Ex5_6a.R new file mode 100644 index 00000000..ff69fdc5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.a/Ex5_6a.R @@ -0,0 +1 @@ +1-pexp(5000, rate = 10000) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.b/Ex5_6b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.b/Ex5_6b.R new file mode 100644 index 00000000..cfb3b157 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.b/Ex5_6b.R @@ -0,0 +1,5 @@ +#When C is put to use, one other machine(either A or B ) will still be working . +#The probability of this machine or C failing is equal due to +#the memoryless propoerty of exponential random variables. + +cat("The probability that machine which is still operable is machine C is ",1/2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.c/Ex5_6c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.c/Ex5_6c.R new file mode 100644 index 00000000..ed14eb83 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.6.c/Ex5_6c.R @@ -0,0 +1,7 @@ +new <- function(lamda,n, t ) { + newsum = 0; + for (i in 1:n){ + newsum= newsum + lamda[i] + result=(exp(1))^(-1*newsum*t) + } +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.a/Ex5_8a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.a/Ex5_8a.R new file mode 100644 index 00000000..8bdec096 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.a/Ex5_8a.R @@ -0,0 +1 @@ +pchisq(30,df =26) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.b/Ex5_8b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.b/Ex5_8b.R new file mode 100644 index 00000000..5dece624 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.b/Ex5_8b.R @@ -0,0 +1 @@ +qchisq((1-0.05),df =15) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.c/Ex5_8c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.c/Ex5_8c.R new file mode 100644 index 00000000..9487b82b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.c/Ex5_8c.R @@ -0,0 +1 @@ +1-pchisq(9/4,df =3) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.d/Ex5_8d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.d/Ex5_8d.R new file mode 100644 index 00000000..ecb26a7d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.d/Ex5_8d.R @@ -0,0 +1,3 @@ +1-pchisq(9/4,df =2) +#or +1-pexp(9/4,1/2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.e/Ex5_8e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.e/Ex5_8e.R new file mode 100644 index 00000000..af07ae41 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.e/Ex5_8e.R @@ -0,0 +1,4 @@ +#a +pt(1.4,12) +#b +-qt(0.025,9) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.f/Ex5_8f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.f/Ex5_8f.R new file mode 100644 index 00000000..3d987780 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH5/EX5.8.f/Ex5_8f.R @@ -0,0 +1 @@ +pf(1.5,6,14) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.a/Ex6_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.a/Ex6_3a.R new file mode 100644 index 00000000..3d92860b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.a/Ex6_3a.R @@ -0,0 +1 @@ +1-pnorm(8300000,320*25000,540*sqrt(25000)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.c/Ex6_3c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.c/Ex6_3c.R new file mode 100644 index 00000000..126675b0 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.c/Ex6_3c.R @@ -0,0 +1 @@ +1-pnorm((150.5-(450*0.3))/sqrt(450*.3*(1-.3))) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.d/Ex6_3d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.d/Ex6_3d.R new file mode 100644 index 00000000..924e747f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.d/Ex6_3d.R @@ -0,0 +1,4 @@ +#a +2*pnorm(.8889)-1 +#b +2*pnorm(1.7778)-1 \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.e/Ex6_3e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.e/Ex6_3e.R new file mode 100644 index 00000000..c46bda4f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.3.e/Ex6_3e.R @@ -0,0 +1,3 @@ +qnorm(((1+.95)/2),0,1) +n = (1.96*4)^2 +n \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.5.a/Ex6_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.5.a/Ex6_5a.R new file mode 100644 index 00000000..183e83eb --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.5.a/Ex6_5a.R @@ -0,0 +1,4 @@ +n = 15 +sigmasq = 9 +Ssq = 12 +1-pchisq(((n-1)*Ssq/sigmasq),n-1) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.6.a/Ex6_6a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.6.a/Ex6_6a.R new file mode 100644 index 00000000..b752c2fa --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.6.a/Ex6_6a.R @@ -0,0 +1,10 @@ +favour = 0.45; +samplesize = 200; +expec= favour*samplesize; +sd = sqrt(samplesize*favour*(1-favour)); +cat("The expected value is",expec) +cat("The standard deviation is",sd) + +#b +prob = 1-pbinom(q = samplesize/2, size = samplesize,prob = favour) +cat("Probability that more than half the members of the sample favour the candidate",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.6.b/Ex6_6b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.6.b/Ex6_6b.R new file mode 100644 index 00000000..9b1bea3e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH6/EX6.6.b/Ex6_6b.R @@ -0,0 +1,8 @@ +meaneach = 147; +sdeach = 62; +samplesize = 25; +lim =150; +samplemean = meaneach; +samplesd= sdeach/sqrt(samplesize) +prob = 1 - pnorm(q = lim,mean = samplemean,sd = samplesd) +prob \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.a/Ex7_2a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.a/Ex7_2a.R new file mode 100644 index 00000000..627e082e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.a/Ex7_2a.R @@ -0,0 +1,3 @@ +samplesize = 1000; +acceptable =921; +cat("The maximum likelihood estimate of p is",acceptable/samplesize) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.b/Ex7_2b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.b/Ex7_2b.R new file mode 100644 index 00000000..4126db70 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.b/Ex7_2b.R @@ -0,0 +1,5 @@ +totalerror<-function(n1, n2, n12){ + totalerror = n1*n2/n12 + return(totalerror) +} +totalerror(n1 = 33000,n2 = 33000,n12 = 17000) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.c/Ex7_2c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.c/Ex7_2c.R new file mode 100644 index 00000000..15fb6e8c --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.c/Ex7_2c.R @@ -0,0 +1,3 @@ +total_people = 857; +days= 20; +cat("The maximum likelihood estimate of lambda",total_people/days) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.d/Ex7_2d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.d/Ex7_2d.R new file mode 100644 index 00000000..d1664385 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.d/Ex7_2d.R @@ -0,0 +1,5 @@ +accidents<-c(4,0,6,5,2,1,2,0,4,3) +lambda= mean(accidents) +cat("lambda:",lambda) +prob = ppois(q = 2, lambda = lambda) +cat("Proportion of non-rainy days that had 2 or fewer accidents that year:",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.e/Ex7_2e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.e/Ex7_2e.R new file mode 100644 index 00000000..0f1744a3 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.e/Ex7_2e.R @@ -0,0 +1,9 @@ +normal <-function(X, Xmean, n){ + u= Xmean; + newsum = 0; + for (i in 1:n){ + newsum= newsum + (X(i)-Xmean)^2 + } + sigmasquared = sqrt((newsum/n)); + return(u,sigmasquared) +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.f/Ex7_2f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.f/Ex7_2f.R new file mode 100644 index 00000000..af9a7612 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.f/Ex7_2f.R @@ -0,0 +1,13 @@ +X<-c(2.2,3.4,1.6,0.8,2.7,3.3,1.6,2.8,2.5,1.9) +upperlimX = 3 +lowerlimX = 2 +upperlimlogX= log(upperlimX) +lowerlimlogX = log(lowerlimX) + +logX = log(X) +samplemean= mean(logX) +samplesd= sqrt(var(logX)) +samplemean +samplesd +prob = pnorm(upperlimlogX, samplemean, samplesd) - pnorm(lowerlimlogX, samplemean, samplesd) +prob \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.g/Ex7_2g.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.g/Ex7_2g.R new file mode 100644 index 00000000..e1e29e43 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.2.g/Ex7_2g.R @@ -0,0 +1,3 @@ +unif <- function(X, n) { + max(X)/2 +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.a/Ex7_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.a/Ex7_3a.R new file mode 100644 index 00000000..b872442d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.a/Ex7_3a.R @@ -0,0 +1,8 @@ +avg = 0; +var = 4; +num = 9; +X<-c(5,8.5,12,15,7,9,7.5,6.5,10.5) +samplemean= mean(X); +lowerlim = samplemean - (1.96*sqrt(var/num)) +upperlim = samplemean + (1.96*sqrt(var/num)) +cat("The 95% confidence interval is ",lowerlim,"to ",upperlim) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.b/Ex7_3b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.b/Ex7_3b.R new file mode 100644 index 00000000..805fa74f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.b/Ex7_3b.R @@ -0,0 +1,10 @@ +avg = 0; +var = 4; +num = 9; +X<-c(5,8.5,12,15,7,9,7.5,6.5,10.5) +samplemean= mean(X); +lowerlim = samplemean - (1.645*sqrt(var/num)) +upperlim = samplemean + (1.645*sqrt(var/num)) + +cat("The 95% upper confidence interval is ",lowerlim," to infinity") +cat("The 95% upper confidence interval is minus infinity to ",upperlim) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.c/Ex7_3c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.c/Ex7_3c.R new file mode 100644 index 00000000..e05c99c0 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.c/Ex7_3c.R @@ -0,0 +1,18 @@ +var = 4; +num = 9; +X<-c(5,8.5,12,15,7,9,7.5,6.5,10.5) +samplemean= mean(X); +samplesd = sd(X) +alpha= 0.005; +zalpha = qnorm(p = alpha,mean = 0,sd = 1,lower.tail = FALSE) +zalpha +lowerlim = samplemean - (zalpha*sqrt(var/num)) +upperlim = samplemean + (zalpha*sqrt(var/num)) +cat("The 95% confidence interval is ",lowerlim, "to ",upperlim) + +alpha= 0.01; +zalpha = qnorm(p = alpha,mean = 0,sd = 1,lower.tail = FALSE) +lowerlim = samplemean - (zalpha*sqrt(var/num)) +upperlim = samplemean + (zalpha*sqrt(var/num)) +cat("The 95% upper confidence interval is ",lowerlim," to infinity") +cat("The 95% upper confidence interval is minus infinity to ",upperlim) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.d/Ex7_3d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.d/Ex7_3d.R new file mode 100644 index 00000000..263978bf --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.d/Ex7_3d.R @@ -0,0 +1,4 @@ +sd= 0.3; +lim = 0.1; +num = (1.96*sd/lim)^2; +cat("Sample size should be greater than",round(num)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.e/Ex7_3e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.e/Ex7_3e.R new file mode 100644 index 00000000..2b4c43e7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.e/Ex7_3e.R @@ -0,0 +1,18 @@ +X<-c(5, 8.5, 12, 15, 7, 9, 7.5, 6.5, 10.5) +num = 9; +meanX= mean(X); +X2 = X^2; +s2= (sum(X2)- (num*(meanX^2)))/(num-1); +s= sqrt(s2); +tval = qt(.975,8) +upperlim = meanX + (tval*s)/sqrt(num); +lowerlim = meanX - (tval*s)/sqrt(num); +cat("The 95% confidence interval is ", lowerlim, "to ",upperlim ) + +#7.3a +s2= 4 +s= sqrt(s2); +tval = qt(.975,8) +upperlim = meanX + (tval*s)/sqrt(num); +lowerlim = meanX - (tval*s)/sqrt(num); +cat("The 95% confidence interval is ", lowerlim, "to ",upperlim ) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.f/Ex7_3f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.f/Ex7_3f.R new file mode 100644 index 00000000..0f7e114c --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.f/Ex7_3f.R @@ -0,0 +1,14 @@ +X<-c(54, 63, 58, 72, 49, 92, 70, 73, 69, 104, 48, 66, 80, 64, 77) +num = 15; +meanX= mean(X); +X2 = X^2; +s2= (sum(X2)- (num*(meanX^2)))/(num-1); +s= sqrt(s2); +tval = qt(.975,num-1) +upperlim = meanX + (tval*s)/sqrt(num); +lowerlim = meanX - (tval*s)/sqrt(num); +cat("The 95% confidence interval is ",lowerlim,"to ",upperlim) +alpha = 0.05; +tval = qt(1-alpha,num-1) +lim = meanX + (tval*s)/sqrt(num); +cat("The 95% lower confidence interval is from minus infinity to ",lim) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.g/Ex7_3g.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.g/Ex7_3g.R new file mode 100644 index 00000000..c34531aa --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.g/Ex7_3g.R @@ -0,0 +1,26 @@ +#Method 1: Monte Carlo Integration +#install.packages("functional") +library(functional) +funct<-function(sampleXVals) { + oned = sqrt(1-(sampleXVals*sampleXVals)) + return(oned) +} +MCIntegrate <- function(funct, a,b,N) { + sampleXVals = matrix(0,N) + set.seed(148) + sampleXVals = a + (b-a)*runif(N) + Integral = (b-a)* mean(funct(sampleXVals)) + return(Integral) +} +MCIntegrate(funct,0,1,50000000) + + +#Method 2 +meanX = 0.786; +s= 0.03; +num = 100; +alpha = 0.05; +tval = qt(1-alpha,num-1) +upperlim = meanX + (tval*s)/sqrt(num); +lowerlim = meanX - (tval*s)/sqrt(num); +cat("The 95% confidence interval is ",lowerlim,"to ",upperlim) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.h/Ex7_3h.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.h/Ex7_3h.R new file mode 100644 index 00000000..dffe3724 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.3.h/Ex7_3h.R @@ -0,0 +1,11 @@ +num=10; +X<-c(0.123, 0.133, 0.124, 0.126, 0.120, 0.130, 0.125, 0.128, 0.124, 0.126) +var(X) +s2 = var(X) +chi1 = qchisq(1-.95,num-1) +chi2 = qchisq(.95,num-1) +lowerlim = (num-1)*s2/chi2; +lowerlim +upperlim = (num-1)*s2/chi1; +upperlim +cat("The 90% confidence interval is ",sqrt(lowerlim), "to ",sqrt(upperlim)) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.4.a/Ex7_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.4.a/Ex7_4a.R new file mode 100644 index 00000000..804ead45 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.4.a/Ex7_4a.R @@ -0,0 +1,19 @@ +A<-c(36, 44, 41, 53, 38, 36, 34, 54, 52, 37, 51, 44, 35, 44) +B<-c(52, 64, 38, 68, 66, 52, 60, 44, 48, 46, 70, 62) +sigmaA= 40; +sigmaB= 100; +alpha = 1-0.95; +beta= alpha/2; +meanA = mean(A); +meanB= mean(B); +zbeta = qnorm(1-beta) + +lowerlim= mean(A) - mean(B) - (zbeta*sqrt((sigmaA/length(A)) + (sigmaB/length(B)))) ; +upperlim= mean(A) - mean(B) + (zbeta*sqrt((sigmaA/length(A)) + (sigmaB/length(B)))) ; +cat("The 95% confidence interval is ",lowerlim, "to ",upperlim) + +beta=alpha; +zbeta = qnorm(1-beta) + +upperlim= mean(A) - mean(B) + (zbeta*sqrt((sigmaA/length(A)) + (sigmaB/length(B)))) ; +cat("A value that exceed the difference of the means with 95% confidence is",upperlim) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.4.b/Ex7_4b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.4.b/Ex7_4b.R new file mode 100644 index 00000000..1e81c274 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.4.b/Ex7_4b.R @@ -0,0 +1,22 @@ +tech1<-c(140, 136, 138, 150, 152, 144, 132, 142, 150, 154, 136, 142) +tech2<-c(144, 132, 136, 140, 128, 150, 130, 134, 130, 146, 128, 131, 137, 135) +num1= 12; +num2= 14; +mean1= mean(tech1); +mean2= mean(tech2); +alpha = 0.9; +S1 = var(tech1) +S2 = var(tech2) +Sp = (((num1-1)*S1) + ((num2-1)*S2))/(num1+ num2 -2); +Sp= sqrt(Sp); +num= (1/num1)+(1/num2); +betaa = (1-alpha)/2; +tval = qt(1-betaa,num1+num2-2) +upperlim = mean1-mean2 + (tval*Sp)*sqrt(num); +lowerlim = mean1-mean2 - (tval*Sp)*sqrt(num); +cat("The 90% confidence interval is ",lowerlim, "to ", upperlim) +alpha = 0.95 +betaaa = 1-alpha; +tval = qt(1-betaa,num1+num2-2) +lowerlim = mean1-mean2 - (tval*Sp)*sqrt(num); +cat("the upper confidence interval is",lowerlim," to infinity") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.a/Ex7_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.a/Ex7_5a.R new file mode 100644 index 00000000..61d006d7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.a/Ex7_5a.R @@ -0,0 +1,7 @@ +phat = 0.8; +zalpha = 1.96; + +samplesize = 100; +lowerlim = phat - (zalpha*sqrt(phat*(1-phat)/samplesize)); +upperlim = phat + (zalpha*sqrt(phat*(1-phat)/samplesize)); +cat("The 95% confidence interval is ",lowerlim, "to ",upperlim) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.b/Ex7_5b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.b/Ex7_5b.R new file mode 100644 index 00000000..e5b12ff9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.b/Ex7_5b.R @@ -0,0 +1,5 @@ +phat = 0.52; +error = 0.04; +zalpha = 1.96; +samplesize = (error/zalpha)^2/(phat*(1-phat)); +1/samplesize \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.c/Ex7_5c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.c/Ex7_5c.R new file mode 100644 index 00000000..384c417b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.5.c/Ex7_5c.R @@ -0,0 +1,13 @@ +initialsample = 30; +acceptable= 26; +phat = acceptable/initialsample; +error = 0.05/2; +zalpha = 2.58; + +samplesize = (error/zalpha)^2/(phat*(1-phat)); +finalsize = round(1/samplesize); +acceptablenew= 1040 + acceptable; +phat = acceptablenew/finalsize; +lowerlim = phat - (zalpha*sqrt(phat*(1-phat)/finalsize)); +upperlim = phat + (zalpha*sqrt(phat*(1-phat)/finalsize)); +cat("The 99% confidence interval is ",lowerlim, "to ",upperlim) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.6.a/Ex7_6a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.6.a/Ex7_6a.R new file mode 100644 index 00000000..59ac9460 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.6.a/Ex7_6a.R @@ -0,0 +1,14 @@ +sum_lives = 1740; +num = 10; +alpha = (1-0.95)/2; +chi1= qchisq(1-alpha,2*num) +chi2 = qchisq(alpha,2*num) +lowerlim = 2*sum_lives/chi1; +upperlim = 2*sum_lives/chi2; +cat("The 95% confidence interval is ",lowerlim, "to ",upperlim) + +' +Textbook confidence interval is from 101.847 to 360.211 +whereas in above solution is 101.84489 to 362.8485 because of the difference in the value of chi-square(0.975, 20). +The textbook says the value is 9.661 whereas R calculates its value as 9.59 +' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.a/Ex7_7a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.a/Ex7_7a.R new file mode 100644 index 00000000..75310cd8 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.a/Ex7_7a.R @@ -0,0 +1,6 @@ +estimator1 <- function(x) { + X[1] +} +estimator2 <- function(variables) { + mean(X) +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.b/Ex7_7b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.b/Ex7_7b.R new file mode 100644 index 00000000..60a30cca --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.b/Ex7_7b.R @@ -0,0 +1,10 @@ +estimate <- function(d, sigma) { + sigmainv = 1/sigma + new = d/sigma + result1 = sum(new)/sum(sigmainv) +} + +mserror <- function(sigma) { + sigmainv = 1/sigma + result1 = 1/sum(sigmainv) +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.c/Ex7_7c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.c/Ex7_7c.R new file mode 100644 index 00000000..c90721c8 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.7.c/Ex7_7c.R @@ -0,0 +1,4 @@ +unbiasedestimator <- function(X, n) { + c=(n+2)/(n+1) + result = c*max(X) +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.a/Ex7_8a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.a/Ex7_8a.R new file mode 100644 index 00000000..ea5dd8d7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.a/Ex7_8a.R @@ -0,0 +1,3 @@ +estimator <- function(X, n) { + (sum(X) +1)/(n+2) +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.b/Ex7_8b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.b/Ex7_8b.R new file mode 100644 index 00000000..5b3a3fd6 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.b/Ex7_8b.R @@ -0,0 +1,8 @@ +meanestimator <- function(sigma0 , u, sigma, n, X) { + meanX= mean(X) + result = (n*meanX/sigma0)/((n/sigma0)+(1/sigma)) + (u/sigma)/((n/sigma0)+(1/sigma)) +} + +varestimator <- function(sigma0 , sigma, n) { + (sigma0*sigma)/((n*sigma)+sigma0) +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.d/Ex7_8d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.d/Ex7_8d.R new file mode 100644 index 00000000..bd3da092 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH7/EX7.8.d/Ex7_8d.R @@ -0,0 +1,23 @@ +meanestimator <- function(sigma0 , u, sigma, n, X) { + meanX= mean(X); + result = (n*meanX/sigma0)/((n/sigma0)+(1/sigma)) + (u/sigma)/((n/sigma0)+(1/sigma)); + return(result) +} + +varestimator <- function(sigma0 , sigma, n) { + result = (sigma0*sigma)/((n*sigma)+sigma0); + return(result) +} + +u = 50; +sigma= 100; +sigma0 = 60; +n =1; +X =40; +expec = meanestimator(sigma0 , u, sigma, n, X); +var = varestimator (sigma0, sigma,n); + +zalpha = 1.645 +lowerlim = -1*sqrt(var)*zalpha+expec; +upperlim = sqrt(var)*zalpha+expec; +cat("With probability 0.9, the sent signal lies between ",lowerlim, "to ", upperlim ) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.a/Ex8_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.a/Ex8_3a.R new file mode 100644 index 00000000..484d982b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.3.a/Ex8_3a.R @@ -0,0 +1,12 @@ +noise_var = 4; +noise_mean= 0; +num = 5; +Xbar = 9.5; +u = 8; +statistic = sqrt(num/noise_var)*(Xbar - u); +compare = qnorm(0.975,0, 1); +if(statistic10} = ",val); +cat("Manufacturers claim cannot be rejected at the 5% level of significance") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.6.b/Ex8_6b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.6.b/Ex8_6b.R new file mode 100644 index 00000000..f833cc87 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.6.b/Ex8_6b.R @@ -0,0 +1,9 @@ +samplesize = 300; +p =0.02; +defective=9; +compare = 10; +npo = samplesize*p; +sd = sqrt(npo*(1-p)); +tol = 0.5; +pvalue = 1- pnorm(compare-tol, npo,sd ); +cat("The pvalue is",pvalue) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.6.c/Ex8_6c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.6.c/Ex8_6c.R new file mode 100644 index 00000000..39b180cb --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.6.c/Ex8_6c.R @@ -0,0 +1,7 @@ +samplesize = 500; +p =0.04; +defective=16; +prob1 = 1-pbinom(defective, samplesize, p, 1-p) +prob2 = pbinom(defective-1, samplesize, p, 1-p); +pvalue = 2*min(prob1,prob2); +cat("The pvalue is",pvalue) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.a/Ex8_7a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.a/Ex8_7a.R new file mode 100644 index 00000000..6f2c9dcb --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.a/Ex8_7a.R @@ -0,0 +1,5 @@ +x<-c(28, 34, 32, 38, 22) +claim = 25; +total = sum(x); +pval = 1 - ppois(total-1, (claim*length(x))); +cat("The pvalue is",pval) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.b/Ex8_7b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.b/Ex8_7b.R new file mode 100644 index 00000000..489f4c08 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.b/Ex8_7b.R @@ -0,0 +1,11 @@ +plant1<-c(16, 18, 9, 22, 17, 19, 24, 8) +plant2<-c(22, 18, 26, 30, 25, 28) +X1= sum(plant1); +X2 = sum(plant2); +n =length(X1); +m= length(X2); +prob1 = 1 - pbinom(X1, X1+X2,(4/7),(3/7)); +prob2 = pbinom(X1-1 ,X1+X2, 4/7, 3/7 ); +cat(prob1, prob2) +pvalue = 2*min(prob1,prob2); +cat("The pvalue is",pvalue) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.c/Ex8_7c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.c/Ex8_7c.R new file mode 100644 index 00000000..f370a11b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH8/EX8.7.c/Ex8_7c.R @@ -0,0 +1,7 @@ +Aerror =28; +Berror = 18; +common =10; +N2 = Aerror - common; +N3 =Berror- common; +pval = pbinom(N2-1, N2 + N3, 0.5, 0.5); +cat("P-value is",pval) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.1.a/Ex9_1a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.1.a/Ex9_1a.R new file mode 100644 index 00000000..781d6068 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.1.a/Ex9_1a.R @@ -0,0 +1,5 @@ +X<-c(100, 110, 120, 130, 140, 150, 160, 170, 180, 190); +Y<-c(45, 52, 54, 63, 62, 68, 75, 76, 92, 88) +dev.new(width=5, height=4) +plot(X, Y) +cat("A linear regression model seems appropriate") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.a/Ex9_10a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.a/Ex9_10a.R new file mode 100644 index 00000000..91096b6f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.a/Ex9_10a.R @@ -0,0 +1,33 @@ +x1<-c(679, 1420, 1349, 296, 6975, 323, 4200, 633) +x2<-c(30.4, 34.1, 17.2, 26.8, 29.1, 18.7, 32.6, 32.5) +y = matrix(1,8,1); +n = 8 +y<-c(11.6,16.1, 9.3, 9.1, 8.4, 7.7, 11.3, 8.4) +x = matrix(1,8,3); +for (i in 1:8){ + x[i,2]= x1[i]; + x[i,3]= x2[i]; +} + +pro1 = t(x) +pro2= pro1%*%x; +pro3 = solve(pro2); +pro4 = pro3%*%pro1; +pro5 = pro4%*%y; + +B<-matrix(0,3,8) +matrix(1,3,1); +for (i in 1:3){ + B[i,1]= 0; + for (k in 1:8){ + B[i,1]=B[i,1]+(pro4[i, k]*y[k]); + } +} +cat(B); +SSR = t(y) +SSR= SSR%*%y; +sub = t(B); +sub = sub%*%t(x); +sub= sub%*%y; +SSR =SSR[1,1] - sub[1,1]; +cat("SSr is",SSR) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.b/Ex9_10b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.b/Ex9_10b.R new file mode 100644 index 00000000..b7413cef --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.b/Ex9_10b.R @@ -0,0 +1,38 @@ +x1<-c(679, 1420, 1349, 296, 6975, 323, 4200, 633) +x2<-c(30.4, 34.1, 17.2, 26.8, 29.1, 18.7, 32.6, 32.5) +y = matrix(1,8,1); +n = 8 +y<-c(11.6,16.1, 9.3, 9.1, 8.4, 7.7, 11.3, 8.4) +x = matrix(1,8,3); +for (i in 1:8){ + x[i,2]= x1[i]; + x[i,3]= x2[i]; +} + +pro1 = t(x) +pro2= pro1%*%x; +pro3 = solve(pro2); +pro4 = pro3%*%pro1; +pro5 = pro4%*%y; + +B<-matrix(0,3,8) +matrix(1,3,1); +for (i in 1:3){ + B[i,1]= 0; + for (k in 1:8){ + B[i,1]=B[i,1]+(pro4[i, k]*y[k]); + } +} +cat(B); +SSR = t(y) +SSR= SSR%*%y; +sub = t(B); +sub = sub%*%t(x); +sub= sub%*%y; +SSR =SSR[1,1] - sub[1,1]; +cat("SSr is",SSR) + +k=2; +den = n-k-1; +sigma = SSR/den; +cat("The variance is",sigma) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.c/Ex9_10c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.c/Ex9_10c.R new file mode 100644 index 00000000..fe28f95b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.c/Ex9_10c.R @@ -0,0 +1,41 @@ +x1<-c(44, 33, 33, 32, 34, 31, 33, 30, 34, 34, 33, 36, 33, 34, 37) +x2<-c(1.3, 2.2, 2.2, 2.6, 2.0, 1.8, 2.2, 3.6, 1.6, 1.5, 2.2, 1.7, 2.2, 1.3, 2.6) +x3<-c(250, 115, 75, 85, 100, 75, 85, 75, 225, 250, 255, 175, 75, 85, 90) +x4<-c(0.63, 0.59, 0.56, 0.55, 0.54, 0.59, 0.56, 0.46, 0.63, 0.60, 0.63, 0.58, 0.55, 0.57, 0.62) +y<-c(18.1, 19.6, 16.6, 16.4, 16.9, 17.0, 20.0, 16.6, 16.2, 18.5, 18.7, 19.4, 17.6, 18.3, 18.8) +n =length(x1); +x= matrix(1,15, 5); +for (i in 1:15){ + x[i,2]= x1[i] + x[i,3]= x2[i] + x[i,4]= x3[i] + x[i,5]= x4[i] +} + +pro1 = t(x) +pro2= pro1%*%x +pro3 = solve(pro2) +pro4 = pro3%*%pro1 +pro5 = pro4%*%y +B<-matrix(0,5,15) +for (i in 1:5){ + B[i,1]= 0 + for (k in 1:15){ + B[i,1]=B[i,1]+(pro4[i, k]*y[k]) + } +} +SSR = t(y) +SSR= SSR%*%y +sub = t(B) +sub = sub%*%t(x) +sub= sub%*%y +SSR =SSR[1,1] - sub[1,1] +SSR +xxinv = 0.379; +k= 4; +ts = sqrt((n-k-2)/SSR)*B[2]/0.616; +pvalue = 2*(1- pt(ts, n-k-2)) +cat("The p-value is",pvalue) +' +The SSR calculated by R is 19.34 whereas the textbook gives the value as 19.26 , thus the difference in the final answer. +' \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.d/Ex9_10d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.d/Ex9_10d.R new file mode 100644 index 00000000..1bd2bd3f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.10.d/Ex9_10d.R @@ -0,0 +1,45 @@ +y<-c(79.2, 64.0, 55.7, 56.3, 58.6, 84.3, 70.4, 61.3, 51.3, 49.8) +x1<-c(0.02, 0.03, 0.03, 0.04, 0.10, 0.15, 0.15, 0.09, 0.13, 0.09) +x2<-c(1.05, 1.20, 1.25, 1.30, 1.30, 1.00, 1.10, 1.20, 1.40, 1.40) +tvalue= 2.365; +x = matrix(1,10,3); +for (i in 1:10){ + x[i,2]= x1[i] + x[i,3]= x2[i] +} + +pro1 = t(x) +pro2= pro1%*%x +pro3 = solve(pro2) +pro4 = pro3%*%pro1 +pro5 = pro4%*%y +B= matrix(1,3,1) + +for (i in 1:3){ + B[i,1]= 0 + for ( k in 1:10){ + B[i,1]= B[i,1]+(pro4[i, k]*y[k]) + } +} + +SSR = t(y) +SSR= SSR%*%y +sub = t(B) +sub = sub%*%t(x) +sub= sub%*%y +SSR =SSR[1,1] - sub[1,1] +cat("SSr is",SSR) + +smallx<-c(1, 0.15, 1.15) +product = smallx %*% B +n = 10; +k=2; +val= sqrt(SSR/(n-k-1)); + +pro5 = smallx %*% pro3 +pro6 = pro5 %*% (smallx) +pro7 = val*sqrt(pro6)*tvalue + +up = product + pro7; +low = product - pro7; +cat(" 95% confidence interval is from ",low,"to",up) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.11.a/Ex9_11a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.11.a/Ex9_11a.R new file mode 100644 index 00000000..c2bf8b97 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.11.a/Ex9_11a.R @@ -0,0 +1,5 @@ +cancer = 84; +total = 111; +level = 250; +alpha= -1*log((total-cancer)/total)/level; +cat("Alpha is ",alpha) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.2.a/Ex9_2a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.2.a/Ex9_2a.R new file mode 100644 index 00000000..d860d3c4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.2.a/Ex9_2a.R @@ -0,0 +1,9 @@ +A<-c(46, 53, 29, 61, 36, 39, 47, 49, 52, 38, 55, 32, 57, 54, 44) +B<-c(12, 15, 7, 17, 10, 11, 11, 12, 14, 9, 16, 8, 18, 14, 12) +plot(A, B,xlab ="Relative humidity",ylab = "Moisture content",main = "Estimated regression line") +X = lm(B~A) +Y = X$coefficients[1] +X = X$coefficients[2] +p = seq(0,65,0.1) +q = p*X + Y +lines(p, q) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.3.a/Ex9_3a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.3.a/Ex9_3a.R new file mode 100644 index 00000000..9c151d84 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.3.a/Ex9_3a.R @@ -0,0 +1,32 @@ +x<-c(5, 6, 7, 10, 12, 15, 18, 20) +y<-c(7.4, 9.3, 10.6, 15.4, 18.1, 22.2, 24.1, 24.8) +plot(x,y); + +xbar = mean(x); +ybar= mean(y); +n= 8; +SxY = 0; +for (i in (1:n)){ + SxY = SxY + (x[i]*y[i]) - (xbar*ybar) +} + +Sxx = 0; +for (i in 1:n){ + Sxx= Sxx + (x[i]*x[i]) - (xbar*xbar); +} + +SYY = 0; +for (i in 1:n){ + SYY = SYY + (y[i]*y[i]) - (ybar*ybar); +} + +B = SxY/Sxx; +A = ybar - (B*xbar); +cat("A is",A); +cat("B is",B); +p= seq(0,20,0.1) +q= A + B*p; +lines(p,q) + +SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ; +cat("The SSR is",SSR) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.a/Ex9_4a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.a/Ex9_4a.R new file mode 100644 index 00000000..a5155c1e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.a/Ex9_4a.R @@ -0,0 +1,36 @@ +x<-c(45, 50, 55, 60, 65, 70, 75) +y<-c(24.2, 25.0, 23.3, 22.0, 21.5, 20.6, 19.8) +xbar = mean(x); +ybar= mean(y); +n= 7; +SxY = 0; +for (i in 1:n){ + SxY = SxY + (x[i]*y[i]) - (xbar*ybar) +} + +Sxx = 0; +for (i in 1:n){ + Sxx= Sxx + (x[i]*x[i]) - (xbar*xbar); +} +SYY = 0; +for (i in 1:n){ + SYY = SYY + (y[i]*y[i]) - (ybar*ybar); +} +B = SxY/Sxx; +A = ybar - (B*xbar); +cat("A is",A); +cat("B is",B); + +SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ; +cat("The SSR is",SSR) + +ts = sqrt(((n-2)*Sxx)/SSR)*abs(B); +cat("the test statistic is",ts); +tvalue= qt(0.995,5); +cat("tvalue is",tvalue); + +if(tvalue < ts){ + cat("Hypothesis beta= 0 is rejected at 1% level of significance") +} else{ + cat("Hypothesis beta= 0 is accepted at 1% level of significance") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.b/Ex9_4b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.b/Ex9_4b.R new file mode 100644 index 00000000..4324f3c4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.b/Ex9_4b.R @@ -0,0 +1,33 @@ +x<-c(45, 50, 55, 60, 65, 70, 75) +y<-c(24.2, 25.0, 23.3, 22.0, 21.5, 20.6, 19.8) +xbar = mean(x); +ybar= mean(y); +n= 7; +SxY = 0; +for (i in 1:n){ + SxY = SxY + (x[i]*y[i]) - (xbar*ybar) +} + +Sxx = 0; +for (i in 1:n){ + Sxx= Sxx + (x[i]*x[i]) - (xbar*xbar); +} +SYY = 0; +for (i in 1:n){ + SYY = SYY + (y[i]*y[i]) - (ybar*ybar); +} +B = SxY/Sxx; +A = ybar - (B*xbar); +cat("A is",A); +cat("B is",B); + +SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ; +cat("The SSR is",SSR) + +tvalue= qt(0.975, 5); +cat("tvalue is",tvalue); + +k = sqrt(SSR/((n-2)*Sxx))*tvalue; +int1 = B + k; +int2= B-k; +cat("The 95% confidence interval is ",int2, "to ", int1) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.c/Ex9_4c.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.c/Ex9_4c.R new file mode 100644 index 00000000..28951a84 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.c/Ex9_4c.R @@ -0,0 +1,38 @@ +x<-c(60, 62, 64, 65, 66, 67, 68, 70, 72, 74) +y<-c(63.6, 65.2, 66, 65.5, 66.9, 67.1, 67.4, 68.3, 70.1, 70) +plot(x,y,xlab ="Father's Height",ylab = "Son's Height") +xbar = mean(x) +ybar= mean(y) +n= 10; +SxY = 0 +for (i in 1:n){ + SxY = SxY + (x[i]*y[i]) - (xbar*ybar); +} + +Sxx = 0; +for (i in 1:n){ + Sxx= Sxx + (x[i]*x[i]) - (xbar*xbar); +} + +SYY = 0; +for (i in 1:n){ + SYY = SYY + (y[i]*y[i]) - (ybar*ybar); +} + +B = SxY/Sxx; +A = ybar - (B*xbar); +cat("A is",A); +cat("B is",B); +p= seq(60,72,0.1) +q= A + B*p; +lines(p,q) +SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ; +ts = sqrt(((n-2)*Sxx)/SSR)*(B-1) +ts +tvalue= qt(0.99,n-2) +tvalue +if(ts<(-1*tvalue)){ + cat("Null hypotheis is rejected at 1% level of significance") +} else{ + cat("Null hypotheis is accepted at 1% level of significance") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.d/Ex9_4d.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.d/Ex9_4d.R new file mode 100644 index 00000000..f6d3164e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.d/Ex9_4d.R @@ -0,0 +1,28 @@ +x<-c(121, 96, 85, 113, 102, 118, 90, 84, 107, 112, 95, 101) +y<-c(104, 91, 101, 110, 117, 108, 96, 102, 114, 96, 88, 106) + +plot(x,y,xlab = "Deaths in 1988",ylab = "Deaths in 1989"); + +xbar = mean(x); +ybar= mean(y); +n= 12; + +SxY = 0 +for (i in 1:n){ + SxY = SxY + (x[i]*y[i]) - (xbar*ybar); +} + +Sxx = 0; +for (i in 1:n){ + Sxx= Sxx + (x[i]*x[i]) - (xbar*xbar); +} + +SYY = 0; +for (i in 1:n){ + SYY = SYY + (y[i]*y[i]) - (ybar*ybar); +} + +B = SxY/Sxx; +A = ybar - (B*xbar); +cat("A is",A); +cat("B is",B) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.e/Ex9_4e.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.e/Ex9_4e.R new file mode 100644 index 00000000..d81fdbd4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.e/Ex9_4e.R @@ -0,0 +1,29 @@ +x<-c(60, 62, 64, 65, 66, 67, 68, 70, 72, 74) +y<-c(63.6, 65.2, 66, 65.5, 66.9, 67.1, 67.4, 68.3, 70.1, 70) +x0 = 68; +xbar = mean(x); +ybar= mean(y); +n= 10; +SxY = 0 +for (i in 1:n){ + SxY = SxY + (x[i]*y[i]) - (xbar*ybar); +} + +Sxx = 0; +for (i in 1:n){ + Sxx= Sxx + (x[i]*x[i]) - (xbar*xbar); +} + +SYY = 0; +for (i in 1:n){ + SYY = SYY + (y[i]*y[i]) - (ybar*ybar); +} +B = SxY/Sxx; +A = ybar - (B*xbar); +tvalue= qt(0.975, n-2); +SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ; +intvl = A + (B*x0); +change = sqrt((1/n)+(((x0-xbar)^2)/Sxx))* sqrt(SSR/(n-2))*tvalue; +intvl1 = intvl - change; +intvl2= intvl + change; +cat("The 95% confidence interval is ",intvl1, "to ", intvl2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.f/Ex9_4f.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.f/Ex9_4f.R new file mode 100644 index 00000000..9fd55e66 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.4.f/Ex9_4f.R @@ -0,0 +1,29 @@ +x<-c(60, 62, 64, 65, 66, 67, 68, 70, 72, 74) +y<-c(63.6, 65.2, 66, 65.5, 66.9, 67.1, 67.4, 68.3, 70.1, 70) +x0 = 68; +xbar = mean(x); +ybar= mean(y); +n= 10; +SxY = 0 +for (i in 1:n){ + SxY = SxY + (x[i]*y[i]) - (xbar*ybar); +} + +Sxx = 0; +for (i in 1:n){ + Sxx= Sxx + (x[i]*x[i]) - (xbar*xbar); +} + +SYY = 0; +for (i in 1:n){ + SYY = SYY + (y[i]*y[i]) - (ybar*ybar); +} +B = SxY/Sxx; +A = ybar - (B*xbar); +tvalue= qt(0.975, n-2); +SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ; +intvl = A + (B*x0); +change = sqrt(((n+1)/n)+(((x0-xbar)^2)/Sxx))* sqrt(SSR/(n-2))*tvalue; +intvl1 = intvl - change; +intvl2= intvl + change; +cat("The 95% confidence interval is ",intvl1, "to ", intvl2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.5.a/Ex9_5a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.5.a/Ex9_5a.R new file mode 100644 index 00000000..b2129b46 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.5.a/Ex9_5a.R @@ -0,0 +1,28 @@ +x<-c(60, 62, 64, 65, 66, 67, 68, 70, 72, 74) +y<-c(63.6, 65.2, 66, 65.5, 66.9, 67.1, 67.4, 68.3, 70.1, 70) + +xbar = mean(x); +ybar= mean(y); +n= 10; + +SxY = 0 +for (i in 1:n){ + SxY = SxY + (x[i]*y[i]) - (xbar*ybar); +} + +Sxx = 0; +for (i in 1:n){ + Sxx= Sxx + (x[i]*x[i]) - (xbar*xbar); +} + +SYY = 0; +for (i in 1:n){ + SYY = SYY + (y[i]*y[i]) - (ybar*ybar); +} + +B = SxY/Sxx; +A = ybar - (B*xbar); + +SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ; +R2 = 1 - (SSR/SYY); +cat("The coefficient of determination is",R2) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.7.a/Ex9_7a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.7.a/Ex9_7a.R new file mode 100644 index 00000000..716cf140 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.7.a/Ex9_7a.R @@ -0,0 +1,37 @@ +x<-c(5, 10, 20, 30, 40, 50, 60, 80) +yold<-c(0.061, 0.113, 0.192, 0.259, 0.339, 0.401, 0.461, 0.551) +plot(x, yold); +y = -1*log(1-yold); +plot(x, y); + + +xbar = mean(x); +ybar= mean(y); +n= 8; + +SxY = 0 +for (i in 1:n){ + SxY = SxY + (x[i]*y[i]) - (xbar*ybar); +} + +Sxx = 0; +for (i in 1:n){ + Sxx= Sxx + (x[i]*x[i]) - (xbar*xbar); +} + +SYY = 0; +for (i in 1:n){ + SYY = SYY + (y[i]*y[i]) - (ybar*ybar); +} + +B = SxY/Sxx; +A = ybar - (B*xbar); +SSR = ((Sxx*SYY)- (SxY*SxY))/Sxx ; +chat = exp(-1*A); +dhat = 1 - exp(-1*B); +phat = 1 - chat*(1-dhat)^x +pres = yold - phat +cat("chat is",chat); +cat("dhat is",dhat); +cat("phat is",phat); +cat("p - phat, i.e. the residuals are",pres) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.8.b/Ex9_8b.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.8.b/Ex9_8b.R new file mode 100644 index 00000000..520d6de0 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.8.b/Ex9_8b.R @@ -0,0 +1,29 @@ +x<-c(0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10) +y<-c(15, 15.1, 16.5, 19.9, 27.7, 29.7, 26.7, 35.9, 42, 49.4) +w<-c() +for (i in 1:10){ + w[i] = 1/x[i] +} +n = 10; +p = matrix(0,2,2) +q = matrix(0,2,1) +p[1, 1] = sum(w); +p[1,2] = n; +p[2,1] = n; +p[2,2] = sum(x); +new<-c() +for (i in 1:10){ + new[i] = w[i]*y[i] +} + +q[1,1]= 1*sum(new); +q[2,1] = 1*sum(y); +sol = solve(p,q); +A = sol[1,1]; +B = sol[2,1]; +cat("A is",A); +cat("B is",B); +plot(x,y) +l = seq(0,10,0.1) +k = A + B*l +lines(l,k) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.9.a/Ex9_9a.R b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.9.a/Ex9_9a.R new file mode 100644 index 00000000..615f8574 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/CH9/EX9.9.a/Ex9_9a.R @@ -0,0 +1,27 @@ +x<-seq(1,10,1); +y<-c(20.6, 30.8, 55, 71.4, 97.3, 131.8, 156.3, 197.3, 238.7, 291.7) +plot(x, y,xlab = "X",ylab = "Y"); +n = length(x) +xsquared = x^2; +xcube = x^3; +xfour = x^4; +xy = x*y; +x2y = xy*x; +p= matrix(0,3,3); +q = matrix(0,3,1); +p[1,1] = n; +p[1,2] = sum(x); +p[1,3]=sum(xsquared); +p[2,1] = sum(x); +p[2,2] = sum(xsquared); +p[2,3]=sum(xcube); +p[3,1] = sum(xsquared); +p[3,2] = sum(xcube); +p[3,3]=sum(xfour); +q[1,1]= 1*sum(y); +q[2,1] = 1*sum(xy); +q[3,1] = 1*sum(x2y); +B= solve(p, q); +cat("B0 is",B[1,1]); +cat("B1 is",B[2,1]); +cat("B2 is",B[3,1]) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/README.txt b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/README.txt new file mode 100644 index 00000000..c59f5142 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_For_Engineers_And_Scientists_by_Sheldon_M._Ross/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Bhushan Manjarekar +Course: Be +Branch: Electronics Engineering +College/Institute/Organization: Mumbai University + +About The Book + +Book: Introduction To Probability And Statistics For Engineers And Scientists +Author: Sheldon M. Ross +Publisher: Elsevier Academic Press, Usa +Year Of Publication: 2004 +ISBN: 0-12-598057-4 +Edition: 3 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.10/Ex1_10.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.10/Ex1_10.R new file mode 100644 index 00000000..0c454823 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.10/Ex1_10.R @@ -0,0 +1,4 @@ +GPAs<-c(2.8,3.0,3.0,3.3,2.4,3.4,3.0,0.21) +stripchart(GPAs,method = "stack") +summary(GPAs) +#summary function is used to find the outlier \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.11/Ex1_11.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.11/Ex1_11.R new file mode 100644 index 00000000..9e38db28 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.11/Ex1_11.R @@ -0,0 +1,5 @@ +visits <- c(6,4,6,5,3,7,6,5,5,5,1,4,6,5,7,5,6,3,7,5,6,8,4,6,5) +h<-hist(visits, plot=F) +h$counts <- h$counts / sum(h$counts) +plot(h, freq=TRUE, ylab="Relative Frequency") + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.3/Ex1_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.3/Ex1_3.R new file mode 100644 index 00000000..c41ef5d9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.3/Ex1_3.R @@ -0,0 +1,11 @@ +rating<-c("A","B","C","D") +frequency<-c(35,260,93,12) +total<-sum(frequency) +relative_frequency_percent<-c(frequency/total)*100 +label<-paste(rating,relative_frequency_percent) +label<-paste(label,"%",sep=" ") +par(mfrow=c(1,2)) +pie(relative_frequency_percent,labels = label,clockwise = TRUE) +DF<-data.frame(rating,frequency) +barplot(frequency, ylab="frequency",xlab="rating",names.arg = c("A","B","C","D")) +#The answer may slightly vary due to rounding off values \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.4/Ex1_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.4/Ex1_4.R new file mode 100644 index 00000000..62932b22 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.4/Ex1_4.R @@ -0,0 +1,4 @@ +color<-c("Brown","Green","Brown","Blue","Red","Red","Green","Brown","Yellow","Orange","Green","Blue","Brown","Blue","Blue","Brown","Orange","Blue","Brown","Orange","Yellow") +color.frequency<-table(color) +barplot(color.frequency[order(color.frequency,decreasing = T)],ylab = "frequency",xlab = "color" ) +#please zoom the plot to view the plot clearly diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.5/Ex1_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.5/Ex1_5.R new file mode 100644 index 00000000..e23600e9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.5/Ex1_5.R @@ -0,0 +1,7 @@ +category<-c("Millitary personnel","Operation and maintenance","Procurement","Research and development","Military construction","Other") +amount<-c(127.5,188.1,82.3,65.7,5.3,5.5) +label<-paste(category,amount) +label<-paste(label,"%",sep=" ") +par(mfrow=c(1,2)) +pie(amount,labels = label,clockwise = TRUE) +barplot(amount, ylab="amount(in Billions)",xlab="category",ylim=c(0,200),names.arg = c("Millitary personnel","Operation and maintenance","Procurement","Research and development","Military construction","Other")) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.6/Ex1_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.6/Ex1_6.R new file mode 100644 index 00000000..5f04c7a4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.6/Ex1_6.R @@ -0,0 +1,6 @@ +years <- c(2010,2020,2030,2040,2050) +equal_85_and_over <- c(6.1,7.3,9.6,15.4,20.9) +par(mfrow=c(1,2)) +plot(years,equal_85_and_over,type = "b") +plot(years,equal_85_and_over,ylim=c(0,100),type = "b") + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.7/Ex1_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.7/Ex1_7.R new file mode 100644 index 00000000..db5d4e9f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.7/Ex1_7.R @@ -0,0 +1,2 @@ +prices<-c(90,65,75,70,70,68,70,70,60,68,70,74,65,75,70,40,70,95,65) +stem(prices, scale = 2) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.8/Ex1_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.8/Ex1_8.R new file mode 100644 index 00000000..3e971a3d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH1/EX1.8/Ex1_8.R @@ -0,0 +1,2 @@ +weights<-c(7.2,7.8,6.8,6.2,8.2,8.0,8.2,5.6,8.6,7.1,8.2,7.7,7.5,7.2,7.7,5.8,6.8,6.8,8.5,7.5,6.1,7.9,9.4,9.0,7.8,8.5,9.0,7.7,6.7,7.7) +stem(weights) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.11/Ex10_11.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.11/Ex10_11.R new file mode 100644 index 00000000..390faeb7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.11/Ex10_11.R @@ -0,0 +1,13 @@ +sigma_square <- 100 +n <- 10 +xbar <- 312 +s_square <- 195 +x_square <- ((n -1) * s_square)/sigma_square +alpha <- 0.05 +df <- n -1 +x_square_0.05 <- qchisq(1 - alpha, df) +if(x_square > x_square_0.05){ + print("reject the null hypothesis and the range of concrete strength measurements exceeds the manufacturer's claim") +}else{ + print("accept the null hypothesis") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.12/Ex10_12.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.12/Ex10_12.R new file mode 100644 index 00000000..66ccc4dc --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.12/Ex10_12.R @@ -0,0 +1,15 @@ +sigma_square <- 4 +n <- 3 +df <- n - 1 +measurements <- c(4.1,5.2,10.2) +s_square <- var(measurements) +s_square +x_square <- ((n - 1) * s_square) / sigma_square +cat("p-value is greater than 0.10 so accept the null hypothesis") +alpha <- 0.10 #at 90% confidence interval alpha = 0.10 +x_square_0.95 <- qchisq(alpha/2,df) +x_square_0.05 <- qchisq(1-alpha/2,df) +x_square_0.05 +lower_value <- round((n - 1) * s_square/x_square_0.05,2) +upper_value <- round((n - 1) * s_square/x_square_0.95,2) +cat("the interval is from",lower_value,"to",upper_value) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.13/Ex10_13.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.13/Ex10_13.R new file mode 100644 index 00000000..26daae21 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.13/Ex10_13.R @@ -0,0 +1,6 @@ +f1 <- round(qf(0.95,6,9),2) #1 - 0.05 = 0.95 +f2 <- round(qf(0.95,5,10),2) +f3 <- round(qf(0.99,6,9),2) #1 - 0.01 = 0.99 +cat("value of f in case 1 is",f1) +cat("value of f in case 2 is",f2) +cat("value of f in case 3 is",f3) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.14/Ex10_14.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.14/Ex10_14.R new file mode 100644 index 00000000..05fd3c72 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.14/Ex10_14.R @@ -0,0 +1,16 @@ +variance1 <- 7.14; +variance2 <- 3.21; +n1 <- 10; +n2 <- 8; +df1 <- n1 - 1 +df2 <- n2 - 1 +alpha <- 0.05 +rejection_region <- round(qf(1 - (alpha / 2), df1, df2),2) +rejection_region +test_statistics <- variance1/variance2; +cat("the calculated value of test statistics is",test_statistics) +if(test_statistics > rejection_region){ + print("reject the null hypothesis") +}else{ + print("Cannot reject null hypothesis and there is sufficient evidence to indicate a difference in the population variance") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.15/Ex10_15.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.15/Ex10_15.R new file mode 100644 index 00000000..a6d81e1e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.15/Ex10_15.R @@ -0,0 +1,12 @@ +variance1 <- 7.14; +variance2 <- 3.21; +n1 <- 10; +n2 <- 8; +df1 <- n1 - 1 +df2 <- n2 - 1 +alpha <- 0.05 +f97 <- round(qf( 0.95, df1=9, df2=7),2) +f79 <- round(qf(.95, df1=7, df2=9),2) +lower_value <- round((variance1 / variance2) * (1 / f97),2) +upper_value <- round((variance1 / variance2) * (f79),2) +cat("the interval is between ",lower_value,"and",upper_value) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.16/Ex10_16.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.16/Ex10_16.R new file mode 100644 index 00000000..e3dabb34 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.16/Ex10_16.R @@ -0,0 +1,14 @@ +x1bar <- 302 +x2bar <- 3.0 +s1_square <- 1.04 +s2_square <- 0.51 +n1 <- n2 <- 25 +f <- (s1_square / s2_square) +df1 <- df2 <- n1 - 1 +f_0.050 <- qf(1 - 0.050,df1,df2) +f_0.025 <- qf(1 - 0.025,df1,df2) +if(f > f_0.050 & f < f_0.025){ + print("p-value lies between 0.025 and 0.05 and hence at 5% level null hypothesis is rejected") +}else{ + print("null hypothesis is accepted") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.2/Ex10_2.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.2/Ex10_2.R new file mode 100644 index 00000000..e48cbded --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.2/Ex10_2.R @@ -0,0 +1,3 @@ +sample_size <- 10; +t <- round((qt(p = 0.01, df = sample_size - 1 ,lower.tail = T)),3) +cat("value of t is",t) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.3/Ex10_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.3/Ex10_3.R new file mode 100644 index 00000000..ceb44b33 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.3/Ex10_3.R @@ -0,0 +1,3 @@ +weights <- c(0.46,0.61,0.52,0.48,0.57,0.54) +t.test(weights, mu = 0.5, alternative = "greater", conf.level = 0.95) +cat("the range of possible values of mean is both greater and smaller than 0.5 so there is no sufficient evidence and our test fails.") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.4/Ex10_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.4/Ex10_4.R new file mode 100644 index 00000000..614b7e77 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.4/Ex10_4.R @@ -0,0 +1,9 @@ +data <- c(310,311,412,368,447,376,303,410,365,350) +mean <- mean(data) +s <- sd(data) +mu0 <- 400 +t.test(data,mu = mu0) +p.value <- t.test(data,mu = mu0)$p.value +p.value +cat(p.value < 0.05) +cat("Since p-value is less than 0.05 so null hypothesis is rejected and there is sufficient evidence to indiacte the coverage differs from 400") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.5/Ex10_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.5/Ex10_5.R new file mode 100644 index 00000000..8f2eee2c --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.5/Ex10_5.R @@ -0,0 +1,24 @@ +online <- c(32,37,35,28,41,44,35,31,34) +classroom <- c(35,31,29,25,34,40,27,32,31) +alpha <- 0.05 +df <- length(online) + length(classroom) - 2 +stem(online) +stem(classroom) +cat("stem and leaf plot of the data show at least a mounding pattern so the assumption of normality is not unreasonable.") +critical_value <- round((qt(p = 1 -alpha,df,lower.tail = T)),3) +cat("critical value is",critical_value) +t.test(online,classroom,alternative = "greater") +t <- t.test(online,classroom,alternative = "greater")$statistic +if(t > critical_value){ + print("reject the null hypothesis") +}else{ +print("cannot reject the null hypothesis so there is insufficient evidence to indicate that the online course grades are higher than the conventional course grades at the 5 % level of significance.") + } + + + + + + + + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.6/Ex10_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.6/Ex10_6.R new file mode 100644 index 00000000..a5dad8a5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.6/Ex10_6.R @@ -0,0 +1,5 @@ +#values are referred to example 10.5 in textbook +online <-c (32,37,35,28,41,44,35,31,34) +classroom <-c (35,31,29,25,34,40,27,32,31) +p_value <- t.test(online,classroom,alternative = "greater")$p.value +cat("p-value =",p_value,"is geater than 0.05,most researchers would report the result as not significant.") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.7/Ex10_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.7/Ex10_7.R new file mode 100644 index 00000000..6898a4b1 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.7/Ex10_7.R @@ -0,0 +1,7 @@ +online <- c(32,37,35,28,41,44,35,31,34) +classroom <- c(35,31,29,25,34,40,27,32,31) +t.test(online,classroom,alternative = "greater") +lower <- t.test(online,classroom,alternative = "greater")$conf.int[1] +cat("lower confidence bound is",lower) +cat("since the difference of equal means is included in the confidence interval so it is possible that two means are equal so there is insufficient evidence to indicate that the online average is higher than the classroom average.") +#the results may slightly vary due to rounding off values in textbook. diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.8/Ex10_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.8/Ex10_8.R new file mode 100644 index 00000000..e486e03c --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.8/Ex10_8.R @@ -0,0 +1,11 @@ +tire_A <- c(10.6,9.8,12.3,9.7,8.8) +tire_B <- c(10.2,9.4,11.8,9.1,8.3) +alpha <- 0.05 +critical_value <- qt( 1 - alpha/2,df = 4) +k <- t.test(tire_A,tire_B, paired = TRUE, alternative = "two.sided") +test_statistics <- k[1] +cat(test_statistics > critical_value) +cat("test statistics from t.test() is larger than critical value hence there is difference in the mean wear for tire type A and B") + + + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.9/Ex10_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.9/Ex10_9.R new file mode 100644 index 00000000..30e75fc5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH10/EX10.9/Ex10_9.R @@ -0,0 +1,6 @@ +tire_A <- c(10.6,9.8,12.3,9.7,8.8) +tire_B <- c(10.2,9.4,11.8,9.1,8.3) +t.test(tire_A,tire_B, paired = TRUE, alternative = "two.sided") + + + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.10/Ex11_10.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.10/Ex11_10.R new file mode 100644 index 00000000..326ddbc8 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.10/Ex11_10.R @@ -0,0 +1,42 @@ +A <- c(27,68,308) +B <- c(24,76,326) +C <- c(31,65,312) +D <- c(23,67,300) +t1 <- sum(A) +t2 <- sum(B) +t3 <- sum(C) +t4 <- sum(D) +b1 <- 105 +b2 <- 276 +b3 <- 1246 +k <- 4; +n1 <- n2 <- n3 <- n4 <- 3 +n <- 12; +b <- 3 + +sum_square_X <- sum(A) + sum(B) + sum(C) + sum(D) +sum_square_X +cm <- (sum_square_X * sum_square_X)/n +cm + +l <- c(A,B,C,D) +l +sum_of_all <-sum( c(l * l)) +sum_of_all +total_ss <- sum_of_all - cm +total_ss +sst <- (( t1 * t1 + t2 * t2 + t3 * t3 + t4 * t4)/ n1)- cm +sst +ssb <- ((b1 * b1 + b2 * b2 + b3 * b3) / k ) - cm +ssb +sse <- total_ss - sst - ssb +sse +t2_bar <- t2 / n2 +t3_bar <- t3 / n3 +mse <- sse / ((b - 1) * (k - 1)) +mse +alpha <- 0.05 +df <- (b - 1) * (k - 1) +lower_range <- round((t2_bar - t3_bar) - qt(1 - alpha/2,df) * sqrt(mse * (2 / b)),2) +upper_range <-round((t2_bar - t3_bar) + qt(1 - alpha/2,df) * sqrt(mse * (2 / b)),2) +cat("the difference between two average costs is estimated as betwen",lower_range,"and",upper_range,".") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.12/Ex11_12.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.12/Ex11_12.R new file mode 100644 index 00000000..6b36da0a --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.12/Ex11_12.R @@ -0,0 +1,6 @@ +observation <- c(571,480,470,610,474,430,625,540,450,480,625,630,516,600,680,465,581,661) +supervisor <- c(1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2) +shift <- c("day","swing","night","day","swing","night","day","swing","night","day","swing","night","day","swing","night","day","swing","night") +model <- aov(observation ~ supervisor * shift) +model +summary(model) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.4/Ex11_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.4/Ex11_4.R new file mode 100644 index 00000000..0521c4af --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.4/Ex11_4.R @@ -0,0 +1,32 @@ +no_breakfast<-c(8,7,9,13,10) +light_breakfast<-c(14,16,12,17,11) +full_breakfast<-c(10,12,16,15,12) + +k <- 3; +n1 <- n2 <- n3 <- 5 +n <- 15; + + +sum_square_X <- sum(no_breakfast) + sum(light_breakfast) + sum(full_breakfast) +cm <- (sum_square_X * sum_square_X)/n +cm +x <- sum(no_breakfast) +y <- sum(light_breakfast) +z <- sum(full_breakfast) +total_ss <- (8*8 + 7*7 + 9*9 + 13*13 + 10*10 + 14*14 + 16*16 + 12*12 + 17*17 + 11*11 + 10*10 + 12*12 + 16*16 + 15*15 + 12*12 ) - cm +total_ss +degree_of_freedom <- n-1 +degree_of_freedom +sst <- ((x*x + y*y + z*z)/5) - cm +sst +df <- k - 1 +sse <- total_ss -sst +sse +deg_of_freedom <- n - k +deg_of_freedom + +combined<-data.frame(cbind(no_breakfast,light_breakfast,full_breakfast)) +stacked<-stack(combined) +stacked +Anova_Results<-aov(values ~ ind,data = stacked) +summary(Anova_Results) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.5/Ex11_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.5/Ex11_5.R new file mode 100644 index 00000000..5ea3cecc --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.5/Ex11_5.R @@ -0,0 +1,44 @@ +no_breakfast<-c(8,7,9,13,10) +light_breakfast<-c(14,16,12,17,11) +full_breakfast<-c(10,12,16,15,12) + +k <- 3; +n1 <- n2 <- n3 <- 5 +n <- 15; + + +sum_square_X <- sum(no_breakfast) + sum(light_breakfast) + sum(full_breakfast) +cm <- (sum_square_X * sum_square_X)/n +cm +x <- sum(no_breakfast) +y <- sum(light_breakfast) +z <- sum(full_breakfast) +total_ss <- (8*8 + 7*7 + 9*9 + 13*13 + 10*10 + 14*14 + 16*16 + 12*12 + 17*17 + 11*11 + 10*10 + 12*12 + 16*16 + 15*15 + 12*12 ) - cm +total_ss +degree_of_freedom <- n-1 +degree_of_freedom +sst <- ((x*x + y*y + z*z)/5) - cm +sst +df1 <- k - 1 +df1 +sse <- total_ss -sst +sse +df2 <- n - k +df2 + +combined<-data.frame(cbind(no_breakfast,light_breakfast,full_breakfast)) +stacked<-stack(combined) +stacked +Anova_Results<-aov(values ~ ind,data = stacked) +summary(Anova_Results) +mse <- sse / (n - k) +mse +mst <- sst / (k - 1) +mst +f <- mst / mse +f +alpha <- 0.05 +f_0.05 <- qf(1 - alpha, df1, df2) +if(f > f_0.05){ + print("reject h0, there is sufficient evidence to indicate that at least one of the three average attention spans is different from at least one of the others") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.6/Ex11_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.6/Ex11_6.R new file mode 100644 index 00000000..745f7df9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.6/Ex11_6.R @@ -0,0 +1,33 @@ +#values are referred to example 11_4in the textbook +no_breakfast<-c(8,7,9,13,10) +light_breakfast<-c(14,16,12,17,11) +full_breakfast<-c(10,12,16,15,12) +x1_bar <- mean(no_breakfast) +x2_bar <- mean(light_breakfast) +x3_bar <- mean(full_breakfast) + +k <- 3; +n1 <- n2 <- n3 <- 5 +n <- 15; + + +total_ss <- (8*8 + 7*7 + 9*9 + 13*13 + 10*10 + 14*14 + 16*16 + 12*12 + 17*17 + 11*11 + 10*10 + 12*12 + 16*16 + 15*15 + 12*12 ) - cm +total_ss +degree_of_freedom <- n-k +degree_of_freedom +sst <- ((x*x + y*y + z*z)/5) - cm +sst +sse <- total_ss -sst +sse +mse <- sse/(n-k) +s2 <- mse +s <- sqrt(s2) +alpha <- 0.05/2; +t_value <- qt(1-alpha,degree_of_freedom) +t_value +left1 <- round(x1_bar - (t_value * (s/sqrt(n1))),2) +right1 <- round(x1_bar + (t_value * (s/sqrt(n1))),2) +cat("confidence interval for no breakfast are between",left1,"and",right1,"minutes") +left2 <- round((x2_bar - x3_bar) - t_value*(sqrt(s2*((1/n2) + (1/n3)))),2) +right2 <- round((x2_bar - x3_bar) + t_value*(sqrt(s2*((1/n2) + (1/n3)))),2) +cat("confidence interval for the difference in the average attention spans for light versus full breakfast eaters are between",left2,"and",right2,"minutes") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.7/Ex11_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.7/Ex11_7.R new file mode 100644 index 00000000..01394f40 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.7/Ex11_7.R @@ -0,0 +1,34 @@ +no_breakfast<-c(8,7,9,13,10) +light_breakfast<-c(14,16,12,17,11) +full_breakfast<-c(10,12,16,15,12) + +k <- 3; +n1 <- n2 <- n3 <- 5 +n <- 15; + +sum_square_X <- sum(no_breakfast) + sum(light_breakfast) + sum(full_breakfast) +cm <- (sum_square_X * sum_square_X)/n +cm +x <- sum(no_breakfast) +y <- sum(light_breakfast) +z <- sum(full_breakfast) +total_ss <- (8*8 + 7*7 + 9*9 + 13*13 + 10*10 + 14*14 + 16*16 + 12*12 + 17*17 + 11*11 + 10*10 + 12*12 + 16*16 + 15*15 + 12*12 ) - cm +total_ss +sst <- ((x*x + y*y + z*z)/5) - cm +sst +sse <- total_ss -sst +sse +df <- n - k +df +mse <- sse / (n - k) +mse +mst <- sst / (k - 1) +mst +f <- mst / mse +f +s <- sqrt(mse) +s +alpha <- 0.05 +w <- (qtukey(1 - alpha, k, df)) * (s / sqrt(n1)) +w +cat("the difference between no break fast and light breakfas exceeds w = ",w," so no breakfast and light breakfast are declared significantly different ") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.8/Ex11_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.8/Ex11_8.R new file mode 100644 index 00000000..435c0acc --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.8/Ex11_8.R @@ -0,0 +1,14 @@ +b <- 3 +k <- 4 +low <- c(27,24,31,23) +middle <- c(68,76,65,67) +high <- c(308,326,312,300) +df <- data.frame(low, middle, high) +data <-c((as.matrix(df))) +data +f <- c("a","b","c","d") +company <- gl(k,1, b*k,factor(f)) +usage <- gl(b, k, k * b) +model <- aov(data ~ usage + company) +model +summary(model) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.9/Ex11_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.9/Ex11_9.R new file mode 100644 index 00000000..9f398c17 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH11/EX11.9/Ex11_9.R @@ -0,0 +1,18 @@ +b <- 3 +k <- 4 +low <- c(27,24,31,23) +middle <- c(68,76,65,67) +high <- c(308,326,312,300) +df <- data.frame(low, middle, high) +data <-c((as.matrix(df))) +data +f <- c("a","b","c","d") +company <- gl(k,1, b*k,factor(f)) +usage <- gl(b, k, k * b) +model <- aov(data ~ usage + company) +model +summary(model) +p.value <- summary(model)[[1]][["Pr(>F)"]][[2]] +p.value +cat("since the p-value from anova test p.value=",p.value,"is too large to allow rejection of null hypothesis.") +cat("hence there is insufficient evidence to indicate a difference in the averge monthly costs for the four companies.") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.1/Ex12_1.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.1/Ex12_1.R new file mode 100644 index 00000000..553cabed --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.1/Ex12_1.R @@ -0,0 +1,6 @@ +x <- c(39,43,21,64,57,47,28,75,34,52) +y <- c(65,78,52,82,92,89,73,98,56,75) +df <- data.frame(x, y) +lm(y ~ x, df) +cat("least square regression line is: ycap = 40.7842 + 0.7656x") + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.2/Ex12_2.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.2/Ex12_2.R new file mode 100644 index 00000000..c770ef05 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.2/Ex12_2.R @@ -0,0 +1,33 @@ +x <- c(39,43,21,64,57,47,28,75,34,52) +y <- c(65,78,52,82,92,89,73,98,56,75) +x_square <- c(x**2) +y_square <- c(y**2) +xy <- c(x*y) +n <- 10; +sum_x <- sum(x) +sum_y <- sum(y) +sum_x_square <- sum(x_square) +sum_y_square <- sum(y_square) +sum_xy <- sum(xy) +s_xx <- sum_x_square - (sum_x * sum_x)/n +s_yy <- sum_y_square - (sum_y * sum_y)/n +s_xy <- sum_xy - (sum_x *sum_y)/n +y_bar <- sum(y)/n +x_bar <- sum(x)/n +b <- (s_xy/s_xx) +a <- y_bar - b*x_bar +a +b +total_ss <- s_yy +ssr <- (s_xy * s_xy)/s_xx +sse <- total_ss - ssr +mse <- sse / (n - 2) +mse +sse +test_statistics <- round(((b - 0)/sqrt(mse / s_xx)),2) +cat("test statistics is",test_statistics) +alpha <- 0.05 # 5% significance level +range <- round(qt(1 - alpha/2, df = 8),3) +range +cat("rejection region is greater then",range,"or","less than",-range) +cat("there is significant linear relationship") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.3/Ex12_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.3/Ex12_3.R new file mode 100644 index 00000000..8bc997d4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.3/Ex12_3.R @@ -0,0 +1,9 @@ +x <- c(39,43,21,64,57,47,28,75,34,52) +y <- c(65,78,52,82,92,89,73,98,56,75) +df <- data.frame(x, y) +cat("interval is from",left,"to",right) +m <- lm(y ~ x, df) +m +confint(m,level = 0.95) +print(paste0("The 95% confidence interval is ",sprintf("[ %4.3f, %4.3f ]", confint(m,level = 0.95)[2],confint(m,level = 0.95)[4]))); +#the answers may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.4/Ex12_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.4/Ex12_4.R new file mode 100644 index 00000000..ebcbdbfe --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.4/Ex12_4.R @@ -0,0 +1,13 @@ +x <- c(39,43,21,64,57,47,28,75,34,52) +y <- c(65,78,52,82,92,89,73,98,56,75) +x0 <- 50 +df <- data.frame(x, y) +lmresult <- lm(y ~ x, data = df) +lmresult +df2 <- data.frame(x = 50) +df2 +ycap <- predict(lmresult, df2, interval = "confidence")[1] +ycap +lower <- predict(lmresult, df2, interval = "confidence")[2] +upper <- predict(lmresult, df2, interval = "confidence")[3] +cat("the average calculus grade for students who score 50 on the achievement test will lie between",lower,"and",upper) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.5/Ex12_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.5/Ex12_5.R new file mode 100644 index 00000000..7de606ff --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.5/Ex12_5.R @@ -0,0 +1,15 @@ +x <- c(39,43,21,64,57,47,28,75,34,52) +y <- c(65,78,52,82,92,89,73,98,56,75) +x0 <- 50 +df <- data.frame(x, y) +lmresult <- lm(y ~ x, data = df) +lmresult +df2 <- data.frame(x = 50) +df2 +ycap <- predict(lmresult, df2, interval = "prediction")[1] +ycap +lower <- predict(lmresult, df2, interval = "prediction")[2] +upper <- predict(lmresult, df2, interval = "prediction")[3] +cat("the 95% confidence interval is from",lower,"to",upper) + + \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.6/Ex12_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.6/Ex12_6.R new file mode 100644 index 00000000..bc5d6d55 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.6/Ex12_6.R @@ -0,0 +1,15 @@ +x <- c(39,43,21,64,57,47,28,75,34,52) +y <- c(65,78,52,82,92,89,73,98,56,75) +x0 <- 0 +df <- data.frame(x, y) +lmresult <- lm(y ~ x, data = df) +lmresult +df2 <- data.frame(x = 0) +df2 +ycap <- predict(lmresult, df2, interval = "confidence")[1] +ycap +lower <- predict(lmresult, df2, interval = "confidence")[2] +upper <- predict(lmresult, df2, interval = "confidence")[3] +cat("the 95% confidence interval is from",lower,"to",upper) +cat(", this interval does not contain the value alpha = 0 hence y intercept cannot be 0.") +cat("data does not support the hypothesis of 0 intercept") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.7/Ex12_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.7/Ex12_7.R new file mode 100644 index 00000000..06303915 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.7/Ex12_7.R @@ -0,0 +1,4 @@ +x <- c(73,71,75,72,72,75,67,69,71,69) +y <- c(185,175,200,210,190,195,150,170,180,175) +r <- cor(x, y) +cat("correlation coefficient is",r) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.8/Ex12_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.8/Ex12_8.R new file mode 100644 index 00000000..e7c4b07e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH12/EX12.8/Ex12_8.R @@ -0,0 +1,6 @@ +#refer to example 12.7 for height and weight values +height <- c(73,71,75,72,72,75,67,69,71,69) +weight <- c(185,175,200,210,190,195,150,170,180,175) +cor.test(height, weight, method = "pearson", alternative = "two.sided") +print(cor.test(height, weight, method = "pearson", alternative = "two.sided")[3]) +cat("correlation is declared significant at 1% level") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.2/Ex13_2.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.2/Ex13_2.R new file mode 100644 index 00000000..829ca56d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.2/Ex13_2.R @@ -0,0 +1,10 @@ +y <- c(169.0,218.5,216.5,225.5,229.9,235.0,239.9,247.9,260.0,269.9,234.9,255.0,269.9,294.5,309.9) +x1 <- c(6,10,10,11,13,13,13,17,19,18,13,18,17,20,21) +x2 <- c(1,1,1,1,1,2,1,2,2,1,1,1,2,2,2) +x3 <- c(2,2,3,3,3,3,3,3,3,3,4,4,4,4,4) +x4 <- c(1,2,2,2,1.7,2.5,2,2.5,2,2,2,2,3,3,3) +df = data.frame(y, x1, x2, x3, x4) +df +model <- lm(y~x1+x2+x3+x4, data = df) +model +#The results may slightly vary due to rounding off values \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.3/Ex13_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.3/Ex13_3.R new file mode 100644 index 00000000..798eb4a7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.3/Ex13_3.R @@ -0,0 +1,4 @@ +y <- c(4.08,3.40,3.51,3.09,2.92,1.94,4.11,3.16,3.75,3.60) +x <- c(21.0,12.0,25.2,10.4,30.9,6.8,19.6,14.5,25.0,19.1) +plot(x,y) +cat("The relationship appears to be curvilinear and a quadratic model will provide more accurate estimations and predictions") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.4/Ex13_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.4/Ex13_4.R new file mode 100644 index 00000000..9bf319c0 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.4/Ex13_4.R @@ -0,0 +1,6 @@ +y <- c(4.08,3.40,3.51,3.09,2.92,1.94,4.11,3.16,3.75,3.60) +x <- c(21.0,12.0,25.2,10.4,30.9,6.8,19.6,14.5,25.0,19.1) +model <- lm(y ~ x + I(x^2)) +model +summary(model) +cat("quadratic model provide accurate prediction") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.6/Ex13_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.6/Ex13_6.R new file mode 100644 index 00000000..cec77c50 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.6/Ex13_6.R @@ -0,0 +1,16 @@ +salary <- c(60710,NA,63160,63210,64140,65760,65590,59510,60440,61340,61760,62750,63200,NA) +x1 <- c(1,2,3,3,4,5,5,1,2,3,3,4,5,5) +x2 <- c(1,1,1,1,1,1,1,0,0,0,0,0,0,0) +df <- data.frame(salary, x1, x2) +df +model <- lm(salary ~ x1 * x2, data = df) +summary(model) +model +model1 <- aov(model, data = df) +model1 +summary(model1) +par(mfrow=c(1,2)) +plot(model, pch=16, which=1) +plot(model, pch=16, which=2) +#the textbook's f-value from anova table is wrong and rest all of the values are correct + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.7/Ex13_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.7/Ex13_7.R new file mode 100644 index 00000000..91741564 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.7/Ex13_7.R @@ -0,0 +1,12 @@ +salary <- c(60710,NA,63160,63210,64140,65760,65590,59510,60440,61340,61760,62750,63200,NA) +x1 <- c(1,2,3,3,4,5,5,1,2,3,3,4,5,5) +x2 <- c(1,1,1,1,1,1,1,0,0,0,0,0,0,0) +df <- data.frame(salary, x1, x2) +df +model <- aov(salary ~ x1 * x2, data = df) +model +summary(model) +p_value <- summary(model)[[1]][["Pr(>F)"]][[3]] +p_value +cat("the p-value =",p_value,"is twice of what it would be for one- tailed test so null hypothesis is rejected ") +cat("So there is sufficient evidence to indicate that the annual rate of increase in men's faculty salaries exceeds the rate for women") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.8/Ex13_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.8/Ex13_8.R new file mode 100644 index 00000000..b31f0a1f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH13/EX13.8/Ex13_8.R @@ -0,0 +1,36 @@ +y <- c(169.0,218.5,216.5,225.5,229.9,235.0,239.9,247.9,260.0,269.9,234.9,255.0,269.9,294.5,309.9) +x1 <- c(6,10,10,11,13,13,13,17,19,18,13,18,17,20,21) +x2 <- c(1,1,1,1,1,2,1,2,2,1,1,1,2,2,2) +x3 <- c(2,2,3,3,3,3,3,3,3,3,4,4,4,4,4) +x4 <- c(1,2,2,2,1.7,2.5,2,2.5,2,2,2,2,3,3,3) +k <- 4 +r <- 1 +df = data.frame(y, x1, x2, x3, x4) +df +model <- lm(y~x1+x2+x3+x4, data = df) +model +summary(model) +aov(model) +summary(aov(model)) +sr <- (summary(aov(model))) +model1 <- lm(y ~ x1) +model1 +aov(model1) +s <- (summary(aov(model1))) +s +sse1 <- s[[1]][[2]][[2]] +sse2 <- sr[[1]][[2]][[5]] +sse2 +mse2 <- sr[[1]][[3]][[5]] +mse2 +f <- round(((sse1 - sse2) / ((k - r))/mse2),1) +cat("test statistics is",f) +alpha <- 0.05 +critical_value_f <- qf(1 - alpha, df1 = 3, df2 = 10) +critical_value_f +if(f > critical_value_f){ + print("reject the null hypothesis") +}else{ + print("cannot reject null hypothesis") +} +#The results may slightly vary due to rounding off values diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.1/Ex14_1.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.1/Ex14_1.R new file mode 100644 index 00000000..ee848cea --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.1/Ex14_1.R @@ -0,0 +1,9 @@ +df1 <- data.frame(green <- 20, red <- 39, blue <- 31) +chisq <- chisq.test(df1) +n <- 90 +p_value <- chisq$p.value +p_value +cat("since the p-value is less than 0.05 so the null hypothesis is rejected") +cat("So there is sufficient evidence to indicate that the rat has a preference for one of the three doors") + + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.2/Ex14_2.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.2/Ex14_2.R new file mode 100644 index 00000000..b894098d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.2/Ex14_2.R @@ -0,0 +1,24 @@ +o1 <- 89 +o2 <- 18 +o3 <- 12 +o4 <- 81 +e1 <- 82 +e2 <- 20 +e3 <- 8 +e4 <- 90 +p1 <- 0.41 +p2 <- 0.10 +p3 <- 0.04 +p4 <- 0.45 +k <- 4 +df <- k -1 +alpha <- 0.100 +x_square_observed <- ((o1 - e1) * (o1 - e1) / e1) + ((o2 - e2) * (o2 - e2) / e2) + ((o3 - e3) * (o3 - e3) / e3) + ((o4 - e4) * (o4 - e4) / e4) +x_square_observed +x_square_0.100 <-qchisq(1 - alpha, df) #x-square at alpha = 0.100 using chi- square +x_square_0.100 +if(x_square_observed < x_square_0.100){ + print("p-value is greater than 0.100, do not have sufficient evidence to reject null h0") + }else{ + print("reject the h0") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.4/Ex14_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.4/Ex14_4.R new file mode 100644 index 00000000..ae7f6a66 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.4/Ex14_4.R @@ -0,0 +1,10 @@ +shift1 <- c(15,21,45,13) +shift2 <- c(26,31,34,5) +shift3 <- c(33,17,49,20) +data <- data.frame(shift1, shift2, shift3) +data +chisq.test(data) +p_value <- chisq.test(data)$p.value +cat(p_value < 0.05) +cat("since p-value is less than 0.005 so null hypothesis can be rejected and there is sufficient evidene that the proportion of defect types vary shift to shift") +#the answers may slightly vary due to rounding off values \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.5/Ex14_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.5/Ex14_5.R new file mode 100644 index 00000000..0a216cc1 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.5/Ex14_5.R @@ -0,0 +1,7 @@ +survey <- matrix(c(24,9,13,289,100,565),ncol = 3, byrow = TRUE) +colnames(survey) <- c("No Vaccine","One Shot","Two Shots") +rownames(survey) <- c("Flu","No Flu") +survey <- as.table(survey) +survey +chisq.test(survey,correct = F) +cat("null hypothesis is rejected so there is sufficient evidence to indicate a relationship between treatment and influence of flu") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.7/Ex14_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.7/Ex14_7.R new file mode 100644 index 00000000..e64f5deb --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH14/EX14.7/Ex14_7.R @@ -0,0 +1,7 @@ +voter <- matrix(c(76,53,59,48,124,147,141,152),ncol = 4, byrow = TRUE) +colnames(voter) <- c("1","2","3","4") +rownames(voter) <- c("Favor A","Do Not Favor A") +voter <- as.table(voter) +voter +chisq.test(voter,correct = F) +cat("X-squared value is too large so null hypothesis is rejected") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.1/Ex15_1.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.1/Ex15_1.R new file mode 100644 index 00000000..a9c6e0c6 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.1/Ex15_1.R @@ -0,0 +1,15 @@ +species1 <- c(235,225,190,188); +species2 <- c(180,169,180,185,178,182); +n1 <-length(species1); +n2 <- length(species2); +data <- c(species1,species2); +rank1 <- rank(sort(data)) +t1 <- 7+8+9+10; +t1_ <- n1 * (n1 + n2 + 1) - t1 +t1_ #for n1=4 and n2=6, the critical value of T at alpha = 0.05 is 12 +if(t1_ <= 12){ + print("Reject the Null Hypothesis") +}else{ + print("Accept the Null Hypothesis") + } + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.10/Ex15_10.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.10/Ex15_10.R new file mode 100644 index 00000000..5cf0c7e9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.10/Ex15_10.R @@ -0,0 +1,9 @@ +xi <- c(7,4,2,6,1,3,8,5) +yi <- c(1,5,3,4,8,7,2,6) +di <- c(xi - yi) +n <- 8; +di_square <- c(di * di) +total = sum(di_square) +total +rs <- 1 - (6 * total)/((n) * (n * n - 1 )) +cat("rs is ",rs) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.11/Ex15_11.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.11/Ex15_11.R new file mode 100644 index 00000000..64447807 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.11/Ex15_11.R @@ -0,0 +1,12 @@ +xi <- c(7,4,2,6,1,3,8,5) +yi <- c(1,5,3,4,8,7,2,6) +alpha <- 0.05 +cor.test(xi, yi) +rs <- cor.test(xi, yi)$estimate +cat("rs is",rs) +p_value <- cor.test(xi, yi)$p.value +if(p_value <= alpha){ + print("null hypothesis is rejected") +}else{ + print("null hypothesis is accepted") +} diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.2/Ex15_2.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.2/Ex15_2.R new file mode 100644 index 00000000..e12f1e95 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.2/Ex15_2.R @@ -0,0 +1,28 @@ +standard1 <- c(1.21,1.43,1.35,1.51,1.39,1.17,1.48,1.42,1.29,1.40) +treated2 <- c(1.49,1.37,1.67,1.50,1.31,1.29,1.52,1.37,1.44,1.53) +n1 <- length(standard1) +n2 <- length(treated2) +alpha = 0.05 +x <- c(standard1,treated2) +ranksum<-function(x,start,end){ + return(sum(x[start:end])) +} +rank <- rank(x) +t1 <- ranksum(rank,1,n1) +t2 <- n1 * (n1 + n2 + 1) - t1 +if(t1 <= 82){ #critical value of T at n1=n2=10 at alpha = 0.05 is 82 + print("Reject the hypothesis") +}else{ + print("Insufficient evidence to conclude that the treated kraft paper is stronger than the standard paper") +} +muo_t <- (n1 * (n1 * n2 + 1))/2 +sigma_sqr_t <- ((n1 * n2) *(n1 + n2 +1))/12 +sigma_t <- sqrt(sigma_sqr_t) +z <- (t1 - muo_t)/sigma_t; +p_value <- 0.5 - 0.4292 +p_value +if(p_value <= alpha){ + print("Reject the hypothesis") +}else{ + print("Cannot conclude the treated kraft paper is stronger than the standard paper") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.3/Ex15_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.3/Ex15_3.R new file mode 100644 index 00000000..8f377770 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.3/Ex15_3.R @@ -0,0 +1,7 @@ +line_A <- c(170,164,140,184,174,142,191,169,161,200); +line_B <- c(201,179,159,195,177,170,183,179,170,212); +n = 10; +x = 1 +p_value = 2 * round(pbinom(x,n,0.5),3) #hypothesized value of p is 0.5 +p_value +cat("Reject the hypothesis at 5% level ") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.4/Ex15_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.4/Ex15_4.R new file mode 100644 index 00000000..01ed7f20 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.4/Ex15_4.R @@ -0,0 +1,10 @@ +x <- 63; +n <- 100; +alpha <- 0.05; +z <- (x - 0.5 * n)/(0.5 * sqrt(n)); +z_expected <- qnorm(1-alpha/2) +if(z == z_expected ){ +print("Accept the null hypothesis") +}else{ + print("Reject the null hypothesis and the data provide sufficient evidence") +} diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.5/Ex15_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.5/Ex15_5.R new file mode 100644 index 00000000..bfa82b3c --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.5/Ex15_5.R @@ -0,0 +1,14 @@ +x_A <- c(.135,.102,.098,.141,.131,.144) +x_B <- c(.129,.120,.112,.152,.135,.163) +alpha <- 0.10 +t0 <- round(qt(1 - alpha/2,5),1) +boxplot(x_A - x_B,horizontal = TRUE,xlab = "Differences") +wilcox.test(x_A,x_B,paired = T) +t_positive <- wilcox.test(x_A,x_B,paired = T)$statistic +t0 +t_positive +if(t_positive <= t0){ + print("Reject the null hypothesis so two population frequency distribution of cake densities differ") +}else{ + print("Accept the hypothesis") +} \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.6/Ex15_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.6/Ex15_6.R new file mode 100644 index 00000000..34c46331 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.6/Ex15_6.R @@ -0,0 +1,18 @@ +one <- c(65,87,73,79,81,69) +two <- c(75,69,83,81,72,79,90) +three <- c(59,78,67,62,83,76) +four <- c(94,89,80,88) +k <- 4 +kruskal.test(list(one, two, three, four)) +h <- kruskal.test(list(one, two, three, four))$statistic +h +df <- k - 1 +alpha <- 0.05 +x_square_0.05 <- qchisq(1 - alpha, df) +x_square_0.05 +if(h >= x_square_0.05){ + print("sufficent evidence to indicate differences") +}else{ + print("there is insufficient evidence to indicate differences in the distributions of achievement test scores for the four teaching techniques") +} +#the answers may slightly vary due to rounding off values \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.8/Ex15_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.8/Ex15_8.R new file mode 100644 index 00000000..9d468f30 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.8/Ex15_8.R @@ -0,0 +1,31 @@ +a <- c(.6,.7,.9,.5) +B <- c(.9,1.1,1.3,.7) +c <- c(.8,.7,1.0,.8) +d <- c(.7,.8,1.0,.6) +e <- c(.5,.5,.7,.4) +f <- c(.6,.5,.8,.6) +g <- c(a,B,c,d,e,f) +rank_a <- c(2.5,3.5,3,2) +rank_b <- c(6,6,6,5) +rank_c <- c(5,3.5,4.5,6) +rank_d <- c(4,5,4.5,3.5) +rank_e <- c(1,1.5,1,1) +rank_f <- c(2.5,1.5,2,3.5) +t1 <- sum(rank_a) +t2 <- sum(rank_b) +t3 <- sum(rank_c) +t4 <- sum(rank_d) +t5 <- sum(rank_e) +t6 <- sum(rank_f) +k <- 6 +b <- 4 +fr <- 12 / (b * k * (k + 1)) * (t1 * t1 + t2 * t2 + t3 * t3 + t4 * t4 + t5 * t5 + t6 * t6 ) - (3 * b * (k + 1)) +fr +df <- k - 1 +alpha <- 0.05 +x_square <- qchisq(1 - alpha, 5) #sampling distribution of fr +if(fr > x_square){ + print("reject null hypothesis, so the distribution of reaction times differ in location for at least two stimuli") +}else{ + print("accpept the null hypothesis ") +} diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.9/Ex15_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.9/Ex15_9.R new file mode 100644 index 00000000..740ce5a0 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH15/EX15.9/Ex15_9.R @@ -0,0 +1,11 @@ +a <- c(.6,.7,.9,.5) +B <- c(.9,1.1,1.3,.7) +c <- c(.8,.7,1.0,.8) +d <- c(.7,.8,1.0,.6) +e <- c(.5,.5,.7,.4) +f <- c(.6,.5,.8,.6) +data2 <- matrix(c(.6,.9,.8,.7,.5,.6,.7,1.1,.7,.8,.5,.5,.9,1.3,1.0,1.0,.7,.8,.5,.7,.8,.6,.4,.6),nrow = 4, ncol = 6,byrow = T) +dimnames(data2) = list(c(1,2,3,4), c("a","b","c","d","e","f")) +friedman.test(data2) +p_value <- friedman.test(data2)$p.value +cat(" Approximate p-value = ",p_value,",which is slightly less than 0.005") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.1/Ex2_1.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.1/Ex2_1.R new file mode 100644 index 00000000..ed4a6198 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.1/Ex2_1.R @@ -0,0 +1,4 @@ +measurement<-c(2,9,11,5,6) +stripchart(measurement, xlab = "Measurements") +sample_mean<-mean(measurement) +cat("sample mean is",sample_mean) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.10/Ex2_10.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.10/Ex2_10.R new file mode 100644 index 00000000..bd2f5a24 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.10/Ex2_10.R @@ -0,0 +1,5 @@ +data <- c(26.1,26.0,14.5,29.3,19.7,22.1,21.2,26.6,31.9,25.0,15.9,20.8,20.2,31.9,25.0,15.9,20.8,20.2,17.8,13.3,25.6,26.5,15.7,22.1,13.8,29.0,21.3,23.5,22.1,10.2) +x <- range(data) +range <- x[2]-x[1] +sd <- range /4 +cat("standard deviation from range approximation is",sd) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.11/Ex2_11.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.11/Ex2_11.R new file mode 100644 index 00000000..a5015d5d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.11/Ex2_11.R @@ -0,0 +1,5 @@ +measurement<-c(1,1,0,15,2,3,4,0,1,3) +mean <- mean(measurement) +s <- sd(measurement) +x <- 15 +cat("z_score is",(x-mean)/s) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.13/Ex2_13.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.13/Ex2_13.R new file mode 100644 index 00000000..995b7114 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.13/Ex2_13.R @@ -0,0 +1,6 @@ +measurement<-c(16,25,4,18,11,13,20,8,11,9) +cat("Lower quantile is",quantile(measurement, 0.25)) +cat("Upper quantile is",quantile(measurement, 0.75)) +cat("IQR =",IQR(measurement)) +summary(measurement) +#the answers provided in the textbook is wrong \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.14/Ex2_14.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.14/Ex2_14.R new file mode 100644 index 00000000..469bbab5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.14/Ex2_14.R @@ -0,0 +1,10 @@ +data<-c(340,300,520,340,320,290,260,330) +boxplot(data,horizontal = TRUE) +summary(data) +cat("q1 =",quantile(data,0.25)) +cat("m =",quantile(data,0.50)) +cat("q3 =",quantile(data,0.75)) +IQR(data) +boxplot.stats(data) +#outlier is 520 +#the answers provided in the textbook is wrong diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.2/Ex2_2.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.2/Ex2_2.R new file mode 100644 index 00000000..ba980fed --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.2/Ex2_2.R @@ -0,0 +1,3 @@ +set<-c(2,9,11,5,6) +median<-median(set) +cat("median is",median) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.3/Ex2_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.3/Ex2_3.R new file mode 100644 index 00000000..ca19c8ba --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.3/Ex2_3.R @@ -0,0 +1,3 @@ +set<-c(2,9,11,5,6,27) +median <- median(set) +cat("Median for the set of measurements is",median) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.5/Ex2_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.5/Ex2_5.R new file mode 100644 index 00000000..ef745ca5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.5/Ex2_5.R @@ -0,0 +1,5 @@ +measurement<-c(5,7,1,2,4) +variance <- var(measurement) +standard_deviation <- sd(measurement) +cat("the variance is",variance) +cat("the standard deviation is",standard_deviation) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.6/Ex2_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.6/Ex2_6.R new file mode 100644 index 00000000..f32f1366 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.6/Ex2_6.R @@ -0,0 +1,9 @@ +x_bar <- 75 +variance <- 100 +standard_deviation <- sqrt(variance) +lower1 <- x_bar - 2 * standard_deviation +upper1 <- x_bar + 2 * standard_deviation +lower2 <- x_bar - 3 * standard_deviation +upper2 <- x_bar + 3 * standard_deviation +cat("atleast 3/4 of the 25 measurements lie in the interval",lower1,"to",upper1,".") +cat("atleast 8/9 of the 25 measurements lie in the interval",lower2,"to",upper2,".") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.7/Ex2_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.7/Ex2_7.R new file mode 100644 index 00000000..63b51381 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.7/Ex2_7.R @@ -0,0 +1,11 @@ +x_bar <- 12.8 +standard_deviation <- 1.7 +lower1 <- x_bar - 1 * standard_deviation +upper1 <- x_bar + 1 * standard_deviation +lower2 <- x_bar - 2 * standard_deviation +upper2 <- x_bar + 2 * standard_deviation +lower3 <- x_bar - 3 * standard_deviation +upper3 <- x_bar + 3 * standard_deviation +cat("approximately 68% ofmeasurements lie in the interval",lower1,"to",upper1,".") +cat("approximately 95% ofmeasurements lie in the interval",lower2,"to",upper2,".") +cat("approximately 99.7% ofmeasurements lie in the interval",lower3,"to",upper3,".") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.9/Ex2_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.9/Ex2_9.R new file mode 100644 index 00000000..2bc813ed --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH2/EX2.9/Ex2_9.R @@ -0,0 +1,6 @@ +measurements<-c(5,7,1,2,4) +x<-range(measurements) +range <- x[2]-x[1] +sd <- range /4 +cat("standard deviation from range approximation is",sd) +#the value of standard deviation from range approximation is not accurate \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.1/Ex3_1.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.1/Ex3_1.R new file mode 100644 index 00000000..4ecdff36 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.1/Ex3_1.R @@ -0,0 +1,7 @@ +data<- matrix(c(94.8,65.9,56.4,118.1,76.0,65.1),ncol=3,byrow=TRUE) +colnames(data) <- c("Full Professor","Associate Professor","Assistant Professor") +rownames(data) <- c("public","private") +data <- as.table(data) +data +barplot(data, ylab="Average Salary ($ Thousands)", ylim=c(0,120), col=c("blue","grey"), + legend = c("public","private"), beside=TRUE) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.2/Ex3_2.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.2/Ex3_2.R new file mode 100644 index 00000000..4133e19a --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.2/Ex3_2.R @@ -0,0 +1,15 @@ +public<-c(24,57,69) +private<-c(60,78,112) +private_percent<-(private*100)/250 +public_percent<-(public*100)/150 +private_percent +label<-paste(public_percent,"%",sep=" ") +label1<-paste(private_percent,"%",sep=" ") +par(mfrow = c(1,2)) +color<-c("white","aliceblue","cadetblue1") +pie(private_percent,labels = label1,clockwise = TRUE,main="Private",col = color) +legend("bottomleft",c("Full Professor","Assosiate Professor","Assistant Professor"),cex=0.35,fill = color) +pie(public_percent,labels = label,clockwise = TRUE,main="Public",col = color) +legend("bottomleft",c("Full Professor","Assosiate Professor","Assistant Professor"),cex=0.35,fill = color) +cat("proportion of assistant professor is roughly same for both private and public colleges") +cat("public colleges have smaller proportion of full professors and a large proportion of associate professors") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.3/Ex3_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.3/Ex3_3.R new file mode 100644 index 00000000..73466663 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.3/Ex3_3.R @@ -0,0 +1,3 @@ +x<-c(2,2,3,4,1,5) +y<-c(95.75,110.19,118.33,150.92,85.86,180.62) +plot(x,y) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.4/Ex3_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.4/Ex3_4.R new file mode 100644 index 00000000..252e0306 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.4/Ex3_4.R @@ -0,0 +1,9 @@ +#install package("ggplot2") +#install library("ggplot2") +cases<-c(23,21,19,18,15,17,19,20,25,24) +price<-c(10,10,11,11,12,12,13,13,14,14) +DF<-data.frame(price,cases) +library(ggplot2) +#read library("ggplot2) +ggplot(DF,aes(price,cases)) + geom_point() +cat("there exists Linear relationship ") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.5/Ex3_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.5/Ex3_5.R new file mode 100644 index 00000000..0a45b0cf --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.5/Ex3_5.R @@ -0,0 +1,4 @@ +x<-c(1360,1940,1750,1550,1790,1750,2230,1600,1450,1870,2210,1480) +y<-c(278.5,375.7,339.5,329.8,295.6,310.3,460.5,305.2,288.6,365.7,425.3,268.8) +plot(x,y) +cat("Plot represents the linear pattern in data") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.6/Ex3_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.6/Ex3_6.R new file mode 100644 index 00000000..338557b3 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.6/Ex3_6.R @@ -0,0 +1,4 @@ +x<-c(1360,1940,1750,1550,1790,1750,2230,1600,1450,1870,2210,1480) +y<-c(278.5,375.7,339.5,329.8,295.6,310.3,460.5,305.2,288.6,365.7,425.3,268.8) +correlation_Coefficient <- round(cor(x, y),4) +cat("correlation coefficient of x and y is",correlation_Coefficient) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.7/Ex3_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.7/Ex3_7.R new file mode 100644 index 00000000..5b3b0a54 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH3/EX3.7/Ex3_7.R @@ -0,0 +1,9 @@ +#install package("ggplot2") +#install library("ggplot2") +x<-c(2,3,4,5,6,7) +y<-c(6.00,7.50,8.00,12.00,13.00,15.50) +install.packages("ggplot2") +DF<-data.frame(x,y) +library(ggplot2) +#read library("ggplot2") +ggplot(DF,aes(x,y))+geom_point()+geom_smooth(method= "lm" , se= F) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.10/Ex4_10.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.10/Ex4_10.R new file mode 100644 index 00000000..251b0867 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.10/Ex4_10.R @@ -0,0 +1,2 @@ +coin_ways <- 2 +cat("Simple events in the sample space when three coins are tossed are",coin_ways * coin_ways * coin_ways) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.11/Ex4_11.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.11/Ex4_11.R new file mode 100644 index 00000000..fc07ff8a --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.11/Ex4_11.R @@ -0,0 +1,4 @@ +Routes_A_B <- 3; +Routes_B_C <- 4; +Routes_C_D <- 3; +cat("Possible A to D routes are",Routes_A_B * Routes_B_C * Routes_C_D) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.12/Ex4_12.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.12/Ex4_12.R new file mode 100644 index 00000000..fe257691 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.12/Ex4_12.R @@ -0,0 +1,2 @@ +simple_events <- factorial(50)/factorial(50-3); +cat("Total Simple events are",simple_events) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.13/Ex4_13.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.13/Ex4_13.R new file mode 100644 index 00000000..a109e132 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.13/Ex4_13.R @@ -0,0 +1,2 @@ +Total_tests <- factorial(5)/factorial(5-5); +cat("Total number of tests are",Total_tests) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.14/Ex4_14.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.14/Ex4_14.R new file mode 100644 index 00000000..98ca9041 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.14/Ex4_14.R @@ -0,0 +1,3 @@ +suppliers <- 5 +choose <- 3 +cat("Total number of ways in which three suppliers are to be choosen from five are",choose(suppliers, choose)) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.15/Ex4_15.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.15/Ex4_15.R new file mode 100644 index 00000000..a25e0553 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.15/Ex4_15.R @@ -0,0 +1,4 @@ +Total_ways <- 10; +Two_out_of_best <- choose(3, 2); +one_out_of_not_best <- choose(2, 1); +cat("Probability of selecting exactly two of best three are",(Two_out_of_best * one_out_of_not_best) / Total_ways) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.17/Ex4_17.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.17/Ex4_17.R new file mode 100644 index 00000000..9554ac56 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.17/Ex4_17.R @@ -0,0 +1,5 @@ +Prob_A <- 0.80; +Prob_B <- 0.18; +Prob_c <- 0.02; +cat("probability of A or B",Prob_A + Prob_B) +cat("probability of B or C",Prob_B + Prob_c) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.18/Ex4_18.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.18/Ex4_18.R new file mode 100644 index 00000000..8d7516b9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.18/Ex4_18.R @@ -0,0 +1,13 @@ +Child_Too_High <- 0.35; +Child_Right_Amount <- 0.08; +Child_Too_Little <- 0.01; +No_Child_Too_High <- 0.25; +No_Child_Right_Amount <- 0.20; +No_Child_Too_Little <- 0.11; +too_high <- 0.60; +right_ammount <- 0.28; +too_little <- 0.12; +child_college <- Child_Too_High + Child_Too_Little +Child_Right_Amount; +cat("probability that respondent has a child in college is",child_college) +cat("probability that respondent does not have a child in college is",1-child_college) +cat("probability that respondent has child in college and with too high load is",too_high + child_college - Child_Too_High) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.19/Ex4_19.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.19/Ex4_19.R new file mode 100644 index 00000000..0abdc683 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.19/Ex4_19.R @@ -0,0 +1,7 @@ +prob_r <- 2/8; +prob_g <- 6/8; +prob_rr <- 1/7; +prob_rg <- 6/7; +prob_gr <- 2/7; +prob_gg <- 5/7; +cat("probability that child choose the two red toys is",prob_r * prob_rr) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.20/Ex4_20.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.20/Ex4_20.R new file mode 100644 index 00000000..86d8be2f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.20/Ex4_20.R @@ -0,0 +1,9 @@ +s <- c("hh","ht","th","tt") +prob_a <- 1/2 +prob_b <- 1/2 +prob_a_and_b <- 1/4 +if((prob_a * prob_b) == prob_a_and_b){ + print("events must be independent") +}else{ + print("events are not independent") + } \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.21/Ex4_21.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.21/Ex4_21.R new file mode 100644 index 00000000..b422a6f4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.21/Ex4_21.R @@ -0,0 +1,13 @@ +Child_Too <- 0.35; +Child_Right_Amount <- 0.08; +Child_Too_Little <- 0.01; +No_Child_Too_High <- 0.25; +No_Child_Right_Amount <- 0.20; +No_Child_Too_Little <- 0.11; +too_high <- 0.60; +right_amount <- 0.28; +too_little <- 0.12; +child_college <- 0.44; +No_child_college <- 0.56; +x = too_high * child_college +cat("x and child_college values are not same so both events are dependent ") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.22/Ex4_22.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.22/Ex4_22.R new file mode 100644 index 00000000..e54b7362 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.22/Ex4_22.R @@ -0,0 +1,9 @@ +ace_on_first <- 4/52; +ten_on_second_when_ace_on_first <- 4/51; +ten_on_first <- 4/52; +ace_on_Second <- 4/51; +x <- ace_on_first * ten_on_second_when_ace_on_first +y <- ten_on_first * ace_on_Second +cat("probability of ace on first and ten on second draw",x) +cat("probability of ten on first and ace on second draw",y) +cat("probability that the draw includes an ace and a ten is",x+y) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.23/Ex4_23.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.23/Ex4_23.R new file mode 100644 index 00000000..344a126a --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.23/Ex4_23.R @@ -0,0 +1,12 @@ +pg1 <- 0.09 +pg2 <- 0.20 +pg3 <- 0.31 +pg4 <- 0.23 +pg5 <- 0.17 +p_a_g1 <- 0.26 +p_a_g2 <- 0.20 +p_a_g3 <- 0.13 +p_a_g4 <- 0.18 +p_a_g5 <- 0.14 +pA <- (pg1 * p_a_g1) + (pg2 * p_a_g2) +(pg3 * p_a_g3) +(pg4 * p_a_g4) +(pg5 * p_a_g5) +cat("the required probability is",pA) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.24/Ex4_24.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.24/Ex4_24.R new file mode 100644 index 00000000..ebe3ae5e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.24/Ex4_24.R @@ -0,0 +1,12 @@ +pg1 <- 0.09 +pg2 <- 0.20 +pg3 <- 0.31 +pg4 <- 0.23 +pg5 <- 0.17 +p_a_g1 <- 0.26 +p_a_g2 <- 0.20 +p_a_g3 <- 0.13 +p_a_g4 <- 0.18 +p_a_g5 <- 0.14 +required_probability <- (pg5 * p_a_g5) / ((pg1 * p_a_g1) + (pg2 * p_a_g2) +(pg3 * p_a_g3) +(pg4 * p_a_g4) +(pg5 * p_a_g5)) +cat("the required probability is",required_probability) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.26/Ex4_26.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.26/Ex4_26.R new file mode 100644 index 00000000..e4bf27e6 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.26/Ex4_26.R @@ -0,0 +1,11 @@ +x <- c(0,1,2,3,4,5) +prob_x <- c(0.10,0.40,0.20,0.15,0.10,0.05) +k<- c(x*prob_x) +mean <- weighted.mean(x, prob_x) +l <- c((x-mean)*(x-mean)) +m <- c(l*prob_x) +variance <- sum(m) +standard_deviation=round(sqrt(variance),2) +cat("mean is",mean) +cat("variance is",variance) +cat("standard deviation is",standard_deviation) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.27/Ex4_27.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.27/Ex4_27.R new file mode 100644 index 00000000..84c48d5a --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.27/Ex4_27.R @@ -0,0 +1,6 @@ +gain<-c(-20,23980) +prob_gain<-c((7998/8000),(2/8000)) +prob_gain +expected_gain <- weighted.mean(gain, prob_gain) +#expected_gain is in dollar +cat("expected gain per lottery would be a loss of",expected_gain) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.5/Ex4_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..e950fb9d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,3 @@ +E2 <- 1/4; +E3 <- 1/4; +cat("Probability of observing exactly one head in two tosses is",E2+E3) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.6/Ex4_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.6/Ex4_6.R new file mode 100644 index 00000000..7855a645 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.6/Ex4_6.R @@ -0,0 +1,5 @@ +A <- 0.41; +B <- 0.10; +AB <- 0.04; +o <- 0.45; +cat("Probability that person is either type A or type AB is",A+AB) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.7/Ex4_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.7/Ex4_7.R new file mode 100644 index 00000000..8c8773f7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.7/Ex4_7.R @@ -0,0 +1,3 @@ +R1R2 <- 1/6; +R2R1 <- 1/6; +cat("Probability that both candies are red is",R1R2 + R2R1) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.8/Ex4_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.8/Ex4_8.R new file mode 100644 index 00000000..1002200d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.8/Ex4_8.R @@ -0,0 +1,3 @@ +m <- 6; +n <- 6; +cat("Total number of simple events in the sample space S are",m*n) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.9/Ex4_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.9/Ex4_9.R new file mode 100644 index 00000000..67205f05 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH4/EX4.9/Ex4_9.R @@ -0,0 +1,3 @@ +first_candy <- 3; +second_candy <- 2; +cat("Simple events in the sample space S are",first_candy * second_candy) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.10/Ex5_10.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.10/Ex5_10.R new file mode 100644 index 00000000..9ccf5bc2 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.10/Ex5_10.R @@ -0,0 +1,10 @@ +total <- 1000; +prob <- 0.001; +mean <- total * prob; +none_defective <- dpois(0,mean) +cat("probability that none is defective is",none_defective) +three_defective <- dpois(3,mean) +cat("probability that three is defective",three_defective) +four_defective <- dpois(4,mean) +cat("probability that four are defective",four_defective) +#the asnwer may slightly vary due to rounding off \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.11/Ex5_11.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.11/Ex5_11.R new file mode 100644 index 00000000..963e09b6 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.11/Ex5_11.R @@ -0,0 +1,18 @@ +total_bottles <- 12; +spoiled_wine <- 3; +sample <- 4; +prob_zero <- (choose(spoiled_wine,0) * choose(total_bottles - spoiled_wine,(sample - 0)))/choose(total_bottles,sample) +cat("probability distribution of no bottle of spoiled wine is",prob_zero) +prob_one <- (choose(spoiled_wine,1) * choose(total_bottles - spoiled_wine,(sample - 1)))/choose(total_bottles,sample) +cat("probability distribution of one bottle of spoiled wine in sample is",prob_one) +prob_two <- (choose(spoiled_wine,2) * choose(total_bottles - spoiled_wine,(sample - 2)))/choose(total_bottles,sample) +cat("probability distribution of two bottle of spoiled wine in sample is",prob_two) +prob_three <- (choose(spoiled_wine,3) * choose(total_bottles - spoiled_wine,(sample - 3)))/choose(total_bottles,sample) +cat("probability distribution of three bottle of spoiled wine in sample is",prob_three) +mean = sample * (spoiled_wine/total_bottles) +cat("mean is",mean) +variance <- sample * (spoiled_wine/total_bottles)*(9/total_bottles)*((total_bottles-sample)/11) +cat("variance is",variance) +#"The answer may slightly vary due to rounding off values" + + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.12/Ex5_12.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.12/Ex5_12.R new file mode 100644 index 00000000..125e7a0e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.12/Ex5_12.R @@ -0,0 +1,5 @@ +total_items <- 20; +sample_items <- 5; +defective <- 4; +prob_accept_lot <- choose(defective,0) * choose(total_items - defective,(sample_items - 0))/choose(total_items,sample_items) + choose(defective,1) * choose(total_items - defective,(sample_items - 1))/choose(total_items,sample_items) +cat("probability of get accepted is",prob_accept_lot) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.3/Ex5_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.3/Ex5_3.R new file mode 100644 index 00000000..07d545f7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.3/Ex5_3.R @@ -0,0 +1,5 @@ +x <- 2; +n<- 10; +p <- 0.1; +prob <- round((dbinom(x,n,p)),4) +cat("the required probability is",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.4/Ex5_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.4/Ex5_4.R new file mode 100644 index 00000000..6a6b92d6 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.4/Ex5_4.R @@ -0,0 +1,8 @@ +total_throws <- 4; +prob <- 0.8; +x <- 2; +y <- 0; +case_one <- dbinom(x,total_throws,prob) +cat("probability that he will make exactly two free throws is",case_one) +case_two <- 1-dbinom(y,total_throws,prob) +cat("probability that he will make atleast one free throw is",case_two) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.5/Ex5_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.5/Ex5_5.R new file mode 100644 index 00000000..e65ca40b --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.5/Ex5_5.R @@ -0,0 +1,9 @@ +total <- 5; +prob <- 0.6; +x <- 3; +y <- 2 +case_one <- pbinom(x,total,prob)-pbinom(y,total,prob) +cat("probability of exactly three successes is",case_one) +case_two <- 1-pbinom(y,total,prob) +cat("probability of three or ore successes is",case_two) +#the answer may slightly vary due to rounding off values diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.6/Ex5_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.6/Ex5_6.R new file mode 100644 index 00000000..85b4cafa --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.6/Ex5_6.R @@ -0,0 +1,5 @@ +total <- 10; +prob <- 0.5; +x <- 7; +eight_or_more <- 1 - pbinom(x,10,0.5) +cat("probability of exactly three success is",eight_or_more) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.7/Ex5_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.7/Ex5_7.R new file mode 100644 index 00000000..bae26021 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.7/Ex5_7.R @@ -0,0 +1,8 @@ +prob_correct <- 0.2 +prob_incorrect <- 1 - prob_correct +n <- 100 +mu0 <- n * prob_correct +sigma <- sqrt(n * prob_correct * prob_incorrect) +cat("a large proportion of score will lie within two standard deviations of the mean, or from",(mu0 - 2 * sigma),"to",(mu0 + 2 * sigma),"." ) +cat("allmost all the score will lie within three standard deviations of the mean, or from",(mu0 - 3 * sigma),"to",(mu0 + 3 * sigma),"." ) +cat("guessing will be better than zero score but the student will not pass the exam") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.8/Ex5_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.8/Ex5_8.R new file mode 100644 index 00000000..ce8228f5 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.8/Ex5_8.R @@ -0,0 +1,8 @@ +mean <- 2; +accidents_in_case_one <- 0; +case_one <- round((dpois(accidents_in_case_one,mean)),6) +cat("probability of no accident on this section of highway during a 1-week period is",case_one) +case_two_mean <- 2*mean; +case_two_mean +case_two <- round((dpois(0,case_two_mean)+ dpois(1,case_two_mean) + dpois(2,case_two_mean) + dpois(3,case_two_mean)),6) +cat("probability of atmost three accidetns on this section of highway during a 2-week period is",case_two) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.9/Ex5_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.9/Ex5_9.R new file mode 100644 index 00000000..53b72558 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH5/EX5.9/Ex5_9.R @@ -0,0 +1,6 @@ +total_men <- 5000; +prob <- 0.001; +claims <- 4; +mean <- total_men * prob +exact_prob <- round((dpois(claims,mean)),3) +cat("probability that the company will have to pay 4 claims during a given year is",exact_prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.1/Ex6_1.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.1/Ex6_1.R new file mode 100644 index 00000000..9d9d6201 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.1/Ex6_1.R @@ -0,0 +1,3 @@ +given_value <- 0.2 +required_probability <- punif(given_value, max = 0.5, min = -0.5) - punif(- given_value, max = 0.5, min = -0.5) +cat("required probability is",required_probability) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.10/Ex6_10.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.10/Ex6_10.R new file mode 100644 index 00000000..36fb5980 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.10/Ex6_10.R @@ -0,0 +1,5 @@ +mean <- 25.5; +standard_deviation <- 4.5; +percent <- 95 / 100; +cat("The gasoline use rate for the new car must be",qnorm(percent, mean, standard_deviation)) + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.11/Ex6_11.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.11/Ex6_11.R new file mode 100644 index 00000000..c421554f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.11/Ex6_11.R @@ -0,0 +1,11 @@ +total <- 25; +prob <- 0.5; +actual_prob <- round((pbinom(10,total,prob)-pbinom(7,total,prob)),4) +mean <- total * prob; +standard_deviation <- sqrt(total*prob*0.5) +x_lower <- 7.5; +x_upper <- 10.5; +approx_prob <- round(pnorm(x_upper, mean, standard_deviation) - pnorm(x_lower, mean, standard_deviation) ,4) +cat("actual probability is",actual_prob) +cat("approximate probability is",approx_prob) +cat("approximate and actual probability are quite close") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.12/Ex6_12.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.12/Ex6_12.R new file mode 100644 index 00000000..e73b1a4e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.12/Ex6_12.R @@ -0,0 +1,9 @@ +x_value <- 26.5; +total <- 1000; +defective <- 0.02; +reliability <- 0.98; +mean = total * defective; +standard_deviation <-round( sqrt((total * defective) * reliability),2) +approx_prob <- 1 - round(pnorm(x_value, mean, standard_deviation),4) +cat("Approximate probablity of observing 27 or more defective is",approx_prob) +#the answers may slightly vary due to rounding off values \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.13/Ex6_13.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.13/Ex6_13.R new file mode 100644 index 00000000..ec127bc8 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.13/Ex6_13.R @@ -0,0 +1,9 @@ +consumers <- 2500; +brand_share <- 10; +prob_correct <- brand_share/100; +prob_not_correct <- 1 - prob_correct; +mean = consumers * prob_correct; +standard_deviation <- sqrt(consumers * prob_correct * prob_not_correct) +x_value <- 211.5; +required_prob <- round((pnorm(x_value, mean, standard_deviation)),4) +cat("probability of observing 211 or fewer consumers who prefer her band of soft drink is",required_prob) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.2/Ex6_2.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.2/Ex6_2.R new file mode 100644 index 00000000..3df5e7a4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.2/Ex6_2.R @@ -0,0 +1,4 @@ +average_waiting_time <- 5 +waiting_time <- 10 +required_probability <- 1 - pexp(waiting_time, rate = 1 / average_waiting_time) +cat("the required probability is",required_probability) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.3/Ex6_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.3/Ex6_3.R new file mode 100644 index 00000000..1eca6719 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.3/Ex6_3.R @@ -0,0 +1,3 @@ +point <- 1.63; +prob <- round((pnorm(point)),4); +cat("the required probability is",prob) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.4/Ex6_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.4/Ex6_4.R new file mode 100644 index 00000000..993db432 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.4/Ex6_4.R @@ -0,0 +1,4 @@ +point <- -0.5; +prob <- 1-pnorm(point); +cat("the required probability is",round(prob,4)) + \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.5/Ex6_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.5/Ex6_5.R new file mode 100644 index 00000000..3b7737e9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.5/Ex6_5.R @@ -0,0 +1,6 @@ +point_one <- -0.5; +point_two <- 1.0; +prob_one <- pnorm(point_one); +prob_two <- pnorm(point_two); +prob <- round((prob_two - prob_one),4); +cat("The required probability is",prob) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.6/Ex6_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.6/Ex6_6.R new file mode 100644 index 00000000..e5a7b9c8 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.6/Ex6_6.R @@ -0,0 +1,7 @@ +point_one <- 1; +point_two <- 2; +prob_one <- round(pnorm(point_one) - pnorm(-point_one),5); +prob_two <- round(pnorm(point_two) - pnorm(-point_two),4); +cat(" probability that a normally distributed random variable will fall within One standard deviation of its mean",prob_one) +cat(" probability that a normally distributed random variable will fall within Two standard deviations of its mean",prob_two) +#the answers may slightly vary due to rounding off values \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.7/Ex6_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.7/Ex6_7.R new file mode 100644 index 00000000..2739a878 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.7/Ex6_7.R @@ -0,0 +1,5 @@ +shaded_area <- 0.95 +A1 <- (1 - shaded_area) / 2 +cumulative_Area_left_of_z0 <- shaded_area + A1 +z_value <- round(qnorm(cumulative_Area_left_of_z0),2) +cat("the required z value is",z_value) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.8/Ex6_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.8/Ex6_8.R new file mode 100644 index 00000000..e6101ba3 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.8/Ex6_8.R @@ -0,0 +1,6 @@ +mean <- 10; +standard_deviation <- 2; +lower_X <- 11; +upper_x <- 13.6; +prob <- round((pnorm(upper_x, mean, standard_deviation) - pnorm(lower_X, mean, standard_deviation)),4); +cat("the required probability is",prob) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.9/Ex6_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.9/Ex6_9.R new file mode 100644 index 00000000..7b6cfd47 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH6/EX6.9/Ex6_9.R @@ -0,0 +1,6 @@ +mean <- 25.5; +standard_deviation <- 4.5; +value_x <- 30; +prob <- 1 - pnorm(value_x, mean, standard_deviation); +percentage <- prob *100; +cat("the required percentage is",round(percentage,2)) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.1/Ex7_1.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.1/Ex7_1.R new file mode 100644 index 00000000..045fec0a --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.1/Ex7_1.R @@ -0,0 +1,3 @@ +N <- 1000 +n <- 5 +sample(N, n, replace = FALSE, prob = NULL) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.4/Ex7_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.4/Ex7_4.R new file mode 100644 index 00000000..49dc80ab --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.4/Ex7_4.R @@ -0,0 +1,14 @@ +sample_size <- 30; +x_value <- 7; +mean <- 8; +sd <- 4; +prob_less_7 <- round(pnorm(x_value, mean, round((sd / sqrt(sample_size)),2)),6) +cat("The approximate probability duration for average duration is less than 7 years is",prob_less_7) +prob_exceed_7 <- round((1 - prob_less_7),5) +cat("The approximate probability for average duation exceeds 7 years is",prob_exceed_7) +x1_value <- 9; +prob_of_interest <- (pnorm(x1_value, mean, round((sd / sqrt(sample_size)),2))) - (pnorm(x_value, mean, round((sd / sqrt(sample_size)),2))) +cat("The approximate probability for average duration lies within 1 year of the population mean=8 is",prob_of_interest) +#"The answers may sligthly vary due to rounding off values" + + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.5/Ex7_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.5/Ex7_5.R new file mode 100644 index 00000000..c734ec47 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.5/Ex7_5.R @@ -0,0 +1,7 @@ +no_of_bottles <- 10; +mean <- 12.1; +x_value <- 12; +standard_Deviation <- 0.2; +standard_error <- standard_Deviation/sqrt(no_of_bottles) +required_prob <- round((pnorm(x_value, mean, standard_error)),4) +cat("The required probability is",required_prob) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.6/Ex7_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.6/Ex7_6.R new file mode 100644 index 00000000..f599e7c8 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.6/Ex7_6.R @@ -0,0 +1,7 @@ +sample_space <- 500; +mean <- 0.60; +standard_error <- sqrt((mean * (1-mean))/sample_space) +standard_error <- round(standard_error,3) +cat("standard error is",standard_error) +p <- 2 * standard_error +cat("required value is",p) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.7/Ex7_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.7/Ex7_7.R new file mode 100644 index 00000000..bb5c7b18 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.7/Ex7_7.R @@ -0,0 +1,8 @@ +# textbook refered to example 7.6 for values +sample_space <- 500; +proportion <- 0.55; +observed_value <- 0.60; +standard_error <- round(sqrt((proportion * (1-proportion))/sample_space),4) +cat("standard error is",standard_error) +req_prob <- round(1 - pnorm(observed_value, proportion, standard_error),4) +cat("probobality of observing a sample proportion as large as or larger than the observed value is",req_prob) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.8/Ex7_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.8/Ex7_8.R new file mode 100644 index 00000000..3fb6e761 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.8/Ex7_8.R @@ -0,0 +1,16 @@ +#install package ("qicharts") +#install library ("qicharts") +install.packages("qicharts") +library(qicharts) +n <- 4 +bearing1 <- c(0.992,1.015,0.988,0.996,1.015,1.000,0.989,0.994,1.018,0.997,1.020,1.007,1.016,0.982,1.001,0.992,1.020,0.993,0.978,0.984,0.990,1.015,0.983,1.011,0.987) +bearing2 <- c(1.007,0.984,0.993,1.020,1.006,0.982,1.009,1.010,1.016,1.005,0.986,0.986,1.002,0.995,1.000,1.008,0.988,0.987,1.006,1.009,1.012,0.983,0.990,1.012,0.987) +bearing3 <- c(1.016,0.976,1.011,1.004,1.002,1.005,1.019,1.009,0.990,0.989,1.002,0.981,1.010,1.011,0.983,1.001,1.015,1.006,1.002,0.983,1.010,1.003,0.997,0.991,1.007) +bearing4 <- c(0.991,1.000,0.981,0.999,1.001,0.989,0.994,0.990,1.011,1.001,0.989,0.995,0.999,0.987,1.002,0.996,0.986,1.001,0.982,0.986,1.007,0.989,1.002,1.008,0.995) +sample <- c(1:25) +measurement <- c(bearing1 + bearing2 + bearing3 +bearing4) +sample_mean <- c((bearing1 + bearing2 + bearing3 + bearing4) / n) +df <- data.frame(sample, bearing1, bearing2, bearing3, bearing4,sample_mean) +df +qic(sample_mean, x = sample, data = df, chart = 'i',main = 'Xbar chart of Diameter', xlab = 'sample', ylab = 'sample mean') +#The results may slightly vary due to rounding off values \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.9/Ex7_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.9/Ex7_9.R new file mode 100644 index 00000000..748d375e --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH7/EX7.9/Ex7_9.R @@ -0,0 +1,10 @@ +#install package ("qcc") +#install library ("qcc") +install.packages("qcc") +library(qcc) +proportion <- c(0.0200,0.0125,0.0225,0.0100,0.0150,0.0200,0.0275,0.0175,0.0200,0.0250,0.0100,0.0175,0.0250,0.0175,0.0275,0.0200,0.0225,0.0100,0.0175,0.0200,0.0300,0.0200,0.0125,0.0175,0.0225,0.0150,0.0200,0.0250,0.0150,0.0175,0.0225,0.0175,0.0225,0.0100,0.0125,0.0300,0.0200,0.0150,0.0150,0.0225) +n <- 400 +defects <- c(proportion * n) +qcc(defects, type = "p",sizes = n, xlab = "day", ylab = "proportion") + + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.10/Ex8_10.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.10/Ex8_10.R new file mode 100644 index 00000000..7e8a4e2c --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.10/Ex8_10.R @@ -0,0 +1,14 @@ +sample_size_men <- 50; +sample_size_women <- 50; +sample_mean_men <- 756; +sample_mean_women <- 762; +sample_standard_Deviation_men <- 35; +sample_standard_Deviation_women <- 30; +z_value <- 1.96 +#we know from z table that for 95% confidence interval the z value is 1.96; +point_estimate <- sample_mean_men -sample_mean_women; +standard_error <- sqrt(((sample_standard_Deviation_men * sample_standard_Deviation_men)/sample_size_men + (sample_standard_Deviation_women * sample_standard_Deviation_women)/sample_size_women)) +value <- z_value * standard_error; +left <- round((point_estimate - value),2); +right <- round((point_estimate + value),2); +cat("The 95% confidence interval is from",left,"to",right) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.11/Ex8_11.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.11/Ex8_11.R new file mode 100644 index 00000000..f1bebbc7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.11/Ex8_11.R @@ -0,0 +1,20 @@ +p1_cap <- 0.76 +p2_cap <- 0.65 +q1_cap <- 0.24 +q2_cap <- 0.35 +n1 <- 50 +n2 <- 100 +p1_cap - p2_cap +standard_error <- round(sqrt(((p1_cap * q1_cap) / n1 ) + ((p2_cap * q2_cap) / n2 )),4) +standard_error +alpha <- 0.01 #at 99% confidence interval alpha = 0.01 +z_0.005 <- qnorm( 1 - alpha/2) +lower_value <- (p1_cap - p2_cap) - z_0.005 * standard_error +upper_value <- (p1_cap - p2_cap) + z_0.005 * standard_error +cat("the interval is from",lower_value,"to",upper_value) +n <- 150 +point_estimation <- 103/n +margin_of_error <- 1.96 * sqrt((point_estimation * (1 - point_estimation) / n)) +margin_of_error1 <- - 1.96 * sqrt((point_estimation * (1 - point_estimation) / n)) +cat("margin of error is",margin_of_error,"and",margin_of_error1,".") +cat("interval is from",point_estimation - margin_of_error,"to",point_estimation + margin_of_error,".") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.12/Ex8_12.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.12/Ex8_12.R new file mode 100644 index 00000000..06c5118f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.12/Ex8_12.R @@ -0,0 +1,10 @@ +alpha <- 0.05 #at 95% confidence interval the alpha = 0.05 +x_bar <- 10.3 +n <- 40 +s <- 0.31 +se <- s / sqrt(n) +z_0.05 <- qnorm(1 - alpha) +z_0.05 +ucb <- x_bar + z_0.05 * se +ucb +cat("the 95% upper confidence bound is",ucb) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.13/Ex8_13.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.13/Ex8_13.R new file mode 100644 index 00000000..29a82973 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.13/Ex8_13.R @@ -0,0 +1,7 @@ +bound_b <- 0.04 +alpha <- 0.10 #at 0.90 confidence coefficient +z_0.05 <- qnorm(1 - alpha/2) +z_0.05 +p <- q <- 0.5 +n <- ((z_0.05 * 0.5) / bound_b) ** 2 +cat("the producer must include atleast",round(n,0),"wholesalers in survey") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.14/Ex8_14.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.14/Ex8_14.R new file mode 100644 index 00000000..21901af4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.14/Ex8_14.R @@ -0,0 +1,7 @@ +range <- 8 +sigma1 <- sigma2 <- sigma <- range / 4 +alpha <- 1 - 0.95 # at 0.95 confidence coefficient +z_0.05 <- qnorm(1 - alpha/2) +z_0.05 +n <- (z_0.05 * sqrt(8)) ** 2 +cat("there should be atleast",round(n,0),"workers in each group.") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.4/Ex8_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.4/Ex8_4.R new file mode 100644 index 00000000..cd1fc6a4 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.4/Ex8_4.R @@ -0,0 +1,5 @@ +sample <- 50; +standard_deviation <- 105; +margin_of_error <- 1.96 * (standard_deviation/sqrt(sample)) +margin_of_error +cat("the average weight of all arctic polar bears are within more or less of 29 pounds of sample estimate of 980 pounds") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.5/Ex8_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.5/Ex8_5.R new file mode 100644 index 00000000..605c6d12 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.5/Ex8_5.R @@ -0,0 +1,6 @@ +sample <- 100; +p <- 0.73; +q <- 1 - p; +k <- sqrt((p * q)/sample); +margin_of_error <- round((1.96 * k),2) +cat("margin of error is",margin_of_error) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.6/Ex8_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.6/Ex8_6.R new file mode 100644 index 00000000..18a952d1 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.6/Ex8_6.R @@ -0,0 +1,8 @@ +sample_mean <- 756; +sample_size <- 50; +standard_deviation <- 35; +standard_error <- qnorm(0.975) *( standard_deviation / sqrt(sample_size)) +left <- round((sample_mean - standard_error),2); +right <- round((sample_mean + standard_error),2); +cat("95% confidence interval for sample mean is from ",left, "to" ,right,"grams") + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.7/Ex8_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.7/Ex8_7.R new file mode 100644 index 00000000..d3b2c69f --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.7/Ex8_7.R @@ -0,0 +1,8 @@ +sample_mean <- 756; +sample_size <- 50; +standard_deviation <- 35; +z <- round((qnorm(0.995,lower.tail = T)),2); #99% confidence interval-> 1 - 0.005 = 0.995 +standard_error <- z *( standard_deviation / sqrt(sample_size)) +left <- sample_mean - standard_error; +right <- sample_mean + standard_error; +cat("99% confidence interval is from ",left, "to" ,right, "grams per day") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.8/Ex8_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.8/Ex8_8.R new file mode 100644 index 00000000..7c06290d --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.8/Ex8_8.R @@ -0,0 +1,12 @@ +sample_size <- 985; +vote_for_republican <- 592; +point_estimate <- vote_for_republican/sample_size; +standard_error <- sqrt((point_estimate * (1 - point_estimate))/sample_size) +standard_error +point_estimate +coin_interval <- 90/100; +z <- qt((1+coin_interval)/2,df=sample_size-1) +value <- z * standard_error +left <- round((point_estimate - value),3); +right <- round((point_estimate + value),3); +cat("90% confidence interval is from ",left, "to" ,right) diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.9/Ex8_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.9/Ex8_9.R new file mode 100644 index 00000000..38f37b04 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH8/EX8.9/Ex8_9.R @@ -0,0 +1,14 @@ +miles_cover_by_type1 <- 26400; +miles_cover_by_type2 <- 25100; +type1_sample <- 100; +type2_sample <- 100; +variance1 <- 1440000; +variance2 <- 1960000; +point_estimate <- miles_cover_by_type1 - miles_cover_by_type2; +standard_error <- sqrt(((variance1)/type1_sample) + (variance2)/type2_sample); +confidence_interval_percent <- 0.99; +z_value <- round((qnorm(0.995)),2) +value <- z_value * standard_error; +left <- point_estimate - value; +right <- point_estimate + value; +cat("The difference in the average miles to wearout for the two types of tires is estimated to lie between ",left,"and",right,"miles of wear") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.10/Ex9_10.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.10/Ex9_10.R new file mode 100644 index 00000000..0f0f8167 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.10/Ex9_10.R @@ -0,0 +1,18 @@ +# In textbook values are refered to example 9.9 +non_owners <- 100; +owners <- 100; +average_non_owner <- 2.70; +average_owner <- 2.54; +variance_non_owner <- 0.36; +variance_owner <- 0.40; +d_nod <- 0; +point_estimate <- average_non_owner - average_owner; +standard_error <- sqrt(((variance_non_owner)/non_owners) + (variance_owner)/owners); +confidence_interval_percent <- 0.95; +z_value <- qnorm(1-(1 - confidence_interval_percent)/2) +value = z_value * standard_error; +left = round((point_estimate - value),2); +right = round((point_estimate + value),2); +cat("The confidence interval is approximated from",left,"to",right) +cat("there is not enough evidence so we cannot conclude") + diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.11/Ex9_11.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.11/Ex9_11.R new file mode 100644 index 00000000..99d8fbec --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.11/Ex9_11.R @@ -0,0 +1,7 @@ +hypothesized_value <- 0.2; +observed_value <- 15/100; +standard_error <- sqrt((hypothesized_value * (1-hypothesized_value))/100) +z_value <- (observed_value - hypothesized_value)/standard_error; +p_value <- pnorm(z_value) +cat("pvalue is",p_value) +cat("null hypothesis cannot be rejected so there is insufficient evidence to make conclusion") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.12/Ex9_12.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.12/Ex9_12.R new file mode 100644 index 00000000..27d91726 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.12/Ex9_12.R @@ -0,0 +1,15 @@ +admitted_men <- 52; +admitted_women <- 23; +sample_men <- 1000; +sample_women <- 1000; +p1_value <- admitted_men/sample_men; +p2_value <- admitted_women/sample_women; +pooled_estimate <- (admitted_men + admitted_women)/(sample_men + sample_women); +standard_error <- sqrt(pooled_estimate * (1 - pooled_estimate) * ((1/1000) + (1/1000))) +test_statistics <- (p1_value - p2_value)/standard_error +test_statistics +alpha <- 0.05; +k <- abs(qnorm(alpha)) +lower_bound <- (p1_value - p2_value) - k * sqrt((p1_value * (1 - p1_value)/sample_men) + (p2_value * (1 - p2_value)/sample_women)) +cat("Lowest likely value for the difference is",lower_bound) +cat("the data present sufficient evidence to indicate that the percentage of men entering the hospital because of heart disease is higher than women") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.3/Ex9_3.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.3/Ex9_3.R new file mode 100644 index 00000000..6c5e9935 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.3/Ex9_3.R @@ -0,0 +1,9 @@ +mean <- 14 +s <- 2 +n <- 100 +se <- s / sqrt(n) +x_bar <- 15 +z <- (x_bar - mean) / se +z +p_value <- 2 * pnorm(-abs(z)) +cat("p-value is approximately zero") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.4/Ex9_4.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.4/Ex9_4.R new file mode 100644 index 00000000..1b0730dd --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.4/Ex9_4.R @@ -0,0 +1,14 @@ +xbar <- 725; # sample mean +mu0 <- 670; # hypothesized value +sigma <- 102; # standard deviation +sample_size <- 40; # sample size +z <- (xbar - mu0)/(sigma/sqrt(sample_size)) +z # test statistic +alpha <- .01 +z.alpha <- qnorm(1 - alpha) +z.alpha # critical value +cat("The value of z is",z) +cat("critical value is",z.alpha) +cat("null hypothesis rejected ") +cat("average weekly earning for male are higher than average for female") +#the answer may slightly vary due to rounding off values diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.5/Ex9_5.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.5/Ex9_5.R new file mode 100644 index 00000000..6bc299f9 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.5/Ex9_5.R @@ -0,0 +1,13 @@ +sample_mean <- 871; # sample mean +hypothesized_value <- 880; # hypothesized value +sigma <- 21; # standard deviation +sample_size <- 50; # sample size +z <- round(((sample_mean - hypothesized_value)/(sigma/sqrt(sample_size))),2) +z # test statistic +alpha <- .05 +z.alpha <- round((qnorm(1 - alpha/2)),2) +z.alpha # critical value +cat("The value of z is",z) +cat("critical value is",z.alpha) +cat("null hypothesis can be rejected") +cat("she is reasonably confident that the decision is correct") \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.6/Ex9_6.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.6/Ex9_6.R new file mode 100644 index 00000000..4d5ebbe7 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.6/Ex9_6.R @@ -0,0 +1,9 @@ +sample_mean <- 871; # sample mean +hypothesized_value <- 880; # hypothesized value +sigma <- 21; # standard deviation +sample_size <- 50; # sample size +z_value <- (sample_mean - hypothesized_value)/(sigma/sqrt(sample_size)) +z_value #test statistics +p_value <- round((1 - pnorm(-z_value)) + pnorm(z_value),4) +cat("p value is",p_value) +cat("reject null hypothesis at either 5% or 1% level of significance") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.7/Ex9_7.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.7/Ex9_7.R new file mode 100644 index 00000000..7884cd60 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.7/Ex9_7.R @@ -0,0 +1,16 @@ +sample_mean <- 3400; # sample mean +hypothesized_value <- 3300; # hypothesized value +sigma <- 1100; # standard deviation +sample_size <- 100; # sample size +z_value <- (sample_mean - hypothesized_value)/(sigma/sqrt(sample_size)) +z_value # test statistic +alpha <- 0.05 +z.alpha <- qnorm(1 - alpha) +z.alpha # critical value +cat("The value of z is",z_value) +cat("critical value is",z.alpha) +p_value <- 1 - pnorm(z_value) +cat("p value is",p_value) +cat("null hyppothesis is not rejected") +cat("not enough evidence ") +#the answer may slightly vary due to rounding off values diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.8/Ex9_8.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.8/Ex9_8.R new file mode 100644 index 00000000..14f1d6be --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.8/Ex9_8.R @@ -0,0 +1,20 @@ +sample_mean <- 871; # sample mean +hypothesized_value <- 880; # hypothesized value +sigma <- 21; # standard deviation +sample_size <- 50; # sample size +alpha <- .05 +z.alpha <- round((qnorm(1 - alpha/2)),2) +z.alpha # critical value +lower <- round(hypothesized_value - z.alpha * ((sigma/sqrt(sample_size))),2) +lower +upper <- round(hypothesized_value + z.alpha * ((sigma/sqrt(sample_size))),2) +upper +mu <- 870 +z1 <- round(((lower - mu)/(sigma/sqrt(sample_size))),2) +z1 +z2 <- round(((upper - mu)/(sigma/sqrt(sample_size))),2) +z2 +beta <- round( 1 - pnorm( z1),4) +power_of_test <- 1 - beta +cat("beta is",beta) +cat("power of test is",power_of_test) \ No newline at end of file diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.9/Ex9_9.R b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.9/Ex9_9.R new file mode 100644 index 00000000..4d8b9a94 --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/CH9/EX9.9/Ex9_9.R @@ -0,0 +1,19 @@ +non_owners <- 100; +owners <- 100; +average_non_owner <- 2.70; +average_owner <- 2.54; +variance_non_owner <- 0.36; +variance_owner <- 0.40; +d_nod <- 0; +point_estimate <- average_non_owner - average_owner; +standard_error <- sqrt(((variance_non_owner)/non_owners) + (variance_owner)/owners); +z = round(((point_estimate - d_nod)/standard_error),2); +cat("value of z is",z) +alpha <- .05 +z.alpha <- round((qnorm(1 - alpha/2)),2) +z.alpha # critical value +cat("The value of z is",z) +cat("critical value is",z.alpha) +p_value <- round(((1-pnorm(z)) + pnorm(-z)),4) +cat("p value is",p_value) +cat("null hypothesis cannot be rejected and there is insufficient evidence") diff --git a/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/README.txt b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/README.txt new file mode 100644 index 00000000..aede837c --- /dev/null +++ b/Introduction_To_Probability_And_Statistics_by_William_Mendenhall,_Robert_J_Beaver,_And_Barbara_M_Beaver/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Shivam Sharma +Course: Bachelor Of Technology +Branch: Information Technology +College/Institute/Organization: Inderprastha Engineering College, Ghaziabad + +About The Book + +Book: Introduction To Probability And Statistics +Author: William Mendenhall, Robert J Beaver, And Barbara M Beaver +Publisher: Brooks Cole, Usa +Year Of Publication: 2008 +ISBN: 9780495389538 +Edition: 13 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.10/EX1_10.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.10/EX1_10.R new file mode 100644 index 00000000..3dd0d373 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.10/EX1_10.R @@ -0,0 +1,45 @@ +#Example 1.10. +#page 10 +#simulation of a deck of cards +deck <- c(rep("Diamonds",13), rep("Clubs",13), rep("Hearts",13), rep("Spades",13)) +deck +#simulation of picking 3 cards from a deck of 52 cards +picks <- sample(deck, size=3, replace= FALSE) +picks +#counting number of elements in a pick +count<-table(picks) +#initializing a list "alpha" to store the probability of not getting a heart for each 3 picks +alpha<-numeric(3) +#function to calculate probability +eventProbability <- function(cardnumber,decknumber) +{ + notHeartprobability <- (cardnumber/decknumber) + return (notHeartprobability) +} +#loop to store probability in list alpha +for (i in 1:3){ +# number of cards in deck before picking a card +deckNumber <- 52 +# number of cards other than heart before picking a card +notHeartNumber <- 39 +#after picking cards without replacement +cardsDrawn <- (i-1) +deckNumber <- deckNumber- cardsDrawn +print(deckNumber) +HeartDrawn <- (i-1) +notHeartNumber <- notHeartNumber - HeartDrawn +print(notHeartNumber) +#finding probability for each picking +heartprobability <- eventProbability (notHeartNumber,deckNumber) +#storing the probability to list +alpha [i]<- heartprobability +print(alpha) +print (heartprobability) +} + +print(alpha) +#finding the total probabilty of not getting a heart when piking 3 cards from 52 cards +probabilityNotHeart <- (alpha[1]*alpha[2]*alpha[3]) +print(probabilityNotHeart) +print(heartprobability) + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.11/EX1_11.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.11/EX1_11.R new file mode 100644 index 00000000..3ddfc5d4 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.11/EX1_11.R @@ -0,0 +1,27 @@ +#EX_1_11 +#page25 +#initialize variables +decreaseInGroups<- 4 +studentDecrease <- 1 +studentSlotInGroups <-12 +studentSlot <- 15 +#initialize the array of probability +alpha<-numeric(3) +#function to calculate probability +probability <- function(students,studSlot) +{prob <- (students/studSlot) +return (prob) +} +for(i in 1:3){ +probs <- probability(studentSlotInGroups,studentSlot) +print(probs) +alpha[i]<- probs +print(alpha) +studentSlotInGroups<- studentSlotInGroups - decreaseInGroups +print (studentSlotInGroups) +studentSlot <- studentSlot - studentDecrease +print(studentSlot) +}#loop to calculate probability +#calculating probability of having gaduate student in each group +totalProbability <- alpha[1]*alpha[2]*alpha[3] +print (totalProbability) diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.12/EX1_12.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.12/EX1_12.R new file mode 100644 index 00000000..1f54c3e8 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.12/EX1_12.R @@ -0,0 +1,11 @@ +#EX_1_12 +#page26 +mat<-numeric(3) +win <- matrix(c(0.3, 0.4, 0.5),nrow=3,byrow=TRUE, dimnames=list(c("p(B|A1)","P(B|A2)","P(B|A3)"),c("probability"))) #the probability of winning given playing with i'th opponent +win +playing <- matrix(c(0.5, 0.25, 0.25),nrow=3,byrow=TRUE,dimnames=list(c("p(A1)","P(A2)","P(A3)"),c("probability"))) #the probability of playing with i'th opponent +playing +for(i in 1:3){mat[i]<-playing[i]*win[i]} #to do the total multiplication theorem +mat#printing the product +totalprobability<-sum(mat) #total probability of winning,P(B) +totalprobability#prints the total probabilty of winning p(B) diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.18/EX1_18.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.18/EX1_18.R new file mode 100644 index 00000000..7d7aa6c8 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.18/EX1_18.R @@ -0,0 +1,12 @@ +#EX_1_18 +#page34 +number_flips <- 100 +# created coin object with head and tail +coin <- c("heads","tails") +#simulating the flip of the object coin +flips <- sample(coin, size=number_flips, replace= TRUE) +#probability of getting head if we specify that head and tail is equally likely +dbinom(1, size=1, prob=0.5) +#total probability of head and tail +dbinom(1, size=1, prob=0.5)#p(H1|D) +dbinom(1, size=1, prob=0.5)#p(H2|D) diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.2/EX1_2.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.2/EX1_2.R new file mode 100644 index 00000000..e439d687 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.2/EX1_2.R @@ -0,0 +1,17 @@ +# EX1_2 +#page 10 +number_flips <- 100 +# created coin object with head and tail +coin <- c("heads","tails") +#simulating the flip of the object coin +flips <- sample(coin, size=number_flips, replace= TRUE) +#counting the number of heads and tails in the flips +freq <- table(flips) +#typing the frequency of heads and tails +freq +#probability of getting head if we specify that head and tail is equally likely +dbinom(1, size=1, prob=0.5) +#total probability of head and tail +dbinom(1, size=1, prob=0.5)+ +dbinom(1, size=1, prob=0.5) + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.28/EX1_28.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.28/EX1_28.R new file mode 100644 index 00000000..b211897b --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.28/EX1_28.R @@ -0,0 +1,8 @@ +#EX_1_28 +#page45 +install.packages("prob") +library(prob) +permsn(4,2)#permutation of 4 letters out of which 2 is taken +combn(4,2)#combination of 4 letters out of which 2 is picked up +ncol(combn(4,2))#number of combinations when 4 letters from which 2 is picked out + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.29/EX1_29.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.29/EX1_29.R new file mode 100644 index 00000000..13ce7b84 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.29/EX1_29.R @@ -0,0 +1,35 @@ +#EX_1_29 +#page46 +TATTOO <- list("T","A","T","T","O","O")# listing the letters of Tattoo +L<-length(TATTOO) +M<-0 +N<-0 +R<-0 +for(i in 1:L)#loop to count the number of same type of letters in tattoo +{ + if(as.character(TATTOO[i])=="T") + { + M<-(M+1) + } + + else if(as.character(TATTOO[i])=="A") + { + N<- (N+1) + } + else if(as.character(TATTOO[i])=="O") + { + R<- (R+1) + } +} +#the counters in the loop will count the number of same letters +repetition<- matrix(c(M,N,R),nrow=3,byrow=T,dimnames = list(c("T","A","O"),c("repetition"))) +repetition#matrix give the number of repeated letters +Per<- function(p,q,s,t) +{ + X<-prod(factorial(p))/(factorial(q)*factorial(s)*factorial(t)) + return(X) + +}#function to calculate the permutation +p<-Per(L,M,N,R) +p + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.3/EX1_3.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.3/EX1_3.R new file mode 100644 index 00000000..2b70aa33 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.3/EX1_3.R @@ -0,0 +1,34 @@ +#EX_1_3 +#page 11 +Dice<- seq(1:4) +d<-0 +c<-0 +a<- numeric(2)#creating an array +Sample_Space<-expand.grid(Dice,Dice)#creating the sample space +Sum_Matrix <- matrix(nrow=4,ncol=4) #creating a sample matrix +#storing the sum of sample space of rolling 2 dice +for (i in 1:4) + { + for (j in 1:4) + { + a[1]<-i + a[2]<-j + Sum_Matrix[i,j]=sum(a)#stores the sum of the sample in the matrix b + if((Sum_Matrix[i,j]%%2)== 0)#to check whether the sum is even + { + print(Sum_Matrix[i,j]) + d <-d+1#count the even sums + }else + { + c<-c+1#count odd sums + } + } +} +total_sample_space<- nrow(Sample_Space)#finding the number of sample space +n<-total_sample_space#printing the sample space count +Even_Sum<- d/n +Even_Sum #printing the probability of getting even numbers +Odd_Sum<-c/n +Odd_Sum #printing the probability of getting odd numbers + + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.30/EX1_30.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.30/EX1_30.R new file mode 100644 index 00000000..b4df3ca1 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.30/EX1_30.R @@ -0,0 +1,15 @@ +#EX_1_30 +#page47 +install.packages("prob") +library(prob) +total_sample_space<- prod(factorial(16))/(factorial(4)*factorial(4)*factorial(4)*factorial(4)) +graduate<-letters[1:4]#creating sample spaceof 4 graduate +permsn(graduate,4)# sample space combination of 4 graduate in 4 groups +f1<-ncol(permsn(graduate,4))# number of combination of 4 graduate in 4 groups +#Take the remaining 12 undergraduate students and distribute them to the four groups (3 students in each). +c<-prod(factorial(12))/(factorial(3)*factorial(3)*factorial(3)*factorial(3)) +c +f2<-f1*c#total possibility of dividing the 4 graduate and 12 undergraduate students is randomly divided into four groups of 4. +f2 +p<-f2/total_sample_space +p#total probability of the sample space diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.6/EX1_6.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.6/EX1_6.R new file mode 100644 index 00000000..bf7cda16 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.6/EX1_6.R @@ -0,0 +1,23 @@ +#EX1_6.R +#page 19 +coins<- c("H","T","H","T","H","T") +for(i in 1:8){ +flips <- sample(coins, size=3, replace=FALSE) +print(flips) +} +A<-dbinom(2, size=3, prob=0.5) +dbinom(3, size=3, prob=0.5) +#probability of getting more heads than tails +p<-dbinom(3, size=3, prob=0.5)+ +dbinom(2, size=3, prob=0.5) +print(p) +#probability of first toss is a head +q<- 1-p +#probability of (A and B) +s<- 3/8 +#conditional probabilty p(A|B) +r<- s/q +print(r) + + + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.8/EX1_8.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.8/EX1_8.R new file mode 100644 index 00000000..d5a0e4f6 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.8/EX1_8.R @@ -0,0 +1,21 @@ +#EX_1_8 +#page 19 +p1<- 2/3 +#probabilty of team n succes +#p(SS)+P(FS)=1/2 +p2<- 1/2 +#probabilty atleast one got selected =p(SS)+p(SF)+p(FS) +p3<-3/4 +#Difference of p3 and p1= p(FS) +FS<-sum(p3,-p1) +FS +SF<-sum(p3,-p2) +SF +p4<-sum(p1,p2) +SS<-sum(p4,-p3) +SS +#the probability that it was designed by team N +#conditional probabilty +#P({FS}|{SF,FS}) +PN<- FS/sum(FS,SF) +PN#prints the probability that it is designed by N diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.9/EX1_9.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.9/EX1_9.R new file mode 100644 index 00000000..ba3935ed --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH1/EX1.9/EX1_9.R @@ -0,0 +1,32 @@ +#EX_1_9 +#page 21 +Rate<-100000# specifying the number of trials +Aircraft<- sample(c("no","yes"),size=Rate,replace=TRUE,prob=c(0.95,0.05)) #created the sample space of presence of aircraft +Radar<- rep(NA,Rate)#creating the radar sample array +#creating the sample space in which radar detects the aircraft eventhough there is not an aircraft +Radar[Aircraft=="no"]<-sample(c("detects","notdetect"),size=sum(Aircraft=="no"),replace=TRUE,prob=c(0.10,0.90)) +#Creating the sample space in which radar detects aircraft with the presence of aircraft +Radar[Aircraft=="yes"]<-sample(c("detects","notdetect"),size=sum(Aircraft=="yes"),replace=TRUE,prob=c(0.99,0.01)) +p1<-mean(Radar[Aircraft=="yes"]=="detects")# probability radar detects aircraft given aircraft present +p2<-mean(Radar[Aircraft=="yes"]=="notdetect")#probability radar not detects given aircraft is present +p3<- mean(Radar[Aircraft=="no"]=="detects")# probability radar detects given aircraft is not present +p4<-mean(Radar[Aircraft=="no"]=="notdetect")# probabilityradar not detects given aircraft is not present +p5<-mean(Aircraft=="yes")#probability of presence of aircraft +p6<-mean(Aircraft=="no")#probability aircraft is not present +#A = {an aircraft is present}, B = {the radar registers an aircraft presence} +#A! = {an aircraft is not present}, B! = {the radar does not register an aircraft presence}. +probability <- matrix(c(p1,p2,p3,p4,p5,p6), nrow=6, byrow=TRUE, dimnames =list(c("P(B|A)","P(B!|A)","P(B|A!)","P(B!|A!)","P(A)","P(A!)"),c("probability"))) +probability +Con_prob<- function(a,b) +{ + return(a*b) + +} +#P(false alarm) = P(A!B)=P(A!)P(B|A!) +p7<- Con_prob(p6,p3)#P(A!B) +p7 +#P(missed detection) = P(AB!)=P(A)P(B!|A) +p8<- Con_prob(p5,p2)# P(AB!) +p8 + + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.1/EX_2_1.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.1/EX_2_1.R new file mode 100644 index 00000000..d78ac511 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.1/EX_2_1.R @@ -0,0 +1,40 @@ +#EX_2_1 +#page 10 +x<-numeric(9)#creating the sample array +y<-numeric(4) +X<-c(-4:4)#creating the sample space of x and y +y<-c(1:4) +#function to caculate sample space of p(x) +px<-function(x) +{ + if(-4<=x&&x<=4) + { + return(1/9) + }else{ + return(0) + } +} +#creating the probability function of y +py<-function(y) +{ + if(1<=y&&y<=4) + { + return(2/9) + }else if(y==0) + { + return(1/9) + }else{ + return(0) + } +} +#printing the sample space of p(x) +for(i in 1:9) +{ + print(px(i-5)) +} +#printing the sample space of p(y) +for(i in 1:5) +{ + print(py(i-1)) + +} \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.11/EX_2_11.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.11/EX_2_11.R new file mode 100644 index 00000000..e09574e5 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.11/EX_2_11.R @@ -0,0 +1,17 @@ +#EX_2_11 +#page 29 +sum<-0 +mat<-matrix(c(16/48,12/48,9/48,0,4/48,6/48,0,0,1/48), nrow=3,ncol=3,byrow=T,dimnames= list(c(x=0:2),c(y=0:2))) +mat#the matrix of the joint PMF +x[2] +mat[1,1] + +for(i in 2:3) +{ + for(j in 2:3) + { + sum<-sum+mat[i,j] + } +} +sum# probabilty of atleast one wrong + \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.13/EX_2_13.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.13/EX_2_13.R new file mode 100644 index 00000000..17c9d71c --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.13/EX_2_13.R @@ -0,0 +1,42 @@ +#EX_2_13 +#page 31 +#x travel time of given message +#y the length of the given message +py<-function(y) +{ + if(y==100) + { + return(5/6) + }else if(y==10^4){ + return(1/6) + } +}#function to calculate the PMF (y) +pxy<<-function(x) +{ + if(x==0.01) + { + return(1/2) + }else if(x==0.1){ + return(1/3) + }else if(x==1){ + return(1/6) + } +}#function to calculate the PMF(x,10^2) +PXY<-function(x) +{ + if(x==1) + { + return(1/2) + }else if(x==10){ + return(1/3) + }else if(x==100){ + return(1/6) + } +}#function to calcualte the PMF(x,10^4) +#using the probability formula calculated each probability +px0.01<-py(100)*pxy(0.01) +px0.01 +px0.1<-py(100)*pxy(0.1) +px0.1 +px1<-(py(100)*pxy(1))+py(10^4)*PXY(1) +px1 \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.14/EX_2_14.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.14/EX_2_14.R new file mode 100644 index 00000000..df37cad8 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.14/EX_2_14.R @@ -0,0 +1,13 @@ +#EX_2_14 +#page 34 +#E[X]iseasily calculated using the total expectation theorem as +p<-numeric(3) +t<-numeric(3) +ex<-numeric(3) +p<-c(0.5,0.3,0.2) +t<-c(0.05,0.1,0.3) +for(i in 1:3) +{ + ex[i]<-prod(p[i],t[i]) +} +sum(ex)#E(x) is simpley calculated using total expectation theorem \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.16/EX_2_16.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.16/EX_2_16.R new file mode 100644 index 00000000..2c832311 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.16/EX_2_16.R @@ -0,0 +1,52 @@ +#EX_2_16 +#page 34 +install.packages("prob") +library(prob) +PXx<-numeric(3) +PXAx<-numeric(3) +toss<-matrix(nrow=4,ncol=4) +p<-numeric(4) +mat<-matrix(nrow=3,ncol=3) +coin<-c("H","T") +toss<-expand.grid(coin,coin) +toss#gives the sample space of all combination of 2 independent toss +table(toss) +nrow(toss)#gives number of rows +ncol(toss) +probspace(toss)#gives the probability of each sample in sample space +mat<-noorder(probspace(toss))#table the repeating probabilty + +mat[3]#takes the probabilty +#Let X be the number of heads and +#function to calculate the PMF of x +pxx<-function(x) +{ + if(x==0) + { + return(1/4) + }else if(x==1){ + return(0) + }else if(x==2){ + return(1/2) + } +} +#function to calculate the conditional PMF +pxax<-function(x) +{ + if(x==0) + { + return(1/2) + }else if(x==1){ + return(0) + }else if(x==2){ + return(1/2) + } +} +#loop to print the PMF(x) +for(i in 1:3) +{ + PXx[i]<-pxx(i-1) + PXAx[i]<-pxax(i-1) +} +PXx#print the PMF(x) +PXAx#print the conditonal PMF(X|A) diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.18/EX_2_18.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.18/EX_2_18.R new file mode 100644 index 00000000..fde923db --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.18/EX_2_18.R @@ -0,0 +1,16 @@ +#EX_2_18 +#page 40 +n<-100000 +binomial<-numeric(2) +#Xi be a random variable that encodes the response of the i th person: +Xi<-c(1,0)#1 if i th person approves C's performnce +#0 if the ith person dissapproves C's performance +binomial<-rbinom(Xi,n,0.5)#creating a random variable of the approval of c's performance +binomial#printing the random variable +p<-1/2#the common mean of appproval +q<-1-p#the common mean of dissapproval +sn<-binomial[1]/n#sn is the mean from the sample random variable +sn +Esn<-p#printing the expectation of the mean of sample space is the common mean +varsn<-prod(p,q)/n +varsn#variance of the mean \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.2/EX_2_2.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.2/EX_2_2.R new file mode 100644 index 00000000..86c60386 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.2/EX_2_2.R @@ -0,0 +1,28 @@ +#EX_2_2 +#page12 +install.packages("prob") +library(prob) +fx<-numeric(3)#initializing the probability mass function +x<-numeric(3)#initializing the x value +M<-numeric(3)#initializing the array to have the loop value to calculate mean +V<- numeric(3)#initializing the array to have the loop value of standard deviation +fx <-c(((1/4)^2),(2*1/4*3/4),(3/4)^2)#initializing the array of PMF +x<- c(0,1,2)#initializing the x variable +coin<- c("H","T")# initializing object coin +iidspace(coin,ntrials=2,probs=(c(0.75,0.25)))#sample space of tossing 2 coin with probability .75 of getting head +#for loop to calculate the product of PMF and x +for(i in 1:3) +{ + M[i]<-prod(fx[i],x[i]) +} +mean<-sum(M)#calculated the mean +mean# print the mean +#loop to calculate the variance +for(i in 1:3) +{ + V[i]<-(x[i]-mean)^2 +} +variance<-V#calcualted the variance +variance# print the variance +standard_deviation<-sqrt(variance)#standard deviation is the square root of variance +standard_deviation# print the standard deviation \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.3/EX_2_3.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.3/EX_2_3.R new file mode 100644 index 00000000..a1bdbba2 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.3/EX_2_3.R @@ -0,0 +1,59 @@ +#EX_2_3 +#page 14 +M<- numeric(9)#created the sample array +x<-numeric(9) +z<- numeric(9) +Z<-numeric(5) +V<- numeric(5) +PMFZ<-numeric(5) +x<-c(-4:4) +#function to create the sample space of PX(x) +PMF<-function(x) +{ + if(1<=x&&x<=9) + { + return(1/9) + }else{ + return(0) + } +} +for(i in 1:9) +{ + M[i]<-x[i]*PMF(i) +} +Ex<-sum(M) +Ex#the expected valur of Px(x) +#loop to calculate the Z +for(i in 1:9) +{ + z[i]<-(x[i]-mean)^2 +} +Z<-z[5:9] +Z#calculating the sample space of Z +PMFz<-function(z) +{ + if((z==1||z==4||z==9||z==16)&&z!=0) + { + return(2/9) + }else if(z==0){ + return(1/9) + }else{ + return(0) + } +} +#loop to print the PMF(z) +for(i in 1:5) +{ + print("PMF(z)") + print(PMFz(Z[i])) +} +#loop to calculate the multiplication of each element +for(i in 2:5) +{ + V[i]<- Z[i]*PMFz(1) +} +V +variance<-sum(V) +variance#calcualted total variance + + \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.4/EX_2_4.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.4/EX_2_4.R new file mode 100644 index 00000000..a2fc0984 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.4/EX_2_4.R @@ -0,0 +1,23 @@ +#EX_2_4 +#page 17 +#let p=0.15 +#(1-p)=0.85 +X<-numeric(2)#initializing the array of size 2 to store the varaible +px<-numeric(2)#initializing the array PX to store the probability of occuring the event +px1<-numeric(2)#initializing the array to store mean of X +px2<-numeric(2)#initializing the array to store mean of X^2 +X<-c(1,0)#the events +PX<-c(0.15,0.85)#probability of events +for(i in 1:2)#loop to clculate the product of events and the probability of occuring the events +{ + px1[i]<-X[i]*PX[i] +} +px1<-sum(px1)#calcualted the mean +for(i in 1:2)#;loop to calculate the product of square of event and the probabilty of occuring the events +{ + px2[i]<-X[i]^2*PX[i] +} +px2<-sum(px2)#calcualted the mean of square of the events +variance<-px2-px1^2#cacualted the variance +variance +prod(PX) diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.5/EX_2_5.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.5/EX_2_5.R new file mode 100644 index 00000000..e9756d63 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.5/EX_2_5.R @@ -0,0 +1,19 @@ +#EX_2_5 +#page 18 +x<-numeric(6)#initialize the array of size 6 to store the events +px<-numeric(6)#initialize the array to store the probaility of events +ex<-numeric(6)#initialize the array to store the product of probabilty and the events +ex1<-numeric(6)# initialize the array to store the product between the probaility and the events +x<-c(1:6)#the events +px<-1/6#the probabilty of events +for(i in 1:6)#loop to calcualte the product between the probabilty of events and between the square of events +{ + ex[i]<-prod(x[i],px) + ex1[i]<-prod(x[i]^2,px) +} +EX<-sum(ex)#calcualted the sum of E(X) +EX1<-sum(ex1)#calcualted the sum of E(X^2) +EX +EX1 +variance<-EX1-EX^2#calcualted the variance +variance# print the calcualted variance diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.7/EX_2_7.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.7/EX_2_7.R new file mode 100644 index 00000000..85108506 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.7/EX_2_7.R @@ -0,0 +1,21 @@ +#EX_2_7 +#page 20 +#Quiz problem +x1<-numeric(3)#creating the sample list +x2<-numeric(3) +p1<-numeric(3) +p2<-numeric(3) +ex1<-numeric(3) +ex2<-numeric(3) +x1<-c(0,100,300)#creating the sample space of the x1 and x2 +x2<-c(0,200,300) +p1<-c(0.2,0.8*0.5,0.5*0.8)#creating the sample space of the probabilty of both x1 and x2 +p2<-c(0.5,0.5*0.2,0.5*0.8) +#loop to calculate the multiplication of both probabilities +for(i in 1:3) +{ + ex1[i]<-prod(x1[i],p1[i]) + ex2[i]<-prod(x2[i],p2[i]) +} +sum(ex1)#the expected values of the both x1 and x2 +sum(ex2) \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.8/EX_2_8.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.8/EX_2_8.R new file mode 100644 index 00000000..cc85ccd4 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.8/EX_2_8.R @@ -0,0 +1,13 @@ +#EX_2_8 +#page 21 +# Average Speed Versus Average Time +t<-numeric(2)#initialize the array to store the time +p<-numeric(2)#initialize the array to store the probability +et<-numeric(2)#array to store the product +t<-c(2/5,2/30)#timre array +p<-c(0.6,0.4)#probability array +for(i in 1:2)#loop to calculate the product of probability and the time +{ + et[i]<-prod(t[i],p[i]) +} +sum(et)#calcualted the mean \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.9/EX_2_9.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.9/EX_2_9.R new file mode 100644 index 00000000..bf916b71 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH2/EX2.9/EX_2_9.R @@ -0,0 +1,7 @@ +#EX_2_9 +#page 25 +# Mean of the Binomial +x<-300#each 300 student get 1 PMF +p<-1/3#probaility of each getting A +e<-prod(x,p)#the mean E[X]=Sum((i=1to 300)*1/3) +e#printing the mean \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.11/EX_3_11.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.11/EX_3_11.R new file mode 100644 index 00000000..62a8d79a --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.11/EX_3_11.R @@ -0,0 +1,30 @@ +#EX_3_11 +#page 24 +# Mean and Variance of a Piecewise Constant PDF +x<-readline(prompt="x: ")#enter the random variable x in the console +#this enters the constant PDF of x +if(0<=x&&x<=1) + { + pA1<-1/3 + print("pA1:") + return(pA1) +}else if(1=x[i]){ + print("FX") + print(0) + }else{ + print("fx") + print(0) + } +} \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.3/EX_3_3.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.3/EX_3_3.R new file mode 100644 index 00000000..7ce62ab1 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.3/EX_3_3.R @@ -0,0 +1,18 @@ +#EX_3_3 +#page 6 +#function to print the sample space of fX(x) +fx<-function(x) + { + if(01/3){ + return(2) + } +} +#function to calcualte the PMF Py +pY<-function(gx) +{ + if(gx==1) + { + return(1/3) + }else if(gx==2){ + return(2/3) + } +} +#to calcualte the E(Y) +EY<-sum(pY(1)*gx(1/3),pY(2)*gx(2/3)) +EY + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.5/EX_3_5.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.5/EX_3_5.R new file mode 100644 index 00000000..5f48b186 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.5/EX_3_5.R @@ -0,0 +1,16 @@ +#EX_3_5 +#page 10 +lamda<-1/10 +px<-function(a,lamda) +{ + return(exp(1)^(-lamda*a)) +} +#function to calculate the probability +PX<-function(x) +{ + if(1/4<=x||x<=3/4) + { + return(px(1/4,1/10)-px(3/4,1/10)) + } +} +PX(1/4)#probabilty of meteorite lands between 6 am and 6 pm on the first day \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.7/EX_3_7.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.7/EX_3_7.R new file mode 100644 index 00000000..07d747e1 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.7/EX_3_7.R @@ -0,0 +1,22 @@ +#EX_3_7 +#page 15 +px<-numeric(10) +#we compute the FX(k)first and then the PMF +#functon to calculate the FX(k) +fx<-function(k) +{ + return((k/10)^3) +} +#function to calculate the FX(k-1) +fx1<-function(k) +{ + return(((k-1)/10)^3) +} +#to print the PMF +for(i in 1:10) +{ + px[i]<-fx(i)-fx1(i) +} +px#PMF calculated + + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.8/EX_3_8.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.8/EX_3_8.R new file mode 100644 index 00000000..d9be73e4 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.8/EX_3_8.R @@ -0,0 +1,26 @@ +#EX_3_8 +#page 19 +#Using the Normal Table +# Its CDF is denoted by phi, +pi<-3.14 +#function to calculate the CDF normal random variable +f<-function(t) +{ + return((1/sqrt(2*pi))*exp(1)^(-(t^2)/2)) +} +#to calculate the CDF of Y<=0.5 +f_0.5<-integrate(f,-Inf,0.5) +f_0.5$val +#to calculate the CDF of Y<=-0.5 +f_negative_0.5<-(1-f_0.5$val) +f_negative_0.5 +sd<-20#standard deviation +mean<-60#mean +y<-(80-mean)/20#calcualting the Y +y#Y is 1 +#calculate the CDF of Y<=80-60/20 is phi(1) +f_1<-integrate(f,-Inf,1) +f_1$val +#to calculate the CDF of Y>=80-60/20 +p_x_greater_80<-(1-f_1$val) +p_x_greater_80 \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.9/EX_3_9.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.9/EX_3_9.R new file mode 100644 index 00000000..2bef0083 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH3/EX3.9/EX_3_9.R @@ -0,0 +1,17 @@ +#EX_3_9 +binary_message<-c(-1,1)#the message send may be -1,1 +mean<-0#mean and standard deviation is given +sd<-1 +pi<-3.14 +variance<-sd^2 +#function to calculate the normal table +f<-function(y) +{ + return((1/sqrt(2*pi))*e^((-y^2)/2)) +} +#to calculate the CDF of sending sending message is -1 is normal table phi(1) +f1<-integrate(f,0,1) +f1$val +#probabilty of error +p_N_greater_1<-1-f1$val +p_N_greater_1 \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.1/EX_4_1.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.1/EX_4_1.R new file mode 100644 index 00000000..23b2454a --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.1/EX_4_1.R @@ -0,0 +1,12 @@ +#EX_4_1 +#page 2 +#Transform +x<-c(2,3,5)#creating the uniform random variable of x +px<-c(1/2,1/6,1/3)#creating the pdf function of x +Ms<-sum(1/2*exp(1)^2,1/6*exp(1)^3,1/3*exp(1)^5)#calculating the transform +Ms +par(mfrow=c(2,2))#creating the space for the plots to be plotted +curve((1/2*exp(1)^(2*x)),-10,10,col="red")#curve of the Ms function of x=2 +curve(1/3*exp(1)^(3*x),-10,10,col="violet")#curve of the Ms function of x=3 +curve(1/5*exp(1)^(3*x),-10,10,col="black")#curve of the Ms function of x=5 +plot(x,px,type="h",col="red")#plot the x vs px graph \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.13/EX_4_13.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.13/EX_4_13.R new file mode 100644 index 00000000..9b4d03d8 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.13/EX_4_13.R @@ -0,0 +1,61 @@ +#EX_4_13 +#page 14 +x<-numeric(3)#initializing the variables x,y,w +y<-numeric(3) +py<-numeric(3)#initializing the probability of each variable +w<-numeric(5) +py1<-numeric(3) +pw1<-numeric(5) +x<-c(1:3)#representing the sample space of each variable +y<-c(0:2) +w<-c(1:5) +px<-function(x)#function to print the probabilty of x +{ + if(1<=x&&x<=3) + { + return(1/3) + } + else + { + return(0) + } +} +py<-function(y)#function to print the sample space of probability of y +{ + if(y==0){ + return(1/2) +}else if(y==1){ + return(1/3) +}else if(y==2){ + return(1/6) +}else{ + return(0) +} +} +for(i in 1:3)#loop to print the probabilty of y +{ + py1[i]<-py(i-1) +} +py1#printing the probability +pw<-function(w)#function to print the sample space of probabilty of w +{ + if(w==1) + { + return(px(1)*py(0)) + }else if(w==2){ + return(sum(prod(px(1),py(1)),prod(px(2),py(0)))) + }else if(w==3){ + return(sum(prod(px(1),py(2)),prod(px(2),py(1)),prod(px(3),py(0)))) + }else if(w==4){ + return(sum(prod(px(2),py(2)),prod(px(3),py(1)))) + }else if(w==5){ + return(prod(px(3),py(2))) + }else{ + return(0) + } +} +for(i in 1:5)#loop to print the probabilty of w +{ + pw1[i]<-pw(i) +} +pw1#printing the probabilty diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.16/EX_4_16.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.16/EX_4_16.R new file mode 100644 index 00000000..ca574d1d --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.16/EX_4_16.R @@ -0,0 +1,18 @@ +#EX_4_16 +#page 23 +l<-8#define length of stick as 8 +vary<-function(l) +{ + return((l^2)/12) +}#function to calculate var(y) +f<-function(y) +{ + return((y^2)/(12*8)) +} +varxy<-1/4*vary(l) +varxy#to print var(x|y) +integral<-integrate(f,0,l)#to calculate E(var(x|y)) +Evarxy<-integral$val +Evarxy +varx<-sum(Evarxy,varxy) +varx#to final calcualtion of var(x) diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.20/EX_4_20.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.20/EX_4_20.R new file mode 100644 index 00000000..27f9c840 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.20/EX_4_20.R @@ -0,0 +1,38 @@ +#EX_4_20 +#page 24 +x<-numeric(3)#initializing the variables +x1<-numeric(3) +Y<-numeric(3) +x<-c(0:2)#sample space of x +fx<-c(1/3,1/3,2/3)#sample space of fx +#function to calculate the sample space of y +y<-function(x) +{ + if(x<1){ + return(1) + }else if(x>=1){ + return(2) + } +} +#loop to print the y sample space +for(i in 1:3) +{ + print(y(i-1)) +} +Exy<-c(1/2,3/2)#sample space of Exy +#function to calculate the probability of Exy +pExy<-function(Exy) +{ + if(Exy==1/2){ + return(1/3) + }else if(Exy==3/2){ + return(2/3) + } +} +MeanExy<-7/6#mean of E(x|y) +varExy<-sum(prod(pExy(1/2),((1/2-MeanExy)^2)),prod(pExy(3/2),((3/2-MeanExy)^2)))#calculating the variance of E(x|y) +varExy +varxy<-1/12 +Evarxy<-1/12 +varx<-sum(Evarxy,varExy)#calculating the variance of x +varx \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.21/EX_4_21.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.21/EX_4_21.R new file mode 100644 index 00000000..84f7ea9f --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.21/EX_4_21.R @@ -0,0 +1,11 @@ +#EX-4_21 +#page 27 +gas<-runif(1000,0,1000) +p<-1/2 +s<-1 +MNs<-1/8*(1+exp(1)^3)#the transform of binomial random variable of N open gas station +MNs +Mxs<-(((exp(1)^(1000*s))-1)/(1000*s))#transform of amount of gas available +Mxs +Mys<-(1/8)*(1+Mxs)^3 +Mys#transform assosiated with y \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.4/EX_4_4.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.4/EX_4_4.R new file mode 100644 index 00000000..9ee9c40d --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.4/EX_4_4.R @@ -0,0 +1,15 @@ +#EX_4_4 +#page 4 +#function to calculate the exponential randm variable of x +exponential_transform<-function(l,s){ + return(l/l-s) +} +#function to calculate the exponential transform of y +y<-function(a,b,l,s) +{ + (exp(1)^b*s)*l/l-a*s +} +print("l/l-s") +exponential_transform(1,0)#printing the both transform by giving certain values +y(2,3,1,1) + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.5/EX_4_5.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.5/EX_4_5.R new file mode 100644 index 00000000..93d11996 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.5/EX_4_5.R @@ -0,0 +1,16 @@ +#EX_4_5 +#page 5 +x<-numeric(3) +px<-numeric(3) +derrivative<-numeric(3) +x<-c(2,3,5)#creating the uniform random variable of x +px<-c(1/2,1/6,1/3)#creating the pdf function of x +Ms<-sum(1/2*exp(1)^2,1/6*exp(1)^3,1/3*exp(1)^5)#calculating the transform +ex<-expression(px*x*exp(1)^x*s) +derrivative<-D(ex,"s") +derrivative +mx<-expression((1/2*exp(1)^(2*s))+(1/6*exp(1)^(3*s))+(1/3*exp(1)^(5*s)))#to print the mx +ex<-D(mx,"s")#it gives the derrivative of mx +ex +ex2<-D(ex,"s")#it gives the second derrivative +ex2 \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.6/EX_4_6.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.6/EX_4_6.R new file mode 100644 index 00000000..dde34d55 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.6/EX_4_6.R @@ -0,0 +1,21 @@ +#EX_4_6 +#page 6 +x<-numeric(3) +px<-numeric(3) +derrivative<-numeric(3) +x<-c(2,3,5)#creating the uniform random variable of x +px<-c(1/2,1/6,1/3)#creating the pdf function of x +Ms<-sum(1/2*exp(1)^2,1/6*exp(1)^3,1/3*exp(1)^5)#calculating the transform +Ms +mx<-expression((1/2*exp(1)^(2*s))+(1/6*exp(1)^(3*s))+(1/3*exp(1)^(5*s)))#giving the expression +ex<-D(mx,"s")#finding the first derrivative of expression +ex +ex2<-D(ex,"s")#finding the second derrivative of the expression +ex2 +#finding the values of transforms with s=1 and s=0 +Mx<-((1/2*exp(1)^(2))+(1/6*exp(1)^(3))+(1/3*exp(1)^(5)))#s=1 +Mx +dMx<-(1/2*2+(1/6*3)+(1/3*5))#s=0 +dMx +d2Mx<-(1/2*4)+(1/6*9)+(1/3*25)#s=0 +d2Mx \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.7/EX_4_7.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.7/EX_4_7.R new file mode 100644 index 00000000..143b3b41 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.7/EX_4_7.R @@ -0,0 +1,11 @@ +#EX_4_7 +#page 8 +x<-c(-1,0,4,5) +px<-c(1/4,1/2,1/8,1/8) +Ms<-expression((1/4)*exp(1)^(-1*s)+(1/2)*exp(1)^(0*s)+(1/8)*exp(1)^(4*s)+(1/8)*exp(1)*(5*s))#expressing the transform function +s<-1#giving free variable s as 1 +Ms1<-function(a,b){ + return((1/a)*exp(1)^b) +}#function for calculating the transform at s=1 +Ms<-sum(Ms1(1/4,-1),Ms1(1/2,0),Ms1(1/8,4),Ms1(1/8,5))#the value of transform at free variable =1 +Ms \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.9/EX_4_9.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.9/EX_4_9.R new file mode 100644 index 00000000..039b1fe3 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH4/EX4.9/EX_4_9.R @@ -0,0 +1,11 @@ +#EX_4_9 +#page 9 +lamda<-c(6,4)#expressing lamda +p<-1/3#initiating probabilty of selecting one teller +s<-1#expressed the free variable as 1 +fx<-function(x) +{ + return((exp(1)^x)*((2/3)*6*exp(1)^(-6*x)+(1/3)*4*exp(1)^(-4*x))) +}#function for calculating the M(s) +Ms<-integrate(fx,0,Inf) #integrate to get the M(s) +Ms$val#giving the value of M(s) \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.12/EX_5_12.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.12/EX_5_12.R new file mode 100644 index 00000000..46984208 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.12/EX_5_12.R @@ -0,0 +1,13 @@ +#EX_5_12 +#page 24 +n<-56 +lamda<-2#callers depart with poisson process a rate of lamda + #the waiting time Y +EY<-n/lamda +#the function to calculate the probabilty you have to wait for more than an hour +PY60<-function(y) +{ + return((lamda^n)*(y^(n-1))*(exp(1)^(-lamda*y))/factorial(n-1)) +} +probability<-integrate(PY60, 60, Inf)#the integral function to calculate the probability of waiting more than an hour +probability$val diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.17/EX_5_17.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.17/EX_5_17.R new file mode 100644 index 00000000..329836d4 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.17/EX_5_17.R @@ -0,0 +1,12 @@ +#EX_5_17 +#page 30 +# Random incidence in a non-Poisson arrival process +T1<-15 +T2<-45 +#person arrives at interarrival time of 15 minute with probabilty 1/4 +p1<-1/4 +#person arrives at interarrival time of 45 is of probability 3/4 +p2<-3/4 +#the expected value of chosen interarrival time is +T<-sum((T1*p1),(T2*p2)) +T \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.5/EX_5_5.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.5/EX_5_5.R new file mode 100644 index 00000000..38347bfe --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.5/EX_5_5.R @@ -0,0 +1,27 @@ +#EX_5_5 +#page 13 +p<-0.01 +q<-1-p +pz1<-numeric(4)#representing a sample list +px1<-numeric(4) +#function to calculate PX(x) +px<-function(x) +{ + if(x==0) + { + return((1-0.01)^100) + }else if(x==2||x==5||x==10){ + return(prod(factorial(n),(p^x),q^(n-x))/prod(factorial(n-x),factorial(x))) + } +} +#printing the PX(x) +px1<-c(px(0),px(2),px(5),px(10)) +#function to calculate PZ(x) +pz<-function(x) +{ + (exp(1)^-1)/factorial(x) +} +#printing the PZ(x) +pz1<-c(pz(0),pz(2),pz(5),pz(10)) +px1 +pz1 diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.6/EX_5_6.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.6/EX_5_6.R new file mode 100644 index 00000000..ce946bb1 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.6/EX_5_6.R @@ -0,0 +1,9 @@ +#EX_5_6 +#page 14 +p<-0.0001#initializing the variables p,n,n1 +n<-(log(0.999,base=exp(1)))/(log(0.9999,base=exp(1))) +n1<-(-log(0.999,base=exp(1)))/p +Ps<-1-(1-p)^n#calcualating the probability of free variable S +Ps +poisS<-1-exp(1)^-(p*n1)#calcuating the probability of free variable using the poisson approximation +poisS \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.7/EX_5_7.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.7/EX_5_7.R new file mode 100644 index 00000000..03ca5ece --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.7/EX_5_7.R @@ -0,0 +1,13 @@ +#EX_5_7 +#page 19 +lamda<-0.2# initializing the variables lamda +#function to calculate the probability usung the poisson PMF +PMF<-function(lamda,T,k) +{ + return(prod((lamda*T)^k,(exp(1)^-(lamda*T)))/factorial(k)) +} +PMF(0.2,1,0)#PMF of different lamda,Time,and k value is being calculated +PMF(0.2,1,1) +PMF(0.2,24,0) +PMF24<-(PMF(0.2,1,0))^24#use poisson PMF +PMF24 \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.9/EX_5_9.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.9/EX_5_9.R new file mode 100644 index 00000000..3aeb9608 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH5/EX5.9/EX_5_9.R @@ -0,0 +1,7 @@ +#EX_5_9 +#page 19 +mue1<-5 +mue2<-3 +# the PMF of the total number of accidents between 8 am and 11 am? +PMF<-sum(5,(3*2)) +PMF# sum of indepemdent poisson random variable with parmeters 5& 3*2 diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.1/EX_6_1.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.1/EX_6_1.R new file mode 100644 index 00000000..37ed04ff --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.1/EX_6_1.R @@ -0,0 +1,9 @@ +#EX_6_1 +#page 2 +library(markovchain)#loading libraries +library(diagram) +p<-c(0.8,0.2,0.6,0.4) +probability<-matrix(p,nrow=2,ncol=2,byrow=T) +probability#probabilty matrix +plotmat(probability) + \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.11/EX_6_11.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.11/EX_6_11.R new file mode 100644 index 00000000..0bed0201 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.11/EX_6_11.R @@ -0,0 +1,23 @@ +#EX_6_11 +#page 26 +library(markovchain)#loading libraries +library(diagram) +par(mfrow=c(2,2))#to create matrix in the plot to accomodate the plot +x<-c(1,0,0,0,0,0.2,0.3,0.4,0.1,0,0,0.2,0,0.3,0.5,0,0,0,0.3,0.7,0,0,0,1,0)#transition elements of first transition +x2<-c(1,0,0,0,0.2,0.3,0.4,0.1,0,0.2,0,0.8,0,0,0,1)#elemennts in the second transition +p<-matrix(x,nrow=5,ncol=5,byrow=T) +p#to create the element matrix +transition<-c(1:5)#nsmes of the transition matrix +row.names(p)<-transition +colnames(p)<-transition +p +plotmat(p)#to plot the markov chain of transition matrix +new_transition<-matrix(x2,nrow=4,ncol=4,byrow=T)#new transition matrix +name<-c(1,2,3,6) +row.names(new_transition)<-name +colnames(new_transition)<-name +new_transition +plotmat(new_transition)#plotting the markov chain of the new transition matrix +#since it is a singular matrix can't solve in r +a2<-21/31 +a3<-29/31 \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.13/EX_6_13.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.13/EX_6_13.R new file mode 100644 index 00000000..9b6b83d5 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.13/EX_6_13.R @@ -0,0 +1,17 @@ +#EX_6_13 +#page 30 +m<-4 +i<-c(2,3) +mue<-c(0.6,-0.3,0.7,-0.4)#representing the multiplication vactors with mu +mat<-matrix(mue,nrow=2,ncol=2,byrow=T)#representing to matrix +mat +b<-matrix(c(1,1),nrow=2,ncol=1,byrow=T)#the solution matrix +b +m<-solve(mat,b)#this solve the both matrix to give the value of mu +mu<-matrix(m,nrow=2,ncol=1,byrow=T)#representing tthe valur of mu in a matrix +row.names(mu)<-c("mu1","mu2") +mu#represent the values of mu1, mu2 in the matrix "mu" +#let m=5 +transition<-c(1,0,0,0.3,0.4,0.3,0,0.3,0.4) +transition_mat<-matrix(transition,nrow=3,ncol=3,byrow=T) +plotmat(transition_mat)#markov chain representation of the transition matrix \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.14/EX_6_14.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.14/EX_6_14.R new file mode 100644 index 00000000..995e61c3 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.14/EX_6_14.R @@ -0,0 +1,15 @@ +#EX_6_14 +#page 32 +p<-c(0.8,0.2,0.6,0.4) +mat<-matrix(p,nrow=2,ncol=2,byrow=T)#probabilty matrix +mat +t<-c(0,0.6,1,0.2) +T<-matrix(t,nrow=2,ncol=2,byrow=T)#matrix to represent the t matrix +T +b<-matrix(c(1,1),nrow=2,ncol=1,byrow=T) +b +t1<-solve(T,b)#calculate the first passage time to state 1 from state2 +b1<-matrix(c(0,1),nrow=2,ncol=1,byrow=T) +t2<-solve(T,b1)#calculate the mean recurrence time +t1[1,1]#mean first passage time to state1 starting from sate2 +t2[1,1]#mean recurrence time to state 1 diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.2/EX_6_2.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.2/EX_6_2.R new file mode 100644 index 00000000..da99cf33 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.2/EX_6_2.R @@ -0,0 +1,26 @@ +#EX_6_2 +#page 4 +library(markovchain)#loading libraries +library(diagram) +matrix<-matrix(NA,nrow=4,ncol=4,byrow=T)#creating the sample matrix +#loop to enter the probabilty in the matrix +for(i in 1:4) +{ + for(j in 1:4) + { + if(i==1&&j==1) + { + matrix[i,j]<-1 + }else if(i==4&&j==4){ + matrix[i,j]<-1 + }else if(i==j&&i>1){ + matrix[i,j]<-0.4 + }else if(i>=2&&(j==(i-1)||j==(i+1))){ + matrix[i,j]<-0.3 + }else{ + matrix[i,j]<-0 + } + } +} +matrix#printing the matrix +plotmat(matrix)#markov chain representation of the matrix \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.4/EX_6_4.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.4/EX_6_4.R new file mode 100644 index 00000000..239f2a5d --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH6/EX6.4/EX_6_4.R @@ -0,0 +1,10 @@ +#EX_6_4 +#page 15 +p<-c(0.8,0.6,0.2,0.4) +prob<-matrix(p,nrow=2,ncol=2,byrow=T)#matrix of multiples of pi +prob +pi<-c(0.75,0.25) +mat<-matrix(pi,nrow=2,ncol=1,byrow=T)#created matrix of pi giving value of pi +mat +solve(prob,mat)#generate the solution of the pi + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.1/EX_7_1.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.1/EX_7_1.R new file mode 100644 index 00000000..93ede225 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.1/EX_7_1.R @@ -0,0 +1,32 @@ +#EX_7_1 +#page 3 +EX<-2#expected mean +#MArkov inequality asserts that +#function to calculatemthe Msrkov Inequality +PX<-function(x) +{ + if(x>=2&&x<3) + { + return(1) + }else if(x>=3&&x<4){ + return(2/3) + }else if(x>=4){ + return(2/4) + } +} +#function to calcualte the normal probability +px<-function(x) +{ + if(x>=2&&x<3) + { + return(0.5) + }else if(x>=3&&x<4){ + return(0.25) + }else if(x>=4){ + return(0) + } +} + +c<-c(PX(2),PX(3),PX(4),px(2),px(3),px(4)) +compare<-matrix(c,nrow=3,ncol=2,byrow=T) +compare#matrix to compare both Markov Inequality and normal proabability \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.10/EX_7_10.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.10/EX_7_10.R new file mode 100644 index 00000000..ff291c6b --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.10/EX_7_10.R @@ -0,0 +1,20 @@ +#EX_7_10 +#page 12 +n<-100#consider the case n=100 and e=0.1 +e<-0.1 +z<-function(e,n) +{ + return(2*e*sqrt(n)) +}#function to calculate the standardized value +Z<-z(e,n) +Z#2*0.01*sqrt(n)>= 1.96 +f<-function(t) +{ + return((1/sqrt(2*pi))*exp(1)^(-(t^2)/2)) +}#function to calculate the CDF normal random variable +phi<-integrate(f,-Inf,Z)#the normal CDF of 2 from normal table +phi$val#phi(2) +p<-2-(2*phi$val) +p#2-2phi(2*0.01·sqrt(n))<= 0.05 + + diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.11/EX_7_11.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.11/EX_7_11.R new file mode 100644 index 00000000..0d8c1066 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.11/EX_7_11.R @@ -0,0 +1,31 @@ +#EX_7_11 +#page 15 +n<-36 +p<-0.5 +P21<-numeric(22) +comb<-function(n,x) +{ + return(factorial(n)/factorial(n-x)/factorial(x)) +}#function to calculate the combination +for(i in 1:22) +{ + P21[i]<-comb(n,(i-1)) +} +P21#exact valuep(Sn<=21) +p<-sum(P21*(0.5^36)) +f<-function(t) +{ + return((1/sqrt(2*pi))*exp(1)^(-(t^2)/2)) +}#function to calculate the CDF normal random variable +p21<-integrate(f,-Inf,1) +p21$val#the central limit approximation +P21<-integrate(f,Inf,1.17)#Using the proposed re???nement +P21$val#which is much closer to the exact value +z1<-(19.5-18)/3 +z2<-(18.5-18)/3 +p1<-integrate(f,-Inf,z1) +p2<-integrate(f,-Inf,z2) +p19<-p1$val-p2$val +p19# de Moivre - Laplace formula also allows us to approximate the probability of a single value +P19<-comb(n,19)*(0.5^36) +P19#exact value P(Sn=19) \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.4/EX_7_4.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.4/EX_7_4.R new file mode 100644 index 00000000..98cea84d --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.4/EX_7_4.R @@ -0,0 +1,9 @@ +#EX_7_4 +#page 6 +#polling +PMnp<-function(n,e) +{ + return(1/(4*n*e^2)) +}#function to calculate the chebyshev inequality +PMnp(100,0.1) +PMnp(1000000,0.01)# calculated the chebyshev inequality \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.8/EX_7_8.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.8/EX_7_8.R new file mode 100644 index 00000000..105cf38d --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.8/EX_7_8.R @@ -0,0 +1,22 @@ +#EX_7_8 +#page 11 +n<-100#number of packages loaded +p1<-5#weights are uniformly distributed between 5and 50 +p2<-50 +pi<-3.14 +#mean and variance of single package +mue<-sum(p1,p2)/2 +mue +var<-sum(50,-5)^2/12 +var +z<-(3000-prod(100,mue))/sqrt(var*100)#normalized value of the mean and variance +z +#function to calculate the CDF normal random variable +f<-function(t) +{ + return((1/sqrt(2*pi))*exp(1)^(-(t^2)/2)) +} +phi1.92<-integrate(f,-Inf,1.92)#calculate the CDF of normal random variable from the normal table +phi1.92$val +p_greater_3000<-1-phi1.92$val#the desired probability that the total weight exceeds 3000pounds +p_greater_3000 \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.9/EX_7_9.R b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.9/EX_7_9.R new file mode 100644 index 00000000..91b47fd2 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/CH7/EX7.9/EX_7_9.R @@ -0,0 +1,15 @@ +#EX_7_9 +#page 12 +#processing time is independent random variable between 1and 5 +mue<-3#the variance and the mean +var<-16/12 +var +n<-100#the number of parts +z<-(320-(n*mue))/sqrt(var*n) +z#calculated the normalized value +f<-function(t) +{ + return((1/sqrt(2*pi))*exp(1)^(-(t^2)/2)) +}#function to calculate the CDF normal random variable +phi1.73<-integrate(f,-Inf,1.73)#the desired approximation gives p(S100>320) it is t from the normal table +phi1.73$val \ No newline at end of file diff --git a/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/README.txt b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/README.txt new file mode 100644 index 00000000..b3862b93 --- /dev/null +++ b/Introduction_To_Probability_by_Dimitri_P._Bertsekas_And_John_N._Tsitsiklis/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Midhun C Kachappilly +Course: B-tech +Branch: Electrical Engineering +College/Institute/Organization: Government Engineering College Barton Hill + +About The Book + +Book: Introduction To Probability +Author: Dimitri P. Bertsekas And John N. Tsitsiklis +Publisher: Athena Scientific +Year Of Publication: 2008 +ISBN: 978-1-886529-23-6 +Edition: 2 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.1/example1_sect1_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.1/example1_sect1_1.zip new file mode 100644 index 00000000..a78af5ae Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.1/example1_sect1_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.3/example3_sec1_1.R b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.3/example3_sec1_1.R new file mode 100644 index 00000000..12a82a3a --- /dev/null +++ b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.3/example3_sec1_1.R @@ -0,0 +1,6 @@ +#Example 3, page 3 +#Find the solution for: x + 2y + 3z =6 ; 2x - 3y +2z =14 ; 3x + y - z= -2 ; +A= matrix(c(1,2,3,2,-3,2,3,1,-1),3,3,T) +b= matrix(c(6,14,-2),3,1,T) +#value of x,y & z are: +solve(A,b) \ No newline at end of file diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.4/example4_sec1_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.4/example4_sec1_1.zip new file mode 100644 index 00000000..65416fa1 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.4/example4_sec1_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.5/example5_sec1_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.5/example5_sec1_1.zip new file mode 100644 index 00000000..b33c5146 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.5/example5_sec1_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.6/example6_sec1_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.6/example6_sec1_1.zip new file mode 100644 index 00000000..f14b977d Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.1.6/example6_sec1_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.10/example10_sec1_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.10/example10_sec1_2.zip new file mode 100644 index 00000000..bb1cb18e Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.10/example10_sec1_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.12/example12_sec1_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.12/example12_sec1_2.zip new file mode 100644 index 00000000..cd96122e Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.12/example12_sec1_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.14/example14_sec1_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.14/example14_sec1_2.zip new file mode 100644 index 00000000..8da46a2e Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.14/example14_sec1_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.15/example15_sec1_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.15/example15_sec1_2.zip new file mode 100644 index 00000000..f4f69fed Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.15/example15_sec1_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.3/example3_sec1_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.3/example3_sec1_2.zip new file mode 100644 index 00000000..e9f8795b Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.2.3/example3_sec1_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.1/example1_sec1_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.1/example1_sec1_3.zip new file mode 100644 index 00000000..176e5cf7 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.1/example1_sec1_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.10/example10_sec1_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.10/example10_sec1_3.zip new file mode 100644 index 00000000..04049615 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.10/example10_sec1_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.21/example21_sec1_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.21/example21_sec1_3.zip new file mode 100644 index 00000000..fc7faa65 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.21/example21_sec1_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.23/example23_sec1_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.23/example23_sec1_3.zip new file mode 100644 index 00000000..f79a855d Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.23/example23_sec1_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.4/example4_sec1_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.4/example4_sec1_3.zip new file mode 100644 index 00000000..0cd679bc Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.4/example4_sec1_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.5/example5_sec1_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.5/example5_sec1_3.zip new file mode 100644 index 00000000..c4376fa7 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.3.5/example5_sec1_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.10/example10_sec1_4.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.10/example10_sec1_4.zip new file mode 100644 index 00000000..c1f41547 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.10/example10_sec1_4.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.11/example11_sec1_4.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.11/example11_sec1_4.zip new file mode 100644 index 00000000..04e24aa7 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.11/example11_sec1_4.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.2/example2_sec_1_4.R b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.2/example2_sec_1_4.R new file mode 100644 index 00000000..8ca4492b --- /dev/null +++ b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.2/example2_sec_1_4.R @@ -0,0 +1,6 @@ +#Example 2, section 1.4, page 41 +#Solve for A+ (-A) where A is a matrix: +A<- matrix(c(2,-4,3,5,4,-2),c(2,3)) +minus= (-A) +solution <- A + minus +print(solution) #Zero matrix or additive identity diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.5/example5_sec1_4.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.5/example5_sec1_4.zip new file mode 100644 index 00000000..7e69496b Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.4.5/example5_sec1_4.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.5.3/example3_sec1_5.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.5.3/example3_sec1_5.zip new file mode 100644 index 00000000..2b697fe0 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.5.3/example3_sec1_5.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.6.4/example4_sec1_6.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.6.4/example4_sec1_6.zip new file mode 100644 index 00000000..acc33553 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.6.4/example4_sec1_6.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.6.5/example5_sec1_6.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.6.5/example5_sec1_6.zip new file mode 100644 index 00000000..175c9f45 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.6.5/example5_sec1_6.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.4/example4_sec1_7.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.4/example4_sec1_7.zip new file mode 100644 index 00000000..895d87e8 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.4/example4_sec1_7.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.5/example5_sec1_7.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.5/example5_sec1_7.zip new file mode 100644 index 00000000..f9d3522e Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.5/example5_sec1_7.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.6/example6_sec1_7.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.6/example6_sec1_7.zip new file mode 100644 index 00000000..621ebe72 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH1/EX1.7.6/example6_sec1_7.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.1.2/example2_sec10_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.1.2/example2_sec10_1.zip new file mode 100644 index 00000000..8d7f650d Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.1.2/example2_sec10_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.2.12/example12_sec10_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.2.12/example12_sec10_2.zip new file mode 100644 index 00000000..bbf58790 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.2.12/example12_sec10_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.2.3/example3_sec10_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.2.3/example3_sec10_2.zip new file mode 100644 index 00000000..ee5841b9 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH10/EX10.2.3/example3_sec10_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.12/example12_sec2_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.12/example12_sec2_2.zip new file mode 100644 index 00000000..6c478fc9 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.12/example12_sec2_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.14/2.2.14.R b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.14/2.2.14.R new file mode 100644 index 00000000..e05b5826 --- /dev/null +++ b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.14/2.2.14.R @@ -0,0 +1,45 @@ +#Example 14 ,section 2.2, page 144 +#Consider the digraph in figure 2.14, and verify A(G)+[A(G)]^2 +[A(G)]^3 + [A(G)]^4 = E to show that digraph is strongly connected. + + +library(igraph) +simple.graph<- graph_from_literal(P1-+P2,P2-+P3,P3++P4, P2-+P4,P3-+P5,P5-+P4,P1++P4,P5-+P2) +plot.igraph(simple.graph) +A<-get.adjacency(simple.graph) +square=A%*%A +cube= square%*% A +fourth= cube%*% A +solution<- A + square + cube + fourth +print(solution) + +check = function(M) +{ + y<-0 + count<-0 + M<-matrix(1:25,nrow=5,ncol=5) + + for(num in M) + if(num>0) + { + count=count+1 + if(count==25) + { + print("Matrix is strongly connected") + y<-TRUE + } + else + { next } + } + else + { + print("Matrix is not connected strongly") + break + } + + return(y) + +} + +check(solution) #returns true if all entries of matrix are non zero,hence verified that matrix is strongly connected . + + diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.5/example5_sec2_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.5/example5_sec2_2.zip new file mode 100644 index 00000000..cdd2ded3 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.5/example5_sec2_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.6/example6_sec2_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.6/example6_sec2_2.zip new file mode 100644 index 00000000..5716b917 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.2.6/example6_sec2_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.4.1/example1_sec2_4.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.4.1/example1_sec2_4.zip new file mode 100644 index 00000000..78037c64 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.4.1/example1_sec2_4.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.1/example1_sec2_5.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.1/example1_sec2_5.zip new file mode 100644 index 00000000..cac32541 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.1/example1_sec2_5.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.3/example3_sec2_5.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.3/example3_sec2_5.zip new file mode 100644 index 00000000..8bb36edc Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.3/example3_sec2_5.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.7/example7_sec2_5.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.7/example7_sec2_5.zip new file mode 100644 index 00000000..c45db187 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX2.5.7/example7_sec2_5.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX7.2.2/example2_sec7_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX7.2.2/example2_sec7_2.zip new file mode 100644 index 00000000..4f26dbfd Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH2/EX7.2.2/example2_sec7_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.10/example10_sec3_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.10/example10_sec3_1.zip new file mode 100644 index 00000000..859f5026 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.10/example10_sec3_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.11/example11_sec3_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.11/example11_sec3_1.zip new file mode 100644 index 00000000..293e3505 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.11/example11_sec3_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.18/example18_sec3_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.18/example18_sec3_1.zip new file mode 100644 index 00000000..bd97210d Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.18/example18_sec3_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.19/example19_sec3_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.19/example19_sec3_1.zip new file mode 100644 index 00000000..04054618 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.19/example19_sec3_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.5/example5_sec3_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.5/example5_sec3_1.zip new file mode 100644 index 00000000..6fcec610 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.5/example5_sec3_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.7/example7_sec3_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.7/example7_sec3_1.zip new file mode 100644 index 00000000..562f4b2a Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.7/example7_sec3_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.9/example9_sec3_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.9/example9_sec3_1.zip new file mode 100644 index 00000000..c1f2fac3 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.1.9/example9_sec3_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.1/example1_sec3_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.1/example1_sec3_2.zip new file mode 100644 index 00000000..e24886af Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.1/example1_sec3_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.2/example2_sec3_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.2/example2_sec3_2.zip new file mode 100644 index 00000000..e8fa4687 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.2/example2_sec3_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.5/example5_sec3_2.R b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.5/example5_sec3_2.R new file mode 100644 index 00000000..258cf8f2 --- /dev/null +++ b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.5/example5_sec3_2.R @@ -0,0 +1,8 @@ +#Example 5,section 3.2, page 200 +#Compute adjoint of matrix A: + +library(matlib) +A<- matrix(c(3,-2,1,5,6,2,1,0,-3),nrow=3,byrow = TRUE) +print(A) + +adjoint(A) \ No newline at end of file diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.7/example7_sec3_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.7/example7_sec3_2.zip new file mode 100644 index 00000000..a80e214c Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.7/example7_sec3_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.9/example9_sec3_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.9/example9_sec3_2.zip new file mode 100644 index 00000000..bd522945 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.2.9/example9_sec3_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.3.14/example14_sec3_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.3.14/example14_sec3_3.zip new file mode 100644 index 00000000..e722d368 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH3/EX3.3.14/example14_sec3_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.14/example14_sec4_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.14/example14_sec4_1.zip new file mode 100644 index 00000000..1e3ac7e3 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.14/example14_sec4_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.15/example15_sec4_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.15/example15_sec4_1.zip new file mode 100644 index 00000000..711c0103 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.15/example15_sec4_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.16/example16_sec4_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.16/example16_sec4_1.zip new file mode 100644 index 00000000..3194bf6f Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.16/example16_sec4_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.3/4.1.3.R b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.3/4.1.3.R new file mode 100644 index 00000000..2059c2b8 --- /dev/null +++ b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.3/4.1.3.R @@ -0,0 +1,9 @@ +#Example 3,section 4.1, page 216 +#Show vector U in cartesian coordinate system: + +library(graphics) +x <- c(0,2) +y <- c(0,3) +plot.new() +plot.default(c(0,4),c(0,4)) +arrows(x0=0,y0=0,x1=2,y1=3,length=0.15,angle=20,code=2 ,lwd=2) diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.6/example6_sec4_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.6/example6_sec4_1.zip new file mode 100644 index 00000000..616c083e Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.6/example6_sec4_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.7/example7_sec4_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.7/example7_sec4_1.zip new file mode 100644 index 00000000..e3a02dd9 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.7/example7_sec4_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.8/example8_sec4_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.8/example8_sec4_1.zip new file mode 100644 index 00000000..6683f89e Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.8/example8_sec4_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.9/example9_sec4_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.9/example9_sec4_1.zip new file mode 100644 index 00000000..186d517d Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.1.9/example9_sec4_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.10/example10_sec4_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.10/example10_sec4_2.zip new file mode 100644 index 00000000..1fa7a40e Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.10/example10_sec4_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.13/example13_sec4_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.13/example13_sec4_2.zip new file mode 100644 index 00000000..2f7f5aa4 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.13/example13_sec4_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.2/example2_sec4_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.2/example2_sec4_2.zip new file mode 100644 index 00000000..b56c4e83 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.2/example2_sec4_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.3/example3_sec4_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.3/example3_sec4_2.zip new file mode 100644 index 00000000..930d1aad Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.2.3/example3_sec4_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.3.2/example2_sec4_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.3.2/example2_sec4_3.zip new file mode 100644 index 00000000..d7ff5465 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.3.2/example2_sec4_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.3.5/example5_sec4_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.3.5/example5_sec4_3.zip new file mode 100644 index 00000000..8d636cd0 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH4/EX4.3.5/example5_sec4_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.1/example1_sec5_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.1/example1_sec5_1.zip new file mode 100644 index 00000000..b325a80c Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.1/example1_sec5_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.4/example4_sec5_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.4/example4_sec5_1.zip new file mode 100644 index 00000000..93bfb13d Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.4/example4_sec5_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.6/example6_sec5_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.6/example6_sec5_1.zip new file mode 100644 index 00000000..351e3909 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH5/EX5.1.6/example6_sec5_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.1.7/example7_sec6_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.1.7/example7_sec6_1.zip new file mode 100644 index 00000000..ec33f894 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.1.7/example7_sec6_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.11/example11_sec6_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.11/example11_sec6_2.zip new file mode 100644 index 00000000..a677efa2 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.11/example11_sec6_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.12/example12_sec6_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.12/example12_sec6_2.zip new file mode 100644 index 00000000..bb8646f8 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.12/example12_sec6_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.3/example3_sec6_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.3/example3_sec6_2.zip new file mode 100644 index 00000000..c6861349 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.2.3/example3_sec6_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.3.2/example2_sec6_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.3.2/example2_sec6_3.zip new file mode 100644 index 00000000..b73b0a77 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.3.2/example2_sec6_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.3.8/example8_sec6_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.3.8/example8_sec6_3.zip new file mode 100644 index 00000000..8bbc739d Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.3.8/example8_sec6_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.4.2/example2_sec6_4.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.4.2/example2_sec6_4.zip new file mode 100644 index 00000000..3b58b63e Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.4.2/example2_sec6_4.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.4.5/6.4.5.R b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.4.5/6.4.5.R new file mode 100644 index 00000000..b0d6c79c --- /dev/null +++ b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.4.5/6.4.5.R @@ -0,0 +1,57 @@ +#Example 5,section 6.4,page 309 +#Let S={v1,v2,v3,v4,v5} be a set of vectors in R4,where ; +v1<-c(1,2,-2,1) +v2<-c(-3,0,-4,3) +v3<-c(2,1,1,-1) +v4<-c(-3,3,-9,-6) +v5<-c(9,3,7,-6) + +library(matlib) +A<-matrix(c(v1,v2,v3,v4,v5),c(4,5)) +A +b<-matrix(c(0,0,0,0),c(4,1)) +echelForm<-echelon(A,b) +echelForm<-echelForm[,-4] +echelForm + +#subsetting matrices , we get +V_1<-echelForm[c(1,2,3,4),c(1)] +V_2<-echelForm[c(1,2,3,4),c(2)] +V_3<-echelForm[c(1,2,3,4),c(3)] +V_4<-echelForm[c(1,2,3,4),c(4)] +V_5<-echelForm[c(1,2,3,4),c(5)] + +check= function(x) +{ + p<-0 + count<-0 + ans<-0 + for(num in x) + { + p=p+num + count=count+1 + if(count==4) + { + ans<-p*p*p + + if(ans==1) + print("vector has leading 1") + else + print("Do not have leading 1") + } + else + { + next + } + + + } + +} + +check(V_1) +check(V_2) +check(V_3) +check(V_4) +check(V_5) +#we can conclde that vectors v1,v2 is a basis for W=span S \ No newline at end of file diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.5.3/example3_sec6_5.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.5.3/example3_sec6_5.zip new file mode 100644 index 00000000..beefaaed Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.5.3/example3_sec6_5.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.6.5/example5_sec6_6.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.6.5/example5_sec6_6.zip new file mode 100644 index 00000000..955d3c46 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.6.5/example5_sec6_6.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.6.8/example8_sec6_6.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.6.8/example8_sec6_6.zip new file mode 100644 index 00000000..8e7a164c Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.6.8/example8_sec6_6.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.7.1/example1_sec6_7.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.7.1/example1_sec6_7.zip new file mode 100644 index 00000000..40dce4a4 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.7.1/example1_sec6_7.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.8.4/example4_sec6_8.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.8.4/example4_sec6_8.zip new file mode 100644 index 00000000..e3520dea Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH6/EX6.8.4/example4_sec6_8.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.1/example1_sec7_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.1/example1_sec7_2.zip new file mode 100644 index 00000000..ee6b9ab7 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.1/example1_sec7_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.2/example2_sec7_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.2/example2_sec7_2.zip new file mode 100644 index 00000000..4f26dbfd Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.2/example2_sec7_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.4/example4_sec7_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.4/example4_sec7_2.zip new file mode 100644 index 00000000..dad045b7 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH7/EX7.2.4/example4_sec7_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.2/example2_sec8_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.2/example2_sec8_1.zip new file mode 100644 index 00000000..3133e9d9 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.2/example2_sec8_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.3/example3_sec8_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.3/example3_sec8_1.zip new file mode 100644 index 00000000..d6e2b26d Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.3/example3_sec8_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.5/example5_sec8_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.5/example5_sec8_1.zip new file mode 100644 index 00000000..0301c50e Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.5/example5_sec8_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.6/example6_sec8_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.6/example6_sec8_1.zip new file mode 100644 index 00000000..ab282cbc Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.6/example6_sec8_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.8/example8_sec8_1.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.8/example8_sec8_1.zip new file mode 100644 index 00000000..c9977da8 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.1.8/example8_sec8_1.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.2.1/example1_sec8_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.2.1/example1_sec8_2.zip new file mode 100644 index 00000000..4245b2b9 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.2.1/example1_sec8_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.2.3/example3_sec8_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.2.3/example3_sec8_2.zip new file mode 100644 index 00000000..3ef7b324 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.2.3/example3_sec8_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.3.1/example1_sec8_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.3.1/example1_sec8_3.zip new file mode 100644 index 00000000..12324a45 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.3.1/example1_sec8_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.3.5/example5_sec8_3.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.3.5/example5_sec8_3.zip new file mode 100644 index 00000000..c0ec6d7d Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH8/EX8.3.5/example5_sec8_3.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.2.5/example5_sec9_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.2.5/example5_sec9_2.zip new file mode 100644 index 00000000..fe0a08c9 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.2.5/example5_sec9_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.2.6/example6_sec9_2.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.2.6/example6_sec9_2.zip new file mode 100644 index 00000000..a7e43616 Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.2.6/example6_sec9_2.zip differ diff --git a/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.4.7/example7_sec9_4.zip b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.4.7/example7_sec9_4.zip new file mode 100644 index 00000000..14fb9f2f Binary files /dev/null and b/Introductory_Linear_Algebra:_An_Applied_First_Course_by_Bernard_Kolman_&_David_.r._Hill/CH9/EX9.4.7/example7_sec9_4.zip differ diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.1/Ex1.1.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.1/Ex1.1.R new file mode 100644 index 00000000..5fbc4950 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.1/Ex1.1.R @@ -0,0 +1,41 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Gaussian Elimination +#Page No.15 / 1-3 +#Prob 1 +#1.1.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('performing Gaussian elimination') +av<-c(1,5,-2,-7) +a=matrix(av, + nrow=2, + ncol=2, + byrow=TRUE) +print('the co-efficient matrix is:') +print(a) +bv<-c(7,-5) +b=matrix( + bv, + nrow=2, + ncol=1, + byrow=TRUE) +cm=cbind(a,b) +print('the augmented matrix is:') +print(cm) +print('R2=R2+2*R1') +cm[2,]=cm[2,]+2*cm[1,] +print(cm) +print('R2=(1/3)*R2') +cm[2,]=(1/3)*cm[2,] +print(cm) +print('R1=R1-5*R2') +cm[1,]=cm[1,]-5*cm[2,] +print(cm) +x1=cm[1,3]/cm[1,1] +x2=cm[2,3]/cm[2,2] +cat('the solution is: x1 =',x1,' x2 =',x2) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.10/Ex1.10.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.10/Ex1.10.R new file mode 100644 index 00000000..dd3cfb62 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.10/Ex1.10.R @@ -0,0 +1,30 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Determine if b is in W +#Page No.25 / 1-13 +#Prob 25 +#1.3.25 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(1,0,-4,4,0,3,-2,1,-2,6,3,-4) + +a=matrix( + av, + nrow=3, + ncol=4, + byrow=TRUE +) + +print('the augmented matrix is:') +print(a) + +print('R3=R3+2*R1') +a[3,]=a[3,]+2*a[1,] +print(a) +print('R3=R3-2*R2') +a[3,]=a[3,]-2*a[2,] +print(a) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.11/Ex1.11.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.11/Ex1.11.R new file mode 100644 index 00000000..0b773db1 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.11/Ex1.11.R @@ -0,0 +1,71 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Applications of Gaussian Elimination +#Page No.26 / 1-14 +#Prob 31 +#1.3.31 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('1 gram at (0,1), 1 gram at (8,1) and 1 gram at (2,4)') +m1v<-c(0,1) +m2v<-c(8,1) +m3v<-c(2,4) +m1=matrix(m1v, + nrow=2, + ncol=1, + byrow=TRUE) +m2=matrix(m2v, + nrow=2, + ncol=1, + byrow=TRUE) +m3=matrix(m3v, + nrow=2, + ncol=1, + byrow=TRUE) +cm=(1/3)*(1*m1+1*m2+1*m3) +print('centre of mass is at') +print(cm) +print('the new weight of the system=9 grams') +print('new centre of mass is at') +sv<-c(2,2) +s=matrix( + sv, + nrow=2, + ncol=1, + byrow=TRUE +) +print(s) +print('let w1,w2 and w3 be the weights added at (0,1),(8,1) and (2,4) respectively') +print('hence, w1+w2+w3=6') +print('using the formula for the centre of mass, we get') +print('8*w2+2*w3=8 and w1+w2+4*w3=12') +av<-c(1,1,1,6,0,8,2,8,1,1,4,12) +a=matrix( + av, + nrow=3, + ncol=4, + byrow=TRUE +) +print('the augmented matrix is:') +print(a) +print('R3=R3-R1') +a[3,]=a[3,]-a[1,] +print(a) +print('R3=(1/3)*R3') +a[3,]=(1/3)*a[3,] +print(a) +print('R2=R2-2*R3 and R1=R1-R3') +a[2,]=a[2,]-2*a[3,] +a[1,]=a[1,]-a[3,] +print(a) +print('R1=R1-(1/8)*R2') +a[1,]=a[1,]-(1/8)*a[2,] +print(a) +print('R2=(1/8)*R2') +a[2,]=(1/8)*a[2,] +print(a) +cat(sprintf('Add %.1f grams at (0,1), %.1f grams at (8,1) and %d grams at (2,4)',a[1,4],a[2,4],a[3,4]) ) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.12/Ex1.12.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.12/Ex1.12.R new file mode 100644 index 00000000..d4779246 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.12/Ex1.12.R @@ -0,0 +1,43 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Vectors as columns of a matrix +#Page No.28 / 1-16 +#Prob 7 +#1.4.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the three vectors are:') +uv<-c(4,-1,7,-4) +vv<-c(-5,3,-5,1) +wv<-c(7,-8,0,2) +u<-matrix(uv, + nrow=4, + ncol=1, + byrow=TRUE) +v<-matrix(vv, + nrow=4, + ncol=1, + byrow=TRUE) +w<-matrix(wv, + nrow=4, + ncol=1, + byrow=TRUE) + +print(u) +print(v) +print(w) +print('u v and w form the columns of A') +A=cbind(u,v,w) +print(A) +print('the augmented matrix is:') +nmv<-c(6,-8,0,-7) +nm<-matrix(nmv, + nrow=4, + ncol=1, + byrow=TRUE) +c=cbind(A,nmv) +print(c) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.13/Ex1.13.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.13/Ex1.13.R new file mode 100644 index 00000000..63e39f17 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.13/Ex1.13.R @@ -0,0 +1,34 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Span of vectors +#Page No.29 / 1-17 +#Prob 13 +#1.4.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix is:') +av<-c(3,-5,0,-2,6,4,1,1,4) +a=matrix( + av, + nrow=3, + ncol=3, + byrow=TRUE +) + +print(a) +print('interchange R1 and R3') +a[c(1,3),]=a[c(3,1),] +print(a) +print('R2=R2+2*R1 and R3=R3-3*R1') +a[2,]=a[2,]+2*a[1,] +a[3,]=a[3,]-3*a[1,] +print(a) +print('R3=R3+R2') +a[3,]=a[3,]+a[2,] +print(a) +print('from the entries of last row, the system is consistent') +print('hence, u is in the plane spanned by the columns of a') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.14/Ex1.14.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.14/Ex1.14.R new file mode 100644 index 00000000..e7cb3496 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.14/Ex1.14.R @@ -0,0 +1,28 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Free and pivot variables +#Page No.33 / 1-21 +#Prob 1 +#1.5.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix is:') +av<-c(2,-5,8,0,-2,-7,1,0,4,2,7,0) +a=matrix(av, + nrow=3, + ncol=4, + byrow=TRUE) +print(a) +print('R2=R2+2*R1 and R3=R3-2*R1') +a[2,]=a[2,]+a[1,] +a[3,]=a[3,]-2*a[1,] +print(a) +print('R3=R3+R2') +a[3,]=a[3,]+a[2,] +print(a) +print('only two columns have non zero pivots') +print('hence, one column is a free column and therefore there exists a non trivial solution') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.15/Ex1.15.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.15/Ex1.15.R new file mode 100644 index 00000000..f25bbea1 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.15/Ex1.15.R @@ -0,0 +1,45 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#General solution of the system +#Page No.34 / 1-22 +#Prob 7 +#1.5.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix is:') +av<-c(1,3,-3,7,0,0,1,-4,5,0) +a=matrix(av, + nrow=2, + ncol=5, + byrow=TRUE) +print(a) +print('R1=R1-3*R2') +a[1,]=a[1,]-3*a[2,] +print(a) +print('basic variables:x1 x2') +print('free variables:x3 x4') +print('x1=-9*x3+8*x4') +print('x2=4*x3-5*x4') +print('hence, solution is') +print('[-9*x3+8*x4 4*x3-5*x4 x3 x4]') +uv<-c(-9,4,1,0) +vv<-c(8,-5,0,1) +u=matrix(uv, + nrow=4, + ncol=1, + byrow=TRUE +) +v=matrix(vv, + nrow=4, + ncol=1, + byrow=TRUE +) +print('The solution set is the same as Span{u,v}') +print('u=') +print(u) +print('v=') +print(v) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.16/Ex1.16.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.16/Ex1.16.R new file mode 100644 index 00000000..dfed9348 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.16/Ex1.16.R @@ -0,0 +1,29 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#General solution of the system +#Page No.34 / 1-22 +#Prob 11 +#1.5.11 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix is') +av<-c(1,-4,-2,0,3,-5,0,0,0,1,0,0,-1,0,0,0,0,0,-1,4,0,0,0,0,0,0,0,0) +a=matrix(av, + nrow=4, + ncol=7, + byrow=TRUE) +print(a) +print('R1=R1-3*R3') +a[1,]=a[1,]-3*a[3,] +print(a) +print('R1=R1+2*R2') +a[1,]=a[1,]+2*a[2,] +print(a) +print('the free variables are:x2, x4 and x6') +print('the basic variables are:x1, x3 and x5') +print('the solution is:') +print('[4*x2-5*x6 x2 x6 x4 4*x6 x6]') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.17/Ex1.17.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.17/Ex1.17.R new file mode 100644 index 00000000..0190b57a --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.17/Ex1.17.R @@ -0,0 +1,26 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#General solution of the system +#Page No.35 / 1-23 +#Prob 13 +#1.5.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +xv<-c(5,-2,0) +x=matrix(xv, + nrow=3, + ncol=1, + byrow=TRUE) +x1v<-c(4,-7,1) +x1=matrix(x1v, + nrow=3, + ncol=1, + byrow=TRUE) +print(x) +print(x1) +print('=p+x3*q') +cat('geometrically the solution set is the line through [', x ,'] parallel to [',x1,']') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.18/Ex1.18.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.18/Ex1.18.R new file mode 100644 index 00000000..5b9b69b4 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.18/Ex1.18.R @@ -0,0 +1,29 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Economic Equilibrium +#Page No.38 / 1-26 +#Prob 1 +#1.6.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(0.8,-0.7,0,-0.8,0.7,0) +a=matrix(av, + nrow=2, + ncol=3, + byrow=TRUE) +print('the augmented matrix is') +print(a) + +#row reduce augmented matrix +a[2,]=a[2,]+a[1,] +print(a) +a=a*1.25 +print(a) + +print('ratio of prices is pg=0.875ps') +print('one equilibrium solution is ps=1000 and pg=875') +print('economic equilibrium is unaffected by a proportional change in prices') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.19/Ex1.19.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.19/Ex1.19.R new file mode 100644 index 00000000..6cdd3ad9 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.19/Ex1.19.R @@ -0,0 +1,76 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Balanced Equation +#Page No.39 / 1-27 +#Prob 7 +#1.6.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +nahcov<-c(1,1,1,3) +hchov<-c(0,8,6,7) +nachov<-c(3,5,6,7) +hov<-c(0,2,0,1) +cov<-c(0,0,1,2) + +nahco=matrix(nahcov, + nrow=4, + ncol=1, + byrow=TRUE) +hcho=matrix(hchov, + nrow=4, + ncol=1, + byrow=TRUE) +nacho=matrix(nachov, + nrow=4, + ncol=1, + byrow=TRUE) +ho=matrix(hov, + nrow=4, + ncol=1, + byrow=TRUE) +co=matrix(cov, + nrow=4, + ncol=1, + byrow=TRUE) + +print('nahco3') +print(nahco) +print('h3c6h5o7') +print(hcho) +print('na3c6h5o7') +print(nacho) +print('h2o') +print(ho) +print('co2') +print(co) +zm= matrix(0, nrow = 4, ncol = 1) +av=cbind(nahco,hcho,nacho,ho,co,zm) + +print('augmented matrix') +av[,3]=av[,3]*-1 +av[,4]=av[,4]*-1 +av[,5]=av[,5]*-1 +print(av) + +amrv<-c(1,0,0,0,-1,0,0,1,0,0,-1/3,0,0,0,1,0,-1/3,0,0,0,0,1,-1,0) +amr=matrix(amrv, + nrow=4, + ncol=6, + byrow=TRUE) +print('reduced augmented matrix') +print(amr) +print('the general solution is :') +print('x1=x5') +print('x2=(1/3)*x5') +print('x3=(1/3)*x5') +print('x4=x5') +print('x5 is free') +print('if x5=3, then') +print('x1=x4=3') +print('x2=x3=1') +print('the balanced equation is :') +print('3NaHCO3+H3C6H5O7 -> Na3C6H5O7+3H20+3C02') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.2/Ex1.2.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.2/Ex1.2.R new file mode 100644 index 00000000..04a99817 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.2/Ex1.2.R @@ -0,0 +1,25 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Gaussian Elimination Singular case +#Page No.15 / 1-3 +#Prob 7 +#1.1.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix is:') +av<-c(1,7,3,-4,0,1,-1,3,0,0,0,1,0,0,1,-2) +a=matrix( + av, + nrow=4, + ncol=4, + byrow=TRUE) +print(a) +print('interchange R3 and R4') +a[c(3,4),]=a[c(4,3),] +print(a) +print('from R4 we get 0=1') +print('hence, no solution') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.20/Ex1.20.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.20/Ex1.20.R new file mode 100644 index 00000000..5deefd06 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.20/Ex1.20.R @@ -0,0 +1,50 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Intersection Equations +#Page No.40 / 1-28 +#Prob 13 +#1.6.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av1<-c(1,-1,0,0,0,0,-50,0,1,-1,1,-1,0,0,0,0,0,0,1,-1,60,0,0,0,1,0,-1,50,1,0,-1,0,0,0,-40) +a1=matrix(av1, + nrow=5, + ncol=7, + byrow=TRUE) +print(a1) +av2<-c(1,-1,0,0,0,0,-50,0,1,-1,1,-1,0,0,0,0,0,1,0,-1,50,0,0,0,0,1,-1,60,0,0,0,0,0,0,0) +a2=matrix(av2, + nrow=5, + ncol=7, + byrow=TRUE) +print('..by reduction') +print(a2) +av3<-c(1,0,-1,0,0,0,-40,0,1,-1,0,0,0,10,0,0,0,1,0,-1,50,0,0,0,0,1,-1,60,0,0,0,0,0,0,0) +a3=matrix(av3, + nrow=5, + ncol=7, + byrow=TRUE) +print('..by reduction') +print(a3) +print('part-a') +print('the general solution is:') +print('x1=x3-40') +print('x2=x3+10') +print('x3 is free') +print('x4=x6+50') +print('x5=x6+60') +print('x6 is free') +print('part-b') +print('x3>=40') +print('x2>=50') +print('x4>=50') +print('x5>=60') +print('the minimum flows are:') +print('x2=50') +print('x3=40') +print('x4=50') +print('x5=60') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.21/Ex1.21.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.21/Ex1.21.R new file mode 100644 index 00000000..79b528a6 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.21/Ex1.21.R @@ -0,0 +1,46 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Linear independence of vectors +#Page No.42 / 1-30 +#Prob 1 +#1.7.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('given vectors u, v and w are') +uv<-c(5,0,0) +um=matrix(uv, + nrow=1, + ncol=3, + byrow=TRUE) +u=t(um) +print(u) +vv<-c(7,2,-6) +vm=matrix(vv, + nrow=1, + ncol=3, + byrow=TRUE) +v=t(vm) +print(v) +wv<-c(9,4,-8) +wm=matrix(wv, + nrow=1, + ncol=3, + byrow=TRUE) +w=t(wm) +print(w) +print('the augmented matrix is') +av<-c(5,7,9,0,0,2,4,0,0,-6,-8,0) +a=matrix(av, + nrow=3, + ncol=4, + byrow=TRUE) +print(a) +print('R3=R3+3*R2') +a[3,]=a[3,]+3*a[2,] +print(a) +print('there are no free variables') +print('hence, the homogeneous equation has only trivial solution and the vectors are linearly independent') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.22/Ex1.22.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.22/Ex1.22.R new file mode 100644 index 00000000..60c08f3c --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.22/Ex1.22.R @@ -0,0 +1,34 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Linear dependence of vectors +#Page No.43 / 1-31 +#Prob 7 +#1.7.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix is') +Av1<-c(1,4,-3,0,0,-2,7,5,1,0,-4,-5,7,-5,0) +A1=matrix(Av1, + nrow=3, + ncol=5, + byrow=TRUE) +print(A1) +Av2<-c(1,4,-3,0,0,0,1,-1,1,0,0,11,-5,5,0) +A2=matrix(Av2, + nrow=3, + ncol=5, + byrow=TRUE) +print(A2) +Av3<-c(1,4,-3,0,0,0,1,-1,1,0,0,0,6,-6,0) +A3=matrix(Av3, + nrow=3, + ncol=5, + byrow=TRUE) +print(A3) +print('since there are three rows, the maximum number of pivots can be 3') +print('hence, at least one of the four variable must be free') +print('so the equations have non trivial solution and the columns of A are linearly independent') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.23/Ex1.23.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.23/Ex1.23.R new file mode 100644 index 00000000..ce2fb0bb --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.23/Ex1.23.R @@ -0,0 +1,26 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Introduction to Linear Transformations +#Page No.46 / 1-34 +#Prob 1 +#1.8.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +Av<-c(2,0,0,2) +uv<-c(1,-3) +A=matrix(Av, + nrow=2, + ncol=2, + byrow=TRUE) +u=matrix(uv, + nrow=2, + ncol=1, + byrow=TRUE) +print(A) +print(u) +T=A %*% u +print(T) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.24/Ex1.24.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.24/Ex1.24.R new file mode 100644 index 00000000..e7825946 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.24/Ex1.24.R @@ -0,0 +1,56 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Introduction to Linear Transformations +#Page No.46 / 1-34 +#Prob 5 +#1.8.5 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av1<-c(1,-5,-7,-2,-3,7,5,-2) +av2<-c(1,-5,-7,-2,0,1,2,1) +av3<-c(1,0,3,3,0,1,2,1) +am1=matrix(av1, + nrow=2, + ncol=4, + byrow=TRUE) +am2=matrix(av2, + nrow=2, + ncol=4, + byrow=TRUE) +am3=matrix(av3, + nrow=2, + ncol=4, + byrow=TRUE) +print(am1) +print('~') +print(am2) +print('~') +print(am3) +print('x1=3-3*x3') +print('x2=1-2*x3') +print('x3 is free') +print('General Solution') +m1v<-c(3,1,0) +m1=matrix(m1v, + nrow=3, + ncol=1, + byrow=TRUE) +m2v<-c(-3,-2,1) +m2=matrix(m2v, + nrow=3, + ncol=1, + byrow=TRUE) +print(m1) +print('+ x3*') +print(m2) +print('when x3=0') +mv<-c(3,1,0) +m=matrix(mv, + nrow=3, + ncol=1, + byrow=TRUE) +print(m) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.25/Ex1.25.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.25/Ex1.25.R new file mode 100644 index 00000000..55088576 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.25/Ex1.25.R @@ -0,0 +1,27 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Introduction to Linear Transformations +#Page No.47 / 1-35 +#Prob 19 +#1.8.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +m1v<-c(2,5) +m2v<-c(-1,6) +m1=matrix(m1v, + nrow=2, + ncol=1, + byrow=TRUE) +print(m1) +m2=matrix(m2v, + nrow=2, + ncol=1, + byrow=TRUE) +print(m2) +print('5y1-3y2=') +tm=5*m1-3*m2 +print(tm) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.26/Ex1.26.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.26/Ex1.26.R new file mode 100644 index 00000000..109a240d --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.26/Ex1.26.R @@ -0,0 +1,26 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Matrix of a linear transformation +#Page No.50 / 1-38 +#Prob 1 +#1.9.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +te1v<-c(3,1,3,1) +te2v<-c(-5,2,0,0) +te1=matrix(te1v, + nrow=4, + ncol=1, + byrow=TRUE) +print(te1) +te2=matrix(te2v, + nrow=4, + ncol=1, + byrow=TRUE) +print(te2) +A=cbind(te1,te2) +print(A) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.27/Ex1.27.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.27/Ex1.27.R new file mode 100644 index 00000000..7bda6e9c --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.27/Ex1.27.R @@ -0,0 +1,36 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Matrix of a linear transformation +#Page No.50 / 1-38 +#Prob 7 +#1.9.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +e1v<-c(-1/sqrt(2),-1/sqrt(2)) +e1=matrix(e1v, + nrow=2, + ncol=1, + byrow=TRUE) +print('e1') +print(e1) +e1[2]=e1[2]*-1 +print('->') +print(e1) + +e2v<-c(1/sqrt(2),-1/sqrt(2)) +e2=matrix(e2v, + nrow=2, + ncol=1, + byrow=TRUE) +print('e2') +print(e2) +e2[2]=e2[2]*-1 +print('->') +print(e2) +A=cbind(e1,e2) +print('A') +print(A) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.28/Ex1.28.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.28/Ex1.28.R new file mode 100644 index 00000000..dc61d472 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.28/Ex1.28.R @@ -0,0 +1,39 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Matrix of a linear transformation +#Page No.51 / 1-39 +#Prob 21 +#1.9.21 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(1,1,4,5) +bv<-c(3,8) +a=matrix(av, + nrow=2, + ncol=2, + byrow=TRUE) +print('a') +print(a) +b=matrix(bv, + nrow=2, + ncol=1, + byrow=TRUE) +print('b') +print(b) +A=cbind(a,b) +print('A') +print(A) +print('R2=R2-4R1') +A[2,]=A[2,]-4*A[1,] +print(A) +print('R1=R1-4R2') +A[1,]=A[1,]-A[2,] +print(A) +xv=c(7,-4) +x=matrix(xv,nrow=2,ncol=1,byrow = TRUE) +print('x=') +print(x) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.29/Ex1.29.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.29/Ex1.29.R new file mode 100644 index 00000000..621fec76 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.29/Ex1.29.R @@ -0,0 +1,46 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Linear Models in Business, Science and Engineering +#Page No.55 / 1-43 +#Prob 1 +#1.10.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(110,130,295,4,3,9,20,18,48,2,5,8) +a=matrix(av, + nrow=4, + ncol=3, + byrow=TRUE) +print(a) +print('~') +print('interchange R1 and R4') +a[c(1,4),]=a[c(4,1),] +print(a) +print('~') +a[1,]=a[1,]/2 +a[3,]=a[3,]/2 +print(a) +a1v<-c(1,2.5,4,0,-7,-7,0,-16,-16,0,-145,-145) +a2v<-c(1,2.5,4,0,1,1,0,0,0,0,0,0) +a3v<-c(1,0,1.5,0,1,1,0,0,0,0,0,0) +a1=matrix(a1v, + nrow=4, + ncol=3, + byrow=TRUE) +a2=matrix(a2v, + nrow=4, + ncol=3, + byrow=TRUE) +a3=matrix(a3v, + nrow=4, + ncol=3, + byrow=TRUE) +print(a1) +print('~') +print(a2) +print('~') +print(a3) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.3/Ex1.3.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.3/Ex1.3.R new file mode 100644 index 00000000..44ce9f25 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.3/Ex1.3.R @@ -0,0 +1,43 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Gaussian Elimination with row exchange +#Page No.15 / 1-3 +#Prob 13 +#1.1.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix is') +av<-c(1,0,-3,8,2,2,9,7,0,1,5,-2) +a=matrix( + av, + nrow=3, + ncol=4, + byrow=TRUE) +print(a) +print('R2=R2-2*R1') +a[2,]=a[2,]-2*a[1,] +print(a) +print('interchange R2 and R3') +a[c(2,3),]=a[c(3,2),] +print(a) +print('R3=R3-2*R2') +a[3,]=a[3,]-2*a[2,] +print(a) +print('R3=(1/5)*R3') +a[3,]=(1/5)*a[3,] +print(a) +print('R2=R2-5*R3 and R1=R1+3*R3') +a[2,]=a[2,]-5*a[3,] +a[1,]=a[1,]+3*a[3,] +print(a) +s=matrix( + c(a[1,4],a[2,4],a[3,4]), + nrow=3, + ncol=1, + byrow=TRUE) +print('solution is') +print(s) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.30/Ex1.30.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.30/Ex1.30.R new file mode 100644 index 00000000..d7a2124a --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.30/Ex1.30.R @@ -0,0 +1,52 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Linear Models in Business, Science and Engineering +#Page No.56 / 1-44 +#Prob 7 +#1.10.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +r1v<-c(12,-7,0,-4) +r2v<-c(-7,15,-6,0) +r3v<-c(0,-6,14,-5) +r4v<-c(-4,0,-5,13) +r1=matrix(r1v, + nrow=4, + ncol=1, + byrow=TRUE) +r2=matrix(r2v, + nrow=4, + ncol=1, + byrow=TRUE) +r3=matrix(r3v, + nrow=4, + ncol=1, + byrow=TRUE) +r4=matrix(r4v, + nrow=4, + ncol=1, + byrow=TRUE) +print('r1') +print(r1) +print('r2') +print(r2) +print('r3') +print(r3) +print('r4') +print(r4) +R=cbind(r1,r2,r3,r4) +print(R) +vv<-c(40,30,20,-10) +v=matrix(vv, + nrow=4, + ncol=1, + byrow=TRUE) +print('v') +print(v) +x<-solve(R,v) +print('the solution is') +print(x) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.31/Ex1.31.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.31/Ex1.31.R new file mode 100644 index 00000000..0d1dda04 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.31/Ex1.31.R @@ -0,0 +1,93 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Linear Models in Business, Science and Engineering +#Page No.57 / 1-45 +#Prob 13 +#1.10.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +mv<-c(0.95,0.03,0.05,0.97) +x0v<-c(600000,400000) +m=matrix(mv, + nrow=2, + ncol=2, + byrow=TRUE) +print('M') +print(m) +x0=matrix(x0v, + nrow=2, + ncol=1, + byrow=TRUE) +print('when X0=') +print(x0) +x5v<-c(523293,476707) +x5=matrix(x5v, + nrow=2, + ncol=1, + byrow=TRUE) +print('x5') +print(x5) +x10v<-c(472737,527263) +x10=matrix(x10v, + nrow=2, + ncol=1, + byrow=TRUE) +print('x10') +print(x10) +x15v<-c(439417,560583) +x15=matrix(x15v, + nrow=2, + ncol=1, + byrow=TRUE) +print('x15') +print(x15) +x20v<-c(417456,582544) +x20=matrix(x20v, + nrow=2, + ncol=1, + byrow=TRUE) +print('x20') +print(x20) +x0=matrix(x0v, + nrow=2, + ncol=1, + byrow=TRUE) +x0v<-c(350000,650000) +print('when X0=') +x0=matrix(x0v, + nrow=2, + ncol=1, + byrow=TRUE) +print(x0) +x5v<-c(358523,641477) +x5=matrix(x5v, + nrow=2, + ncol=1, + byrow=TRUE) +print('x5') +print(x5) +x10v<-c(364140,635860) +x10=matrix(x10v, + nrow=2, + ncol=1, + byrow=TRUE) +print('x10') +print(x10) +x15v<-c(367843,632157) +x15=matrix(x15v, + nrow=2, + ncol=1, + byrow=TRUE) +print('x15') +print(x15) +x20v<-c(370283,629717) +x20=matrix(x20v, + nrow=2, + ncol=1, + byrow=TRUE) +print('x20') +print(x20) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.32/Ex1.32.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.32/Ex1.32.R new file mode 100644 index 00000000..625da448 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.32/Ex1.32.R @@ -0,0 +1,38 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Supplementary Exercises +#Page No.58 / 1-46 +#Prob 7a +#7a + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +v1v<-c(2,-5,7) +v2v<-c(-4,1,-5) +v3v<-c(-2,1,-3) + +v1=matrix(v1v,3,1,TRUE) +v2=matrix(v2v,3,1,TRUE) +v3=matrix(v3v,3,1,TRUE) +print('v1') +print(v1) +print('v2') +print(v2) +print('v3') +print(v3) +R=cbind(v1,v2,v3) +print(R) +R[1,]=R[1,]/2 +print('~') +print(R) +Rnv<-c(1,-2,-1,0,-9,-4,0,9,4) +Rn=matrix(Rnv,3,3,TRUE) +print('~') +print(Rn) +Rnv<-c(1,-2,-1,0,-9,-4,0,0,0) +Rn=matrix(Rnv,3,3,TRUE) +print('~') +print(Rn) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.4/Ex1.4.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.4/Ex1.4.R new file mode 100644 index 00000000..f8d01e25 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.4/Ex1.4.R @@ -0,0 +1,24 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Condition for a solution to exist +#Page No.16 / 1-4 +#Prob 19 +#1.1.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix for h=2') +av<-c(1,2,4,3,6,8) +a=matrix(av, + nrow=2, + ncol=3, + byrow=TRUE) +print(a) +print('R2-2*R1') +a[2,]=a[2,]-3*a[1,] +print(a) +print('from R3 we get 0=-4') +print('hence, if h=2 no solution, else solution exists') diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.5/Ex1.5.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.5/Ex1.5.R new file mode 100644 index 00000000..b2ba1d80 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.5/Ex1.5.R @@ -0,0 +1,30 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Consistent System +#Page No.16 / 1-4 +#Prob 25 +#1.1.25 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the co-efficient matrix is:') +av<-c(1,-4,7,0,3,-5,-2,5,-9) +a=matrix(av, + nrow = 3, + ncol = 3, + byrow = TRUE) +print(a) +print('let g,h,k be the constants on RHS') +print('R3=R3+2*R1') +a[3,]=a[3,]+2*a[1,] +print(a) +print('the constants on RHS are:g,h,k+2g') +print('R3=R3+R2') +a[3,]=a[3,]+a[2,] +print(a) +print('the constants on RHS are:g,h,k+2g+h') +print('for solution to exist') +print('from R3:k+2g+h=0') diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.6/Ex1.6.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.6/Ex1.6.R new file mode 100644 index 00000000..4cb5d98e --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.6/Ex1.6.R @@ -0,0 +1,34 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#General solution of the system +#Page No.20 / 1-8 +#Prob 7 +#1.2.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix is') +av<-c(1,3,4,7,3,9,7,6) +a=matrix(av, + nrow = 2, + ncol=4, + byrow=TRUE) +print(a) +print('R2=R2-3*R1') +a[2,]=a[2,]-3*a[1,] +print(a) +print('(-1/5)*R2') +a[2,]=(-1/5)*a[2,] +print(a) +print('R1=R1-4*R2') +a[1,]=a[1,]-4*a[2,] +print('the row reduced form is:') +print(a) +print('corresponding equations are') +print('x1+3*x2=-5 and x3=3') +print('free variables:x2') +print('general solution is:') +print('x1=-5-3*x2, x2, x3=3') diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.7/Ex1.7.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.7/Ex1.7.R new file mode 100644 index 00000000..e02cfcd9 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.7/Ex1.7.R @@ -0,0 +1,30 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#General solution of the system +#Page No.20 / 1-8 +#Prob 13 +#1.2.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the augmented matrix is') +av<-c(1,-3,0,-1,0,-2,0,1,0,0,-4,1,0,0,0,1,9,4,0,0,0,0,0,0) +a=matrix(av, + nrow=4, + ncol=6, + byrow=TRUE) +print(a) +print('R1=R1+R3') +a[1,]=a[1,]+a[3,] +print(a) +print('R1=R1+3*R2') +a[1,]=a[1,]+3*a[2,] +print(a) +print('corresponding equations are:') +print('x1-3*x5=5, x2-4*x5=1, x4+9*x5=4, and 0=0') +print('free variables:x3, x5') +print('general solution is:') +print('x1=5+3*x5, x2=1+4*x5, x3, x4=4-9*x5, x5') diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.8/Ex1.8.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.8/Ex1.8.R new file mode 100644 index 00000000..72aa92af --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.8/Ex1.8.R @@ -0,0 +1,32 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Linear Combination of two vectors +#Page No.23 / 1-11 +#Prob 1 +#1.3.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +uv<-c(-1,2) +u=matrix(uv, + nrow=2, + ncol=1, + byrow=TRUE) +print('u=') +print(u) +vv<-c(-3,-1) +v=matrix(vv, + nrow=2, + ncol=1, + byrow=TRUE) +print('v=') +print(v) +a=u+v +print('u+v=') +print(a) +s=u-2*v +print('u-2v=') +print(s) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.9/Ex1.9.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.9/Ex1.9.R new file mode 100644 index 00000000..39eab1b9 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH1/EX1.9/Ex1.9.R @@ -0,0 +1,29 @@ +#Chapter 1 - Linear Equations In Linear Algebra +#Determination of Linear Combination +#Page No.25 / 1-13 +#Prob 13 +#1.3.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(1,-4,2,3,0,3,5,-7,-2,8,-4,-3) + +a=matrix( + av, + nrow=3, + ncol=4, + byrow=TRUE +) + +print('the augmented matrix is:') +print(a) + +#Row reduce the augmented matrix to reach echelon form +print('R3=R3+2*R1') +a[3,]=a[3,]+2*a[1,] +print(a) +print('The system for the augmented matrix is inconsistent, so b is not a linear combination of the columns of A') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.1/Ex2.1.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.1/Ex2.1.R new file mode 100644 index 00000000..6fbf244f --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.1/Ex2.1.R @@ -0,0 +1,29 @@ +#Chapter 2- Matrix Algebra +#Matrix operations +#Page No.64 / 2-2 +#Prob 1 +#2.1.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(2,0,-1,4,-5,2) +a=matrix(av,2,3,TRUE) +print('A=') +print(a) +print('-2A=') +print(-2*a) +print('matrix B') +bv<-c(7,-5,1,1,-4,-3) +b=matrix(bv,2,3,TRUE) +print(b) +print('B-2A') +print(b-2*a) +c=matrix(c(1,2,-2,1),2,2,TRUE) +d=matrix(c(3,5,-1,4),2,2,TRUE) +cd=c %*% d +print('CD') +print(cd) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.10/Ex2.10.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.10/Ex2.10.R new file mode 100644 index 00000000..45ccbc66 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.10/Ex2.10.R @@ -0,0 +1,32 @@ +#Chapter 2- Matrix Algebra +#LU decomposition of a matrix +#Page No.84 / 2-22 +#Prob 7 +#2.5.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('given matrix is:') +av<-c(2,5,-3,-4) +a=matrix(av,2,2,TRUE) +d=a; +print(a) +print('performing row operations') +a[2,]=a[2,]-(a[2,1]/a[1,1])*a[1,] +print(a) +print(a) +print('thus, the upper triangular matrix is') +U=a; +print('U=') +print(U) +print('the lower triangular matrix is:') +c2=d[2,1]/d[1,1] +r1=matrix(c(1,c2),2,1,TRUE) +r2=matrix(c(0,1),2,1,TRUE) +L=cbind(r1,r2) +print('L=') +print(L) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.11/Ex2.11.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.11/Ex2.11.R new file mode 100644 index 00000000..063f5ebf --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.11/Ex2.11.R @@ -0,0 +1,41 @@ +#Chapter 2- Matrix Algebra +#LU decomposition of a matrix +#Page No.84 / 2-22 +#Prob 13 +#2.5.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('given matrix is:') +av<-c(1,3,-5,-3,-1,-5,8,4,4,2,-5,-7,-2,-4,7,5) +a=matrix(av,4,4,TRUE) +d=a +print(a) +print('performing row operations') +p21=a[2,1]/a[1,1] +p31=a[3,1]/a[1,1] +p41=a[4,1]/a[1,1] +a[2,]=a[2,]-p21*a[1,] +a[3,]=a[3,]-p31*a[1,] +a[4,]=a[4,]-p41*a[1,] +print(a) +p32=a[3,2]/a[2,2] +p42=a[4,2]/a[2,2] +a[3,]=a[3,]-p32*a[2,] +a[4,]=a[4,]-p42*a[2,] +print(a) +print('thus, lower triangular matrix is:') +v1=matrix(c(1,0,0,0),1,4,TRUE) +v2=matrix(c(p21,1,0,0),1,4,TRUE) +v3=matrix(c(p31,p32,1,0),1,4,TRUE) +v4=matrix(c(p41,p42,0,1),1,4,TRUE) +L=rbind(v1,v2,v3,v4) +print('L=') +print(L) +print('Upper triangular matrix is:') +print('U=') +print(a) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.12/Ex2.12.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.12/Ex2.12.R new file mode 100644 index 00000000..6d3d9a0d --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.12/Ex2.12.R @@ -0,0 +1,23 @@ +#Chapter 2- Matrix Algebra +#Application of matrix algebra +#Page No.91 / 2-29 +#Prob 1 +#2.6.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the consumption matrix is:') +cv<-c(.1,.6,.6,.3,.2,0,.3,.1,.1) +cm=matrix(cv,3,3,TRUE) +print(cm) +print('Assuming that agriculture plans to produce 100 units and other units produce nothing') +print('the production vector is given by') +x=matrix(c(0,100,0),3,1,TRUE) +print('x=') +print(x) +print('thus the intermediate demand is:') +print(cm %*% x) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.13/Ex2.13.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.13/Ex2.13.R new file mode 100644 index 00000000..978d380a --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.13/Ex2.13.R @@ -0,0 +1,31 @@ +#Chapter 2- Matrix Algebra +#Application of matrix algebra +#Page No.91 / 2-29 +#Prob 7 +#2.6.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the consumption matrix is:') +Cv<-c(0,.5,.6,.2) +Cm=matrix(Cv,2,2,TRUE) +print(Cm) +print('the demand for 1 unit of output sector 1') +d1=matrix(c(1,0),2,1,TRUE) +print(d1) +print('the production required to satisfy demand d1 is:') +x1=solve(diag(2)-Cm) %*% d1 +print('x1=') +print(x1) +print('the final demand is:') +d2=matrix(c(51,30),2,1,TRUE) +print('d2=') +print(d2) +print('the production required to satisfy demand d2 is:') +x2=solve(diag(2)-Cm) %*% d2 +print('x2=') +print(x2) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.14/Ex2.14.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.14/Ex2.14.R new file mode 100644 index 00000000..dd4b610a --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.14/Ex2.14.R @@ -0,0 +1,28 @@ +#Chapter 2- Matrix Algebra +#Application of matrix algebra +#Page No.93 / 2-31 +#Prob 7 +#2.7.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the matrix in R2 to rotate a vector by 60 degrees is:') +av<-c(cos(pi/3),-sin(pi/3),sin(pi/3),cos(pi/3)) +a=matrix(av,2,2,TRUE) +print(a) +x=matrix(c(6,8),2,1,TRUE) +print('x=') +print(x) +print('so the 3X3 matrix for rotation about x is:') +yv<-c(1,0,6,0,1,8,0,0,1) +y=matrix(yv,3,3,TRUE) +zv<-c(1,0,-6,0,1,-8,0,0,1) +z=matrix(zv,3,3,TRUE) +av<-c(cos(pi/3),-sin(pi/3),0,sin(pi/3),cos(pi/3),0,0,0,1) +a=matrix(av,3,3,TRUE) +R=y %*% (a %*% z) +print(R) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.15/Ex2.15.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.15/Ex2.15.R new file mode 100644 index 00000000..ea2419f5 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.15/Ex2.15.R @@ -0,0 +1,27 @@ +#Chapter 2- Matrix Algebra +#R3 coordinates of matrix +#Page No.94 / 2-32 +#Prob 19 +#2.7.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +Pv<-c(1,0,0,0,0,1,0,0,0,0,0,0,0,0,-0.1,1) +P=matrix(Pv,4,4,TRUE) +print(P) +Dv<-c(4.2,6,2,1.2,4,2,4,2,6,1,1,1) +D=matrix(Dv,4,3,TRUE) +print(D) +PD=P %*% D +print('PD') +print(PD) +R3=matrix(0,3,3,TRUE) +R31=PD[1:3,1]/PD[4,1] +R32=PD[1:3,2]/PD[4,2] +R33=PD[1:3,3]/PD[4,3] +R3=cbind(R31,R32,R33) +print(R3) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.16/Ex2.16.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.16/Ex2.16.R new file mode 100644 index 00000000..68129f2b --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.16/Ex2.16.R @@ -0,0 +1,35 @@ +#Chapter 2- Matrix Algebra +#Column space of a matrix +#Page No.95 / 2-33 +#Prob 7c +#2.8.7c + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +Av<-c(2,-3,-4,-8,8,6,6,-7,-7) +A=matrix(Av,3,3,TRUE) +print('A=') +print(A) +print('the given vector is:') +p=matrix(c(6,-10,11),3,1,TRUE) +print('p=') +print(p) +print('combining A and p') +b=cbind(A,p) +print(b) +print('performing row operations') +b[2,]=b[2,]-(b[2,1]/b[1,1])*b[1,] +b[3,]=b[3,]-(b[3,1]/b[1,1])*b[1,] +print(b) +b[3,]=b[3,]-(b[3,2]/b[2,2])*b[2,] +print(b) +if(b[3,3]==0 & b[3,4]==0){ + print('p lies in column space of A') +}else{ + print('p does not lie in column space of A') +} \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.17/Ex2.17.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.17/Ex2.17.R new file mode 100644 index 00000000..e511d155 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.17/Ex2.17.R @@ -0,0 +1,33 @@ +#Chapter 2- Matrix Algebra +#Matrix operation +#Page No.96 / 2-34 +#Prob 13 +#2.8.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(3,2,1,-5,0,-9,-4,1,7,0,9,2,-5,1,0) +a=matrix(av,3,5,TRUE) +print(a) +a[2,]=a[2,]+a[3,] +a[2,]=a[2,]/(-1) +a[3,]=a[3,]-3*a[1,] +print(a) +a[3,]=a[3,]+2*a[2,] +print(a) +a[2,]=a[2,]/2 +print(a) +a[1,]=a[1,]-2*a[2,] +a[1,]=a[1,]/3 +print(a) +print('the generalsolution is x1=x3-x4') +print('and x2=-2x3+4x4') +print('x3 and x4 are free') +print('if x3=1 and x4=0') +print('vector is (1,-2,1,0)') +print('if x3=0 and x4=1') +print('vector is (-1,4,0,1)') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.18/Ex2.18.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.18/Ex2.18.R new file mode 100644 index 00000000..df841a9f --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.18/Ex2.18.R @@ -0,0 +1,42 @@ +#Chapter 2- Matrix Algebra +#Pivot columns +#Page No.96 / 2-34 +#Prob 23 +#2.8.23 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +av<-c(4,5,9,-2,6,5,1,12,3,4,8,-3) +a=matrix(av,3,4,TRUE) +print(a) +print('performing row operaions') +a[1,]=a[1,]*(1/4) +a[2,]=a[2,]-6*a[1,] +a[3,]=a[3,]-3*a[1,] +a[2,]=a[2,]*(-2/5) +a[3,]=a[3,]+(-1/4)*a[2,] +a[1,]=a[1,]+(-5/4)*a[2,] +a[1,]=a[1,]+2*a[2,] +print(a) +il<-c(1:3) +jl<-c(1:4) +for(i in il){ + for(j in jl){ + if(a[i,j]!=0){ + cat('column ',j,' is a pivot column\n') + break + } + } +} +a[1,]=a[1,]-2*a[2,] +zm=matrix(0,3,1,TRUE) +c=cbind(a,zm) +print(c) +print('x1-4x3+7x4=0') +print('x2+5x3-6x4=0') +print('0=0') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.19/Ex2.19.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.19/Ex2.19.R new file mode 100644 index 00000000..25a71bb7 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.19/Ex2.19.R @@ -0,0 +1,50 @@ +#Chapter 2- Matrix Algebra +#Pivot columns +#Page No.97 / 2-35 +#Prob 25 +#2.8.25 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +av<-c(1,4,8,-3,-7,-1,2,7,3,4,-2,2,9,5,5,3,6,9,-5,-2) +a=matrix(av,4,5,TRUE) +print(a) +print('performing row operations') +a[2,]=a[2,]+a[1,] +a[3,]=a[3,]+2*a[1,] +a[4,]=a[4,]-3*a[1,] +a[2,]=a[2,]*(1/6) +a[3,]=a[3,]-10*a[2,] +a[4,]=a[4,]+6*a[2,] +a[3,]=a[3,]*-1 +a[4,]=a[4,]-4*a[3,] +a[1,]=a[1,]+3*a[3,] +a[2,]=a[2,]*2 +print(a) +il<-c(1:4) +jl<-c(1:5) +for(i in il){ + for(j in jl){ + if(a[i,j]!=0){ + cat('column ',j,' is a pivot column\n') + break + } + } +} +a[2,]=a[2,]/2 +a[1,]=a[1,]-4*a[2,] +print(a) +print('x1-2x3+7x5=0') +print('x2+2.5x3-0.5x5=0') +print('x4+4x5=0') +print('0=0') +print('x1=2x3-7x5') +print('x2=-2.5x3+0.5x5') +print('x3=x3') +print('x4=-4x5') +print('x5=x5') diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.2/Ex2.2.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.2/Ex2.2.R new file mode 100644 index 00000000..a1bc7c56 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.2/Ex2.2.R @@ -0,0 +1,18 @@ +#Chapter 2- Matrix Algebra +#Inverse of a matrix +#Page No.67 / 2-5 +#Prob 1 +#2.2.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('given matrix:') +av<-c(8,6,5,4) +a=matrix(av,2,2,TRUE) +print(a) +print('inverse of the matrix is:') +print(solve(a)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.20/Ex2.20.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.20/Ex2.20.R new file mode 100644 index 00000000..52e15143 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.20/Ex2.20.R @@ -0,0 +1,38 @@ +#Chapter 2- Matrix Algebra +#Pivot columns +#Page No.98 / 2-36 +#Prob 37 +#2.8.37 + +#clear console +cat("\014") +#clear variables +rm(list=ls(all=TRUE)) +av<-c(3,-5,0,-1,3,-7,9,-4,9,-11,-5,7,-2,5,-7,3,-7,-3,4,0) +a=matrix(av,4,5,TRUE) +print(a) +a[1,]=a[1,]*(1/3) +a[2,]=a[2,]+7*a[1,] +a[3,]=a[3,]+5*a[1,] +a[4,]=a[4,]+(-3)*a[1,] +a[2,]=a[2,]*(-3/8) +a[3,]=a[3,]+(4/3)*a[2,] +a[4,]=a[4,]+2*a[2,] +a[1,]=a[1,]+(5/3)*a[2,] +a[4,]=ceiling(a[4,])#the numbers are very small +a[3,]=floor(a[3,])#the numbers are very small +a[1,2]=ceiling(a[1,2]) +print(a) +il<-c(1:4) +jl<-c(1:5) +for(i in il){ + for(j in jl){ + if(a[i,j]!=0){ + cat('column ',j,' is a pivot column\n') + break + } + } +} +print('x1+2.5x3-4.5x4+3.5x5=0') +print('x2+1.5x3-2.5x4+1.5x5=0') +print('x3,x4,x5 are free') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.21/Ex2.21.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.21/Ex2.21.R new file mode 100644 index 00000000..716e2ea7 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.21/Ex2.21.R @@ -0,0 +1,20 @@ +#Chapter 2- Matrix Algebra +#Pivot columns +#Page No.101 / 2-39 +#Prob 1 +#2.9.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +xs=matrix(c(3,2),2,1,TRUE) +print(xs) +b1=matrix(c(1,1),2,1,TRUE) +b2=matrix(c(2,-1),2,1,TRUE) +print(b1) +print(b2) +x=3*b1+2*b2 +print(x) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.22/Ex2.22.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.22/Ex2.22.R new file mode 100644 index 00000000..29e108f4 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.22/Ex2.22.R @@ -0,0 +1,22 @@ +#Chapter 2- Matrix Algebra +#Pivot columns +#Page No.102 / 2-40 +#Prob 7 +#2.9.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +xs=matrix(c(2,-1),2,1,TRUE) +print(xs) +xs1=matrix(c(1.5,0.5),2,1,TRUE) +print(xs1) +b1=matrix(c(3,0),2,1,TRUE) +b2=matrix(c(-1,2),2,1,TRUE) +print(b1) +print(b2) +x=1.5*b1+0.5*b2 +print(x) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.23/Ex2.23.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.23/Ex2.23.R new file mode 100644 index 00000000..389e90b2 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.23/Ex2.23.R @@ -0,0 +1,38 @@ +#Chapter 2- Matrix Algebra +#Dimension of a matrix +#Page No.102 / 2-40 +#Prob 13 +#2.9.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +av<-c(1,-3,2,-4,-3,9,-1,5,2,-6,4,-3,-4,12,2,7) +a=matrix(av,4,4,TRUE) +print(a) +print('performing row operations') +a[2,]=a[2,]-(a[2,1]/a[1,1])*a[1,] +a[3,]=a[3,]-(a[3,1]/a[1,1])*a[1,] +a[4,]=a[4,]-(a[4,1]/a[1,1])*a[1,] +print(a) +a[4,]=a[4,]-2*a[2,] +print(a) +a[4,]=a[4,]-a[3,] +print(a) +k=0 +il=c(1:4) +jl=c(1:4) +for(i in il) +{for (j in jl){ +if(a[i,j]!=0){ + k=k+1 +break +} +} +} +print('dimension of the matrix=') +print(k) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.3/Ex2.3.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.3/Ex2.3.R new file mode 100644 index 00000000..475eeaa5 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.3/Ex2.3.R @@ -0,0 +1,49 @@ +#Chapter 2- Matrix Algebra +#Inverse of a matrix +#Page No.67 / 2-5 +#Prob 7 +#2.2.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the co-efficient matrix is:') +av<-c(1,2,5,12) +a=matrix(av,2,2,TRUE) +print(a) +print('inverse of the matrix is:') +print(solve(a)) +print('solution is:') + +b1v<-c(-1,3) +b1=matrix(b1v,2,1,TRUE) +c=solve(a) +res=c %*% b1 +print(res) + +b2v<-c(1,-5) +b2=matrix(b2v,2,1,TRUE) +res1=c %*% b2 +print(res1) + +b3v<-c(2,6) +b3=matrix(b3v,2,1,TRUE) +res2=c %*% b3 +print(res2) + +b4v<-c(3,5) +b4=matrix(b4v,2,1,TRUE) +res3=c %*% b4 +print(res3) + +cm=cbind(a,b1,b2,b3,b4) +print(cm) +cm[2,]=cm[2,]-5*cm[1,] +print(cm) +cm[2,]=cm[2,]/2 +print(cm) +cm[1,]=cm[1,]-2*cm[2,] +print(cm) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.4/Ex2.4.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.4/Ex2.4.R new file mode 100644 index 00000000..e5fb6a85 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.4/Ex2.4.R @@ -0,0 +1,31 @@ +#Chapter 2- Matrix Algebra +#Matrix +#Page No.70 / 2-8 +#Prob 31 +#2.2.31 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(1,0,-2,-3,1,4,2,-3,4) +a=matrix(av,3,3,TRUE) +i=diag(3) +ai=cbind(a,i) +print(ai) +ai[2,]=ai[2,]+3*ai[1,] +print(ai) +ai[3,]=ai[3,]-2*ai[1,] +print(ai) +ai[3,]=ai[3,]+3*ai[2,] +print(ai) +ai[1,]=ai[1,]+ai[3,] +print(ai) +ai[2,]=ai[2,]+ai[3,] +print(ai) +ai[3,]=ai[3,]/2 +print(ai) +print('A^-1') +print(ai[,c(4,5,6)]) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.5/Ex2.5.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.5/Ex2.5.R new file mode 100644 index 00000000..4d8876d7 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.5/Ex2.5.R @@ -0,0 +1,19 @@ +#Chapter 2- Matrix Algebra +#Invertibility of a matrix +#Page No.73 / 2-11 +#Prob 1 +#2.3.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +av<-c(5,7,-3,-6) +a=matrix(av,2,2,TRUE) +print(a) +print('the columns are lineraly independent') +print('hence, by invertible matrix theorem') +print('the matrix A is invertible') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.6/Ex2.6.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.6/Ex2.6.R new file mode 100644 index 00000000..2a0c0727 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.6/Ex2.6.R @@ -0,0 +1,23 @@ +#Chapter 2- Matrix Algebra +#Invertible matrix +#Page No.73 / 2-11 +#Prob 7 +#2.3.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(-1,-3,0,1,3,5,8,-3,-2,-6,3,2,0,-1,2,1) +a=matrix(av,4,4,TRUE) +print(a) +a[1,]=a[1,]*-1 +a[2,]=a[2,]-3*a[1,] +a[3,]=a[3,]+2*a[1,] +a[1,]=a[1,]*-1 +print(a) +a[4,]=4*a[4,]-a[2,] +a[4,]=a[4,]/4 +print(a) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.7/Ex2.7.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.7/Ex2.7.R new file mode 100644 index 00000000..1c353367 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.7/Ex2.7.R @@ -0,0 +1,23 @@ +#Chapter 2- Matrix Algebra +#Invertible matrix theorem +#Page No.74 / 2-12 +#Prob 33 +#2.3.33 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('matrix A corresponding to transformation T is:') +Av<-c(-5,9,4,-7) +A=matrix(Av,2,2,TRUE) +print(A) +print('determinant of A is:') +print(det(A)) +print('since det(A) is not equal to zero') +print('by IMT, A is invertible') +print('hence, the inverse of A exists') +print('inverse of A is:') +print(solve(A)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.8/Ex2.8.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.8/Ex2.8.R new file mode 100644 index 00000000..0f732fcb --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.8/Ex2.8.R @@ -0,0 +1,54 @@ +#Chapter 2- Matrix Algebra +#Inverse using matrix partition +#Page No.81 / 2-19 +#Prob 25 +#2.4.25 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('given matrix is:') +av<-c(1,2,0,0,0,3,5,0,0,0,0,0,2,0,0,0,0,0,7,8,0,0,0,5,6) +a=matrix(av,5,5,TRUE) +print(a) +print('partitioning the matrix into 4 submatrices') +A11=rbind(a[1,1:2],a[2,1:2]) +print('A11=') +print(A11) +A22=rbind(a[3,3:5],a[4,3:5],a[5,3:5]) +print('A22=') +print(A22) +A12=matrix(0,2,3,TRUE) +print('A12=') +print(A12) +A21=matrix(0,3,2,TRUE) +print('A21=') +print(A21) +print('partitioning A22 into 4 submatrices') +A221=matrix(2,1,1,TRUE) +print(A221) +B=rbind(A22[2,2:3],A22[3,2:3]) +print('B=') +print(B) +print(matrix(0,1,2,TRUE)) +print(matrix(0,2,1,TRUE)) +print('determinant of B=') +print(det(B)) +print('Hence, B is invertible') +print('inverse of B is') +print(solve(B)) +print('determinant of inverse of B is:') +print(det(solve(B))) +print('inverse of A11') +print(solve(A11)) +print('hence the inverse of A22 is:') +v1=det(solve(B)) +v2=matrix(0,1,2,TRUE) +v3=matrix(c(0,3,-4),1,3,TRUE) +v4=matrix(c(0,-2.5,3.5),1,3,TRUE) +r1=cbind(v1,v2) +c=rbind(r1,v3,v4) +print(c) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.9/Ex2.9.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.9/Ex2.9.R new file mode 100644 index 00000000..f1d96dcf --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH2/EX2.9/Ex2.9.R @@ -0,0 +1,62 @@ +#Chapter 2- Matrix Algebra +#Application of LU decomposition +#Page No.83 / 2-21 +#Prob 1 +#2.5.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the lower triangular matrix is:') +Lv<-c(1,0,0,-1,1,0,2,-5,1) +L=matrix(Lv,3,3,TRUE) +print(L) +print('the upper triangular matrix is:') +Uv<-c(3,-7,-2,0,-2,-1,0,0,-1) +U=matrix(Uv,3,3,TRUE) +print(U) +print('the RHS of the equations are') +bv<-c(-7,5,2) +b=matrix(bv,3,1,TRUE) +print(b) +print('combining matrices L and b') +cm=cbind(L,b) +print(cm) +print('performing row operations') +print('R2=R2+R1') +cm[2,]=cm[2,]+cm[1,] +print(cm) +print('R3=R3-2*R1') +cm[3,]=cm[3,]-2*cm[1,] +print(cm) +print('R3=R3+5*R2') +cm[3,]=cm[3,]+5*cm[2,] +print(cm) +y=cm[,4] +print('y=') +print(y) +print('combining U and y') +d=cbind(U,y) +print(d) +print('performing row operations') +print('R3=R3/-6') +d[3,]=d[3,]/(-1) +print(d) +print('R2=R2+R3 and R1=R1+2*R3') +d[2,]=d[2,]+d[3,] +d[1,]=d[1,]+2*d[3,] +print(d) +print('R1=R1-3.5*R2') +d[1,]=d[1,]-3.5*d[2,] +print(d) +print('R1=R1/3 and R2=R2/-2') +d[1,]=d[1,]/3 +d[2,]=d[2,]/(-2) +print(d) +print('the solution is:') +x=d[,4] +print('x=') +print(x) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.1/Ex3.1.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.1/Ex3.1.R new file mode 100644 index 00000000..f4b5b496 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.1/Ex3.1.R @@ -0,0 +1,20 @@ +#Chapter 3- Determinants +#Determinant of a matrix +#Page No.108 / 3-2 +#Prob 1 +#3.1.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +Av<-c(3,0,4,2,3,2,0,5,-1) +A=matrix(Av,3,3,TRUE) +print(A) +print('calculating det(A) using cofactor expression along first row') +print('det(A)=3 X (-1 X 3-5 X 2)+4 X (2 X 5-3 X 0)') +print('det(A) =') +print(det(A)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.10/Ex3.10.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.10/Ex3.10.R new file mode 100644 index 00000000..22335e6e --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.10/Ex3.10.R @@ -0,0 +1,37 @@ +#Chapter 3- Determinants +#Cramers Rule +#Page No.115 / 3-9 +#Prob 1 +#3.3.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the co-efficient matrix is:') +av<-c(5,7,2,4) +a=matrix(av,2,2,TRUE) +print('A=') +print(a) +print('the RHS is:') +b=matrix(c(3,1),2,1,TRUE) +print(b) +print('applying cramers rule') +print('replacing first column of matrix A by b') +A1v<-c(3,7,1,4) +A1=matrix(A1v,2,2,TRUE) +print('A1=') +print(A1) +print('replacing second column of matrix A by b') +A2v<-c(5,3,2,1) +A2=matrix(A2v,2,2,TRUE) +print('A2=') +print(A2) +print('x1=det(A1)/det(A)') +print('=') +print((det(A1)/det(a))) +print('x2=det(A2)/det(A)') +print('=') +print((det(A2)/det(a))) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.11/Ex3.11.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.11/Ex3.11.R new file mode 100644 index 00000000..3b9f19bf --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.11/Ex3.11.R @@ -0,0 +1,66 @@ +#Chapter 3- Determinants +#Inverse of a matrix +#Page No.116 / 3-10 +#Prob 13 +#3.3.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +av<-c(3,5,4,1,0,1,2,1,1) +a=matrix(av,3,3,TRUE) +print('A=') +print(a) +print('the cofactors are:') +m1=matrix(c(0,1,1,1),2,2,TRUE) +C11=det(m1) +print('C11=') +print(C11) +m2=matrix(c(1,1,2,1),2,2,TRUE) +C12=-det(m2) +print('C12=') +print(C12) +m3=matrix(c(1,0,2,1),2,2,TRUE) +C13=det(m3) +print('C13=') +print(C13) +m3=matrix(c(5,4,1,1),2,2,TRUE) +C21=-det(m3) +print('C21=') +print(C21) +m4=matrix(c(3,4,2,1),2,2,TRUE) +C22=det(m4) +print('C22=') +print(C22) +m4=matrix(c(3,5,2,1),2,2,TRUE) +C23=-det(m4) +print('C23=') +print(C23) +m5=matrix(c(5,4,0,1),2,2,TRUE) +C31=det(m5) +print('C31=') +print(C31) +m6=matrix(c(3,4,1,1),2,2,TRUE) +C32=-det(m6) +print('C32=') +print(C32) +m7=matrix(c(3,5,1,0),2,2,TRUE) +C33=det(m7) +print('C33=') +print(C33) +c1m=rbind(C11,C12,C13) +c2m=rbind(C21,C22,C23) +c3m=rbind(C31,C32,C33) +B=cbind(c1m,c2m,c3m) +print('adj(A)=') +print(B) +print('A.adj(A)=') +adja=ceiling(a %*% B) +print(adja) +C=B/(det(a)) +print('inv(A)=') +print(C) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.12/Ex3.12.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.12/Ex3.12.R new file mode 100644 index 00000000..adc41f84 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.12/Ex3.12.R @@ -0,0 +1,22 @@ +#Chapter 3- Determinants +#Applicant of determinant +#Page No.117 / 3-11 +#Prob 19 +#3.3.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the points forming the parrallelogram are') +print('(0,0),(5,2),(6,4),(11,6)') +print('using the vertices adjacent to origin to form a matrix') +Av<-c(5,6,2,4) +A=matrix(Av,2,2,TRUE) +print('A=') +print(A) +print('Area of parallelogram = det(A)') +print('=') +print(det(A)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.2/Ex3.2.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.2/Ex3.2.R new file mode 100644 index 00000000..6e4c7c3c --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.2/Ex3.2.R @@ -0,0 +1,20 @@ +#Chapter 3- Determinants +#Determinant of a matrix +#Page No.108 / 3-2 +#Prob 7 +#3.1.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('given matrix is:') +Av<-c(4,3,0,6,5,2,9,7,3) +A=matrix(Av,3,3,TRUE) +print(A) +print('calculating det(A) using cofactor expression along first row') +print('det(A)=4 X (5 X 3-7 X 2)-3 X (6 X 3-9 X 2)') +print('det(A) =') +print(det(A)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.3/Ex3.3.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.3/Ex3.3.R new file mode 100644 index 00000000..dcfd67d1 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.3/Ex3.3.R @@ -0,0 +1,37 @@ +#Chapter 3- Determinants +#Determinant of a matrix +#Page No.108 / 3-2 +#Prob 13 +#3.1.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +Av<-c(4,0,-7,3,-5,0,0,2,0,0,7,3,-6,4,-8,5,0,5,2,-3,0,0,9,-1,2) +A=matrix(Av,5,5,TRUE) +print('A=') +print(A) +P=A +print('since row 2 has maximum zeros, using row 2 for cofactor expression') +A<-A[-(2),] +A<-A[,-(3)] +print('deleting second row and third column from A, we get') +print(A) +print('det(A)=-2 X') +print('det') +print(A) +print('for the 4X4 matrix obtained, using column 2 for cofactor exansion') +print('deleting second column and row from the 4X4 matrix') +A<-A[-(2),] +A<-A[,-(2)] +print(A) +print('det(A)=-2 X 3 X') +print('det') +print(A) +print('-6 X [4 X (4-3)-5 X (6-5)]') +print('=') +print(-6*det(A)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.4/Ex3.4.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.4/Ex3.4.R new file mode 100644 index 00000000..fa1b2045 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.4/Ex3.4.R @@ -0,0 +1,25 @@ +#Chapter 3- Determinants +#Property of determinants +#Page No.110 / 3-4 +#Prob 37 +#3.1.37 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +Av<-c(3,1,4,2) +A=matrix(Av,2,2,TRUE) +print('the given matrix is:') +print(A) +print('det(A)=') +print(det(A)) +print('5 X A = ') +print(5*A) +print('det(5*A)=') +print(det(5*A)) +print('thus, det(5A) is not equal to 5Xdet(A)') +print('infact, the relation between det(rA) and det(A) for a nxn matrix is:') +print('det(rA)=(r^n)*det(A)') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.5/Ex3.5.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.5/Ex3.5.R new file mode 100644 index 00000000..e95d171c --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.5/Ex3.5.R @@ -0,0 +1,17 @@ +#Chapter 3- Determinants +#Determinant of a matrix +#Page No.110 / 3-4 +#Prob 41 +#3.1.41 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(3,1,0,2) +a=matrix(av,2,2,TRUE) +print(a) +print('det=') +print(det(a)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.6/Ex3.6.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.6/Ex3.6.R new file mode 100644 index 00000000..6bb74ac8 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.6/Ex3.6.R @@ -0,0 +1,30 @@ +#Chapter 3- Determinants +#Determinant of a matrix +#Page No.111 / 3-5 +#Prob 7 +#3.2.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +Av<-c(1,3,0,2,-2,-5,7,4,3,5,2,1,1,-1,2,-3) +A=matrix(Av,4,4,TRUE) +print('A=') +print(A) +print('performing row operations') +A[2,]=A[2,]-(A[2,1]/A[1,1])*A[1,] +A[3,]=A[3,]-(A[3,1]/A[1,1])*A[1,] +A[4,]=A[4,]-(A[4,1]/A[1,1])*A[1,] +print(A) +A[3,]=A[3,]-(A[3,2]/A[2,2])*A[2,] +A[4,]=A[4,]-(A[4,2]/A[2,2])*A[2,] +print(A) +A[4,]=A[4,]-(A[4,3]/A[3,3])*A[3,] +print(A) +print('det(A) is the product of diagonal entries') +print('det(A)=') +print(det(A)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.7/Ex3.7.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.7/Ex3.7.R new file mode 100644 index 00000000..502756f3 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.7/Ex3.7.R @@ -0,0 +1,37 @@ +#Chapter 3- Determinants +#Determinant of a matrix +#Page No.112 / 3-6 +#Prob 13 +#3.2.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +av<-c(2,5,4,1,4,7,6,2,6,-2,-4,0,-6,7,7,0) +a=matrix(av,4,4,TRUE) +print('A=') +print(a) +print('performing row operations') +a[2,]=a[2,]-2*a[1,] +print(a) +print('using cofactor expansion about fourth column') +a<-a[-(1),] +a<-a[,-(4)] +print('det(A)= -1 X') +print('det') +print(a) +print('performing row operations') +a[3,]=a[3,]+a[2,] +print(a) +print('using cofactor expansion about first column') +a<-a[-(2),] +a<-a[,-(1)] +print('det(A)= -1 X -6 X') +print('det') +print(a) +print('=') +print(6*det(a)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.8/Ex3.8.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.8/Ex3.8.R new file mode 100644 index 00000000..732d0b77 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.8/Ex3.8.R @@ -0,0 +1,37 @@ +#Chapter 3- Determinants +#Determinant of a matrix +#Page No.112 / 3-6 +#Prob 19 +#3.2.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +print('A=') +print(' a b c') +print('2d+a 2e+b 2f+c') +print(' g h i') +print('B=') +print('a b c') +print('d e f') +print('g h i') +print('given, det(B)=7') +print('performing row operations on A') +print('R2=R2-R1') +print('A=') +print('a b c') +print('2d 2e 2f') +print('g h i') +print('factoring 2 out of row 2') +print('A=') +print('2 X') +print('a b c') +print('d e f') +print('g h i') +print('therefore, det(A)=2 X det(B)') +print('=2 X 7') +print('= 14') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.9/Ex3.9.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.9/Ex3.9.R new file mode 100644 index 00000000..7a56c8dc --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH3/EX3.9/Ex3.9.R @@ -0,0 +1,35 @@ +#Chapter 3- Determinants +#Linear independency using determinants +#Page No.112 / 3-6 +#Prob 25 +#3.2.25 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given vectors are:') +v1v<-c(7,-4,-6) +v2v<-c(-8,5,7) +v3v<-c(7,0,-5) +v1=matrix(v1v,3,1,TRUE) +v2=matrix(v2v,3,1,TRUE) +v3=matrix(v3v,3,1,TRUE) +print('v1=') +print(v1) +print('v2=') +print(v2) +print('v3=') +print(v3) +print('combining them as a matrix') +a=cbind(v1,v2,v3) +print('A=') +print(a) +print('if det(A) is not equal to zero, then v1 v2 and v3 are linearly independent') +print('expanding about third column') +print('det(A)=7 X (-28+30) - 5 X (35-32)') +print('=') +print(det(a)) +print('hence, v1 v2 and v3 are linearly independent') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.1/Ex4.1.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.1/Ex4.1.R new file mode 100644 index 00000000..6c593cc1 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.1/Ex4.1.R @@ -0,0 +1,41 @@ +#Chapter 4- Vector Spaces +#Subspace of vectors +#Page No.123 / 4-3 +#Prob 13c +#4.1.13c + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given vectors are:') +v1=matrix(c(1,0,-1),3,1,TRUE) +print('v1=') +print(v1) +v2=matrix(c(2,1,3),3,1,TRUE) +print('v2=') +print(v2) +v3=matrix(c(4,2,6),3,1,TRUE) +print('v3=') +print(v3) +w=matrix(c(3,1,2),3,1,TRUE) +print('w=') +print(w) +print('It is clear that w is not one of the three vectors in v1,v2 and v3') +print('The span of v1,v2 and v3 contains infinitely many vectors.') +print('To check if w is in the subspace of v1,v2 and v3,') +print('we form an augmented matrix.') +av<-c(1,2,4,3,0,1,2,1,-1,3,6,2) +a=matrix(av,3,4,TRUE) +print(a) +print('performing row operations') +print('R3=R3+R1') +a[3,]=a[3,]+a[1,] +print(a) +print('R3=R3-5xR2') +a[3,]=a[3,]-5*a[2,] +print(a) +print('there is no pivot in the augmented column,') +print('hence the vector equation is consistent and w is in span{v1 v2 v3}.') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.10/Ex4.10.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.10/Ex4.10.R new file mode 100644 index 00000000..64996773 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.10/Ex4.10.R @@ -0,0 +1,36 @@ +#Chapter 4- Vector Spaces +#Rank of a matrix +#Page No.141 / 4-21 +#Prob 1 +#4.6.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('to find the rank of matrix A') +av<-c(1,-4,9,-7,-1,2,-4,1,5,-6,10,7) +a=matrix(av,3,4,TRUE) +p=a +print('A=') +print(a) +print('performing row operations') +a[2,]=a[2,]+a[1,] +a[3,]=a[3,]-5*a[1,] +a[3,]=a[3,]+7*a[2,] +a[1,]=a[1,]-2*a[2,] +print(a) +print('It is clear that matrix A has 2 pivot columns') +print('Hence, rank(A)=2') +print('Columns 1 and 2 are pivot columns') +print('Hence, basis for C(A) is:') +cat(p[,1],'and',p[,2]) +print('Basis for row space of A is:') +cat(a[1,],'and',a[2,]) +print('To find the basis of N(A), solve Ax=0') +print('on solving, we get the basis of N(A) as:') +u=matrix(c(1,2.5,1,0),4,1,TRUE) +v=matrix(c(-5,-3,0,1),4,1,TRUE) +cat(v,'and',u) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.11/Ex4.11.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.11/Ex4.11.R new file mode 100644 index 00000000..816ac403 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.11/Ex4.11.R @@ -0,0 +1,24 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.145 / 4-25 +#Prob 1a +#4.7.1a + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +b1=matrix(c(6,-2),2,1,TRUE) +print(b1) +b2=matrix(c(9,-4),2,1,TRUE) +print(b2) +pcb=cbind(b1,b2) +print(pcb) + +#4.7.1b +xb=matrix(c(-3,2),2,1,TRUE) +print(xb) +xc=pcb %*% xb +print(xc) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.12/Ex4.12.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.12/Ex4.12.R new file mode 100644 index 00000000..ca384e9f --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.12/Ex4.12.R @@ -0,0 +1,29 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.145 / 4-25 +#Prob 7 +#4.7.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +c1=matrix(c(1,-5),2,1,TRUE) +c2=matrix(c(-2,2),2,1,TRUE) +b1=matrix(c(7,5),2,1,TRUE) +b2=matrix(c(-3,-1),2,1,TRUE) +m=cbind(c1,c2,b1,b2) +print(m) +m[2,]=m[2,]+5*m[1,] +print(m) +m[2,]=m[2,]/8 +m[2,]=m[2,]/-1 +print(m) +m[1,]=m[1,]+2*m[2,] +print(m) +pcb=m[,3:4] +print(pcb) +print('inv(pcb)') +print(solve(pcb)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.13/Ex4.13.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.13/Ex4.13.R new file mode 100644 index 00000000..153520bb --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.13/Ex4.13.R @@ -0,0 +1,37 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.146 / 4-26 +#Prob 13 +#4.7.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +b1c=matrix(c(1,-2,1),3,1,TRUE) +b2c=matrix(c(3,-5,4),3,1,TRUE) +b3c=matrix(c(0,2,3),3,1,TRUE) +print('b1c') +print(b1c) +print('b2c') +print(b2c) +print('b3c') +print(b3c) +pcb=cbind(b1c,b2c,b3c) +print(pcb) +print('coordinate vector [-1+2t]B satisfies') +print('pcb [-1+2t]B = [-1+2t]C') +print('=[-1 2 0]') +nm=matrix(c(-1,2,0),3,1,TRUE) +cvm=cbind(pcb,nm) +print(cvm) +cvm[2,]=cvm[2,]+2*cvm[1,] +cvm[3,]=cvm[3,]-1*cvm[1,] +cvm[3,]=cvm[3,]-1*cvm[2,] +cvm[2,]=cvm[2,]-2*cvm[3,] +cvm[1,]=cvm[1,]-3*cvm[2,] +print(cvm) +print('[-1+2t]B = ') +print(cvm[,4]) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.14/Ex4.14.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.14/Ex4.14.R new file mode 100644 index 00000000..cfbbcd37 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.14/Ex4.14.R @@ -0,0 +1,29 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.146 / 4-26 +#Prob 19a +#4.7.19a + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +vv<-c(-2,-8,-7,2,5,2,3,2,6) +pv<-c(1,2,-1,-3,-5,0,4,6,1) +v=matrix(vv,3,3,TRUE) +p=matrix(pv,3,3,TRUE) +print(v) +print(p) +vp=v %*% p +print(vp) +u1=vp[,1] +u2=vp[,2] +u3=vp[,3] +print('u1') +print(u1) +print('u2') +print(u2) +print('u3') +print(u3) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.15/Ex4.15.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.15/Ex4.15.R new file mode 100644 index 00000000..b5f5c7d8 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.15/Ex4.15.R @@ -0,0 +1,22 @@ +#Chapter 4- Vector Spaces +#Linear Independence +#Page No.148 / 4-28 +#Prob 7 +#4.8.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(1^0,2^0,(-2)^0,1^1,2^1,(-2)^1,1^2,2^2,(-2)^2) +a=matrix(av,3,3,TRUE) +print(a) +a[2,]=a[2,]-a[1,] +print(a) +a[3,]=a[3,]-a[1,] +print(a) +a[3,]=a[3,]-3*a[2,] +print(a) +print('Hence the set of signals is linearly independent in S') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.16/Ex4.16.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.16/Ex4.16.R new file mode 100644 index 00000000..19241436 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.16/Ex4.16.R @@ -0,0 +1,19 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.149 / 4-29 +#Prob 13 +#4.8.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +r1=(1+(1/3))/2 +r2=(1-(1/3))/2 +print('r=') +print(r1) +print('or') +print(r2) +cat('Two solutions of the difference equation are',r1,'^k and',r2,'^k') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.17/Ex4.17.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.17/Ex4.17.R new file mode 100644 index 00000000..85d32766 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.17/Ex4.17.R @@ -0,0 +1,21 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.149 / 4-29 +#Prob 19 +#4.8.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +r1=(-4+sqrt(16-4))/2 +r2=(-4-sqrt(16-4))/2 +print('r=') +print(r1) +print('or') +print(r2) +cat('Two solutions of the difference equation are',r1,'^k and',r2,'^k') +print('') +cat('The general solution has the form c1',r1,'^k+c2',r2,'^k') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.18/Ex4.18.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.18/Ex4.18.R new file mode 100644 index 00000000..36d0bde3 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.18/Ex4.18.R @@ -0,0 +1,27 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.150 / 4-30 +#Prob 19b +#4.8.19b +#(this solution is for Section 4.7) + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +vv<-c(-2,-8,-7,2,5,2,3,2,6) +v=matrix(vv,3,3,TRUE) +print(v) +pv<-c(5,8,5,-3,-5,-3,-2,-2,-1) +pinv=matrix(pv,3,3,TRUE) +print(pinv) +w= v %*% pinv +print(w) +w1=w[,1] +w2=w[,2] +w3=w[,3] +print(w1) +print(w2) +print(w3) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.19/Ex4.19.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.19/Ex4.19.R new file mode 100644 index 00000000..98d84f94 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.19/Ex4.19.R @@ -0,0 +1,25 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.152 / 4-32 +#Prob 1 +#4.9.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +p=matrix(c(.7,.6,.3,.4),2,2,TRUE) +x1m=matrix(c(1,0),2,1,TRUE) +x2m=matrix(c(.7,.3),2,1,TRUE) +print('x1m') +print(x1m) +print('x2m') +print(x2m) +x1=p %*% x1m +x2=p %*% x2m +print('x1') +print(x1) +print('x2') +print(x2) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.2/Ex4.2.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.2/Ex4.2.R new file mode 100644 index 00000000..13f4d5b5 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.2/Ex4.2.R @@ -0,0 +1,27 @@ +#Chapter 4- Vector Spaces +#Null space of a matrix +#Page No.125 / 4-5 +#Prob 1 +#4.2.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +av<-c(3,-5,-3,6,-2,0,-8,4,1) +a=matrix(av,3,3,TRUE) +print('A=') +print(a) +print('the vector x is:') +x=matrix(c(1,3,-4),3,1,TRUE) +print('x=') +print(x) +print('To check if x is in nullspace of A') +print('Ax=') +zm=matrix(0,3,1,TRUE) +print('=') +print(zm) +print('hence, x is in the null space of A') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.20/Ex4.20.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.20/Ex4.20.R new file mode 100644 index 00000000..033ec41f --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.20/Ex4.20.R @@ -0,0 +1,37 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.153 / 4-33 +#Prob 7 +#4.9.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +pv<-c(.7,.1,.1,.2,.8,.2,.1,.1,.7) +p=matrix(pv,3,3,TRUE) +print(p) +PI=p-diag(3) +print(PI) +zm=matrix(0,3,1,TRUE) +PIx=cbind(PI,zm) +print(PIx) +PIx[,c(1,3)]=PIx[,c(3,1)] +print(PIx) +PIx=PIx*10 +print(PIx) +PIx[2,]=PIx[2,]-2*PIx[1,] +PIx[3,]=PIx[3,]+3*PIx[1,] +PIx[2,]=PIx[2,]/(-4) +PIx[3,]=PIx[3,]-4*PIx[2,] +PIx[1,]=PIx[1,]-1*PIx[2,] +print(round(PIx)) +print('x1=x3') +print('x2=2x3') +print('x3 is free') +print('[x1 x2 x3]=x3[1 2 1]') +print('the entries in [1 2 1] sum to 4') +q=(1/4)*matrix(c(1,2,1),3,1,TRUE) +print(q) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.21/Ex4.21.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.21/Ex4.21.R new file mode 100644 index 00000000..312fde03 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.21/Ex4.21.R @@ -0,0 +1,26 @@ +#Chapter 4- Vector Spaces +#Change of Basis +#Page No.154 / 4-34 +#Prob 13a +#4.9.13a + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +P=matrix(c(.95,.45,.05,.55),2,2,TRUE) +print(P) +PI=P-diag(2) +print(PI) +zm=matrix(0,2,1,TRUE) +PIm=cbind(PI,zm) +print(PIm) +PIm[2,]=round(PIm[2,]+PIm[1,]) +PIm[1,]=PIm[1,]*20 +print(PIm) +print('x1=9x2') +print('x2 is free') +print('A basis for Nul(P-I) is [9 1]') +print('the steady-state vector is q=[.9 .1]') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.3/Ex4.3.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.3/Ex4.3.R new file mode 100644 index 00000000..f581c74b --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.3/Ex4.3.R @@ -0,0 +1,34 @@ +#Chapter 4- Vector Spaces +#Column space of a matrix +#Page No.128 / 4-8 +#Prob 13 +#4.3.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +av<-c(1,0,6,5,0,0,2,5,3,0,0,0,0,0,0) +a=matrix(av,3,5,TRUE) +p=a +print('A=') +print(a) +print('Reducing A to echelon form') +print('R2=R2/2') +a[2,]=a[2,]/2 +print(a) +print('the pivot columns are column 1 and 2 of A') +print('x1=-6x3-5x4') +print('x2=-(5/2)x3-(3/2)x4') +print('x3 and x4 are free') +print('x3[-6 -5/2 1 0] + ') +print('x4[-5 -3/2 0 1]') +print('the standard choice is (-6,-5/2,1,0)') +print('and (-5,-3/2,0,1) ') +print('Another choice is ') +print('(-12,-5,2,0) ') +print('and (-10,-3,0,2) ') +print('which avoids fractions') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.4/Ex4.4.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.4/Ex4.4.R new file mode 100644 index 00000000..42a4f62a --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.4/Ex4.4.R @@ -0,0 +1,18 @@ +#Chapter 4- Vector Spaces +#Matrix operation +#Page No.132 / 4-12 +#Prob 1 +#4.4.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +xb=matrix(c(5,3),2,1,TRUE) +print(xb) +b1=matrix(c(3,-5),2,1,TRUE) +b2=matrix(c(-4,6),2,1,TRUE) +x=5*b1+3*b2 +print(x) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.5/Ex4.5.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.5/Ex4.5.R new file mode 100644 index 00000000..c3f8942a --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.5/Ex4.5.R @@ -0,0 +1,42 @@ +#Chapter 4- Vector Spaces +#Gaussian Elimination +#Page No.132 / 4-12 +#Prob 7 +#4.4.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('vector x=') +x=matrix(c(8,-9,6),3,1,TRUE) +print(x) +print('the given basis is:') +b1=matrix(c(1,-1,-3),3,1,TRUE) +b2=matrix(c(-3,4,9),3,1,TRUE) +b3=matrix(c(2,-2,4),3,1,TRUE) +print('b1=') +print(b1) +print('b2=') +print(b2) +print('b3=') +print(b3) +print('to solve the vector equation') +print('an augmented matrix is formed') +av<-c(1,-3,2,8,-1,4,-2,-9,-3,9,4,6) +a=matrix(av,3,4,TRUE) +print('A=') +print(a) +print('performing row operations') +a[2,]=a[2,]-(a[2,1]/a[1,1])*a[1,] +a[3,]=a[3,]-(a[3,1]/a[1,1])*a[1,] +print(a) +a[3,]=a[3,]/a[3,3] +a[1,]=a[1,]-2*a[3,] +print(a) +a[1,]=a[1,]+3*a[2,] +print(a) +print('Xb=') +print(a[,4]) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.6/Ex4.6.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.6/Ex4.6.R new file mode 100644 index 00000000..751d1aec --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.6/Ex4.6.R @@ -0,0 +1,41 @@ +#Chapter 4- Vector Spaces +#Matix Solution +#Page No.133 / 4-13 +#Prob 13 +#4.4.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('c1+c3=1') +print('c2+2c3=4') +print('c1+c2+c3=7') + +av<-c(1,0,1,1,0,1,2,4,1,1,1,7) +a=matrix(av,3,4,TRUE) +print(a) +a[3,]=a[3,]-1*a[1,] +a[3,]=a[3,]-1*a[2,] +print(a) +a[3,]=a[3,]/-2 +a[2,]=a[2,]-2*a[3,] +a[1,]=a[1,]-1*a[3,] +print(a) +ps=a[,4] +print('ps=') +print(ps) +m1=matrix(c(1,0,1),3,1,TRUE) +m2=matrix(c(0,1,1),3,1,TRUE) +m3=matrix(c(1,2,1),3,1,TRUE) +mm=matrix(c(1,4,7),3,1,TRUE) +print('c1') +print(m1) +print('c2') +print(m2) +print('c3') +print(m3) +print('=') +print(mm) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.7/Ex4.7.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.7/Ex4.7.R new file mode 100644 index 00000000..6d0ab17a --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.7/Ex4.7.R @@ -0,0 +1,43 @@ +#Chapter 4- Vector Spaces +#Linear independence of vectors +#Page No.135 / 4-15 +#Prob 27 +#4.4.27 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('to check if vectors v1 v2 and v3 are linearly independent') +v1=matrix(c(1,0,0,1),4,1,TRUE) +v2=matrix(c(3,1,-2,1),4,1,TRUE) +v3=matrix(c(0,-1,3,-1),4,1,TRUE) +print('v1=') +print(v1) +print('v2=') +print(v2) +print('v3=') +print(v3) +print('forming an augmented matrix') +av<-c(1,3,0,0,0,1,-1,0,0,-2,3,0,1,0,-1,0) +a=matrix(av,4,4,TRUE) +print('A=') +print(a) +print('performing row operations') +a[4,]=a[4,]+a[1,] +a[1,]=a[1,]-a[4,] +a[1,]=a[1,]/(-1) +print(a) +a[4,]=a[4,]-a[1,] +a[3,]=a[3,]+2*a[2,] +a[4,]=a[4,]+3*a[2,] +a[4,]=a[4,]+4*a[3,] +a[4,]=a[4,]-6*a[2,] +a[4,]=a[4,]-a[1,] +a[4,]=a[4,]/8 +a[4,]=a[4,]-a[3,] +print(a) +print('since the vector equation has only the trivial solution') +print('vectors v1 v2 and v3 are linearly independent') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.8/Ex4.8.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.8/Ex4.8.R new file mode 100644 index 00000000..5fd69ded --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.8/Ex4.8.R @@ -0,0 +1,42 @@ +#Chapter 4- Vector Spaces +#Span of vectors +#Page No.135 / 4-15 +#Prob 31a +#4.4.31a + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('to check if the polynomials span R3') +print('placing the coordinate vectors of the polynomial into the columns of a matrix') +av<-c(1,-3,-4,1,-3,5,5,0,5,-7,-6,-1) +a=matrix(av,3,4,TRUE) +print('A=') +print(a) +print('performing row operations') +a[2,]=a[2,]+3*a[1,] +a[3,]=a[3,]-5*a[1,] +print(a) +a[3,]=a[3,]+2*a[2,] +print(a) +print('the four vectors DO NOT span R3 as there is no pivot in row 3') + +#4.4.31b + +print('to check if the polynomials span R3') +print('placing the coordinate vectors of the polynomial into the columns of a matrix') +av1<-c(0,1,-3,2,5,-8,4,-3,1,-2,2,0) +a1=matrix(av1,3,4,TRUE) +print('A=') +print(a1) +print('performing row operations') +a1[c(1,3),]=a1[c(3,1),] +print(a1) +a1[2,]=a1[2,]-5*a1[1,] +print(a1) +a1[3,]=a1[3,]-0.5*a1[2,] +print(a1) +print('the four vectors DO NOT span R3 as there is no pivot in row 3') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.9/Ex4.9.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.9/Ex4.9.R new file mode 100644 index 00000000..b65ee44a --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH4/EX4.9/Ex4.9.R @@ -0,0 +1,26 @@ +#Chapter 4- Vector Spaces +#Dimension of a vector space +#Page No.137 / 4-17 +#Prob 3 +#4.5.3 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('to find the dimension of subspace H, which is the set of linear combination of vectors v1 v2 and v3') +v1=matrix(c(0,1,0,1),4,1,TRUE) +v2=matrix(c(0,-1,1,2),4,1,TRUE) +v3=matrix(c(2,0,-3,0),4,1,TRUE) +print('v1=') +print(v1) +print('v2=') +print(v2) +print('v3=') +print(v3) +print('Clearly, v1 is not equal to zero') +print('and v2 is not a multiple of v1 as third element of v1 is zero whereas that of v2 is 1.') +print('Also, v3 is not a linear combination of v1 and v2 as the first element of v1 and v2 is zero but that of v3 is 2') +print('Hence, v1 v2 and v3 are linearly independent and dim(H)=3') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.1/Ex5.1.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.1/Ex5.1.R new file mode 100644 index 00000000..952e0368 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.1/Ex5.1.R @@ -0,0 +1,21 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Eigenvalue of a matrix +#Page No.157 / 5-1 +#Prob 1 +#5.1.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('to check if 2 is an eigenvalue of matrix A') +a=matrix(c(3,2,3,8),2,2,TRUE) +print('A=') +print(a) +print('A-2I=') +b=a-2*diag(2) +print(b) +print('The columns of A are clearly independent,') +print('hence (A-2I)x=0 has a non trivial solution and 2 is an eigenvalue of matrix A') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.10/Ex5.10.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.10/Ex5.10.R new file mode 100644 index 00000000..45f9a168 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.10/Ex5.10.R @@ -0,0 +1,40 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Diagonalization of a matrix +#Page No.166 / 5-10 +#Prob 7 +#5.3.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('the given matrix is:') +a=matrix(c(1,0,6,-1),2,2,TRUE) +print('A=') +print(a) +print('Since A is triangular, eigenvalues are the diagonal entries.') +cat('Eigenvalues are:',a[2,2],a[1,1]) +print('for lambda=1') +print('A-1I=') +b=a-diag(2) +print(b) +print('Hence, x1=(1/3)x2 with x2 as free variable.') +print('Eigenvector corresponding to lambda=1 is:') +u1=matrix(c(1,3),2,1,TRUE) +print(u1) +print('for lambda=-1') +print('A-(-1)I=') +b=a+diag(2) +print(b) +print('Hence, x1=0 with x2 as free variable.') +print('Eigenvector corresponding to lambda=-1 is:') +u2=matrix(c(0,1),2,1,TRUE) +print(u2) +print('Thus, matrix P=') +um=cbind(u1,u2) +print(um) +print('and matrix D=') +Dm=matrix(c(1,0,0,-1),2,2,TRUE) +print(Dm) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.11/Ex5.11.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.11/Ex5.11.R new file mode 100644 index 00000000..4a6d27fe --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.11/Ex5.11.R @@ -0,0 +1,60 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Diagonalization of a matrix +#Page No.167 / 5-11 +#Prob 13 +#5.3.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Given matrix A=') +av<-c(2,2,-1,1,3,-1,-1,-2,2) +a=matrix(av,3,3,TRUE) +print(a) +print('Given its eigen values are 5 and 1') +print('for lambda=5') +print('A-5I=') +b=a-5*diag(3) +print(b) +print('performing row operations') +zm=matrix(0,3,1,TRUE) +cm=cbind(b,zm) +print(cm) +cm[c(1,2),]=cm[c(2,1),] +print(cm) +cm[2,]=cm[2,]+3*cm[1,] +cm[3,]=cm[3,]+cm[1,] +print(cm) +cm[3,]=cm[3,]-cm[2,] +print(c) +cm[2,]=cm[2,]/cm[2,2] +cm[1,]=cm[1,]+2*cm[2,] +print(cm) +print('With x3 as free variable, x1=-x3 and x2=-x3') +print('Hence, for lambda=5 eigenvector is:') +u1=matrix(c(-1,-1,1),3,1,TRUE) +print(u1) +print('for lambda=1') +print('A-I=') +b=a-diag(3) +print(b) +print('performing row operations') +cn=cbind(b,zm) +print(cn) +cn[2,]=cn[2,]-cn[1,] +cn[3,]=cn[3,]+cn[1,] +print(cn) +print('With x2 and x3 as free variables, eigen vectors corresponding to lambda=1 are') +u2=matrix(c(-2,1,0),3,1,TRUE) +u3=matrix(c(1,0,1),3,1,TRUE) +print(u2) +print(u3) +print('Hence, matrix P=') +pm=cbind(u1,u2,u3) +print(pm) +print('and matrix D=') +Dm=matrix(c(5,0,0,0,1,0,0,0,1),3,3,TRUE) +print(Dm) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.12/Ex5.12.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.12/Ex5.12.R new file mode 100644 index 00000000..7fa98a27 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.12/Ex5.12.R @@ -0,0 +1,78 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Eigen values of matrix +#Page No.168 / 5-12 +#Prob 19 +#5.3.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(5,-3,0,9,0,3,1,-2,0,0,2,0,0,0,0,2) +a=matrix(av,4,4,TRUE) +print(a) +eig=eigen(a) +eigv<-eig$values +print('eigen values are:') +print(eigv) +print('for lambda=2') +print('(A-2I)x=0') +zm=matrix(0,4,1,TRUE) +c1=a-2*diag(4) +m1=cbind(c1,zm) +print(m1) +m1[1,]=m1[1,]+3*m1[2,] +print(m1) +m1[1,]=m1[1,]/3 +print(m1) +print('x1=x3-x4') +print('x2=-x3+2x4') +print('x3 and x4 are free') +v1=matrix(c(-1,-1,1,0),4,1,TRUE) +v2=matrix(c(-1,2,0,1),4,1,TRUE) +print('v1') +print(v1) +print('v2') +print(v2) +print('for lambda=3') +print('(A-3I)x=0') +c2=a-3*diag(4) +m2=cbind(c2,zm) +print(m2) +m2[1,]=m2[1,]/2 +m2[3,]=m2[3,]+m2[2,] +m2[3,]=m2[3,]/(-2) +m2[4,]=m2[4,]+m2[3,] +m2[2,]=m2[2,]+2*m2[3,] +m2[1,]=m2[1,]+(-9/2)*m2[3,] +print(m2) +print('x1=(3/2)x2') +print('x2 is free') +print('x3 and x4 = 0') +print('choosing x2=2 produces eigen vector v3=(3,2,0,0)') +print('for lambda=5') +print('(A-5I)x=0') +c3=a-5*diag(4) +m3=cbind(c3,zm) +print(m3) +m3[1,]=m3[1,]/(-3) +m3[2,]=m3[2,]+2*m3[1,] +m3[3,]=m3[3,]+3*m3[2,] +m3[3,]=ceiling(m3[2,]/(-24)) +m3[4,]=m3[4,]+3*m3[3,] +m3[2,]=m3[2,]+8*m3[3,] +m3[1,]=m3[1,]+3*m3[3,] +print(m3) +print('x1 is free') +print('x2=0') +print('x3=0') +print('x4=0') +print('a basis vector for the eigenspace is v4=(1,0,0,0)') +Pmv<-c(-1,-1,3,1,-1,2,2,0,1,0,0,0,0,1,0,0) +Pm=matrix(Pmv,4,4,TRUE) +print(Pm) +Dmv<-c(2,0,0,0,0,2,0,0,0,0,3,0,0,0,0,5) +Dm=matrix(Dmv,4,4,TRUE) +print(Dm) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.13/Ex5.13.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.13/Ex5.13.R new file mode 100644 index 00000000..f8c7421f --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.13/Ex5.13.R @@ -0,0 +1,28 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Page No.170 / 5-14 +#Prob 29 +#5.3.29 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +p1=matrix(c(1,1,-2,-1),2,2,TRUE) +d1=matrix(c(3,0,0,5),2,2,TRUE) +print('p1=') +print(p1) +print('d1=') +print(d1) +p2=matrix(c(-3,1,6,-1),2,2,TRUE) +print('p2=') +print(p2) +A=p1*d1*solve(p1) +A1=p2*d1*solve(p2) +print('P1D1P1^-1') +print(A) +print('P2D1P2^-1') +print(A1) +print(A==A1) +print('Hence, A=P1D1P1^-1=P2D1P2^-1') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.14/Ex5.14.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.14/Ex5.14.R new file mode 100644 index 00000000..55871b60 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.14/Ex5.14.R @@ -0,0 +1,20 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Transform of matrix +#Page No.172 / 5-16 +#Prob 1 +#5.4.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +b1=matrix(c(3,-5),1,2,TRUE) +b2=matrix(c(-1,6),1,2,TRUE) +b3=matrix(c(0,4),1,2,TRUE) +b1t=t(b1) +b2t=t(b2) +b3t=t(b3) +cm=cbind(b1t,b2t,b3t) +print(cm) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.15/Ex5.15.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.15/Ex5.15.R new file mode 100644 index 00000000..28dcafb2 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.15/Ex5.15.R @@ -0,0 +1,26 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Eigenvalues +#Page No.173 / 5-17 +#Prob 13 +#5.4.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +a=matrix(c(0,1,-3,4),2,2,TRUE) +eig=eigen(a) +eigv<-eig$values +print('the eigen values are') +print(eigv) +print('for lambda=1') +m1=a-diag(2) +print(m1) +print('as a basis vector, take u1=[1 1]') +print('for lambda=3') +m2=a-3*diag(2) +print(m2) +print('as a basis vector, take u1=[1 3]') +#the matrix for lambda=3 has a calculation error in the textbook \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.16/Ex5.16.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.16/Ex5.16.R new file mode 100644 index 00000000..9377795d --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.16/Ex5.16.R @@ -0,0 +1,24 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Eigenvalues +#Page No.175 / 5-19 +#Prob 31 +#5.4.31 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Given matrix A=') +av<-c(-7,-48,-16,1,14,6,-3,-45,-19) +a=matrix(av,3,3,TRUE) +print(a) +print('and matrix P=') +pv<-c(-3,-2,3,1,1,-1,-3,-3,0) +p=matrix(pv,3,3,TRUE) +print(p) +print('Hence, marix D=') +s=solve(p) +Dv=round(s %*% a %*% p) +print(Dv) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.17/Ex5.17.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.17/Ex5.17.R new file mode 100644 index 00000000..16bae4ca --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.17/Ex5.17.R @@ -0,0 +1,33 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Complex Eigenvectors +#Page No.176 / 5-20 +#Prob 1 +#5.5.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Matrix A=') +a=matrix(c(1,-2,1,3),2,2,TRUE) +print(a) +print('Eigen values of A are') +eig=eigen(a) +eigv<-eig$values +print(eigv) +print('for lambda=2+i') +i=complex(real=2,imaginary=1) +print('A-(2+i)I=') +b=a-(i)*diag(2) +print(b) +print('With x2 as free variable, x1=-(1-i)x2') +print('Hence, eigenvector corresponding to lambda=2+i is:') +i1=complex(real=-1,imaginary=1) +m1=matrix(c(i1,1),2,1,TRUE) +print(m1) +i2=complex(real=-1,imaginary=-1) +print('for lambda=2-i, eigenvector is:') +m2=matrix(c(i2,1),2,1,TRUE) +print(m2) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.18/Ex5.18.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.18/Ex5.18.R new file mode 100644 index 00000000..8fab880d --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.18/Ex5.18.R @@ -0,0 +1,21 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Scale factor of transformation +#Page No.176 / 5-20 +#Prob 7 +#5.5.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Matrix A=') +a=matrix(c(sqrt(3),-1,1,sqrt(3)),2,2,TRUE) +print(a) +print('Eigenvalues of A are:') +eig=eigen(a) +eigv<-eig$values +print(eigv) +print('The scale factor associated with the transformation x to Ax is:') +print(abs(eigv[1])) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.19/Ex5.19.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.19/Ex5.19.R new file mode 100644 index 00000000..bfc95caf --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.19/Ex5.19.R @@ -0,0 +1,23 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Page No.177 / 5-21 +#Prob 13 +#5.5.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +i=complex(real=-1,imaginary=-1) +v=matrix(c(i,1),2,1,TRUE) +a=matrix(c(1,-2,1,3),2,2,TRUE) +print(v) +rev=Re(v) +print(rev) +imv=Im(v) +print(imv) +pm=cbind(rev,imv) +print(pm) +cm=solve(pm) %*% a %*% pm +print(cm) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.2/Ex5.2.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.2/Ex5.2.R new file mode 100644 index 00000000..9202d394 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.2/Ex5.2.R @@ -0,0 +1,38 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Eigenvalue of a matrix +#Page No.158 / 5-2 +#Prob 7 +#5.1.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To check if 4 is an eigenvalue of matrix A') +av<-c(3,0,-1,2,3,1,-3,4,5) +a=matrix(av,3,3,TRUE) +print('A=') +print(a) +print('Therefore') +print('A-4I=') +print(a-4*diag(3)) +b=a-4*diag(3) +print('to check the invertibility of A-4I, form an augmented matrix') +zm=matrix(0,3,1,TRUE) +c=cbind(b,zm) +print(c) +print('performing row operations') +c[2,]=c[2,]+2*c[1,] +c[3,]=c[3,]-3*c[1,] +print(c) +c[3,]=c[3,]+4*c[2,] +print(c) +print('We can see that there exists a non trivial solution.') +print('Hence, 4 is an eigenvalue of A.') +print('For the eigenvector, -x1-x3=0 and -x2-x3=0') +print('If x3=1,') +x=matrix(c(-1,-1,1),3,1,TRUE) +print('x=') +print(x) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.20/Ex5.20.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.20/Ex5.20.R new file mode 100644 index 00000000..98128470 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.20/Ex5.20.R @@ -0,0 +1,33 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Page No.177 / 5-21 +#Prob 19 +#5.5.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +a=matrix(c(1.52,-0.7,0.56,0.4),2,2,TRUE) +print(a) +lambdap1=(1.92)/2 +lambdap2=sqrt(abs(-0.3136))/2 +i=complex(real=0,imaginary=lambdap2) +print('lambda = ') +cat(lambdap1+i) +print('or') +cat(lambdap1-i) +print('if x2=2') +iv=complex(real=2,imaginary=-1) +vm=matrix(c(iv,2),2,1,TRUE) +print('v=') +print(vm) +revm=Re(vm) +imvm=Im(vm) +print(revm) +print(imvm) +p=cbind(revm,imvm) +print(p) +fm=solve(p) %*% a %*% p +print(fm) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.21/Ex5.21.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.21/Ex5.21.R new file mode 100644 index 00000000..7eb569f8 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.21/Ex5.21.R @@ -0,0 +1,27 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Page No.179 / 5-23 +#Prob 1 +#5.6.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +v1=matrix(c(1,1),2,1,TRUE) +v2=matrix(c(-1,1),2,1,TRUE) +cat('v1=',v1) +print('') +cat('v2=',v2) +x0=matrix(c(9,1),2,1,TRUE) +nm=cbind(v1,v2,x0) +print(nm) +nm[1,]=nm[1,]+nm[2,] +nm[1,]=nm[1,]/2 +nm[2,]=nm[2,]-nm[1,] +print(nm) +nv1=matrix(c(15,15),2,1,TRUE) +nv2=matrix(c((-4/3),(4/3)),2,1,TRUE) +nvv=nv1-nv2 +print(nvv) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.22/Ex5.22.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.22/Ex5.22.R new file mode 100644 index 00000000..d3cc7f7f --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.22/Ex5.22.R @@ -0,0 +1,24 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Page No.181 / 5-25 +#Prob 13 +#5.6.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +a=matrix(c(.8,.3,-.4,1.5),2,2,TRUE) +print(a) +print('eigen values are') +eig=eigen(a) +print(eig$values) +zm=matrix(0,2,1,TRUE) +c1=a-1.2*diag(2) +m1=cbind(c1,zm) +print(m1) +m1[2,]=m1[2,]-m1[1,] +m1[2,]=round(m1[2,]) +m1[1,]=m1[1,]/(-4) +print(m1) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.23/Ex5.23.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.23/Ex5.23.R new file mode 100644 index 00000000..fd7db729 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.23/Ex5.23.R @@ -0,0 +1,25 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Page No.183 / 5-27 +#Prob 1 +#5.7.1 + +#clear console +cat("\014") + +av<-c(-3,-1,-6,1,1,1) +a=matrix(av,2,3,TRUE) +p=a +print(a) +a[c(1,2),]<-a[c(2,1),] +print(a) +a[2,]=a[2,]+3*a[1,] +a[2,]=a[2,]/2 +a[1,]=a[1,]-a[2,] +print(a) +print('c1=') +print(a[1,3]) +print('c2=') +print(a[2,3]) +print('x(t)=') +cat('[',a[1,3]*p[,1],']*e^4t') +cat('-[',a[2,3]*p[,2],']*e^2t') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.24/Ex5.24.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.24/Ex5.24.R new file mode 100644 index 00000000..7f3462ed --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.24/Ex5.24.R @@ -0,0 +1,36 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Page No.184 / 5-28 +#Prob 19 +#5.7.19 + +#clear console +cat("\014") + +a=matrix(c(-2,(3/4),1,-1),2,2,TRUE) +print(a) +eig=eigen(a) +print('eigen values are') +print(eig$values) +v1=matrix(c(1,2),2,1,TRUE) +v2=matrix(c(-3,2),2,1,TRUE) +print('v1=') +print(v1) +print('v2=') +print(v2) +print('general solution x(t) =') +cat('c1*[',v1,']e^-.5t+c2*[',v2,']e^-2.5t') +print('') +ma1=cbind(v1,v2) +print(ma1) +mb=matrix(c(4,4),2,1,TRUE) +mc=solve(ma1) %*% mb +print(mc) +print('c1=') +print(mc[1]) +print('c2=') +print(mc[2]) +x1=mc[1]*v1 +x2=mc[2]*v2 +print('x(t)=') +cat('[',x1,']*e^-.5t') +cat('-[',x2,']*e^-2.5t') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.3/Ex5.3.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.3/Ex5.3.R new file mode 100644 index 00000000..1c23ae05 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.3/Ex5.3.R @@ -0,0 +1,64 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Eigenvectors +#Page No.158 / 5-2 +#Prob 13 +#5.1.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To find a basis for the eigenspace') +print('Matrix A=') +av<-c(4,0,1,-2,1,0,-2,0,1) +a=matrix(av,3,3,TRUE) +print(a) +print('for lambda=1') +print('A-1I=') +b=a-diag(3) +print(b) +print('solving (A-I)x=0, we get') +print('-2*x1=0 and 3*x1+x3=0') +print('therefore, x1=x3=0') +print('which leaves x2 as a free variable') +print('Hence a basis for the eigen space is:') +es=matrix(c(0,1,0),3,1,TRUE) +print(es) +print('for lambda=2') +print('A-2I=') +b=a-2*diag(3) +print(b) +print('performing row operations on the augmented matrix') +zm=matrix(0,3,1,TRUE) +c=cbind(b,zm) +print(c) +c[2,]=c[2,]+c[1,] +c[3,]=c[3,]+c[1,] +print(c) +c[1,]=c[1,]/c[2,2] +print(c) +print('We can see that x3 is a free variable') +print('x2=x3 and x1=-.05*x3') +print('Hence, a basis for the eigenspace is:') +es1=matrix(c(1,2,2),3,1,TRUE) +print(es1) +print('for lambda=3') +print('A-3I=') +b=a-3*diag(3) +print(b) +print('performing row operations on the augmented matrix') +c=cbind(b,zm) +print(c) +c[2,]=c[2,]+2*c[1,] +c[3,]=c[3,]+2*c[1,] +print(c) +c[2,]=c[2,]/2 +c[2,]=c[2,]/(-1) +print(c) +print('Again x3 is a free variable') +print('x1=-x3 and x2=x3') +print('Hence, a basis for the eigenspace is:') +es2=matrix(c(-1,1,1),3,1,TRUE) +print(es2) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.4/Ex5.4.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.4/Ex5.4.R new file mode 100644 index 00000000..d23e18b9 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.4/Ex5.4.R @@ -0,0 +1,19 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Property of non-invertible matrices +#Page No.159 / 5-3 +#Prob 19 +#5.1.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('The given matrix is:') +av<-c(1,2,3,1,2,3,1,2,3) +a=matrix(av,3,3,TRUE) +print('A=') +print(a) +print('A is not invertible because its columns are linearly dependent.') +print('Hence, 0 is an eigenvalue of matrix A.') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.5/Ex5.5.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.5/Ex5.5.R new file mode 100644 index 00000000..c119dbf8 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.5/Ex5.5.R @@ -0,0 +1,20 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Eigenvalue of a matrices +#Page No.162 / 5-6 +#Prob 1 +#5.2.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To find the eigenvalue of matrix A') +print('A=') +a=matrix(c(2,7,7,2),2,2,TRUE) +print(a) +print('Eigen values of A are:') +eig<-eigen(a) +eigv<-eig$values +print(eigv) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.6/Ex5.6.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.6/Ex5.6.R new file mode 100644 index 00000000..b56b072d --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.6/Ex5.6.R @@ -0,0 +1,21 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Complex eigenvalues +#Page No.162 / 5-6 +#Prob 7 +#5.2.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To find the eigenvalues of matrix A.') +print('A=') +a=matrix(c(5,3,-4,4),2,2,TRUE) +print(a) +print('Eigen values of A are:') +eig<-eigen(a) +eigv<-eig$values +print(eigv) +print('Hence, A has no real eigenvalues.') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.7/Ex5.7.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.7/Ex5.7.R new file mode 100644 index 00000000..0d8fc8c7 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.7/Ex5.7.R @@ -0,0 +1,21 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Eigenvalues of a matrix +#Page No.162 / 5-6 +#Prob 13 +#5.2.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To find the eigenvalues of the matrix A') +print('A=') +av<-c(6,-2,0,-2,9,0,5,8,3) +a=matrix(av,3,3,TRUE) +print(a) +print('Eigenvalues of A are:') +eig<-eigen(a) +eigv<-eig$values +print(eigv) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.8/Ex5.8.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.8/Ex5.8.R new file mode 100644 index 00000000..0d649a5c --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.8/Ex5.8.R @@ -0,0 +1,54 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Eigenvectors +#Page No.163 / 5-7 +#Prob 25a +#5.2.25a + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Matrix A=') +a=matrix(c(.6,.3,.4,.7),2,2,TRUE) +print(a) +print('Eigenvector v1=') +v1=matrix(c(3/7,4/7),2,1,TRUE) +print(v1) +print('vector Xo=') +Xo=matrix(c(.5,.5),2,1,TRUE) +print(Xo) +print('Eigenvalues of A are:') +eig<-eigen(a) +c<-eig$values +print(c) +print('To verify if v1 is an eigenvector of A:') +print('A*v1=') +print(a %*% v1) +print('=') +print('1*v1') +print('Hence v1 is an eigenvector of A corresponding to eigenvalue 1.') +print('for lambda=.3') +print('A-.3I=') +b=a-.3*diag(2) +print(b) +print('performing row operations on the augmented matrix') +zm=matrix(0,2,1,TRUE) +c=cbind(b,zm) +print(c) +c[2,]=c[2,]-(c[2,1]/c[1,1])*c[1,] +c[2,2]=round(c[2,2]) +print(c) +print('hence, x1+x2=0') +print('Eigenvector corresponding to eigenvalue .3 is:') +ev=matrix(c(-1,1),2,1,TRUE) +print(ev) + +#5.2.25b +x0=matrix(c((1/2),(1/2)),2,1,TRUE) +v1=matrix(c((3/7),(4/7)),2,1,TRUE) +md=x0-v1 +print(md) +print('=') +print('(1/14)v2') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.9/Ex5.9.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.9/Ex5.9.R new file mode 100644 index 00000000..7bafc8ed --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH5/EX5.9/Ex5.9.R @@ -0,0 +1,25 @@ +#Chapter 5- Eigenvalues and Eigenvectors +#Diagonalization of a matrix +#Page No.166 / 5-10 +#Prob 1 +#5.3.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('The given eigenvector matrix is:') +p=matrix(c(5,7,2,3),2,2,TRUE) +print('P=') +print(p) +print('The diagonal matrix is:') +d=matrix(c(2,0,0,1),2,2,TRUE) +print('D=') +print(d) +print('Therefore, matrix A=PD(p^-1)') +s=solve(p) +print(p %*% d %*% s) +print('Hence, A^4=P(D^4)(P^-1)') +print(p%*%(d^4)%*%s) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.1/Ex6.1.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.1/Ex6.1.R new file mode 100644 index 00000000..da6dd603 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.1/Ex6.1.R @@ -0,0 +1,29 @@ +#Chapter 6- Orthogonality and Least Squares +#Dot product of vectors +#Page No.193 / 6-1 +#Prob 1 +#6.1.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Vectors u and v are:') +u=matrix(c(-1,2),2,1,TRUE) +v=matrix(c(4,6),2,1,TRUE) +print(u) +print(v) +u2=u * u +vu=v * u +print('u . u') +print(u2[1]+u2[2]) +print('v . u') +print(vu[1]+vu[2]) +print('Projection of v on u=(u.v)/(v.v)') +a=t(u) %*% v +b=t(u) %*% u +p=a/b +print('=') +print(p) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.10/Ex6.10.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.10/Ex6.10.R new file mode 100644 index 00000000..887d6abb --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.10/Ex6.10.R @@ -0,0 +1,47 @@ +#Chapter 6- Orthogonality and Least Squares +#Orthogonal projection +#Page No.199 / 6-7 +#Prob 13 +#6.3.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Given vectors are:') +v1=matrix(c(2,-1,-3,1),4,1,TRUE) +v2=matrix(c(1,1,0,-1),4,1,TRUE) +z=matrix(c(3,-7,2,3),4,1,TRUE) +print('v1=') +print(v1) +print('v2=') +print(v2) +print('z=') +print(z) +a=t(v1) %*% v2 +print('v1.v2=') +print(a) +if(a==0){ +print('v1 and v2 are orthogonal') +} +print('By best approximation theorem, closest point in span{v1 v2} to z is the orthogonal projection') +print('=((z.v1)/(v1.v1))*v1+((z.v2)/(v2.v2))*v2') +a1=t(z) %*% v1 +a2=t(v1) %*% v1 +b1=t(z) %*% v2 +b2=t(v2) %*% v2 +av=(a1/a2) +bv=(b1/b2) +print('=') +print(av[1]*v1) +print('+') +print(bv[1]*v2) +print('=') +zb=(av[1]*v1)+(bv[1]*v2) +print(zb) +zn=z-zb +print(zn) +zn=zn/4 +print(zn) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.11/Ex6.11.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.11/Ex6.11.R new file mode 100644 index 00000000..d8c8e110 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.11/Ex6.11.R @@ -0,0 +1,32 @@ +#Chapter 6- Orthogonality and Least Squares +#Orthogonal decomposition theorem +#Page No.200 / 6-8 +#Prob 19 +#6.3.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('By orthogonal decomposition theorem,') +print('u3 is the sum of a vector in W=span{u1 u2} and a vector v orthogonal to W') +print('To find v, given u1 and u2') +u1=matrix(c(1,1,-2),3,1,TRUE) +u2=matrix(c(5,-1,2),3,1,TRUE) +print('u1=') +print(u1) +print('u2=') +print(u2) +print('Projection of u3 on W') +print('= (-1/3)*u1+(1/15)*u2') +print('=') +print((-1/3)*u1+(1/15)*u2) +print('v= u3-(projection of u3 on W)') +print('=') +m1=matrix(c(0,0,1),3,1,TRUE) +print(m1) +print('-') +print((-1/3)*u1+(1/15)*u2) +print(m1-((-1/3)*u1+(1/15)*u2)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.12/Ex6.12.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.12/Ex6.12.R new file mode 100644 index 00000000..470cddb8 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.12/Ex6.12.R @@ -0,0 +1,36 @@ +#Chapter 6- Orthogonality and Least Squares +#Gram Schimdt Orthogonalisation +#Page No.202 / 6-10 +#Prob 1 +#6.4.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('to orthogonalise the given vectors using Gram-Schimdt orthogonalisation') +x1=matrix(c(3,0,-1),3,1,TRUE) +x2=matrix(c(8,5,-6),3,1,TRUE) +print('x1=') +print(x1) +print('x2=') +print(x2) +print('Let v1=x1') +v1=x1 +print('v2=x2-((x2.v1)/(v1.v1))*v1') +a1=t(x2) %*% v1 +a2=t(v1) %*% v1 +av=(a1/a2) +p=av[1]*v1 +v2=x2-p +print('=') +print(x2) +print('-') +print(p) +print('=') +print(v2) +print('Thus, an orthogonal basis is:') +print(v1) +print(v2) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.13/Ex6.13.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.13/Ex6.13.R new file mode 100644 index 00000000..c66dbeaa --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.13/Ex6.13.R @@ -0,0 +1,41 @@ +#Chapter 6- Orthogonality and Least Squares +#Gram Schimdt Orthogonalisation +#Page No.202 / 6-10 +#Prob 7 +#6.4.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('to orthogonalise the given vectors using Gram-Schimdt orthogonalisation') +x1=matrix(c(2,-5,1),3,1,TRUE) +x2=matrix(c(4,-1,2),3,1,TRUE) +print('x1=') +print(x1) +print('x2=') +print(x2) +print('Let v1=x1') +v1=x1 +print('v2=x2-((x2.v1)/(v1.v1))*v1') +a1=t(x2) %*% v1 +a2=t(v1) %*% v1 +av=(a1/a2) +p=av[1]*v1 +v2=x2-p +print('=') +print(x2) +print('-') +print(p) +print('=') +print(v2) +print('Thus, an orthogonal basis is:') +print(v1) +print(v2) +print('Normalizing v1 and v2, we get') +s1=sqrt(v1[1,1]^2+v1[2,1]^2+v1[3,1]^2) +s2=sqrt(v2[1,1]^2+v2[2,1]^2+v2[3,1]^2) +print(v1/s1) +print(v2/s2) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.14/Ex6.14.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.14/Ex6.14.R new file mode 100644 index 00000000..609b5a8c --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.14/Ex6.14.R @@ -0,0 +1,25 @@ +#Chapter 6- Orthogonality and Least Squares +#QR decomposition of a matrix +#Page No.202 / 6-10 +#Prob 13 +#6.4.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('QR decomposition of a matrix') +print('given matrix A=') +a=matrix(c(5,9,1,7,-3,-5,1,5),4,2,TRUE) +print(a) +print('given matrix Q=') +m1=matrix(c(5,-1,1,5,-3,1,1,3),4,2,TRUE) +q=(1/6)*m1 +print(q) +print('Therefore, R=') +s=t(q) %*% a +print(s) +qr=q %*% s +print(qr) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.15/Ex6.15.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.15/Ex6.15.R new file mode 100644 index 00000000..f02ceea8 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.15/Ex6.15.R @@ -0,0 +1,28 @@ +#Chapter 6- Orthogonality and Least Squares +#Least square solution +#Page No.205 / 6-13 +#Prob 1 +#6.5.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('The co-efficient matrix is:') +a=matrix(c(-1,2,2,-3,-1,3),3,2,TRUE) +print('A=') +print(a) +print('The RHS is:') +b=matrix(c(4,1,2),3,1,TRUE) +print(b) +print('Product of transpose of A and A=') +p1=t(a) %*% a +print(p1) +print('Product of transpose of A and b=') +p2=t(a) %*% b +print(p2) +print('Hence, the solution is:') +p=solve(p1) %*% p2 +print(p) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.16/Ex6.16.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.16/Ex6.16.R new file mode 100644 index 00000000..976038dc --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.16/Ex6.16.R @@ -0,0 +1,55 @@ +#Chapter 6- Orthogonality and Least Squares +#Least square solution +#Page No.206 / 6-14 +#Prob 7 +#6.5.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('The co-efficient matrix is:') +a=matrix(c(1,-2,-1,2,0,3,2,5),4,2,TRUE) +print('A=') +print(a) +print('The RHS is:') +b=matrix(c(3,1,-4,2),4,1,TRUE) +print('b=') +print(b) +print('Product of transpose of A and A=') +p1=t(a) %*% a +print(p1) +print('Product of transpose of A and b=') +p2=t(a) %*% b +print(p2) +print('Forming an augmented matrix to solve the normal equations') +p=cbind(p1,p2) +print(p) +print('performing row operations') +print('R2=R2-R1') +p[2,]=p[2,]-p[1,] +print(p) +print('R1=R1/6 and R2=R2/36') +p[1,]=p[1,]/6 +p[2,]=p[2,]/36 +print(p) +print('R1=R1-R2') +p[1,]=p[1,]-p[2,] +print(p) +print('Hence, the solution is:') +print(p[,3]) +x=p[,3] +print('The least square error is=||Ax-b||') +print('Ax-b=') +print(a %*% x-b) +c=a %*% x-b +s=0 +il<-c(1:4) +for (i in il) +{ +s=s+c[i,1]^2 +} +print('||Ax-b||=') +print(sqrt(s)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.17/Ex6.17.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.17/Ex6.17.R new file mode 100644 index 00000000..2073e4e1 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.17/Ex6.17.R @@ -0,0 +1,41 @@ +#Chapter 6- Orthogonality and Least Squares +#Least square solution +#Page No.207 / 6-15 +#Prob 13 +#6.5.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To determine if u is the least square solution to Ax=b') +print('Given') +a=matrix(c(3,4,-2,1,3,4),3,2,TRUE) +print('A=') +print(a) +b=matrix(c(11,-9,5),3,1,TRUE) +print('b=') +print(b) +u=matrix(c(5,-1),2,1,TRUE) +v=matrix(c(5,-2),2,1,TRUE) +print('u=') +print(u) +print('v=') +print(v) +print('Au=') +print(a %*% u) +c=b-a %*% u +print('b-Au=') +print(c) +print('||b-Au||=') +print(sqrt(c[1,1]^2+c[2,1]^2+c[3,1]^2)) +print('Av=') +print(a %*% v) +d=b-a %*% v +print('b-Av=') +print(d) +print('||b-Av||=') +print(sqrt(d[1,1]^2+d[2,1]^2+d[3,1]^2)) +print('Since Av is more closer to A than Au, u is not the least square solution.') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.18/Ex6.18.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.18/Ex6.18.R new file mode 100644 index 00000000..081a3229 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.18/Ex6.18.R @@ -0,0 +1,37 @@ +#Chapter 6- Orthogonality and Least Squares +#Least squares line +#Page No.209 / 6-17 +#Prob 1 +#6.6.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To obtain a least sqaure line from the given data') +print('Placing the x coordinates of the data in second column of matrix X we get:') +x=matrix(c(1,0,1,1,1,2,1,3),4,2,TRUE) +print('X=') +print(x) +print('Placing the y coordinates in y vector') +y=matrix(c(1,1,2,2),4,1,TRUE) +print('y=') +print(y) +print('Product of transpose of X and X=') +p1=t(x) %*% x +print(p1) +print('Product of transpose of X and y=') +p2=t(x) %*% y +print(p2) +print('The least square solution =') +print(solve(p1) %*% p2) +p=solve(p1) %*% p2 +print('Hence, the least square line is:') +print('y') +print('=') +print(p[1,1]) +print('+') +print(p[2,1]) +print('x') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.19/Ex6.19.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.19/Ex6.19.R new file mode 100644 index 00000000..2837575b --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.19/Ex6.19.R @@ -0,0 +1,29 @@ +#Chapter 6- Orthogonality and Least Squares +#Page No.212 / 6-20 +#Prob 1 +#6.7.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +ipx=matrix(c(4,1,1),3,1,TRUE) +ipy=matrix(c(5,1,1),3,1,TRUE) +x=matrix(c(1,1),2,1,TRUE) +y=matrix(c(5,-1),2,1,TRUE) +print('x') +print(x) +print('y') +print(y) +print('x^2=') +xs=sqrt((ipx[1]*x[1]*x[1])+(ipy[1]*x[2]*x[2])) +ys=sqrt((ipx[1]*y[1]*y[1])+(ipy[1]*y[2]*y[2])) +print('||x||^2') +print(xs) +print('||y||^2') +print(ys) +print('||||^2') +xys=((ipx[1]*x[1]*y[1])+(ipy[1]*x[2]*y[2]))^2 +print(xys) diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.2/Ex6.2.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.2/Ex6.2.R new file mode 100644 index 00000000..c4562ea1 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.2/Ex6.2.R @@ -0,0 +1,18 @@ +#Chapter 6- Orthogonality and Least Squares +#Norm of a vector +#Page No.193 / 6-1 +#Prob 7 +#6.1.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('w=') +w=matrix(c(3,-1,-5),3,1,TRUE) +print(w) +wv=w[1]^2+w[2]^2+w[3]^2 +print('||w||=sqrt(9+1+25)') +print(sqrt(wv)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.20/Ex6.20.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.20/Ex6.20.R new file mode 100644 index 00000000..2f992abf --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.20/Ex6.20.R @@ -0,0 +1,35 @@ +#Chapter 6- Orthogonality and Least Squares +#Page No.214 / 6-22 +#Prob 25 +#6.7.25 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +integrand <-function(t) {1*t} +print('=') +v1=integrate(integrand,lower=-1,upper=1) +print(v1) +integrand1 <-function(t) {1*(t*t)} +print('=') +v2=integrate(integrand1,lower=-1,upper=1) +print(v2) +integrand2 <-function(x) {1*1} +print('<1,1>=') +v3=integrate(Vectorize(integrand2),lower=-1,upper=1) +print(v3) +integrand3 <-function(t) {(t*t)*t} +print('=') +v4=integrate(integrand3,lower=-1,upper=1) +print(v4) +integrand4 <-function(t) {(t*t)} +v5=integrate(integrand4,lower=-1,upper=1) +print('Thus projwt^2=') +projt=(((v2$value/v3$value)*1)+((v4$value/v5$value))) +print(projt) +print('A polynomial orthogonal to W is t^2-projt^2=') +print('t^2-(1/3)') +print('thus the polynomials 1,t^2and 3t^2-1 form an orthogonal basis for Span(1,t,t^2)') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.21/Ex6.21.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.21/Ex6.21.R new file mode 100644 index 00000000..52333ade --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.21/Ex6.21.R @@ -0,0 +1,37 @@ +#Chapter 6- Orthogonality and Least Squares +#Applications of Inner Product Spaces +#Page No.215 / 6-23 +#Prob 1 +#6.8.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +xv<-c(1,-2,1,-1,1,0,1,1,1,2) +x=matrix(xv,5,2,TRUE) +print('X=') +print(x) +yv<-c(0,0,2,4,4) +y=matrix(yv,5,1,TRUE) +print(y) +Wv<-c(1,0,0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,1) +W=matrix(Wv,5,5,TRUE) +WX=W %*% x +print('WX=') +print(WX) +Wy=W %*% y +print('Wy=') +print(Wy) +wxtwx=t(WX) %*% WX +print('(WX)^T*(WX)=') +print(wxtwx) +wxtwy=t(WX) %*% Wy +print('(WX)^T*(Wy)=') +print(wxtwy) +betav=solve(wxtwx) %*% (wxtwy) +print('[B0 B1]=') +print(betav) +cat('the equation of the least squares line is y=',betav[1],'+',betav[2],'x') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.22/Ex6.22.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.22/Ex6.22.R new file mode 100644 index 00000000..2432c452 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.22/Ex6.22.R @@ -0,0 +1,21 @@ +#Chapter 6- Orthogonality and Least Squares +#Applications of Inner Product Spaces +#Page No.216 / 6-24 +#Prob 7 +#6.8.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +integrand <-function(kt) {cos(kt)*cos(kt)} +print('||coskt||^2=') +v1=integrate(integrand,lower=0,upper=360) +print(round(v1$value)) + +integrand <-function(kt) {sin(kt)*sin(kt)} +print('||sinkt||^2=') +v1=integrate(integrand,lower=0,upper=360) +print(round(v1$value)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.23/Ex6.23.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.23/Ex6.23.R new file mode 100644 index 00000000..b7c262f6 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.23/Ex6.23.R @@ -0,0 +1,31 @@ +#Chapter 6- Orthogonality and Least Squares +#Applications of Inner Product Spaces +#Page No.217 / 6-25 +#Prob 9 +#6.8.9 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +integrand <-function(t) {(2*180)-t} +print('The fourier coefficients of f are:') +v1=integrate(integrand,lower=0,upper=360) +v1v=(1/2)*(1/180)*v1$value +print('a0/2=') +print(v1v) +print('for k=1') +integrand1 <-function(t) {((2*180)-t)*cos(t)} +v2=integrate(integrand1,lower=0,upper=360) +v2v=(1/180)*v2$value +print('ak=') +print(round(v2v)) +integrand2 <-function(t) {((2*180)-t)*sin(t)} +v3=integrate(integrand2,lower=0,upper=360) +v3v=(1/180)*v3$value +print('bk=') +print(round(v3v)) +print('The third-order Fourier approximation to f is:') +print('180 + 2sint + sin2t + (2/3)sint3t') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.3/Ex6.3.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.3/Ex6.3.R new file mode 100644 index 00000000..aa478bb2 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.3/Ex6.3.R @@ -0,0 +1,21 @@ +#Chapter 6- Orthogonality and Least Squares +#Distance between two points +#Page No.193 / 6-1 +#Prob 13 +#6.1.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Vector x and y are:') +x=matrix(c(10,-3),2,1,TRUE) +y=matrix(c(-1,-5),2,1,TRUE) +print(x) +print(y) +xyv=((x[1]-y[1])^2+(x[2]-y[2])^2) +print('||x-y||=sqrt(125)') +print('=') +print(sqrt(xyv)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.4/Ex6.4.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.4/Ex6.4.R new file mode 100644 index 00000000..02618421 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.4/Ex6.4.R @@ -0,0 +1,27 @@ +#Chapter 6- Orthogonality and Least Squares +#Orthogonality of vectors +#Page No.195 / 6-3 +#Prob 1 +#6.2.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To verify if u v and w are orthogonal') +u=matrix(c(-1,4,-3),3,1,TRUE) +v=matrix(c(5,2,1),3,1,TRUE) +w=matrix(c(3,-4,-7),3,1,TRUE) +print('u') +print(u) +print('v') +print(v) +print('w') +print(w) +print('u.v=') +print(t(v) %*% u) +print('u.w=') +print(t(u) %*% w) +print('Since u.w is not equal to zero, the set {u v w} is not orthogonal.') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.5/Ex6.5.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.5/Ex6.5.R new file mode 100644 index 00000000..fa1de2e8 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.5/Ex6.5.R @@ -0,0 +1,43 @@ +#Chapter 6- Orthogonality and Least Squares +#Orthogonal basis +#Page No.195 / 6-3 +#Prob 7 +#6.2.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('vectors u1 u2 and x are:') +u1=matrix(c(2,-3),2,1,TRUE) +u2=matrix(c(6,4),2,1,TRUE) +x=matrix(c(9,-7),2,1,TRUE) +print('x') +print(x) +print('u1') +print(u1) +print('u2') +print(u2) +print('u1.u2=') +print(t(u1) %*% u2) +print('u1.u2=0, {u1 u2} is an orthogonal set') +print('Hence {u1 u2} forms a basis of R2') +print('x can be written as: x=a*u1+b*u2') +print('where a=(x.u1)/(u1.u1)') +u1p1=(x * u1) +u1p2=(u1 * u1) +u1m=(u1p1[1]+u1p1[2])/(u1p2[1]+u1p2[2]) +u2p1=(x * u2) +u2p2=(u2 * u2) +u2m=(u2p1[1]+u2p1[2])/(u2p2[1]+u2p2[2]) +x1=(u1m * u1) +x2=(u2m * u2) +x=x1+x2 +print('x1=') +print(x1) +print('x2=') +print(x2) +print('x=') +print(x) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.6/Ex6.6.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.6/Ex6.6.R new file mode 100644 index 00000000..4213dc6e --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.6/Ex6.6.R @@ -0,0 +1,30 @@ +#Chapter 6- Orthogonality and Least Squares +#Projection of vectors +#Page No.195 / 6-3 +#Prob 13 +#6.2.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Vectors y and u are:') +y=matrix(c(2,3),2,1,TRUE) +u=matrix(c(4,-7),2,1,TRUE) +print('u') +print(u) +print('y') +print(y) +print('The orthogonal projection of y on u=((y.u)/(u.u))*u') +a=t(y) %*% u +b=t(u) %*% u +c1=(a/b) +c= c1[1] * u +print('=') +print(c) +print('The component of y orthogonal to u is:') +print(y-c) +print('Thus y=') +print(c+(y-c)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.7/Ex6.7.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.7/Ex6.7.R new file mode 100644 index 00000000..3d67dbb4 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.7/Ex6.7.R @@ -0,0 +1,34 @@ +#Chapter 6- Orthogonality and Least Squares +#Orthonormal vectors +#Page No.196 / 6-4 +#Prob 19 +#6.2.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('given vectors u and v are:') +u=matrix(c(-.6,.8),2,1,TRUE) +v=matrix(c(.8,.6),2,1,TRUE) +print('u') +print(u) +print('v') +print(v) +uvv=u*v +uvv=uvv[1]+uvv[2] +print('u.v=') +print(uvv) +uuv=u*u +uuv=uuv[1]+uuv[2] +print('u.u=') +print(uuv) +vvv=v*v +vvv=vvv[1]+vvv[2] +print('v.v=') +print(vvv) +print('Hence, {u v} is an orthogonal set.') +print('||u||=1 and ||v||=1') +print('Thus, {u v} is an orthonormal set') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.8/Ex6.8.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.8/Ex6.8.R new file mode 100644 index 00000000..ac9f3d23 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.8/Ex6.8.R @@ -0,0 +1,35 @@ +#Chapter 6- Orthogonality and Least Squares +#Orthogonal projection +#Page No.198 / 6-6 +#Prob 1 +#6.3.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Given vectors are:') +u1=matrix(c(0,1,-4,-1),4,1,TRUE) +print('u1') +print(u1) +u2=matrix(c(3,5,1,1),4,1,TRUE) +print('u2') +print(u2) +u3=matrix(c(1,0,1,-4),4,1,TRUE) +print('u3') +print(u3) +u4=matrix(c(5,-3,-1,1),4,1,TRUE) +print('u4') +print(u4) +x=matrix(c(10,-8,2,0),4,1,TRUE) +print('x') +print(x) +print('The vector in span{u4}=((x.u4)/(u4.u4))*u4') +a1=t(x) %*% u4 +a2=t(u4) %*% u4 +av=(a1/a2) +print(av[1]*u4) +print('Therefore, the vector in span{u1 u2 u3}=x-2*u4') +print(x-2*u4) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.9/Ex6.9.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.9/Ex6.9.R new file mode 100644 index 00000000..7e0b0842 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH6/EX6.9/Ex6.9.R @@ -0,0 +1,43 @@ +#Chapter 6- Orthogonality and Least Squares +#Orthogonal projection +#Page No.198 / 6-6 +#Prob 7 +#6.3.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('Vectors u1 u2 and y are') +u1=matrix(c(1,3,-2),3,1,TRUE) +u2=matrix(c(5,1,4),3,1,TRUE) +y=matrix(c(1,3,5),3,1,TRUE) +print('y=') +print(y) +print('u2=') +print(u2) +print('u1=') +print(u1) +print('u1.u2=') +a=t(u1) %*% u2 +print('=') +print(a) +print('Hence, {u1 u2} form an orthogonal basis.') +print('Let W=span{u1 u2}') +print('Therefore, projection of y on W is:') +print('((y.u1)/(u1.u1))*u1+((y.u2)/(u2.u2))*u2') +a1=t(y) %*% u1 +a2=t(u1) %*% u1 +b1=t(y) %*% u2 +b2=t(u2) %*% u2 +print('=') +bv=(b1/b2) +av=(a1/a2) +print(bv[1]*u2) +print('Therefore, projection of y on W is:') +ypy=y-bv[1]*u2 +print(ypy) +ypy=ypy/ypy[2] +print(ypy) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.1/Ex7.1.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.1/Ex7.1.R new file mode 100644 index 00000000..2d958428 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.1/Ex7.1.R @@ -0,0 +1,30 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#Symmetric Matrices +#Page No.222 / 7-2 +#Prob 1 +#7.1.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To check if the given 2X2 matrix is symmetric') + +#Declaration of matrix +a = matrix( + c(3,5,5,-7), + nrow = 2, + ncol = 2, + byrow = TRUE) + +print('A=') +print(a) + +#Check for symmetry +if(a[1,2]==a[2,1]){ + print('A is a symmetric matrix because the (1,2) and(2,1) entries match.') +}else{ + print('A is not a symmetric matrix') +} \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.10/Ex7.10.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.10/Ex7.10.R new file mode 100644 index 00000000..7b42d1cc --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.10/Ex7.10.R @@ -0,0 +1,61 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#The Singular Value Decomposition +#Page No.232 / 7-12 +#Prob 1 +#7.4.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +a=matrix(c(1,0,0,-3),2,2,TRUE) +print('A=') +print(a) +print('ATA') +ata=t(a) %*% a +print(ata) +eig=eigen(ata) +eigv<-eig$values +print('eigen values are:') +print(eigv) +print('eigen vectors are:') +print('for lambda=9') +print(eig$vectors[,1]) +print('for lambda=1') +print(-eig$vectors[,2]) +r1=eig$vectors[,1] +r2=-eig$vectors[,2] +V=cbind(r1,r2) +print('V=') +print(V) +sv1=sqrt(eigv[1]) +sv2=sqrt(eigv[2]) +print('Singular values are:') +print(sv1) +print(sv2) +sigmam=matrix(c(sv1,0,0,sv2),2,2,TRUE) +print('The matrix is the same shape as A=') +print(sigmam) +Av1=a %*% r1 +Av2=a %*% r2 +print('Av1=') +print(Av1) +print('Av2=') +print(Av2) +u1=Av1/sv1 +u2=Av2/sv2 +print('normalize:') +print('u1=') +print(u1) +print('u2=') +print(u2) +um=cbind(u1,u2) +print(um) +print('A=') +print(um) +print('*') +print(sigmam) +print('*') +print(t(V)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.11/Ex7.11.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.11/Ex7.11.R new file mode 100644 index 00000000..183e33d0 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.11/Ex7.11.R @@ -0,0 +1,63 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#The Singular Value Decomposition +#Page No.232 / 7-12 +#Prob 7 +#7.4.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +a=matrix(c(2,-1,2,2),2,2,TRUE) +print('A=') +print(a) +ata=t(a) %*% a +print('ATA=') +print(ata) +eig=eigen(ata) +print('eigen values are:') +eigv<-eig$values +print(eigv) +eigve1<-(-eig$vectors[,1]) +eigve2<-(-eig$vectors[,2]) +print('for lambda=9') +print(eigve1) +print('for lambda=4') +print(eigve2) +V=cbind(eigve1,eigve2) +print(V) +sv1=sqrt(eigv[1]) +sv2=sqrt(eigv[2]) +print('Singular values are') +print(sv1) +print(sv2) +c1<-c(sv1,0) +c2<-c(0,sv2) +sigmam=cbind(c1,c2) +av1=a %*% eigve1 +av2=a %*% eigve2 +print('Av1') +print(av1) +print('Av2') +print(av2) +print('Check orthogonality') +co=av1*av2 +co=co[1]+co[2] +print('Av1.Av2=') +print(co) +u1=av1/sv1 +u2=av2/sv2 +print('u1=') +print(u1) +print('u2=') +print(u2) +um=cbind(u1,u2) +print(um) +print('A=') +print(um) +print('*') +print(sigmam) +print('*') +print(t(V)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.12/Ex7.12.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.12/Ex7.12.R new file mode 100644 index 00000000..bf59e141 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.12/Ex7.12.R @@ -0,0 +1,57 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#The Singular Value Decomposition +#Page No.233 / 7-13 +#Prob 13 +#7.4.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(3,2,2,2,3,-2) +a=matrix(av,2,3,TRUE) +print(a) +aat=a %*% t(a) +print(aat) +eig=eigen(aat) +eigv<-eig$values +print('eigen values are') +print(eigv) +v1=eig$vectors[,1] +v2=eig$vectors[,2] +print('eigen vectors are') +print('for lambda=25') +print(v1) +print('for lambda=9') +print(v2) +V=cbind(v1,v2) +print(V) +sv1=sqrt(eigv[1]) +sv2=sqrt(eigv[2]) +print('singular values are') +print(sv1) +print(sv2) +zm=matrix(0,1,2,TRUE) +c1=matrix(c(sv1,0),1,2,TRUE) +c2=matrix(c(0,sv2),1,2,TRUE) +sigmam=rbind(c1,c2,zm) +print(sigmam) +print(t(a) %*% V) +u1=(t(a) %*% v1)/sv1 +u2=(t(a) %*% v2)/sv2 +print('u1=') +print(u1) +print('u2=') +print(u2) +u3=matrix(c((-2/3),(2/3),(1/3)),3,1,TRUE) +print('u3=') +print(u3) +u=cbind(u1,u2,u3) +print('A=') +print(V) +print('*') +print(t(sigmam)) +print('*') +print(t(u)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.13/Ex7.13.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.13/Ex7.13.R new file mode 100644 index 00000000..5f25e412 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.13/Ex7.13.R @@ -0,0 +1,25 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#Applications to Image Processing and Statistics +#Page No.237 / 7-17 +#Prob 1 +#7.5.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +xv<-c(19,22,6,3,2,20,22,6,9,15,13,5) +x=matrix(xv,2,6,TRUE) +B=x +print(x) +M=matrix(c(12,10),2,1,TRUE) +print(M) +B[1,]=x[1,] - M[1] +B[2,]=x[2,] - M[2] +print(B) +#There is a calculation error in the textbook +S1=B %*% t(B) +S=S1/(dim(B)[2]-1) +print(S) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.14/Ex7.14.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.14/Ex7.14.R new file mode 100644 index 00000000..fe62e60a --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.14/Ex7.14.R @@ -0,0 +1,42 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#Applications to Image Processing and Statistics +#Page No.237 / 7-17 +#Prob 7 +#7.5.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +# Constructing Quadratic Formula +result <- function(a,b,c){ + if(delta(a,b,c) > 0){ # first case D>0 + x_1 = (-b+sqrt(delta(a,b,c)))/(2*a) + x_2 = (-b-sqrt(delta(a,b,c)))/(2*a) + result = c(x_1,x_2) + } + else if(delta(a,b,c) == 0){ # second case D=0 + x = -b/(2*a) + } + else {"There are no real roots."} # third case D<0 +} + +# Constructing delta +delta<-function(a,b,c){ + b^2-4*a*c +} + +a <- result(1,-102,647) +print(a) +print('Two possible choices for new variable are:') +print('y1=-.95x1+.32x2 and') +print('y1=.95x1-.32x2') +print('variance of y1 is') +print(a[1]) +print('total variance is') +print(a[1]+a[2]) +print('the new variable y1 explains about') +print(a[1]/(a[1]+a[2])) +print('% of the variance in the data') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.2/Ex7.2.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.2/Ex7.2.R new file mode 100644 index 00000000..c9f5de62 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.2/Ex7.2.R @@ -0,0 +1,52 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#Orthogonal Matrix +#Page No.222 / 7-2 +#Prob 7 +#7.1.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To show that the given matrix P is orthogonal.') +p = matrix( + c(0.6,0.8,0.8,-0.6), + nrow = 2, + ncol = 2, + byrow = TRUE) + +print('P=') +print(p) +print('P is composed of two vectors.') +p1 = matrix( + c(0.6,0.8), + nrow = 2, + ncol = 1, + byrow = TRUE) + +p2 = matrix( + c(0.8,-0.6), + nrow = 2, + ncol = 1, + byrow = TRUE) + +print('p1=') +print(p1) +print('p2=') +print(p2) +print('To show that the columns are orthonormal') +print('p1.p2=') +s1=p1 * p2 +s=s1[1]+s1[2] +r=t(p1) +print(s) +if(s==0) + print('The columns of P are orthonormal') +end +print('||p1||^2=') +print(sqrt(p[1,1]^2+p[2,1]^2)) +print('||p2||^2=') +print(sqrt(p[1,2]^2+p[2,2]^2)) +print('Hence, ||p1||=||p2||=1. Thus P is an orthogonal matrix') \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.3/Ex7.3.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.3/Ex7.3.R new file mode 100644 index 00000000..9bdc0954 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.3/Ex7.3.R @@ -0,0 +1,102 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#PD decomposition of a matrix +#Page No.222 / 7-2 +#Prob 13 +#7.1.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('To diagonalize the given matrix A') + +#Declaration of matrix +a = matrix( + c(3,1,1,3), + nrow = 2, + ncol = 2, + byrow = TRUE) + +print('A=') +print(a) +eig=eigen(a) +values <- eig$values +print('Eigen values of A are:') +print(values) +print('for lambda=4') +print('A-4I=') +print(a-4*diag(2)) +b=a-4*diag(2) +print('To find the eigenvector, form an augmented matrix.') +zm=matrix( + c(0,0), + nrow=2, + ncol=1, + byrow=TRUE) + +c=cbind(b,zm) +print('performing row operations') +print(c) + +c[2,]=c[2,]+c[1,] +print(c) +print('With x2 as free variable, x1=x2') +print('Hence a basis for the eigenspace is:') +d=matrix( + c(1,1), + nrow=2, + ncol=1, + byrow=TRUE) + +print(d) +print('Upon normalizing') +print(d/(sqrt(2))) +u1=d/(sqrt(2)) +print('for lambda=2') +print('A-2I=') +b=a-2*diag(2) +print(b) +print('To find the eigenvector, form an augmented matrix.') +c=cbind(b,zm) +print('performing row operations') +print(c) +c[2,]=c[2,]-c[1,] +print(c) +print('With x2 as free variable, x1=-x2') +print('Hence a basis for the eigenspace is:') +d=matrix( + c(-1,1), + nrow=2, + ncol=1, + byrow=TRUE) + +print(d) +print('Upon normalizing') +print(d/(sqrt(2))) +u2=d/(sqrt(2)) +print('Matrix P=') +p=cbind(u1,u2) +print(p) +print('The corresponding matrix D=') + +D1=matrix( + c(values[1],0), + nrow=1, + ncol=2, + byrow=TRUE) + +D2=matrix( + c(0,values[2]), + nrow=1, + ncol=2, + byrow=TRUE) + + +D = matrix( + c(D1,D2), + nrow=2, + ncol=2, + byrow = TRUE) +print(D) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.4/Ex7.4.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.4/Ex7.4.R new file mode 100644 index 00000000..a2564a99 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.4/Ex7.4.R @@ -0,0 +1,98 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#PD decomposition of a matrix +#Page No.223 / 7-3 +#Prob 19 +#7.1.19 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('PD decomposition of a matrix A') +av<-c(3,-2,4,-2,6,2,4,2,3) +a=matrix(av,3,3,TRUE) +print('A=') +print(a) +print('Eigenvalues of A are') +eig=eigen(a) +evv=eig$values +print(evv) +cat('for lambda =',evv[1]) +print('A-(lambda)I=') +b=a-evv[1]*diag(3) +print(b) +print('To find eigenvector, form an augmented matrix') +zm=matrix(0,3,1,TRUE) +cm=cbind(b,zm) +print(cm) +print('performing row operations') +cm[2,]=cm[2,]-(cm[2,1]/cm[1,1])*cm[1,] +cm[3,]=cm[3,]-(cm[3,1]/cm[1,1])*cm[1,] +cm[1,]=cm[1,]/-4 +print(cm) +print('With x2 and x3 as free variables, we get two vectors.') +print('x1=-.5x2+x3') +print('Thus, the two vectors are') +v1=matrix(c(-1,2,0),3,1,TRUE) +v2=matrix(c(1,0,1),3,1,TRUE) +print('v1=') +print(v1) +print('v2=') +print(v2) +print('Orthogonalizing v1 and v2') +print('Let x1=v1') +print('x2=v2-((v2.v1)/(v1.v1))*v1') +x1=v1 +a1=t(v2) %*% v1 +a2=t(v1) %*% v1 +av=(a1/a2) +x2=v2-av[1]*v1 +x1=x1/(sqrt(x1[1,1]^2+x1[2,1]^2+x1[3,1]^2)) +u1=x1 +x1=x2/(sqrt(x2[1,1]^2+x2[2,1]^2+x2[3,1]^2)) +print(x2) +x2=x2*5 +print(x2) +print('An orthonormal basis is:') +print('u1=') +print(u1) +print('u2=') +print(x1) +cat('for lambda=',evv[3]) +print('A-(lambda)I=') +b1=a-evv[3]*diag(3) +print(b1) +print('To find eigenvector, form an augmented matrix') +cm1=cbind(b1,zm) +print(cm1) +print('performing row operations') +cm1[2,]=cm1[2,]/2 +cm1[c(1,2),]=cm1[c(2,1),] +cm1[1,]=cm1[1,]/-1 +print(cm1) +cm1[2,]=round(cm1[2,]-5*cm1[1,]) +cm1[3,]=cm1[3,]-4*cm1[1,] +print(cm1) +cm1[3,]=round(cm1[3,]-cm1[2,]) +cm1[2,]=cm1[2,]/18 +print(cm1) +cm1[1,]=round(cm1[1,]+4*cm1[2,]) +print(cm1) +print('With x3 as free variable') +print('x1=x3 and x2=-.5x3') +print('Thus a basis for the eigenspace is:') +v3=matrix(c(-2,-1,2),3,1,TRUE) +print(v3) +print('upon normalizing') +v3=v3/(sqrt(v3[1,1]^2+v3[2,1]^2+v3[3,1]^2)) +print(v3) +print('Thus, matrix P=') +print(cbind(u1,x1,v3)) +print('Corresponding matrix D=') +D1=cbind(evv[1],0,0) +D2=cbind(0,evv[2],0) +D3=cbind(0,0,evv[3]) +D=rbind(D1,D2,D3) +print(D) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.5/Ex7.5.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.5/Ex7.5.R new file mode 100644 index 00000000..dc74b578 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.5/Ex7.5.R @@ -0,0 +1,47 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#Quadratic Form +#Page No.226 / 7-6 +#Prob 1 +#7.2.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +print('given matrix A and vector x') +a = matrix( + c(5,(1/3),(1/3),1), + nrow = 2, + ncol = 2, + byrow = TRUE) + +print('A=') +print(a) + +x = matrix( + c(6,1), + nrow = 2, + ncol = 1, + byrow = TRUE) +print('x=') +print(x) + +print('Product of transpose of x and A and x=') +tx=t(x) +p=tx %*% a %*% x +print(p) +print('New value of vector x=') + +x = matrix( + c(1,3), + nrow = 2, + ncol = 1, + byrow = TRUE) + +print(x) +print('Product of transpose of x and A and x=') +tx1=t(x) +p=tx1 %*% a %*% x +print(p) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.6/Ex7.6.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.6/Ex7.6.R new file mode 100644 index 00000000..b3f12b3c --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.6/Ex7.6.R @@ -0,0 +1,37 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#Page No.226 / 7-6 +#Prob 7 +#7.2.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +a=matrix(c(1,5,5,1),2,2,TRUE) +print('A=') +print(a) +eig=eigen(a) +eigv<-eig$values +print('Eigen values are:') +print(eigv) +ev=eig$vectors +ev1=(ev[,1]/(ev[1,1])) +print('For lambda=6') +print('an eigen vector is') +print(ev1) +print('normalized u1=') +print(eig$vectors[,1]) +ev2=(ev[,2]/(ev[1,1])) +print('For lambda=-4') +print('an eigen vector is') +print(ev2) +print('normalized u2=') +print(eig$vectors[,2]) +pm=eig$vectors +print('P=') +print(pm) +Dm=t(pm) %*% a %*% pm +print('D=') +print(round(Dm)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.7/Ex7.7.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.7/Ex7.7.R new file mode 100644 index 00000000..d099e8fe --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.7/Ex7.7.R @@ -0,0 +1,37 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#Page No.227 / 7-7 +#Prob 13 +#7.2.13 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +a=matrix(c(1,-3,-3,9),2,2,TRUE) +print('A=') +print(a) +eig=eigen(a) +eigv<-round(eig$values) +print('Eigen values are:') +print(eigv) +ev=eig$vectors +ev1=(ev[,1]/(ev[1,1])) +print('For lambda=10') +print('an eigen vector is') +print(ev1) +print('normalized u1=') +print(-eig$vectors[,1]) +ev2=(ev[,2]/(ev[1,1])) +print('For lambda=0') +print('an eigen vector is') +print(ev2) +print('normalized u2=') +print(-eig$vectors[,2]) +pm=-eig$vectors +print('P=') +print(pm) +Dm=t(pm) %*% a %*% pm +print('D=') +print(round(Dm)) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.8/Ex7.8.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.8/Ex7.8.R new file mode 100644 index 00000000..6627f45b --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.8/Ex7.8.R @@ -0,0 +1,35 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#Page No.229 / 7-9 +#Prob 1 +#7.3.1 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(5,2,0,2,6,-2,0,-2,7) +a=matrix(av,3,3,TRUE) +print('A=') +print(a) +eig=eigen(a) +eigv<-eig$values +print('eigen values are:') +print(eigv) +print('for lambda=9') +print('normalized eigenvector u1=') +print(-eig$vectors[,1]) +print('for lambda=6') +print('normalized eigenvector u2=') +print(eig$vectors[,2]) +print('for lambda=3') +print('normalized eigenvector u3=') +print(-eig$vectors[,3]) +print('x=Py') +print('P=') +p1=-eig$vectors[,1] +p2=eig$vectors[,2] +p3=-eig$vectors[,3] +p=cbind(p1,p2,p3) +print(p) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.9/Ex7.9.R b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.9/Ex7.9.R new file mode 100644 index 00000000..6920b631 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/CH7/EX7.9/Ex7.9.R @@ -0,0 +1,29 @@ +#Chapter 7 - Symmetric Matrices And Quadratic Forms +#Page No.229 / 7-9 +#Prob 7 +#7.3.7 + +#clear console +cat("\014") + +#clear variables +rm(list=ls(all=TRUE)) + +av<-c(-2,2,0,2,-1,2,0,2,0) +a=matrix(av,3,3,TRUE) +print('A=') +print(a) +eig=eigen(a) +eigv<-eig$values +print('eigen values are:') +print(eigv) +print('2 is the greatest eigen value') +eigve<-eig$vectors[,1] +v1=eigve/eigve[3] +print('v1=') +print(v1) +v1=v1*2 +print('scaled v1=') +print(v1) +print('u1=') +print(eigve) \ No newline at end of file diff --git a/Linear_Algebra_And_Its_Applications_by_David_C._Lay/README.txt b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/README.txt new file mode 100644 index 00000000..70086c61 --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_David_C._Lay/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Sai Sugun L +Course: Btech +Branch: Electronics Engineering +College/Institute/Organization: Sreenidhi Institute Of Science & Technology + +About The Book + +Book: Linear Algebra And Its Applications +Author: David C. Lay +Publisher: Pearson Addison-wesley +Year Of Publication: 2006 +ISBN: 0-321-28066-0 +Edition: 3 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.11/Ex1_11.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.11/Ex1_11.R new file mode 100644 index 00000000..a005839b --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.11/Ex1_11.R @@ -0,0 +1,18 @@ +#Example 1.11,page 6 +#package used: matlib +#installation run command : install.packages("matlib") +#package repo : https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,2,0,0,-1,-2,1,0,0,1,0,2,0,2,1,1),ncol=4) +b <- c(0,4,0,5) +Ab <- cbind(A,b) +Ab <- rowadd(Ab,1,2,-1) +Ab <- rowswap(Ab,2,3) +Ab <- rowadd(Ab,3,4,-2) +Ab +#Back-substitution gives w = 1, z = 2 , y = -1, and x = -1. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.12/Ex1_12.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.12/Ex1_12.R new file mode 100644 index 00000000..e7c4bf79 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.12/Ex1_12.R @@ -0,0 +1,17 @@ +#Example 1.12 Section I. Solving Linear Systems page7 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installing and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,2,2,3,1,2),ncol = 2) +b <- c(1,-3,-2) +#for this problem we cannot use normal method because the number of equations is more than number of variables +#so we use gaussian elimination technique. +gaussianElimination(A, b, tol = sqrt(.Machine$double.eps), verbose = FALSE, + latex = FALSE, fractions = FALSE) +# result shows that one of the equations is redundant, here x=-2,y=1 \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.13/Ex1_13.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.13/Ex1_13.R new file mode 100644 index 00000000..a7d7f3c3 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.13/Ex1_13.R @@ -0,0 +1,18 @@ +#Example 1.13,page 7 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,2,2,3,1,2),ncol = 2) +b <- c(1,-3,0) +Ab <- cbind(A,b) +Ab <- rowadd(Ab,1,2,-2) +Ab <- rowadd(Ab,1,3,-2) +Ab <- rowadd(Ab,2,3,-(4/5)) +Ab +#the echelon form shows that the system is inconsistent,hence the solution set is empty \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.3/Ex1_3.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.3/Ex1_3.R new file mode 100644 index 00000000..663ef17b --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.3/Ex1_3.R @@ -0,0 +1,6 @@ +#Example 1.3 +#Section I. Solving Linear Systems,page 3 +A <- matrix(c(3,-1,2,1),ncol = 2) +b <- c(7,6) +x <- solve(A) %*% b +x \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.4/Ex1_4.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.4/Ex1_4.R new file mode 100644 index 00000000..7a1b7ebc --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.4/Ex1_4.R @@ -0,0 +1,22 @@ +#Example 1.4,Section I. Solving Linear Systems +#page 3 +#package used: matlib +#installation run command : install.packages("matlib") +#package repo : https://github.com/friendly/matlib + +#installing and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(0,1,1/3,0,5,2,3,-2,0),ncol = 3,nrow = 3) +b <- c(9,2,3) +Ab <- cbind(A,b) +Ab <- rowswap(Ab,1,3) +Ab <- rowmult(Ab,1,3) +Ab <- rowmult(Ab,1,-1) +Ab <- rowadd(Ab,1,2,1) +Ab +#from Ab (X3=3)(since drom row3,3*X3=9) +#from Ab row2 -1*X2-2*x3=-7,so X2=1 +#from Ab row1 X1+6*x2=9,so X1 = 3 \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.7/Ex1_7.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.7/Ex1_7.R new file mode 100644 index 00000000..86158a6f --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.7/Ex1_7.R @@ -0,0 +1,20 @@ +#Example 1.7,page nO:5 +#package used: matlib +#installation run command : install.packages("matlib") +#package repo : https://github.com/friendly/matlib + +#installing and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,2,1,1,-1,-2,0,3,-1),ncol = 3) +b <- c(0,3,3) +Ab <- cbind(A,b) +Ab <- rowadd(Ab,1,2,-2) +Ab <- rowadd(Ab,1,3,-1) +Ab <- rowadd(Ab,2,3,-1) +Ab +#from row3 : -4z=0,so z=0 +#from row2 : -3y+3z=3,so y=-1 +#from row1 : x+y=0,so x=1 \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.8/Ex1_8.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.8/Ex1_8.R new file mode 100644 index 00000000..c4f0cdcf --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.8/Ex1_8.R @@ -0,0 +1,17 @@ +#Example 1.8,page 5 +#package used: matlib +#installation run command : install.packages("matlib") +#package repo : https://github.com/friendly/matlib + +#installing and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(40,-50,15,25),ncol = 2) +b <- c(100,50) +Ab <- cbind(A,b) +Ab <- rowadd(Ab,1,2,1.25) +Ab +#from row2 : 43.75c = 175,so c= 4 +#from row1 : 40h+15c=100,so h=1 diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.9/Ex1_9.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.9/Ex1_9.R new file mode 100644 index 00000000..25e09a21 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX1.9/Ex1_9.R @@ -0,0 +1,21 @@ +#Example 1.9,chapter1 linear systems page 6 +#Example showing gauss method to reduce given system of linear equations +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installing and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,2,3,1,4,6,1,-3,-5),ncol = 3) +b <-c(9,1,0) +Ab <- cbind(A,b) +Ab <-rowadd(Ab,1,2,-2) +Ab <-rowadd(Ab,1,3,-3) +Ab <-rowadd(Ab,2,3,-(3/2)) +Ab +#from Ab row3: z=3 +#from Ab row2: y=-1 +#from Ab row1: x=7 \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.1/Ex1_2_1.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.1/Ex1_2_1.R new file mode 100644 index 00000000..0e4eac30 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.1/Ex1_2_1.R @@ -0,0 +1,20 @@ +#Example 2.1,chapter1,section 1.2,page 13 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(2,1,3,0,-1,-1,1,-1,0),ncol=3) +b <- c(3,1,4) +Ab <- cbind(A,b) +Ab <- rowadd(Ab,1,2,-0.5) +Ab <- rowadd(Ab,1,3,-1.5) +Ab <- rowadd(Ab,2,3,-1) +Ab +#from the result we can see that the system doesnot have a unique solution. +#We can represent the solution set by representing the variables that lead(x,y)by the variable that does not lead(z). +#so solution set {((3/2)-(1/2)z,(1/2)-(3/2)z,z)|z belongs to R} \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.12/Ex1_2_12.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.12/Ex1_2_12.R new file mode 100644 index 00000000..5c8f03e6 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.12/Ex1_2_12.R @@ -0,0 +1,7 @@ +#Example 2.12,section 1.2,chapter 1,page 18. +#vector addition +a <- c(2,3,1) +b <- c(3,-1,4) +a+b +c <- c(1,4,-1,-3) +7*c \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.3/Ex1_2_3.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.3/Ex1_2_3.R new file mode 100644 index 00000000..0e15eae5 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.3/Ex1_2_3.R @@ -0,0 +1,20 @@ +#Example 2.3,chapter1,section 1.2,page 13 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,0,3,0,1,1,0,-1,1,-1,6,1,-1,1,-6,-1),ncol = 4) +b <- c(1,-1,6,1) +Ab <- cbind(A,b) +Ab <- rowadd(Ab,1,3,-3) +Ab <- rowadd(Ab,2,3,3) +Ab <- rowadd(Ab,2,4,1) +Ab +#from the reduced augmented matrix Ab,we can see that only x and y are leading,while z and w are free. +#We represent the solution set by expressing the leading variables in terms of the free variables +#The solution set: {(2 - 2z + 2w,-1 + z - w,z,w)|z,w belongs to R} \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.5/Ex1_2_5.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.5/Ex1_2_5.R new file mode 100644 index 00000000..c37e92e8 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.5/Ex1_2_5.R @@ -0,0 +1,19 @@ +#Example 2.5,section 1.2,page 15 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,2,3,2,0,2,0,1,1,0,0,-1),ncol = 4) +b <- c(1,2,4) +Ab <- cbind(A,b) #augmented matrix +Ab <- rowadd(Ab,1,2,-2) +Ab <- rowadd(Ab,1,3,-3) +Ab <- rowadd(Ab,2,3,-1) +Ab +#The leading variables are x, y, and w. The variable z is free. +#although there are infinitely many solutions, the value of w doesn't vary but is constant w = -1. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.7/Ex1_2_7.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.7/Ex1_2_7.R new file mode 100644 index 00000000..cd004d7c --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX2.7/Ex1_2_7.R @@ -0,0 +1,22 @@ +#Example 2.7,chapter one,section 1.2,page 16 +#package used: matlib +#installation run command : install.packages("matlib") +#package repo : https://github.com/friendly/matlib + +#installing and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,0,1,2,1,0,0,-1,2),ncol = 3) +b <- c(4,0,4) +#creating augmented matrix +Ab <- cbind(A,b) +Ab +#applying reduction techniques +Ab <- rowadd(Ab,1,3,-1) +Ab <- rowadd(Ab,2,3,2) +Ab +#second row: y-z=0 +#first row: x+2*y=4 +#so solution set is : {(4-2*z = 0)} \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX3.3/Ex1_3_3.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX3.3/Ex1_3_3.R new file mode 100644 index 00000000..a8612292 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX3.3/Ex1_3_3.R @@ -0,0 +1,24 @@ +#Example 3.3,section 1.3,chapter 1,page 24 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(3,2,4,-1),ncol = 2) +b <- c(3,1) +c <- c(0,0) +Ab <- cbind(A,b) # linear system +Ac <- cbind(A,c) #system of homogeneous equations +#reduction of original system +Ab <- rowadd(Ab,1,2,-2/3) +#reduction of homogeneous system +Ac <- rowadd(Ac,1,2,-2/3) +#comparing both +Ab +Ac +#Obviously the two reductions go in the same way. +#We can study how to reduce a linear systems by instead studying how to reduce the associated homogeneous system. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH1/EX3.5/Ex1_3_5.R b/Linear_Algebra_by_Jim_Hefferon/CH1/EX3.5/Ex1_3_5.R new file mode 100644 index 00000000..c0a2bc07 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH1/EX3.5/Ex1_3_5.R @@ -0,0 +1,18 @@ +#Example 3.5,chapter 1,section 1.3,page 25 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(7,8,0,0,0,1,1,3,-7,-5,-3,-6,0,-2,0,-1),ncol=4) +b <- c(0,0,0,0) +Ab <- cbind(A,b) +Ab <- rowadd(Ab,1,2,-8/7) +Ab <- rowadd(Ab,2,3,-1) +Ab <- rowadd(Ab,2,4,-3) +Ab <- rowadd(Ab,3,4,-5/2) +Ab \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH2/EX1.16/Ex2_1_16.R b/Linear_Algebra_by_Jim_Hefferon/CH2/EX1.16/Ex2_1_16.R new file mode 100644 index 00000000..87990e40 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH2/EX1.16/Ex2_1_16.R @@ -0,0 +1,16 @@ +#Example 1.16,Section III. Basis and Dimension,page 118 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +v <- c(3,2) +A <- matrix(c(1,1,0,2),ncol = 2) +Av <- cbind(A,v) +Av <- echelon(A,v,reduced = TRUE) +Av +#from Av,c1 = 3 and c2 = -1=2. diff --git a/Linear_Algebra_by_Jim_Hefferon/CH2/EX1.6/Ex2_1_6.R b/Linear_Algebra_by_Jim_Hefferon/CH2/EX1.6/Ex2_1_6.R new file mode 100644 index 00000000..938d80aa --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH2/EX1.6/Ex2_1_6.R @@ -0,0 +1,19 @@ +#Chapter 2. +#Section II. Linear Independence +#Example 1.6,page 103 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +#c1(40 15) + c2(-50 25) = (0 0),check if {(40 15),(-50 25)} is linearly independent +A <- matrix(c(40,15,-50,25),ncol = 2) +b <- c(0,0) +Ab <- cbind(A,b) +Ab <- rowadd(Ab,1,2,-15/40) +Ab +#from Ab,Both c1 and c2 are zero. So the only linear relationship between the two given row vectors is the trivial relationship. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH2/EX1.9/Ex2_1_9.R b/Linear_Algebra_by_Jim_Hefferon/CH2/EX1.9/Ex2_1_9.R new file mode 100644 index 00000000..77f1a7b4 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH2/EX1.9/Ex2_1_9.R @@ -0,0 +1,8 @@ +#Chapter 2. +#Section II. Linear Independence +#Example 1.9,page 104 +v1 <- c(3,4,5) +v2 <- c(2,9,2) +v3 <- c(4,18,4) +(0*v1)+(2*v2)-1*v3 +#the set S = {v1,v2,v3} is linearly dependent because this is a relationship where not all of the scalars are zero \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.10/Ex2_3_10.R b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.10/Ex2_3_10.R new file mode 100644 index 00000000..80b9f9b1 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.10/Ex2_3_10.R @@ -0,0 +1,13 @@ +#Example 3.10,Section III. Basis and Dimension,page 131 +#package used pracma +#install package using command: install.packages("pracma") + +#installation and loading library +#install.packages("pracma") +library("pracma") + +#program +A <- matrix(c(1,2,1,3,6,3,1,3,1,6,16,6),ncol = 4,nrow = 3) +#finding row reduced echelon form("using gauss-jordan reduction") +rref(A) +#Thus, for a reduced echelon form matrix we can find bases for the row and column spaces in essentially the same way, by taking the parts of the matrix, the rows or columns, containing the leading entries. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.2/Ex2_3_2.R b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.2/Ex2_3_2.R new file mode 100644 index 00000000..be64a7ba --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.2/Ex2_3_2.R @@ -0,0 +1,18 @@ +#Example 3.2,Section III. Basis and Dimension,page 127 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(2,4,3,6),ncol = 2) +#Rowspace(A) is this subspace of the space of two-component row vectors +#{c1.(2 3) + c2.(4 6) | c1,c2 belongs to R} +#simplifying A +A <- rowadd(A,1,2,-2) +A +#From the simplified matrix,the second row vector is linearly dependent on the first and so we can simplify the above description to +#{c.(2 3)|c belongs to R} \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.5/Ex2_3_5.R b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.5/Ex2_3_5.R new file mode 100644 index 00000000..1344c076 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.5/Ex2_3_5.R @@ -0,0 +1,20 @@ +#Example 3.5,Section III. Basis and Dimension,page 128 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,1,2,3,4,0,1,1,5),ncol = 3) +#From any matrix, we can produce a basis for the row space by +#performing Gauss's Method and taking the nonzero rows of the resulting echelon form matrix +#simplifying to echelon form +A <- rowadd(A,1,2,-1) +A <- rowadd(A,1,3,-2) +A <- rowadd(A,2,3,6) +A +#on simplification:produces the basis h(1 3 1); (0 1 0); (0 0 3)i for the row space. This is a basis +#for the row space of both the starting and ending matrices, since the two row spaces are equal. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.7/Ex2_3_7.R b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.7/Ex2_3_7.R new file mode 100644 index 00000000..8044a89c --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.7/Ex2_3_7.R @@ -0,0 +1,20 @@ +#Example 3.7,Section III. Basis and Dimension,page 129 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,2,0,4,3,3,1,0,7,8,2,4),ncol = 3) +#to get a basis for the column space, temporarily turn the columns into rows and reduce. +A <- t(A) +A <- rowadd(A,1,2,-3) +A <- rowadd(A,1,3,-7) +A <- rowadd(A,2,3,-2) +#Now turn the rows back to columns +A <- t(A) +A +#The result is a basis for the column space of the given matrix. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.9/Ex2_3_9.R b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.9/Ex2_3_9.R new file mode 100644 index 00000000..5f009c37 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH2/EX3.9/Ex2_3_9.R @@ -0,0 +1,18 @@ +#Example 3.5,Section III. Basis and Dimension,page 130 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +#To get a basis for the span of {x^2 + x^4,2x^2 + 3x^4,-x^2 - 3x^4 } in the space row4 +A <- matrix(c(0,0,0,0,0,0,1,2,-1,0,0,0,1,3,-3),ncol = 5,nrow = 3) +#applying gauss method +A <- rowadd(A,1,2,-2) +A <- rowadd(A,1,3,1) +A <- rowadd(A,2,3,2) +A +#we get the basis (x^2 + x^4,x^4) \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX1.1/Ex3_1_1.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX1.1/Ex3_1_1.R new file mode 100644 index 00000000..fc57c156 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX1.1/Ex3_1_1.R @@ -0,0 +1,13 @@ +#Example 1.1,Section I. page 166 +a <- c(1,2) +a <-t(a) #a becomes row vector +b <-t(a) #b becomes column vector +c <-c(3,4) +c <-t(c) +d <-t(c) +a+c +b+d +#these corresponding vectors add to corresponding totals +5*a +5*b +#correspondence respecting scalar multiplication diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX1.11/Ex3_1_11.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX1.11/Ex3_1_11.R new file mode 100644 index 00000000..7293511e --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX1.11/Ex3_1_11.R @@ -0,0 +1,7 @@ +#Example 1.11,Section II. page 186 +#given map: h(1,0)=(-1,1) and h(0,1)=(-4,4) +#h(3,-2)=h(3*(1,0)-2*(0,1))=3*h(1,0)-2*h(0,1) +a <- c(-1,1) # h(1,0) +b <- c(-4,4) # h(0,1) +3*a-2*b +#the value of h on this argument is a direct consequence of the value of h on the basis vectors. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX1.9/Ex3_1_9.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX1.9/Ex3_1_9.R new file mode 100644 index 00000000..85fb511c --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX1.9/Ex3_1_9.R @@ -0,0 +1,8 @@ +#Example 1.9,Section I. page 170 +#space P5 of polynomials of degree 5 or less and the map f that sends a polynomial p(x) to p(x - 1). +#under this map x^2 ->(x-1)^2 = x^2-2x+1 and x^3+2x -> (x-1)^3+2(x-1) = x^3-3x^2+5x-3. +curve(x^2,from = -1000,to=1000) +curve((x-1)^2,from = -1000,to=1000) +curve(x^3,from = -1000,to=1000) +curve((x-1)^3,from = -1000,to=1000) +#from these plots we can say that this map is an automorphism of this space. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX2.10/Ex3_2_10.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX2.10/Ex3_2_10.R new file mode 100644 index 00000000..7919e0e4 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX2.10/Ex3_2_10.R @@ -0,0 +1,13 @@ +#Example2.10,section III:Computing linear maps,chapter3,page 219 +#package used pracma +#install package using command: install.packages("pracma") + +#installation and loading library +#install.packages("pracma") +library("pracma") + +#program +A <- matrix(c(1,0,2,3),ncol = 2) +Rank(A) +#Any map from R^2 to P1 represented with respect to any pair of bases by the above matrix; +#is nonsingular because this matrix has rank two. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX2.11/Ex3_2_11.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX2.11/Ex3_2_11.R new file mode 100644 index 00000000..513a692e --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX2.11/Ex3_2_11.R @@ -0,0 +1,4 @@ +#Example2.11,section III:Computing linear maps,chapter3,page 220 +A <- matrix(c(1,3,2,6),ncol=2) +det(A) +#map g: V -> W represented by above matrix is singular because this matrix is singular. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX2.5/Ex3_2_5.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX2.5/Ex3_2_5.R new file mode 100644 index 00000000..dd7fe300 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX2.5/Ex3_2_5.R @@ -0,0 +1,14 @@ +#Example2.5,section III:Computing linear maps,chapter3,page 218 +#package used pracma +#install package using command: install.packages("pracma") + +#installation and loading library +#install.packages("pracma") +library("pracma") + +#program +A <- matrix(c(1,1,0,0,2,2,0,0,2,1,3,2),ncol = 3) +Rank(A) +#Any map represented by above matrix must have three-dimensional domain and a four-dimensional codomain. +#Since the rank of this matrix is found to be 2 by above code; +#Any map represented by this matrix has a two-dimensional range space. diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX3.1.11/Ex3_3_1_11.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX3.1.11/Ex3_3_1_11.R new file mode 100644 index 00000000..2f98aaf6 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX3.1.11/Ex3_3_1_11.R @@ -0,0 +1,11 @@ +#Example1.11,section III:Computing linear maps,chapter3,page 211 +a <- matrix(c(1,2,0,0,-1,3),ncol=3) +b <- c(2,-1,1) +a %*% b +#the above result can also be obtained by the method +x <- matrix(c(1,2),ncol = 1) +y <- matrix(c(0,0),ncol = 1) +z <- matrix(c(-1,3),ncol = 1) +#splitting the matrix a into component columns and now multiplying +2*x-1*y+1*z +#we see that both methods are equal. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.1.1/Ex3_4_1_1.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.1.1/Ex3_4_1_1.R new file mode 100644 index 00000000..c59f039a --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.1.1/Ex3_4_1_1.R @@ -0,0 +1,7 @@ +#Example1.1,section IV:Matrix Operations,chapter3,page 224 +#Let f : V -> W be a linear function represented with respect to some bases by this matrix. +f <- matrix(c(1,1,0,1),ncol = 2) +#find the map that is the scalar multiple 5f: V -> W. +5*f +#Changing from the map f to the map 5f has the effect on the representation of the output vector of multiplying each entry by 5. +#Therefore, going from the matrix representing f to the one representing 5f means multiplying all the matrix entries by 5. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.1.2/Ex3_4_1_2.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.1.2/Ex3_4_1_2.R new file mode 100644 index 00000000..2d290db6 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.1.2/Ex3_4_1_2.R @@ -0,0 +1,7 @@ +#Example1.2,section IV:Matrix Operations,chapter3,page 225 +f <- matrix(c(1,2,3,0),ncol = 2) +g <- matrix(c(-2,2,-1,4),ncol = 2) +#two linear maps with the same domain and codomain f; g: R^2 -> R^2 are represented with respect to bases B and D by these matrices. +#find effect of f + g on the map +f+g +#if f does v -> u and g does v -> w then f + g is the function whose action is v -> u + w. \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.4/Ex3_4_2_4.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.4/Ex3_4_2_4.R new file mode 100644 index 00000000..f0ffa844 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.4/Ex3_4_2_4.R @@ -0,0 +1,4 @@ +#Example2.4,section IV:Matrix Operations,chapter3,page 229 +A <- matrix(c(2,4,8,0,6,2),ncol = 2) +B <- matrix(c(1,5,3,7),ncol = 2) +A %*% B diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.5/Ex3_4_2_5.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.5/Ex3_4_2_5.R new file mode 100644 index 00000000..50f9767e --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.5/Ex3_4_2_5.R @@ -0,0 +1,4 @@ +#Example2.5,section IV:Matrix Operations,chapter3,page 229 +A <- matrix(c(1,3,2,4),ncol = 2) +B <- matrix(c(-1,2,0,-2),ncol=2) +A %*% B diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.6/Ex3_4_2_6.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.6/Ex3_4_2_6.R new file mode 100644 index 00000000..643cb0f1 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.2.6/Ex3_4_2_6.R @@ -0,0 +1,4 @@ +#Example2.6,section IV:Matrix Operations,chapter3,page 230 +A <- matrix(c(1,0,1,1,1,0),ncol=2) +B <- matrix(c(4,5,6,7,8,9,2,3),ncol = 4) +A %*% B diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.3.15/Ex3_4_3_15.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.3.15/Ex3_4_3_15.R new file mode 100644 index 00000000..c615c719 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.3.15/Ex3_4_3_15.R @@ -0,0 +1,8 @@ +#Example3.15,section IV.3:Mechanics of Matrix Multiplication,chapter3,page 241 +#A permutation matrix is square and is all 0's except for a single 1 in each row and column. +A <- matrix(c(0,1,0,0,0,1,1,0,0),ncol = 3) #permutation matrix +B <- matrix(c(1,4,7,2,5,8,3,6,9),ncol = 3) +#From the left these matrices permute rows. +A %*% B +#From the right they permute columns. +B %*% A diff --git a/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.4.9/Ex3_4_4_9.R b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.4.9/Ex3_4_4_9.R new file mode 100644 index 00000000..17781554 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH3/EX4.4.9/Ex3_4_4_9.R @@ -0,0 +1,15 @@ +#Example4.9,section IV.4:Inverses,chapter3,page 251 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +# Augmented matrix +A <- matrix(c(0,1,1,3,0,-1,-1,1,0),ncol = 3) +B <- matrix(c(1,0,0,0,1,0,0,0,1),ncol = 3) +AB <- cbind(A,B) +echelon(A,B) diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.10/Ex4_1_10.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.10/Ex4_1_10.R new file mode 100644 index 00000000..41570377 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.10/Ex4_1_10.R @@ -0,0 +1,15 @@ +#Example 1.10,chapter 4,Section III. Laplace's Formula,page 356 +#package used matlib v0.9.1 and pracma +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +t <- matrix(c(1,2,1,0,1,0,4,-1,1),ncol = 3) +#finding inverse: if T has an inverse, if |T| != 0, then T^-1 = (1/|T|)  adj(T) +a <- adjoint(t) +b <- 1/det(t) +i <- b*a +i diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.4/Ex4_1_4.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.4/Ex4_1_4.R new file mode 100644 index 00000000..c42d8991 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.4/Ex4_1_4.R @@ -0,0 +1,14 @@ +#Example 1.4,chapter 4,Section III. Laplace's Formula,page 354 +#package used matlib v0.9.1 and pracma +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +T <- matrix(c(1,4,7,2,5,8,3,6,9),ncol = 3) +T12 <- cofactor(T,1,2) +T22 <- cofactor(T,2,2) +T12 +T22 diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.6/Ex4_1_6.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.6/Ex4_1_6.R new file mode 100644 index 00000000..156a2053 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.6/Ex4_1_6.R @@ -0,0 +1,17 @@ +#Example 1.6,chapter 4,Section III. Laplace's Formula,page 355\ +#package used matlib v0.9.1 and pracma +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +t <- matrix(c(1,4,7,2,5,8,3,6,9),ncol = 3) +x <- det(t) +#computing the determinant by expanding along the first row, +y <- t[1,1]*cofactor(t,1,1)+t[1,2]*cofactor(t,1,2)+t[1,3]*cofactor(t,1,3) +#computing the determinant by expanding along the second row, +z <- t[2,1]*cofactor(t,2,1)+t[2,2]*cofactor(t,2,2)+t[2,3]*cofactor(t,2,3) +all.equal(x,y) +all.equal(x,z) diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.7/Ex4_1_7.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.7/Ex4_1_7.R new file mode 100644 index 00000000..e770d76f --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.7/Ex4_1_7.R @@ -0,0 +1,13 @@ +#Example 1.7,chapter 4,Section III. Laplace's Formula,page 355 +#package used matlib v0.9.1 and pracma +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +t <- matrix(c(1,2,3,5,1,-1,0,1,0),ncol = 3) +#computing the determinant by expanding along the third column. +y <- t[1,3]*cofactor(t,1,3)+t[2,3]*cofactor(t,2,3)+t[3,3]*cofactor(t,3,3) +y diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.5/Ex4_2_5.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.5/Ex4_2_5.R new file mode 100644 index 00000000..2d4cdeab --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.5/Ex4_2_5.R @@ -0,0 +1,20 @@ +#Example 2.5,chapter4,Section I. Definition,page 325 +#package used matlib v0.9.1 +#install package using command: install.packages("matlib") +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(2,4,0,2,4,-3,6,3,5),ncol=3) +b <- det(A) +#determinant by normal ,ethod +A <- rowadd(A,1,2,-2) +A <- rowswap(A,2,3) +A +#reducing with gaussian reduction now multiplying the diagonal terms,keeping in mind the sign change due to row swap to find determinant. +c <- -1*A[1,1]*A[2,2]*A[3,3] +all.equal(b,c) +#so the determinant by both techniques are the same \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.6/Ex4_2_6.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.6/Ex4_2_6.R new file mode 100644 index 00000000..a00f9279 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.6/Ex4_2_6.R @@ -0,0 +1,16 @@ +#Example 2.6,chapter4,Section I. Definition,page 326 +#package used matlib v0.9.1 and pracma +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") + +#program +A <- matrix(c(1,0,0,0,0,1,0,1,1,1,0,0,3,4,5,1),ncol = 4) +A <- rowadd(A,2,4,-1) +A <- rowswap(A,3,4) +A +#multiplying diagonal terms and multiplying it with -1 to compensate for rowswap +-1*A[1,1]*A[2,2]*A[3,3]*A[4,4] + diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.1/Ex4_3_1.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.1/Ex4_3_1.R new file mode 100644 index 00000000..3e45a8cf --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.1/Ex4_3_1.R @@ -0,0 +1,9 @@ +#Example3.1,chapter4,section1,page 329 +X <- matrix(c(4,-2,2,6),ncol = 2) +#scalars come out of each row separately,not from the entire matrix at once. +#so X will become +A <- matrix(c(2,-1,1,3),ncol = 2) +#with scalars 2 & 2 coming out of rows 1 and 2 respectively +c <- det(X) +d <- 4*det(A) +all.equal(c,d) diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.4/Ex4_3_4.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.4/Ex4_3_4.R new file mode 100644 index 00000000..29df6c40 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.4/Ex4_3_4.R @@ -0,0 +1,11 @@ +#Example3.4,chapter 4,page 330 +A <- matrix(c(2,4,1,3),ncol = 2) +#using multinlinearity property to break up the matrix +a <- matrix(c(2,4,0,0),ncol = 2) +b <- matrix(c(2,0,0,3),ncol = 2) +c <- matrix(c(0,4,1,0),ncol = 2) +d <- matrix(c(0,0,1,3),ncol = 2) +#verifying the property +x <- det(A) +y <- det(a)+det(b)+det(c)+det(d) +all.equal(x,y) diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX1.3/Ex5_1_3.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX1.3/Ex5_1_3.R new file mode 100644 index 00000000..3d1d36dc --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX1.3/Ex5_1_3.R @@ -0,0 +1,12 @@ +#Example 1.3,chapter 5,Section II. Similarity,page 390 +#package used matlib v0.9.1 +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") +P <- matrix(c(2,1,1,1),ncol = 2) +T <- matrix(c(2,1,-3,-1),ncol = 2) +#finding similar matrix of T +T1 <- P %*% T %*% Inverse(P) +T1 diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.10/Ex5_2_10.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.10/Ex5_2_10.R new file mode 100644 index 00000000..63487d6c --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.10/Ex5_2_10.R @@ -0,0 +1,16 @@ +#Example 2.10,chapter 5,scetion III.2,page 414 +#package used matlib v0.9.1 +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") +N <- matrix(c(0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0),ncol=4) +P <- matrix(c(1,0,1,0,0,2,1,0,1,1,1,0,0,0,0,1),ncol = 4) +A <- P %*% N %*% Inverse(P) +A +#The new matrix,A is nilpotent; its fourth power is the zero matrix. +x <- P %*% N^4 %*% Inverse(P) +#since (PNP^-1)^4 = P * N^4 *P^-1 +y <- det(x) +all.equal(y,0) diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.17/Ex5_2_17.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.17/Ex5_2_17.R new file mode 100644 index 00000000..e6436638 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.17/Ex5_2_17.R @@ -0,0 +1,21 @@ +#Example 2.17,chapter 5,scetion III.2,page 419 +#package used matlib v0.9.1 +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") +M <- matrix(c(1,1,-1,-1),ncol = 2) +#finding nilpotent index +A <- matrix(c(0,0,0,0),ncol = 2) +count <- 1 +Y <- M +repeat{ + Y <- Y %*% M + if (all.equal(Y,A)){ + print(count+1) + break() + } + count= count+1 +} + diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.18/Ex5_2_18.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.18/Ex5_2_18.R new file mode 100644 index 00000000..960e5899 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.18/Ex5_2_18.R @@ -0,0 +1,20 @@ +#Example 2.18,chapter 5,scetion III.2,page 420 +#package used matlib v0.9.1 +#Github reposiory of matlib :https://github.com/friendly/matlib + +#installation and loading library +#install.packages("matlib") +library("matlib") +M <- matrix(c(0,1,-1,0,1,0,0,1,1,0,0,0,1,0,-1,0,0,-1,0,1,0,0,1,0,-1),ncol = 5) +#finding nilpotent index +A <- matrix(c(0),ncol = 5,nrow = 5) +count <- 1 +Y <- M +repeat{ + Y <- Y %*% M + if (all.equal(Y,A)== TRUE){ + print(count+1) + break() + } + count=count+1 +} diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2.2/Ex5_2_2_2.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2.2/Ex5_2_2_2.R new file mode 100644 index 00000000..b78f52e9 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2.2/Ex5_2_2_2.R @@ -0,0 +1,7 @@ +#Example 2.2,chapter 5,section II.2 Diagonalizability,page 393 +#matrix: T is diagonalizable if there is a nonsingular P such that PTP-1 is diagonal. +T <- matrix(c(4,1,-2,1),ncol = 2) +P <- matrix(c(-1,1,2,-1),ncol = 2) +#checking whether diagonizable +P %*% T %*% Inverse(P) # diagonal matrix +# so matrix P is diagonizable \ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2/Ex5_2_2.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2/Ex5_2_2.R new file mode 100644 index 00000000..cf70b449 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2/Ex5_2_2.R @@ -0,0 +1,12 @@ +#Example 2.2,chapter 5,Section I. Complex Vector Spaces,page 387 +a <- complex(real = 1,imaginary = 1) +b <- complex(real = 0,imaginary = 1) +c <- complex(real = 2,imaginary = -0) +d <- complex(real = -2,imaginary = 3) +e <- complex(real = 1,imaginary = 0) +f <- complex(real = 0,imaginary = 3) +g <- complex(real = 1,imaginary = -0) +h <- complex(real = 0,imaginary = -1) +A <- matrix(c(a,b,c,d),ncol = 2) +B <- matrix(c(e,f,g,h),ncol = 2) +A %*% B diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.4/Ex5_2_4.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.4/Ex5_2_4.R new file mode 100644 index 00000000..ed6d2f8a --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.4/Ex5_2_4.R @@ -0,0 +1,15 @@ +#Example 2.4,chapter 5,section IV.2,page 432 +#package used pracma v1.9.9 +#installing and loading library +#install.packages("pracma") +library("pracma") +T <- matrix(c(2,1,-1,4),ncol=2) +a <- eigen(T) +a$values +#so T has only the single eigenvalue 3. +I <- matrix(c(1,0,0,1),ncol = 2) +T-(3*I) +# so for this,the only eigenvalue is 0 and T -3I is nilpotent. +#to ease this computation we find nulspaces +x <- nullspace(T) +x diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.19/Ex5_3_19.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.19/Ex5_3_19.R new file mode 100644 index 00000000..6b619a24 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.19/Ex5_3_19.R @@ -0,0 +1,4 @@ +#Example3.19,chapter 5,section II.3 Eigenvalues and Eigenvectors,page 404 +T <- matrix(c(2,0,-4,-2,1,8,2,1,3),ncol = 3) +a <- eigen(T) +a$values diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.6/Ex5_3_6.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.6/Ex5_3_6.R new file mode 100644 index 00000000..9bf70023 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.6/Ex5_3_6.R @@ -0,0 +1,5 @@ +#Example3.6,chapter 5,section II.3 Eigenvalues and Eigenvectors,page 398 +T <- matrix(c(2,0,0,0),ncol = 2) +a <-eigen(T) +a$values +a$vectors diff --git a/Linear_Algebra_by_Jim_Hefferon/README.txt b/Linear_Algebra_by_Jim_Hefferon/README.txt new file mode 100644 index 00000000..5bd5c46e --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Ajay Ragh +Course: Bachelor Of Technology +Branch: Information Technology +College/Institute/Organization: Apj Abdul Kalam Technological University + +About The Book + +Book: Linear Algebra +Author: Jim Hefferon +Publisher: Orthogonal Publishing L3c +Year Of Publication: 2017 +ISBN: 978-1944325039 +Edition: 3 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.1/EX1_1.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.1/EX1_1.zip new file mode 100644 index 00000000..1bed99dd Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.1/EX1_1.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.12/EX1_12.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.12/EX1_12.zip new file mode 100644 index 00000000..3c37df5e Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.12/EX1_12.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.13/EX1_13.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.13/EX1_13.zip new file mode 100644 index 00000000..c21ecc0a Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.13/EX1_13.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.16/EX1_16.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.16/EX1_16.zip new file mode 100644 index 00000000..f8022898 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.16/EX1_16.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.2/EX1_2.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.2/EX1_2.zip new file mode 100644 index 00000000..a80589ae Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.2/EX1_2.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.20/EX1_20.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.20/EX1_20.zip new file mode 100644 index 00000000..e09d4d7f Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.20/EX1_20.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.22/EX1_22.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.22/EX1_22.zip new file mode 100644 index 00000000..7fdf074d Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.22/EX1_22.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.30/EX1_30.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.30/EX1_30.zip new file mode 100644 index 00000000..d25437bb Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.30/EX1_30.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.31/EX1_31.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.31/EX1_31.zip new file mode 100644 index 00000000..c6aebfd6 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.31/EX1_31.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.32/EX1_32.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.32/EX1_32.zip new file mode 100644 index 00000000..c6b92905 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.32/EX1_32.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.4/EX1_4.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.4/EX1_4.zip new file mode 100644 index 00000000..98fd87a9 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH1/EX1.4/EX1_4.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.1/EX2_1.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.1/EX2_1.zip new file mode 100644 index 00000000..c3c8f8f0 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.1/EX2_1.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.18/EX2_18.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.18/EX2_18.zip new file mode 100644 index 00000000..b6575a17 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.18/EX2_18.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.20/EX2_20.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.20/EX2_20.zip new file mode 100644 index 00000000..36b2cd14 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.20/EX2_20.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.21/EX2_21.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.21/EX2_21.zip new file mode 100644 index 00000000..d2f20bd9 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.21/EX2_21.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.24/EX2_24.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.24/EX2_24.zip new file mode 100644 index 00000000..2778a52e Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.24/EX2_24.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.26/EX2_26.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.26/EX2_26.zip new file mode 100644 index 00000000..870f4fb3 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.26/EX2_26.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.3/EX2_3.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.3/EX2_3.zip new file mode 100644 index 00000000..7fb8ed32 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.3/EX2_3.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.36/EX2_36.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.36/EX2_36.zip new file mode 100644 index 00000000..b2a7ef9b Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.36/EX2_36.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.4/EX2_4.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.4/EX2_4.zip new file mode 100644 index 00000000..b0ded4e9 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.4/EX2_4.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.5/EX2_5.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.5/EX2_5.zip new file mode 100644 index 00000000..5b8c816a Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH2/EX2.5/EX2_5.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.1/EX3_1.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.1/EX3_1.zip new file mode 100644 index 00000000..aa97408f Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.1/EX3_1.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.10.a/EX3_10_(a).zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.10.a/EX3_10_(a).zip new file mode 100644 index 00000000..3c534778 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.10.a/EX3_10_(a).zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.10.c/EX3_10_(c).zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.10.c/EX3_10_(c).zip new file mode 100644 index 00000000..85d656e5 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.10.c/EX3_10_(c).zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.13/EX3_13.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.13/EX3_13.zip new file mode 100644 index 00000000..55bec9bd Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.13/EX3_13.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.14/EX3_14.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.14/EX3_14.zip new file mode 100644 index 00000000..b640a29f Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.14/EX3_14.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.2/EX3_2.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.2/EX3_2.zip new file mode 100644 index 00000000..68b5ba98 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.2/EX3_2.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.3/EX3_3.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.3/EX3_3.zip new file mode 100644 index 00000000..9f00a322 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.3/EX3_3.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.4/EX3_4.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.4/EX3_4.zip new file mode 100644 index 00000000..90fadd9e Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.4/EX3_4.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.8/EX3_8.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.8/EX3_8.zip new file mode 100644 index 00000000..7d1f3e8f Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH3/EX3.8/EX3_8.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.1/EX4_1.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.1/EX4_1.zip new file mode 100644 index 00000000..1dfb4baf Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.1/EX4_1.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.2/EX4_2.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.2/EX4_2.zip new file mode 100644 index 00000000..af194bc8 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.2/EX4_2.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.3/EX4_3.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.3/EX4_3.zip new file mode 100644 index 00000000..6e6cc97e Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.3/EX4_3.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.4/EX4_4.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.4/EX4_4.zip new file mode 100644 index 00000000..05efe006 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.4/EX4_4.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.6/EX4_6.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.6/EX4_6.zip new file mode 100644 index 00000000..a1fbe752 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.6/EX4_6.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.7/EX4_7.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.7/EX4_7.zip new file mode 100644 index 00000000..59340de0 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.7/EX4_7.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.8/EX4_8.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.8/EX4_8.zip new file mode 100644 index 00000000..3a7848de Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.8/EX4_8.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.9/EX4_9.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.9/EX4_9.zip new file mode 100644 index 00000000..39daabee Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH4/EX4.9/EX4_9.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.1/EX5_1.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.1/EX5_1.zip new file mode 100644 index 00000000..c53ac2e5 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.1/EX5_1.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.10/EX5_10.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.10/EX5_10.zip new file mode 100644 index 00000000..67e7313c Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.10/EX5_10.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.12/EX5_12.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.12/EX5_12.zip new file mode 100644 index 00000000..0e430898 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.12/EX5_12.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.4/EX5_4.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.4/EX5_4.zip new file mode 100644 index 00000000..52441483 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.4/EX5_4.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.5/EX5_5.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.5/EX5_5.zip new file mode 100644 index 00000000..d33fa168 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.5/EX5_5.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.6/EX5_6.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.6/EX5_6.zip new file mode 100644 index 00000000..73920a4d Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.6/EX5_6.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.8/EX5_8.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.8/EX5_8.zip new file mode 100644 index 00000000..d57f8ca1 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.8/EX5_8.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.9/EX5_9.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.9/EX5_9.zip new file mode 100644 index 00000000..6a4c5740 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH5/EX5.9/EX5_9.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.23/EX6_23.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.23/EX6_23.zip new file mode 100644 index 00000000..6961617c Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.23/EX6_23.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.24/EX6_24.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.24/EX6_24.zip new file mode 100644 index 00000000..de00eb9b Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.24/EX6_24.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.25/EX6_25.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.25/EX6_25.zip new file mode 100644 index 00000000..06b7fb67 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.25/EX6_25.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.27/EX6_27.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.27/EX6_27.zip new file mode 100644 index 00000000..876a98e5 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.27/EX6_27.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.31/EX6_31.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.31/EX6_31.zip new file mode 100644 index 00000000..bd1f4b24 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.31/EX6_31.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.34/EX6_34.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.34/EX6_34.zip new file mode 100644 index 00000000..72313845 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.34/EX6_34.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.37/EX6_37.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.37/EX6_37.zip new file mode 100644 index 00000000..446de60c Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.37/EX6_37.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.38/EX6_38.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.38/EX6_38.zip new file mode 100644 index 00000000..92876506 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.38/EX6_38.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.4/EX6_4.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.4/EX6_4.zip new file mode 100644 index 00000000..5b200f44 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.4/EX6_4.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.40/EX6_40.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.40/EX6_40.zip new file mode 100644 index 00000000..23e23d9a Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.40/EX6_40.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.41/EX6_41.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.41/EX6_41.zip new file mode 100644 index 00000000..41a79233 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.41/EX6_41.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.8/EX6_8.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.8/EX6_8.zip new file mode 100644 index 00000000..5c527c7c Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH6/EX6.8/EX6_8.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.10/EX7_10.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.10/EX7_10.zip new file mode 100644 index 00000000..c78bbc49 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.10/EX7_10.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.8/EX7_8.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.8/EX7_8.zip new file mode 100644 index 00000000..b7601d06 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.8/EX7_8.zip differ diff --git a/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.9/EX7_9.zip b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.9/EX7_9.zip new file mode 100644 index 00000000..346b1325 Binary files /dev/null and b/Linear_Algebra_by_Stephen_H._Friedberg,_Arnold_J._Insel,_Lawrence_E._Spence/CH7/EX7.9/EX7_9.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.1/Ex1_1.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.1/Ex1_1.zip new file mode 100644 index 00000000..fb28a81d Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.1/Ex1_1.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.10/Ex1_10.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.10/Ex1_10.zip new file mode 100644 index 00000000..403ad976 Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.10/Ex1_10.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.11/Ex1_11.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.11/Ex1_11.zip new file mode 100644 index 00000000..38d9da3c Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.11/Ex1_11.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.12/Ex1_12.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.12/Ex1_12.zip new file mode 100644 index 00000000..4791ee2e Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.12/Ex1_12.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.13/Ex1_13.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.13/Ex1_13.zip new file mode 100644 index 00000000..44097ba5 Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.13/Ex1_13.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.14/Ex1_14.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.14/Ex1_14.zip new file mode 100644 index 00000000..7606fc27 Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.14/Ex1_14.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.15/Ex1_15.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.15/Ex1_15.zip new file mode 100644 index 00000000..2634c3a0 Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.15/Ex1_15.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.2/Ex1_2.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.2/Ex1_2.zip new file mode 100644 index 00000000..4c7fdf1e Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.2/Ex1_2.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.3/Ex1_3.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.3/Ex1_3.zip new file mode 100644 index 00000000..d8aa3dee Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.3/Ex1_3.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.4/Ex1_4.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.4/Ex1_4.zip new file mode 100644 index 00000000..4d05541d Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.4/Ex1_4.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.5/Ex1_5.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.5/Ex1_5.zip new file mode 100644 index 00000000..c8f2512d Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.5/Ex1_5.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.6/Ex1_6.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.6/Ex1_6.zip new file mode 100644 index 00000000..b969cb52 Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.6/Ex1_6.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.7/Ex1_7.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.7/Ex1_7.zip new file mode 100644 index 00000000..e3846fb5 Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.7/Ex1_7.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.8/Ex1_8.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.8/Ex1_8.zip new file mode 100644 index 00000000..1fee2d01 Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.8/Ex1_8.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.9/Ex1_9.zip b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.9/Ex1_9.zip new file mode 100644 index 00000000..6e7d6764 Binary files /dev/null and b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH1/EX1.9/Ex1_9.zip differ diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.1/Ex2_1.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.1/Ex2_1.R new file mode 100644 index 00000000..a820051a --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.1/Ex2_1.R @@ -0,0 +1,16 @@ +#page - 74 +#section - 2.2 SUBSPACES +#example 1 + +#let us represent 'a' with a value as we cannot multiply character matrix with numerical matrix +a = 7 + +#let unit vectors of F4*1 be E1, E2, E3, E,4 +E1 <- matrix(c(1,0,0,0), 4, 1) +E2 <- matrix(c(0,1,0,0), 4, 1) +E3 <- matrix(c(0,0,1,0), 4, 1) +E4 <- matrix(c(0,0,0,1), 4, 1) + +#thus vector A is +A = (E1 %*% a) + (E2 %*% a) + (E3 %*% a) + (E4 %*% a) +A \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.2/Ex2_2.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.2/Ex2_2.R new file mode 100644 index 00000000..cfc53ea7 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.2/Ex2_2.R @@ -0,0 +1,17 @@ +#page - 75 +#section - 2.2 SUBSPACES +#example 2 + +#included package - matlib + +#for echelon function +library(matlib) + +#matrix A +A <- matrix(c(1,-1,-3,-1,2,5,1,2,6), 3, 3, byrow=TRUE) + +#column matrix k +K <- c(-6,10,15) + +#reduced row-echelon form +echelon(A, K, reduced=FALSE, verbose=TRUE, fractions=TRUE) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.3/Ex2_3.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.3/Ex2_3.R new file mode 100644 index 00000000..d5186aef --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.3/Ex2_3.R @@ -0,0 +1,17 @@ +#page - 80 +#section - 2.3 LINEAR INDEPENDENCE AND BASES +#example 3 + +#included package - matlib + +#for echelon function +library(matlib) + +#matrix A +A <- matrix(c(1,-2,1,2,-5,0,-1,3,1,2,0,10), 4, 3, byrow=TRUE) + +#column matrix k +K <- c(0,0,0,0) + +#reduced row-echelon form +echelon(A, K, reduced=FALSE, verbose=TRUE, fractions=TRUE) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.4/Ex2_4.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.4/Ex2_4.R new file mode 100644 index 00000000..cbaa6ef4 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.4/Ex2_4.R @@ -0,0 +1,17 @@ +#page - 81 +#section - 2.3 LINEAR INDEPENDENCE AND BASES +#example 4 + +#included package - matlib + +#for echelon function +library(matlib) + +#matrix A +A <- matrix(c(-1,-2,2,0,1,3,1,1,1), 3, 3, byrow=TRUE) + +#column matrix k +K <- c(0,0,0) + +#reduced row-echelon form +echelon(A, K, reduced=FALSE, verbose=TRUE, fractions=TRUE) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.5/Ex2_5.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.5/Ex2_5.R new file mode 100644 index 00000000..4c411e66 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.5/Ex2_5.R @@ -0,0 +1,17 @@ +#page - 82 +#section - 2.3 LINEAR INDEPENDENCE AND BASES +#example 5 + +#included package - matlib + +#for echelon function +library(matlib) + +#matrix A +A <- matrix(c(1,2,3,3,2,1,0,2,4,1,1,1), 4, 3, byrow=TRUE) + +#column matrix k +K <- c(1,1,1,1) + +#reduced row-echelon form +B = echelon(A, K, reduced=TRUE, verbose=TRUE, fractions=TRUE) diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.6/Ex2_6.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.6/Ex2_6.R new file mode 100644 index 00000000..8e92816a --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.6/Ex2_6.R @@ -0,0 +1,17 @@ +#page - 82 +#section - 2.3 LINEAR INDEPENDENCE AND BASES +#example 6 + +#included package - matlib + +#for echelon function +library(matlib) + +#matrix A +A <- matrix(c(3,-1,-1,-2,2,-2,-1,-1,3), 3, 3, byrow=TRUE) + +#column matrix k +K <- c(-3,2,1) + +#reduced row-echelon form +B = echelon(A, K, reduced=TRUE, verbose=TRUE, fractions=TRUE) diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.7/Ex2_7.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.7/Ex2_7.R new file mode 100644 index 00000000..5717d144 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH2/EX2.7/Ex2_7.R @@ -0,0 +1,24 @@ +#page - 88 +#section - 2.4 THE RANK OF A MATRIX +#example 7 + +#included package - matlib +#included package - matrixcalc + +#for echelon function +library(matlib) + +#for rank calculation +library(matrixcalc) + +#matrix A +A <- matrix(c(2,1,1,1,-2,1,0,5,-1), 3, 3, byrow=TRUE) + +#column matrix k +K <- c(2,-3,8) + +#reduced row-echelon form +B = echelon(A, K, reduced=TRUE, verbose=TRUE, fractions=TRUE) + +#rank of A +matrix.rank(A) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.1/Ex3_1.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.1/Ex3_1.R new file mode 100644 index 00000000..21351cf2 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.1/Ex3_1.R @@ -0,0 +1,10 @@ +#page - 103 +#section - 3.1 DEFINITION OF THE DETERMINANT +#example 1 + +#matrix A +A <- matrix(c(1,2,3,2,4,1,1,3,0), 3, 3, byrow=TRUE) +A + +#determinant of A +det(A) diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.2/Ex3_2.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.2/Ex3_2.R new file mode 100644 index 00000000..7a4c42fa --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.2/Ex3_2.R @@ -0,0 +1,19 @@ +#page - 106 +#section - 3.2 THE LAPLACE EXPANSION +#example 2 + +#matrix A +A <- matrix(c(1,2,3,4,5,6,7,8,9), 3, 3, byrow=TRUE) +A + +# Minor and cofactor functions +minor <- function(A, i, j) A[-i,-j] +cofactor <- function(A, i, j) (-1)^(i+j) * det(minor(A,i,j)) + +#calculating Minor and cofactor + +minor(A, 1, 2) +cofactor(A, 1, 2) + +minor(A, 3, 3) +cofactor(A, 3, 3) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.3/Ex3_3.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.3/Ex3_3.R new file mode 100644 index 00000000..fd4559f7 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.3/Ex3_3.R @@ -0,0 +1,10 @@ +#page - 108 +#section - 3.2 THE LAPLACE EXPANSION +#example 3 + +#matrix A +A <- matrix(c(2,4,6,1,2,3,1,4,9), 3, 3, byrow=TRUE) +A + +#determinant of A +det(A) diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.4/Ex3_4.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.4/Ex3_4.R new file mode 100644 index 00000000..210794bc --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.4/Ex3_4.R @@ -0,0 +1,10 @@ +#page - 108 +#section - 3.2 THE LAPLACE EXPANSION +#example 4 + +#matrix A +A <- matrix(c(1,-1,2,3,2,2,0,2,4,1,-1,-1,1,2,3,0), 4, 4, byrow=TRUE) +A + +#determinant of A +det(A) diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.5/Ex3_5.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.5/Ex3_5.R new file mode 100644 index 00000000..076d2f98 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.5/Ex3_5.R @@ -0,0 +1,21 @@ +#page - 111 +#section - 3.3 ADJOINTS AND INVERSES +#example 5 + +#matrix A +A <- matrix(c(2,-1,1,4,2,4,6,3,9), 3, 3) + +# Minor and cofactor functions +minor <- function(A, i, j) det(A[-i,-j]) +cofactor <- function(A, i, j) (-1)^(i+j) * minor(A,i,j) + +#Adjoint functions +adjoint <- function(x) { + n <- nrow(x) + B <- matrix(NA, n, n) + for( i in 1:n ) + for( j in 1:n ) + B[j,i] <- cofactor(x, i, j) + B +} +adjoint(A) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.6/Ex3_6.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.6/Ex3_6.R new file mode 100644 index 00000000..33d383e3 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.6/Ex3_6.R @@ -0,0 +1,28 @@ +#page - 114 +#section - 3.2 THE LAPLACE EXPANSION +#example 6 + +#column matrices +c1 <- matrix(c(1,1,2), 3, 1, byrow=TRUE) +c2 <- matrix(c(2,-1,3), 3, 1, byrow=TRUE) +c3 <- matrix(c(1,1,-1), 3, 1, byrow=TRUE) +c4 <- matrix(c(4,5,1), 3, 1, byrow=TRUE) + +A <- matrix(c(c1,c2,c3), 3, 3) +B <- matrix(c(c4,c2,c3), 3, 3) +C <- matrix(c(c1,c4,c3), 3, 3) +D <- matrix(c(c1,c2,c4), 3, 3) +A +B +C +D +#solution of r,s and t +r = det(B)/det(A) +r + +s=det(C)/det(A) +s + +t=det(D)/det(A) +t + diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.7/Ex3_7.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.7/Ex3_7.R new file mode 100644 index 00000000..2cd67afa --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH3/EX3.7/Ex3_7.R @@ -0,0 +1,20 @@ +#page - 115 +#section - 3.4 DETERMINANTS AND RANK +#example 7 + +#included package - matrixcalc + +#for rank calculation +library(matrixcalc) + +#matrix A +A <- matrix(c(1,-1,1,1,1,2,-1,-1,2,-2,1,-1,0,-3,-1,-1), 4, 4, byrow=TRUE) + +#matrix N +N <- matrix(c(0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0), 4, 4, byrow=TRUE) + +#rank of A +matrix.rank(A) + +#rank of N +matrix.rank(N) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.1/Ex4_1.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.1/Ex4_1.R new file mode 100644 index 00000000..4ad0653e --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.1/Ex4_1.R @@ -0,0 +1,18 @@ +#page - 123 +#section - 4.2 MATRIX REPRESENTATION +#example 1 + +#w-coordinate matrices +Crdwb1 <- matrix(c(-2,5,6,-4), 4, 1, byrow=TRUE) +Crdwb2 <- matrix(c(-5,12,11,-5), 4, 1, byrow=TRUE) +Crdwb3 <- matrix(c(3,-5,-5,3), 4, 1, byrow=TRUE) + +#matrix T +Tmat <- matrix(c(Crdwb1,Crdwb2,Crdwb3), 4, 3) +Tmat + +Crdwv <- matrix(c(3,-5,7), 3, 1) +Crdwv + +CrdwTv = Tmat %*% Crdwv +CrdwTv \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.2/Ex4_2.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.2/Ex4_2.R new file mode 100644 index 00000000..3d1be6d0 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.2/Ex4_2.R @@ -0,0 +1,22 @@ +#page - 131 +#section - 4.4 CHANGE OF BASIS AND SIMILARITY +#example - 2 + +#included package - matlib + +#for inverse functions +library(matlib) + +#matrix M +M <- matrix(c(2,4,6,-1,2,3,1,4,9), 3, 3, byrow=TRUE) +M + +#matrix P +P <- matrix(c(1,0,1,1,1,1,1,1,0), 3, 3, byrow=TRUE) +P + +#inverse of matrix P, PI +(PI <- inv(P)) + +Mtx = PI %*% M %*% P +Mtx \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.3/Ex4_3.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.3/Ex4_3.R new file mode 100644 index 00000000..46cfade7 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.3/Ex4_3.R @@ -0,0 +1,22 @@ +#page - 132 +#section - 4.4 CHANGE OF BASIS AND SIMILARITY +#example - 3 + +#included Package - matlib + +#for inverse functions +library(matlib) + +#matrix M +M <- matrix(c(17,12,18,-16,-9,-24,-5,-4,-4), 3, 3, byrow=TRUE) +M + +#matrix Q +Q <- matrix(c(10,-3,-3,-8,3,2,-3,1,1), 3, 3, byrow=TRUE) +Q + +#inverse of matrix Q, QI +(QI <- inv(Q)) + +Mtx = QI %*% M %*% Q +Mtx \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.4/Ex4_4.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..71d7984d --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,16 @@ +#page - 135 +#section - 4.5 CHARACTERISTIC VECTORS AND CHARACTERISTIC VALUES +#example - 4 + +#matrix A +A <- matrix(c(7,-8,-8,9,-16,-18,-5,11,13), 3, 3, byrow=TRUE) +A + +#matrix X +X <- matrix(c(1,3,-2), 3, 1, byrow=TRUE) +X + +A %*% X + +#eigenvalues and eigenvectors +eigen(A) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.5/Ex4_5.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..14a3cdb7 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,15 @@ +#page - 137 +#section - 4.5 CHARACTERISTIC VECTORS AND CHARACTERISTIC VALUES +#example - 5 + +#included package - pracma + +#for charpoly function +library(pracma) + +#matrix A +A <- matrix(c(2,1,1,2,3,2,1,1,2), 3, 3, byrow=TRUE) +A + +#characteristic polynomial +charpoly(A, info = FALSE) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.6/Ex4_6.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.6/Ex4_6.R new file mode 100644 index 00000000..cbf11939 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH4/EX4.6/Ex4_6.R @@ -0,0 +1,15 @@ +#page - 156 +#section - 4.8 SCHUR'S THEOREM AND NORMAL MATRICES +#example - 6 + +#included package - pracma + +#for charpoly function +library(pracma) + +#matrix A +B <- matrix(c(4,-1,1,-1,4,-1,1,-1,4), 3, 3, byrow=TRUE) +B + +#characteristic polynomial +charpoly(B, info = FALSE) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH5/EX5.1/Ex5_1.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH5/EX5.1/Ex5_1.R new file mode 100644 index 00000000..1bffec53 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH5/EX5.1/Ex5_1.R @@ -0,0 +1,24 @@ +#page - 167 +#section - 5.1 THE CAYLEY-HAMILTON THEOREM +#example - 1 + +#included package - polynom + +#for minimum polynomial function +library(polynom) + +#matrix B +B <- matrix(c(17,-8,-12,14,46,-22,-35,41,-2,1,4,-4,4,-2,-2,3), 4, 4, byrow = TRUE) +B + +eigVals <- eigen(B)$values +multEig <- table(eigVals) +k <- length(multEig) +minPoly <- 1 +for(i in 1:k){ + poly.i <- polynomial(c(-as.numeric(names(multEig)[i]), 1)) + minPoly <- (minPoly*poly.i) +} + +#minimum polynomial +minPoly \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH5/EX5.2/Ex5_2.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH5/EX5.2/Ex5_2.R new file mode 100644 index 00000000..ba3232bb --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH5/EX5.2/Ex5_2.R @@ -0,0 +1,31 @@ +#page - 168 +#section - 5.1 THE CAYLEY-HAMILTON THEOREM +#example - 2 + +#included packages - pracma, polynom + +#for charpoly function +library(pracma) + +#for minimum polynomial function +library(polynom) + +#matrix S +S <- matrix(c(4,-1,1,-1,4,-1,1,-1,4), 3, 3, byrow = TRUE) +S + +eigVals <- eigen(S)$values +multEig <- table(eigVals) +k <- length(multEig) +minPoly <- 1 +for(i in 1:k){ + poly.i <- polynomial(c(-as.numeric(names(multEig)[i]), 1)) + minPoly <- (minPoly*poly.i) +} + +#characteristic polynomial +charpoly(S, info = FALSE) + +#minimum polynomial +minPoly + diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH6/EX6.1/Ex6_1.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH6/EX6.1/Ex6_1.R new file mode 100644 index 00000000..f5e852cd --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH6/EX6.1/Ex6_1.R @@ -0,0 +1,35 @@ +#page - 208 +#section - 6.4 MATRICES WITH POLYNOMIAL ELEMENTS +#example 1 + +#included package - exmp + +#for power of a matrix +library(expm) + +#constant matrices +c1 <- matrix(c(0,0,1,1), 2, 2, byrow=TRUE) +c2 <- matrix(c(0,1,0,1), 2, 2, byrow=TRUE) +c3 <- matrix(c(1,1,0,1), 2, 2, byrow=TRUE) + +#matrix A +A <- matrix(c(1,0,0,2), 2, 2) +A + +#square of A +A2 = A %^% 2 +A2 + +#right functional value +Pr = c1%*%A2 + c2%*%A + c3 +Pr + +#left functional value +Pi = A2%*%c1 + A%*%c2 + c3 +Pi + +#function to compare two matrices +matequal <- function(x, y) + is.matrix(x) && is.matrix(y) && dim(x) == dim(y) && all(x == y) + +matequal(Pr,Pi) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH8/EX8.1/Ex8_1.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH8/EX8.1/Ex8_1.R new file mode 100644 index 00000000..1f95dd8b --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH8/EX8.1/Ex8_1.R @@ -0,0 +1,13 @@ +#page - 242 +#section - 8.2 PRIMARY FUNCTIONS +#example 1 + + +#first matrix A +A <- matrix(c(2,1,1,2,3,2,1,1,2), 2, 3, byrow=TRUE) +A + +fn <- function(z) + sin((pi/2)*z) + +fn(A) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.1/Ex9_1.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.1/Ex9_1.R new file mode 100644 index 00000000..c15e2032 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.1/Ex9_1.R @@ -0,0 +1,17 @@ +#page - 253 +#section - 9.2 EXACT METHODS FOR SOLVING AX = K +#example 1 + +#included package - matlib + +#for echelon function +library(matlib) + +#matrix A +A <- matrix(c(2,1,-1,2,1,3,2,-3,-1,2,1,-1,2,-3,-1,4), 4, 4, byrow=TRUE) + +#column matrix k +K <- c(1,0,1,0) + +#reduced row-echelon form +echelon(A, K, reduced=TRUE, verbose=TRUE, fractions=FALSE) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.2/Ex9_2.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.2/Ex9_2.R new file mode 100644 index 00000000..a6d6e1bd --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.2/Ex9_2.R @@ -0,0 +1,17 @@ +#page - 254 +#section - 9.2 EXACT METHODS FOR SOLVING AX = K +#example 2 + +#included package - matlib + +#for echelon function +library(matlib) + +#matrix A +A <- matrix(c(7,9,2,-1,4,-5,-7,2,3,-2,-5,-1,1,6,-4,-3), 4, 4, byrow=TRUE) + +#column matrix k +K <- c(1,2,4,3) + +#reduced row-echelon form +echelon(A, K, reduced=TRUE, verbose=TRUE, fractions=TRUE) diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.3/Ex9_3.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.3/Ex9_3.R new file mode 100644 index 00000000..fb6d466b --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.3/Ex9_3.R @@ -0,0 +1,18 @@ +#page - 259 +#section - 9.2 EXACT METHODS FOR SOLVING AX = K +#example 3 + +#included package - matlib + +#for inverse functions +library(matlib) + +#matrix A +A <- matrix(c(1,0,2,-1,4,5,3,-1,0,1,8,5,-3,1,4,6,2,0,0,1,0,1,4,2,0), 5, 5, byrow=TRUE) +A + +#determinant of matrix A +det(A) + +#inverse of matrix A, AI +(AI <- inv(A)) diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.4/Ex9_4.R b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.4/Ex9_4.R new file mode 100644 index 00000000..1bc7d1d7 --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/CH9/EX9.4/Ex9_4.R @@ -0,0 +1,14 @@ +#page - 265 +#section - 9.4 CHARACTERISTIC VALUES AND VECTORS +#example - 4 + +#matrix A +A <- matrix(c(1,1,3,1,-2,1,3,1,3), 3, 3, byrow=TRUE) +A + +#matrix X +X <- matrix(c(1,1,1), 3, 1, byrow=TRUE) +X + +#eigenvalues and eigenvectors +eigen(A) \ No newline at end of file diff --git a/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/README.txt b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/README.txt new file mode 100644 index 00000000..7751676e --- /dev/null +++ b/Matrices_And_Linear_Transformations_by_Charles_G._Cullen/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Aswin S +Course: Bachelor Of Technology +Branch: Mechanical Engineering +College/Institute/Organization: Government Engineering College, Barton Hill + +About The Book + +Book: Matrices And Linear Transformations +Author: Charles G. Cullen +Publisher: Dover Publications, Inc., New York +Year Of Publication: 1990 +ISBN: 978-0-486-66328-9 +Edition: 2 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.1/EX10_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.1/EX10_1.R new file mode 100644 index 00000000..1a1609c5 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.1/EX10_1.R @@ -0,0 +1,8 @@ +X=8 +n=55 +#The point estimate is +P=X/n +cat("The Point is: ",P) +# standard error is +E=sqrt((P*(1-P))/n) +cat("Error is : ",E) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.10/EX10_10.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.10/EX10_10.R new file mode 100644 index 00000000..ff9ac90b --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.10/EX10_10.R @@ -0,0 +1,17 @@ +#Let p1 be the probability a visitor to the original page purchases and item and let p2 +#be the probability for the modified page +#Hypothesis +#Null hypothesis= p1 = p2 +#Alternative hypothesis= p1 < p2 +#Level of significance:0.01 +#Criterion: Reject the null hypothesis if Z < ??? 2.33 +x1 = 77 +n1 = 2841 +x2 = 107 +n2 = 2297 +Pbar=(x1+x2)/(n1+n2) +Z=(x1/n1-x2/n2)/sqrt(Pbar*(1-Pbar)*(1/n1+1/n2)) +Z +cat("Ther for we reject the null hypothesis") +cat("We conclude that the proportion of purchasers is higher for the modified page than the original page.") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.11/EX10_11.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.11/EX10_11.R new file mode 100644 index 00000000..2f5ee2b7 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.11/EX10_11.R @@ -0,0 +1,12 @@ +#95% confidence interval for p1 ??? p2 +x1=77 +n1=2841 +x2=107 +n2=2297 +P1bar=x1/n1 +P2bar=x2/n2 +Int1=P1bar-P2bar-1.96*sqrt((P1bar*(1-P1bar)/n1)+(P2bar*(1-P2bar)/n2)) +Int2=P1bar-P2bar+1.96*sqrt((P1bar*(1-P1bar)/n1)+(P2bar*(1-P2bar)/n2)) +Int1 +Int2 +message("so the 95% confidence interval is 0.030 < p1 - p2 < 0.009") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.12/EX10_12.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.12/EX10_12.R new file mode 100644 index 00000000..94634d8f --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.12/EX10_12.R @@ -0,0 +1,16 @@ +#expected frequencies +column<-c("Shop1","Shop2","Shop3") +row<-c('Complete','Repair Adjustment','Incomplete') +Shop1<-c(78,56,54) +Shop2<-c(15,30,31) +Shop3<-c(7,14,15) +Total<-c(100,100,100) +Col4<-c(188,76,36) +GT=300#grand total +e11=e12=e13=100*Col4[1]/GT +e21=e22=e23=100*Col4[2]/GT +e31=e32=e33=100*Col4[3]/GT +#Frequency are +e11 +e21 +e31 \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.13/EX10_13.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.13/EX10_13.R new file mode 100644 index 00000000..2006246d --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.13/EX10_13.R @@ -0,0 +1,17 @@ +table<-rbind(c(23,60,29),c(28,79,60),c(9,49,63)) +rownames(table) <- c("Poor","Average","Very good") +colnames(table) <- c("Below Average","Average","Above Average") +table +#Null Hypothesis :Performance in training program and sucess in job are independent +#Alternative hypothesis : Performance in training program and sucess in job are dependent +l.O.c=0.01 +df=4 +chisq0.01=qchisq(1-0.01,df) +Xsq=chisq.test(table) +Xsq +Xsq$expected +#Criterion:Reject The Null Hypothesis if chisq>chisq0.01 +#Calculation: +print("since the chisq value exceed the value of chisq0.01 there for we reject the null hypothesis") + + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.15/EX10_15.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.15/EX10_15.R new file mode 100644 index 00000000..22d79f79 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.15/EX10_15.R @@ -0,0 +1,14 @@ +#Null Hypothesis:Random variable has Poisson distribution with lambda=4.6 +#Alternative Hypothesis:Random variable does not have Poisson distribution with lambda=4.6 +L.o.c=0.01 +n=10 +m=4 +df=n-m +chsqr0.01=qchisq(1-0.01,6) +chsqr0.01 +#Reject Null hypothesis if chisq>chisq0.01 for df=6 +#Calculating Chisq :- +observedf<-c(18,47,76,68,74,46,39,15,9,8)#observed frequency +expectedf<-c(22.4,42.8,65.2,74.8,69.2,52.8,34.8,20,10,8)#expected frequency +chisq.test(observedf, p = expectedf/sum(expectedf)) +print("Since the value of chisq does't exceed chisq0.01 there for the distribution is poisson distribution") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.2/EX10_2.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.2/EX10_2.R new file mode 100644 index 00000000..45f6b24d --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.2/EX10_2.R @@ -0,0 +1,7 @@ +#install.packages("binom") package binomial praportion +library(binom) +n=55#Wind turbines +r=8#Total noisy turbine +binom.confint( r, n, conf.level=0.95,methods="exact") +cat("We are 95% confident that for proportion p of wind turbines that +are too noisy is in between 0.065 and 0.267") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.3/EX10_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.3/EX10_3.R new file mode 100644 index 00000000..5e5dba18 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.3/EX10_3.R @@ -0,0 +1,8 @@ +x=36 +n=100 +#find 95%confidence interval +ratio=x/n +Z.alpha=1.96 +Int1=ratio-Z.alpha*sqrt(ratio*(1-ratio)/n) +Int2=ratio+Z.alpha*sqrt(ratio*(1-ratio)/n) +cat(Int1," < p < ",Int2) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.4/EX10_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.4/EX10_4.R new file mode 100644 index 00000000..da1fd116 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.4/EX10_4.R @@ -0,0 +1,7 @@ +#Maximum error +n=400 +x=136 +Z.alpha=2.575 +ratio=x/n +E=Z.alpha*sqrt((ratio)*(1-ratio)/n) +cat("Error is: ",E) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.5/EX10_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.5/EX10_5.R new file mode 100644 index 00000000..e00fc74d --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.5/EX10_5.R @@ -0,0 +1,11 @@ +#95% confident that the error is at most 0.04 +#(a) we have no idea what the true proportion might be +Z.alpha=qnorm(1-0.025) +E=0.04 +n1=1/4*(Z.alpha/E)^2 +message("The sample size is: ",ceiling(n1)) +#(b)we know that the true proportion does not exceed 0.12 +p=0.12 +n2=p*(1-p)*(Z.alpha/E)^2 +message("The sample size is: ",ceiling(n2)) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.6/EX10_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.6/EX10_6.R new file mode 100644 index 00000000..ecdec742 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.6/EX10_6.R @@ -0,0 +1,10 @@ +#a) +#install.packages("binom") #package +library(binom) +binom.test(4, 34, conf.level=0.95, p=.3,alternative = 'less') +cat("The P-value = 0.0117 provides quite strong evidence against the null +hypothesis H0 : p = 0.3 and in favor of the alternative that the probability is +less than 0.3.") +#b)level of significance for the test +#Alternative test P<0.3 +pbinom(5, 34,0.3)#P(X<= 5) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.7/EX10_7.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.7/EX10_7.R new file mode 100644 index 00000000..a2bc0c64 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.7/EX10_7.R @@ -0,0 +1,14 @@ +#Null hypothesis: p = 0.70 +#Alternative hypothesis: p > 0.70 +loc=0.05 +z.alpha=qnorm(1-0.05) +z.alpha +#Criterion: Reject the null hypothesis if Z > 1.645, where +x = 48 +n = 60 +p0 = 0.70 +Z=(x - n*p0)/sqrt(n*p0*( 1 - p0)) +Z +cat("Since z = 1.69 is greater than 1.645, we reject the null hypothesis at +level 0.05. In other words, there is sufficient evidence to conclude that the +proportion of good transceivers that would be produced is greater than 0.70") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.8/EX10_8.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.8/EX10_8.R new file mode 100644 index 00000000..882a400f --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.8/EX10_8.R @@ -0,0 +1,15 @@ +#equality of three praportion +#null hypothesis:p1=p2=p3 probability of crumbling is the same for all three materials +#alternative hypothesis:p1,p2and p3 or not equal +Crumbled<-c(41,27,22) +Remained_intact<-c(79,53,78) +loc=0.05 +n=3 +df=n-1 +x.chi=qchisq(1-0.05,df) +#reject null hypothesis if X>x.chi +table<-rbind(Crumbled,Remained_intact) +chi_sq=chisq.test(table) +chi_sq +cat("Since chi_sq = 4.575 does not exceed 5.991, the null hypothesis cannot +be rejected") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.9/EX10_9.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.9/EX10_9.R new file mode 100644 index 00000000..f687586c --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH10/EX10.9/EX10_9.R @@ -0,0 +1,16 @@ +#Null hypothesis: p1 = p2 = p3 = p4 no difference in the proportions of superconductors produced +#Alternative hypothesis: p1, p2, p3, and p4 are not all equal +Superconductors<-c(31,42,22,25) +Failures<-c(19,8,28,25) +loc=0.05 +n=4 +df=n-1 +Chi_squr0.05=qchisq(1-0.05,df) +Chi_squr0.05 +#Criterion: Reject the null hypothesis if Chi_squr > 7.815, the value of Chi_squr0.05 +#for 4 - 1 = 3 degrees of freedom. +table<-rbind(Superconductors,Failures) +table +chisq.test(table) +cat("Since 19.50 greatly exceeds 7.815, we reject the null hypothesis of +equal proportions at the 5% level of significance") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.1/EX11_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.1/EX11_1.R new file mode 100644 index 00000000..d6f22a48 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.1/EX11_1.R @@ -0,0 +1,10 @@ +#least squares estimates and sum of squares error for the cooling rate +x<-c(0,1,2,2,4,4,5,6) +y<-c(25,20,30,40,45,50,60,50) +fit<-lm(y~x) +fit +#the least squares line is +message("y=",fit$coefficients[[1]],"+",fit$coefficients[[2]],"x") +anova(fit) +cat("forom Table the SSE is 270") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.10/EX11_10.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.10/EX11_10.R new file mode 100644 index 00000000..daf82d01 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.10/EX11_10.R @@ -0,0 +1,15 @@ +x<-c(2,3,6,10,15,20) +y<-c(164.7,156.1,142.5,133.8,114.6,107.1) +#a)plot of logy vs x +#the relation ship between logy and x is exponenetial curve +plot(x,log(y)) +#b)Regression Equation +summary(lm(log(y)~ x)) +fit=lm(log(y)~ x) +#logarithmic form is: +cat("log(y) = ",fit$coefficients[2],'x +',fit$coefficients[1]) +#exponential form is: +cat("y = ",exp(5.1257),'*e^(',fit$coefficients[2],')') +#c)Using the logarithmic form which is more convenient, we predict +result<-predict(fit,data.frame(x=c(5)),interval = "confidence",level = 0.95) +result diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.11/EX11_11.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.11/EX11_11.R new file mode 100644 index 00000000..de0c6735 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.11/EX11_11.R @@ -0,0 +1,13 @@ +x<-c(0,1,2,3,4,5,6,7,8)#Amount of varnish additive(grams) +y<-c(12,10.5,10,8,7,8,7.5,8.5,9.0)#Drying Time +#a)Scatter plot +plot(x,y) +#b)Fit a second-degree polynomial +fit<-lm(y~x+I(x^2)) +fit +#Polynomial equestion is +cat("y = ",fit$coefficients[[1]],"",fit$coefficients[[2]],"x + ",fit$coefficients[[3]],"x^2") +summary(fit) +lines(smooth.spline(x,predict(fit)),col='blue',lwd=3) +#c)drying time of the varnish when 6.5 grams of the additive is being used +predict(fit,data.frame(x=c(6.5)),interval = "confidence") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.12/EX11_12.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.12/EX11_12.R new file mode 100644 index 00000000..1247dc90 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.12/EX11_12.R @@ -0,0 +1,15 @@ +y<-c(41,49,69,65,40,50,58,57,31,36,44,57,19,31,33,43) +x1<-c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4) +x2<-c(5,5,5,5,10,10,10,10,15,15,15,15,20,20,20,20) +fit<-lm(y~x1+x2) +summary(fit) +anova(lm(y~x1+x2)) +print("The least squares regression plane is") +cat("Y=",fit$coefficients[[1]],'+',fit$coefficients[[2]],'x',fit$coefficients[[3]],'x^2') +cat("This equation estimates that the average number of twists required to break a +bar increases by 7.78 if the percent of element A is increased by 1% and x2 +remains fixed.") + +#For x1=2.5 and x2=12 +data<-data.frame(predict(fit,data.frame(x1=c(2.5),x2=c(12)),interval ="confidence")) +data$fit diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.14/EX11_14.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.14/EX11_14.R new file mode 100644 index 00000000..0fc348fd --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.14/EX11_14.R @@ -0,0 +1,6 @@ +#Time taken by 10 mechine to assemble in morning x and afternoon y +x<-c(11.1,10.3,12.0,15.1,13.7,18.5,17.3,14.2,14.8,15.3) +y<-c(10.9,14.2,13.8,21.5,13.2,21.1,16.4,19.3,17.4,19.0) +plot(x,y,xlim=c(0,20),ylim=c(0,25)) +r=cor(x,y) +r \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.15/EX11_15.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.15/EX11_15.R new file mode 100644 index 00000000..f66e5ea7 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.15/EX11_15.R @@ -0,0 +1,13 @@ +influent<-c(250,290,270,100,300,410,110,130,1100) +effluent<-c(19,10,17,11,70,60,18,30,180) +#(a)make scatter plot +plot(influent,effluent) +#(b)log scatter plot +plot(log(influent),log(effluent)) +#(c) +r1=cor(influent,effluent) +r1 +r2=cor((influent),log(effluent)) +r2 +#d) +cat("hence r is not really appropriate for the original data ") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.17/EX11_17.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.17/EX11_17.R new file mode 100644 index 00000000..4dc8eb88 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.17/EX11_17.R @@ -0,0 +1,12 @@ +#Null hypothesis=delta=0 +#Alternative hypothesis= delta!=0 +l.o.c=0.05 +n=10 +r=0.732 +#reject null hypothesis if Z>1.96 or z<-1.96 +#Z=sqrt(n-1)*Zbar +Zbar=1/2*(log((1+r)/(1-r))) +z=sqrt(n-3)*Zbar +Zbar +z +print("There for we reject the null hypothesis") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.18/EX11_18.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.18/EX11_18.R new file mode 100644 index 00000000..f9b39728 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.18/EX11_18.R @@ -0,0 +1,15 @@ +#Cinfidence interval for delta normal population +r=0.70 +n=30#number of student +z0.025=1.96 +Zbar=1/2*log((1+r)/(1-r)) +Zbar +Int1=Zbar-z0.025/sqrt(n) +Int2=Zbar+z0.025/sqrt(n) +message("the interval is: ",Int1 ," and ",Int2) +r1=(exp(1)^Int1-exp(1)^-Int1)/(exp(1)^Int1+exp(1)^-Int1) +r1 +r2=(exp(1)^Int2-exp(1)^-Int2)/(exp(1)^Int2+exp(1)^-Int2) +r2 +#there for the 95% confidence interval is +message(r1," < rho < ",r2) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.19/EX11_19.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.19/EX11_19.R new file mode 100644 index 00000000..c72703e7 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.19/EX11_19.R @@ -0,0 +1,18 @@ +#Multiple Linear Regrassion +sumx1=40 +sumx2=200 +sumx1squar=120 +sumx2squar=3000 +sumy=723 +x1.y=1963 +x2.y=8210 +x1.x2=500 +n=16 +XbarX=matrix(c(n,sumx1,sumx2,sumx1,sumx1squar,x1.x2,sumx2,x1.x2,sumx2squar),ncol = 3,byrow = TRUE) +XbarX +Inverse=solve(XbarX) +Xbary=matrix(c(sumy,x1.y,x2.y)) +Xbary +b=Inverse%*%Xbary +print("The least square estimation is ") +b diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.2/EX11_2.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.2/EX11_2.R new file mode 100644 index 00000000..0d4d041d --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.2/EX11_2.R @@ -0,0 +1,13 @@ +#ormal Equation of precious example is, +x<-c(20,60,100,140,180,220,260,300,340,380)#AirVelocity(cm/sec) +y<-c(0.18,0.37,0.35,0.78,0.56,0.75,1.18,1.36,1.17,1.650)#Evaporation coefficent(mm^2/sec) +table<-data.frame(x,y) +fit<-lm(y~x) +plot(x,y) +abline(fit) +message("regression equation is: ",fit$coefficients[[2]],'x + ',fit$coefficients[[1]]) +summary(aov(y~x)) +cat("from table SSE is 0.20238") +print("For x = 190, we predict that the evaporation coefficient will be") +Y<-data.frame(predict(fit,data.frame(x=c(190)),interval = "confidence")) +Y$fit diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.20/EX11_20.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.20/EX11_20.R new file mode 100644 index 00000000..21150de4 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.20/EX11_20.R @@ -0,0 +1,24 @@ +X<-matrix(c(0,1,2,3,4)) +X +y<-matrix(c(8,9,4,3,1)) +n=5 +XbarX<-matrix(c(n,sum(X),sum(X),sum(X^2)),ncol = 2,byrow = TRUE) +XbarX +Inverse=solve(XbarX) +Xbary<-matrix(c(sum(y),sum(X*y))) +Xbary +b=Inverse%*%Xbary +b +message("The Fitted equestion is : y = ",b[1],"",b[2],"x ") +XX=matrix(c(1,0,1,1,1,2,1,3,1,4),byrow =TRUE,ncol =2) +XX +ybar=XX%*%b +ybar +#So the vector of residuals +result=y-ybar +#The Residual sum of squares is +result2=t(result) +data=result2%*%result +Ssquar=data/(n-1-1) +message(Ssquar) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.21/EX11_21.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.21/EX11_21.R new file mode 100644 index 00000000..2ca8676a --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.21/EX11_21.R @@ -0,0 +1,13 @@ +#Calculate estimated variances var(b0) and var(b1) +#With refering to previous example +Inverse=matrix(c(0.6,-0.2,-0.2,0.1),ncol =2,byrow = TRUE) +Ssquar=2 +var=Inverse*Ssquar +print("The estimated variances is") +var +varb0=var[1,1] +varb1=var[2,2] +print("The var(b0) is") +varb0 +print("The var(b1) is") +varb1 diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.3/EX11_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.3/EX11_3.R new file mode 100644 index 00000000..de2ceefb --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.3/EX11_3.R @@ -0,0 +1,23 @@ +n = 50 +x = 88.34 +y = 305.58 +Sxx = 7239.22 +Sxy = 17840.1 +Syy = 66976.2 +#(a) Find the least squares line for predicting height from width. +beta=Sxy/Sxx +alpha=y-beta*x +cat('height = ',87.88,' + ',2.464,'width') +#(b) Find the least squares line for predicting width from heigh +beta=Sxy/Syy +alpha=88.34 -0.2664*305.58 +cat('width = ',6.944,' + ',0.266,'height') +#(c) Make a scatter plot and show both lines. +Width<-c(77,80,83,73,79,100,93,92,101,87,96,99,94) +Height<-c(290,292,289,284,271,292,308,303,308,315,309,300,305) +plot(Width,Height) +Height=87.88 + 2.464*Width +lines(Width, Height) +Height=-26.11 + 3.759*Width +lines(Width, Height) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.5/EX11_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.5/EX11_5.R new file mode 100644 index 00000000..4221e8e4 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.5/EX11_5.R @@ -0,0 +1,9 @@ +velocity<-c(20,60,100,140,180,220,260,300,340,380) +Evaporation<-c(0.18,0.37,0.35,0.78,0.56,0.75,1.18,1.36,1.17,1.65) +Dat<-data.frame(velocity,Evaporation) +fit<-lm(Evaporation~velocity) +summary(lm(Evaporation~velocity), data = Dat) +print("the 95% confidence limits are") +predict(fit,data.frame(velocity=c(0.1009737)),interval = "confidence",level = 0.95) + + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.6/EX11_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.6/EX11_6.R new file mode 100644 index 00000000..8d121802 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.6/EX11_6.R @@ -0,0 +1,16 @@ +velocity<-c(20,60,100,140,180,220,260,300,340,380) +Evaporation<-c(0.18,0.37,0.35,0.78,0.56,0.75,1.18,1.36,1.17,1.65) +#Null hypothesis: beta= 0 +#Alternative hypothesis: beta!= 0 +loc=0.05 +t=qt(1-0.025,8) +#Criterion: Reject the null hypothesis if t < -2.306 or t > 2.306, where 2.306 +#is the value of t0.025 +betabar=0.003829 +beta=0 +Sxx=132000 +Se=0.1591 +t=(betabar-beta)*sqrt(Sxx)/Se +t +cat("Decision: Since t = 8.744 exceeds 2.306, the null hypothesis must be rejected, +we conclude that there is a relationship between air velocity and the average") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.7/EX11_7.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.7/EX11_7.R new file mode 100644 index 00000000..173fc914 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.7/EX11_7.R @@ -0,0 +1,39 @@ +#Peak load +y1<-c(8.6,8.9,9.1) +y2<-c(9.0,9.3,9.4) +y3<-c( 9.5,9.8,9.8) +y4<-c(10.2,10.2,10.3) +x<-c(0,3,6,12)#Prestrain +x=c(0,0,0,3,3,3,6,6,6,12,12,12) +y=c(y1,y2,y3,y4) +#a) +summary(lm(y~x)) +summary(aov(y~x)) +plot(x,y) +message("the P-value for the one-sided test is less than 0.0000 when rounded +down. This is very strong evidence that prestressing results in stronger +material.") +#b) +fit<-lm(y~x) +#The estimated regression line is +cat("y = ",fit$coefficients[[1]]," + ",fit$coefficients[[2]],"x") +x=1# percent prestrain +y=data.frame(predict(fit,data.frame(x=c(1)),interval = "confidence")) +message(y$fit," kN") +#The 95% confidence interval becomes +y +message("We are 95% confident that mean strength is between 8.860385 and 9.182154 kN for all +alloy sheets that could undergo a prestrain of 1 percent") +#c)Note:-This is Part (b) of T.B +x=9# percent prestrain +y=data.frame(predict(fit,data.frame(x=c(9)),interval = "confidence")) +message(y$fit," kN") +#The 95% confidence interval becomes +y +message("We are 95% confident that mean strength is between 9.79 and 10.09 kN for all +alloy sheets that could undergo a prestrain of 9 percent") + +#d)Note:-This is Part (c) of T.B +cat(", there are no outliers in the residuals and the assumption of +normal errors appears reasonable. We can rely upon the +statistical conclusions above") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.8/EX11_8.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.8/EX11_8.R new file mode 100644 index 00000000..c8b1e21a --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.8/EX11_8.R @@ -0,0 +1,15 @@ +#95% prediction limit +#from example 7 +y=9.938 +t0.025=qt(1-0.025,11) +Se=0.180634 +n=12 +Sxx=236.250 +x0=9 +xbar=5.25 +Int1=y-t0.025*Se*sqrt(1+1/n+((x0-xbar)/Sxx)) +Int2=y+t0.025*Se*sqrt(1+1/n+((x0-xbar)/Sxx)) +Int1 +Int2 +cat("We are 95% confident that the observed value of peak load for this new +sheet of aluminum lies between 9.51 and 10.37 kN") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.9/EX11_9.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.9/EX11_9.R new file mode 100644 index 00000000..2b917c3a --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH11/EX11.9/EX11_9.R @@ -0,0 +1,10 @@ +x0 = 18 +y1<-c(8.6,8.9,9.1) +y2<-c(9.0,9.3,9.4) +y3<-c( 9.5,9.8,9.8) +y4<-c(10.2,10.2,10.3) +x<-c(0,3,6,12) +y<-c(mean(y1),mean(y2),mean(y3),mean(y4)) +predict(lm(y~x),data.frame(x=c(18)),interval = "confidence",level = 0.95) +cat("We are 95% confident that the observed value of peak load for this +new sheet of aluminum lies between 10.43 and 11.51 kN") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.1/EX12_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.1/EX12_1.R new file mode 100644 index 00000000..e36f9319 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.1/EX12_1.R @@ -0,0 +1,20 @@ +#H0=the laboratories obtaining consistent result +#tin-coating weight for 12 disc in each liboratory is show as +LabA<-c(0.25,0.27,0.22,0.30,0.27,0.28,0.32,0.24,0.31,0.26,0.22,0.28)#Laboratory A Data of Tin-Coting weight +LabB<-c(0.18,0.28,0.21,0.23,0.25,0.20,0.27,0.19,0.24,0.22,0.29,0.16)#Laboratory B Data of Tin-Coting weight +LabC<-c(0.19,0.25,0.27,0.24,0.18,0.26,0.28,0.24,0.25,0.20,0.21,0.19)#Laboratory C Data of Tin-Coting weight +LabD<-c(0.23,0.30,0.28,0.28,0.24,0.34,0.20,0.18,0.24,0.28,0.22,0.21)#Laboratory d Data of Tin-Coting weight +#Null hypothesis: mu1 = mu2 = mu3 = mu4 #Data produce dy 4 diff laboratory has same mean +#Alternative hypothesis: The mu's are not all equal +#mu=mean +#alpha=0.05 +F0.05=qf(1-0.05,3,44) +cat("The F0.05 value is:",F0.05) +weights = c(LabA,LabB,LabC,LabD)#Single vactor of weights +Laboratory = rep(1:4,rep(12, 4))#Making the group in the single vextor +data = data.frame(weight =weights,Laboratory = factor(Laboratory)) +fit = lm(weight ~ Laboratory , data) +anova(fit) +cat("Since the observed value of F exceeds value of F0.05, the null +hypothesis of equal mean weights is rejected at the 0.05 level of significance +We conclude that the laboratories are not obtaining consistent results") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.10/EX12_10.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.10/EX12_10.R new file mode 100644 index 00000000..888cbfc4 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.10/EX12_10.R @@ -0,0 +1,11 @@ +#Find 94% Bonferroni SimultaneousConfidence interval +ED=c(0.99,1.19,0.79,0.95,0.90) +MD=c(1.11,1.53,1.37,1.24,1.42) +PF=c(0.83,0.68,0.94,0.86,0.57) +Strength<-c(ED,MD,PF) +Resin<-rep(1:3,rep(5,3)) +Dat = data.frame(Strength=Strength, Resin = factor(Resin)) +summary(fm1<-aov(lm(Strength~Resin, data=Dat))) +TukeyHSD(fm1,'Resin', conf.level=0.94,ordered = TRUE) + + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.11/12_11.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.11/12_11.R new file mode 100644 index 00000000..42b250ab --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.11/12_11.R @@ -0,0 +1,14 @@ +Tr<-c(1,1,1,1,2,2,2,2,3,3,3,3) +x<-c(0.90,0.95,1.05,0.80,0.50,0.40,0.15,0.25,0.20,0.55,0.30,0.40)#Original reflectivity +y<-c(1.05,0.95,1.15,0.85,1.10,1.00,0.90,0.80,0.75,1.05,0.95,0.90)#Final reflectivity +#Null hypothesis: aplha1 = alpha2 = alpha3 = 0 +#Alternative hypothesis: The alpha's are not all equal to zero. +loc=0.05 +F0.05=qf(1-0.05,2,8) +#criterion: Reject the null hypothesis if F > 4.46, the value of F0.05 for +#k - 1 = 3 - 1 = 2 and nk - k-1 = 4 × 3 -3 - 1 = 8 degrees of freedom +Tr<-c(rep('A',4),rep('B',4),rep('C',4)) +fit<-lm(y~x+factor(Tr)) +anova(fit) +cat("Since F value of Treatments is 6.48 there for we reject the Null Hypothesis") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.2/EX12_2.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.2/EX12_2.R new file mode 100644 index 00000000..89b74e7b --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.2/EX12_2.R @@ -0,0 +1,16 @@ +#Estimating The Parameter of onw-way classification +#tin-coating weight for 12 disc in each liboratory is show as +LabA<-c(0.25,0.27,0.22,0.30,0.27,0.28,0.32,0.24,0.31,0.26,0.22,0.28)#Laboratory A Data of Tin-Coting weight +LabB<-c(0.18,0.28,0.21,0.23,0.25,0.20,0.27,0.19,0.24,0.22,0.29,0.16)#Laboratory B Data of Tin-Coting weight +LabC<-c(0.19,0.25,0.27,0.24,0.18,0.26,0.28,0.24,0.25,0.20,0.21,0.19)#Laboratory C Data of Tin-Coting weight +LabD<-c(0.23,0.30,0.28,0.28,0.24,0.34,0.20,0.18,0.24,0.28,0.22,0.21)#Laboratory d Data of Tin-Coting weight +cbind(LabA,LabB,LabC,LabD)#Table View of data +k=4#Total laboratory +n=12#total no of data in each laboratory +mu=mean(c(LabA,LabB,LabC,LabD)) +sigma1=(sum(LabA)/n)-mu +sigma2=(sum(LabB)/n)-mu +sigma3=(sum(LabC)/n)-mu +sigma4=(sum(LabD)/n)-mu +print("There for Parameters of one way classification are:") +message("mu:",mu,"sigma1:",sigma1,"sigma2:",sigma2,"sigma3:",sigma3,"sigma4:",sigma4) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.3/EX12_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.3/EX12_3.R new file mode 100644 index 00000000..0eca79a3 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.3/EX12_3.R @@ -0,0 +1,24 @@ +#EXAMPLE 3 +#Confidence intervals +#Given +MSE=0.0234 +dfE=12 +n=5 +MDmu=1.334 +Edmu=0.964 +PFmu=0.776 +x=#The Three confidence intervals become +t0.025=-1*qt(0.025,dfE) +Interval<- function(y1,y2,n1,n2){ + int1=y1-y2+(t0.025*sqrt((MSE)*((1/n1)+(1/n2)))) + int2=y1-y2-t0.025*sqrt(MSE*((1/n1)+(1/n2))) + interval<-c(int2," ",int1) + return (interval) +} +MDED=Interval(MDmu,Edmu,n,n) +MDPF=Interval(MDmu,PFmu,n,n) +EDPF=Interval(Edmu,PFmu,n,n) +message(MDED) +message(MDPF) +message(EDPF) +message("The resin MD has a higher bond strength than the other two, which cannot be distinguished") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.4/EX12_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.4/EX12_4.R new file mode 100644 index 00000000..9d2d0ceb --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.4/EX12_4.R @@ -0,0 +1,30 @@ +#EXAMPLE 4 +#There are 4 different types of paper, +#We measuring the strength of paper by repeating the process +Paper1<-c(2.8,0.75,3.70) +Paper2<-c(0.00,-0.1,3.45) +Paper3<-c(1.15,1.75,4.20) +Paper4<-c(1.88,2.65,2.70) +#Mean of different observation +x1=mean(Paper1) +x2=mean(Paper2) +x3=mean(Paper3) +x4=mean(Paper4) +#Null Hypothesis:-alpha1=alpha2=aplha3=alpha4=0 , There is no differnce in two method of testing paper strength +#Alternative Hypothesis:-alpha's not equal to zero +l.o.c=0.5 +pf(1-0.5,3,8) +strength<-c(Paper1,Paper2,Paper3,Paper4) +group = rep(1:4,rep(3, 4)) +data = data.frame(y = strength, group = factor(group)) +fit = lm(y ~ group, data) +anova(fit) +print("Since F doesn't exceed the value of 1 there for we doesn't reject null hypothesis") +mean=mean(strength) +sd=sd(strength) +df3=length(strength)-1 +t0.025=qt(1-0.025,11) +#95% confidence interval for mean is +Int1=mean+t0.025*sd/sqrt(12) +Int2=mean-t0.025*sd/sqrt(12) +cat("The Confidence Interval For Mean is:",c(Int2,Int1)) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.5/EX12_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.5/EX12_5.R new file mode 100644 index 00000000..66611a1b --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.5/EX12_5.R @@ -0,0 +1,24 @@ +#H0=the laboratories obtaining consistent result +#tin-coating weight for 12 disc in each liboratory is show as +LabA<-c(0.25,0.27,0.22,0.30,0.27,0.28,0.32,0.24,0.31,0.26,0.21,0.28)#Laboratory A Data of Tin-Coting weight +LabB<-c(0.18,0.28,0.21,0.23,0.25,0.20,0.27,0.19,0.24,0.22,0.29,0.16)#Laboratory B Data of Tin-Coting weight +LabC<-c(0.19,0.25,0.27,0.24,0.18,0.26,0.28,0.24,0.25,0.20,0.21,0.19)#Laboratory C Data of Tin-Coting weight +LabD<-c(0.23,0.30,0.28,0.28,0.24,0.34,0.20,0.18,0.24,0.28,0.22,0.21)#Laboratory d Data of Tin-Coting weight +cbind(LabA,LabB,LabC,LabD)#Table View of data +k=4 +n=12 +T. = 11.70#grand total +N=48 +SumA=sum(LabA) +SumB=sum(LabB) +SumC=sum(LabC) +SumD=sum(LabD) +C=T.^2/N +SST=sum(LabA^2)+sum(LabB^2)+sum(LabC^2)+sum(LabD^2)-C +SSTr=0.0135 +SSE=SST-SSTr +MSTr=SSTr/(k-1) +MSE=0.0015 +F=MSTr/MSE +F + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.6/EX12_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.6/EX12_6.R new file mode 100644 index 00000000..3c5f6d5b --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.6/EX12_6.R @@ -0,0 +1,19 @@ +Source<-c('Treatments','Blocks','Error') +Treatment1<-c(13,8,9,6) +Treatment2<-c(7,3,6,4) +Treatment3<-c(13,7,12,8) +Temp<-c(Treatment1,Treatment2,Treatment3) +f = c("Item1", "Item2", "Item3", "Item4") +k = 4 # number of treatment levels +n = 3 # number of control blocks +tm = gl(k, 1, n*k, factor(f)) # matching treatment +tm +blk = gl(n, k, k*n) # blocking factor +blk +av = aov(Temp ~blk+ tm) +summary(av) +F0.05=qf(1-0.05,2,6) +cat("The value of F0.05 with 2 and 6 degrees of freedom is 5.14, so we reject the null +hypothesis of equal mean particulate material removal. Blocking was important because + we also reject the null hypothesis of equal block means") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.7/EX12_7.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.7/EX12_7.R new file mode 100644 index 00000000..599b594f --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.7/EX12_7.R @@ -0,0 +1,24 @@ +#There are 4 different type of Detergentfor engen. +#There are 3 engine +#Null hypothesis:alpha1=alpha2=apha3=0 and beta1=beta2=beta3=0 +#Alternative hypothesis:The alphas and betas not equal to zero +l.o.c=0.01 +#Criteria:For treatment ,reject null hypothesis if F>9.78,the value of F0.01 with df is 3 and 6 +#for block reject null hypothesis if F>10.92 for 2 and 6 degrees of freedom +#Calculation +Detergent_A<-c(45,43,51) +Detergent_B<-c(47,46,52) +Detergent_C<-c(48,50,55) +Detergent_D<-c(42,37,49) +data<-c(Detergent_A,Detergent_B,Detergent_C,Detergent_D) +f = c("Item1", "Item2", "Item3") +k = 3 # number of treatment levels +n = 4 # number of control blocks +Engines= gl(k, 1, n*k, factor(f))# matching treatment +Detergents= gl(n, k, k*n) # blocking factor +av = aov(data ~Detergents+ Engines) +summary(av) +print("Sice FDet exceed the value 9.78 there we Conclude that there is difference in effectivness in Detergent") +print("Since FEn exceed the value 10.92 there for we conclude that there is difference in result obtain by 3 machine ") + + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.8/EX12_8.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.8/EX12_8.R new file mode 100644 index 00000000..b285d208 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.8/EX12_8.R @@ -0,0 +1,29 @@ +#Data from Example 7 +Tem=c(45,43,51,47,46,52,48,50,55,42,37,49) +data<-matrix(c(45,43,51,139,47,46,52,145,48,50,55,153,42,37,49,128,182,176,207,565),ncol=4,byrow=TRUE) +data +rownames(data)<-c("Detergent A","Detergent B","Detergent C","Detergent D","Totals") +colnames(data)<-c("Engine 1","Engine 2","Engine 3","Totals") +data +a = 4 +b = 3 +T1. = 139 +T2. = 145 +T3. = 153 +T4. = 128 +T.1 = 182 +T.2 = 176 +T.3 = 207 +T.. = 565 +Sumy=26867 +n=12 +C=T..^2/n#factor +C +SST=sum(Tem^2)-C +SST +SSTr=((139^2+145^2+153^2+128^2)/3)-C +SSTr +SSB=((182^2+176^2+207^2)/4)-C +SSB +SSE=SST-SSTr-SSB +SSE \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.9/EX12_9.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.9/EX12_9.R new file mode 100644 index 00000000..e2c3ab47 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH12/EX12.9/EX12_9.R @@ -0,0 +1,25 @@ +#Find 94% Bonferroni SimultaneousConfidence interval +MSE=0.0237 +alpha=0.06 +k=3 +l.o.c=alpha/k*(k-1) +df=12 +t0.01=qt(1-0.01,df=12) +t0.01 +MDmu=1.334 +Edmu=0.964 +PFmu=0.776 +n=5 +Interval<- function(y1,y2,n1,n2){ + int1=y1-y2+t0.01*sqrt(MSE*((1/n1)+(1/n2))) + int2=y1-y2-t0.01*sqrt(MSE*((1/n1)+(1/n2))) + interval<-c(int2," ",int1) + return (interval) +} +MDED=Interval(MDmu,Edmu,n,n) +MDPF=Interval(MDmu,PFmu,n,n) +EDED=Interval(Edmu,PFmu,n,n) +#There for the interval are as +message(MDED) +message(MDPF) +message(EDED) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.1/EX13_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.1/EX13_1.R new file mode 100644 index 00000000..26d3d67b --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.1/EX13_1.R @@ -0,0 +1,27 @@ +#Null hypotheses: alpha1 = alpha2 = alpha3 = 0; beta1 = beta2 = 0 +#( alphabeta ) terms are all equal to zero +#Alternative hypotheses: The alpha's are not all equal to zero; the beta's are not all +#equal to zero; the (alphabeta) terms are not all equal to zero +F0.01=qf(1-0.01,2,12)#df=2,12 +F0.01 +F0.01=qf(1-0.01,1,12)#df=1,12 +F0.01 +#Criteria:a)For replications reject the null hypotheses if F > 6.93, the value of +#F0.01 for 2,12 df. +#b)for the factor A, reject the null hypothesis if F > 9.33, the value of F0.01 for df=1,12 +#c)for factor B, reject if F > 9.33, the value of F0.01 for df= 1,12 +#d)for the interaction effect, reject if F > 6.93, the value of F0.01 for df=2,12 +rep_1<-c(707,652,522,630,450,845) +rep_2<-c(632,669,554,648,545,810) +rep_3<-c(604,674,484,610,474,682) +r<-c(707,632,604,652,669,674,522,554,484,630,648,610,450,545,474,845,810,682) +A<-c(rep('MN',6),rep('CO',6),rep('TX',6))#Location +B<-c(rep('RCA',3),rep('RPA',3),rep('RCA',3),rep('RPA',3),rep('RCA',3),rep('RPA',3))#Type of Mat. +Dat<-data.frame(A,B,r) +av = lm(r~A*B,data=Dat) +anova(av) +cat('The F = 12.0 for Factor B exceeds F0.01 = 9.33 for 1 and 12 degrees of freedom and that +F = 36.1 for the AB interaction term exceeds F0.01 = 6.93 = for 2 and') + + + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.2/EX13_2.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.2/EX13_2.R new file mode 100644 index 00000000..e5f30258 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.2/EX13_2.R @@ -0,0 +1,27 @@ +#Factor Level +#From previous example variance is Ssquare=0.25 +Ssquare=2394 +t0.025=qt(1-0.025,12) +t0.025 +#There for the confidence intervals for difference in mean due to the a=3 level of oven width,Factor are +ybar1=656.3 +ybar2=574.7 +ybar3=634.3 +b=2 +r=3 +levelss<-function(x,y,a){ + Int1=x-y+(t0.025*sqrt((Ssquare*2)/a*r)) + Int2=x-y-t0.025*sqrt((Ssquare*2)/a*r) + return(c(Int1,Int2)) +} +Level1<-levelss(ybar1,ybar2,b) +Level1 +Level2<-levelss(ybar1,ybar3,b) +Level2 +Level3<-levelss(ybar2,ybar3,b) +Level3 +#Concluesion: +message("Because the interation was significant, we cannot interpret on differences of mean coking time as due to changing over wIdth along") +#Signgle diffeence in mean due to the b=2 flue tem is +mean=levelss(552.4,691.1,3) +mean \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.3/EX13_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.3/EX13_3.R new file mode 100644 index 00000000..1a6aa55f --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.3/EX13_3.R @@ -0,0 +1,24 @@ +#To improve quality in production There are three thing to study that are +# 3 initiators (A), 2 booster charges (B), and 4 main charges(C) +A<-c(rep('Initiator 1',8),rep('Initiator 2',8),rep('Initiator 3',8)) +B<-c('Powder','Pellet','Powder','Pellet','Powder','Pellet','Powder','Pellet','Powder','Pellet','Powder','Pellet','Powder','Pellet','Powder','Pellet','Powder','Pellet','Powder','Pellet','Powder','Pellet','Powder','Pellet') +C<-c('MC1','MC1','MC2','MC2','MC3','MC3','MC4','MC4','MC1','MC1','MC2','MC2','MC3','MC3','MC4','MC4','MC1','MC1','MC2','MC2','MC3','MC3','MC4','MC4') +DelayTime<-c(10.7,9.82,10.02,13.66,14.46,20.86,11.44,13.76,15.04, +16.02,27.26,21.42,20.82,14.46,24.56,36.48,18.42,18.62, +22.80,25.14,33.40,20.62,31.86,19.78,22.94,31.12,32.92,21.38, +27.92,59.86,31.94,28.32,7.14,7.98,24.32,10.26, +8.30,7.86,7.00,8.40,8.40,10.94,17.82,15.28,9.56,19.04,19.98,18.46) +TempC<-c(rep('MC1',4),rep('MC2',4),rep('MC3',4),rep('MC4',4)) +C<-c(rep(TempC,3)) +TempB<-c(rep('Powder',2),rep('Pellet',2)) +B<-c(rep(TempB,12)) +length(B) +A<-c(rep('Initiator 1',16),rep('Initiator 2',16),rep('Initiator 3',16)) +length(DelayTime) +Dat<-data.frame(A,B,C,DelayTime) +fit<-lm(DelayTime~A*B*C,data=Dat) +#The Anova table is +anova(fit) +#the initiators and main charges are significant as, +with(Dat, tapply(DelayTime, list(A), mean)) +with(Dat, tapply(DelayTime, list(C), mean)) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.4/EX13_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.4/EX13_4.R new file mode 100644 index 00000000..7733ca71 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH13/EX13.4/EX13_4.R @@ -0,0 +1,19 @@ +#A compound is produced for a coating process.The Two Facctor Add i.e Addactivity and Tem to get best yield +Run<-c(1,2,3,4,5,6,7,8,9) +Addactive<-c(0,70,35,0,70,70,0,35,35) +Tem<-c(100,100,140,180,180,140,140,100,180) +yield<-c(81,65,92,50,75,75,68,90,77) +Dat<-data.frame(cons,Addactive,Tem,yield) +Dat +fit=lm(yield~Addactive+Tem+I(Addactive^2)+I(Tem^2)+Addactive*Tem,data=Dat) +fit +#Estimated Regression Coefficients for Yield +summary(fit) +# from fit estimated response surface is +cat("y = 60.2639 + 0.0417*x1 + 0.5354*x2 - 0.0141*x1^2 - 0.0033*x2^2 + 0.0073*x^1*x^2") +x1 = 33 +x2 = 117 +y = 60.2639 + 0.0417*x1 + 0.5354*x2 - 0.0141*x1^2 - 0.0033*x2^2 + 0.0073*x^1*x^2 +y +cat("It is usually not reasonable to drop a linear term when the associated square term is +in the response surface model") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.1/EX14_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.1/EX14_1.R new file mode 100644 index 00000000..e5eb11bc --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.1/EX14_1.R @@ -0,0 +1,13 @@ +surment<-c(99.0,102.3,99.8,100.5,99.7,96.2,99.1,102.5,103.3,97.4,100.4,98.9,98.3,98.0,101.6) +mu=98.0 +#install.packages(BSDA) +library(BSDA) +#m0=98.0(p=1/2) +#m1>98.0(p>1/2) +SIGN.test(surment,NULL,alternative = 'g',mu) +print("the probability of X >= 12 is 0.0065") +cat("Since 0.0065 is less than 0.01, the null hypothesis must be rejected; +we conclude that the median octane rating of the given kind of gasoline +exceeds 98.0") + + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.2/EX14_2.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.2/EX14_2.R new file mode 100644 index 00000000..da0a4c47 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.2/EX14_2.R @@ -0,0 +1,28 @@ +#Following is the sverage weekly losses of work-hours due to accident in 10 industrial plants before and after +#safety program was put into operation +Before<-c(45,73,46,124,33,57,83,34,26,17) +After<-c(36,60,44,119,35,51,77,29,24,11) +l.O.c=0.05 +data=Before-After +data +library(BSDA) +SIGN.test(data) +#Null Hypothesis:mu=0 +#Alternative hypothesis:mu>0 +#Criterion:reject null hypothesis if Probability of x is less then 0.05 +sign=c()#This Store the sign for the data +for (i in 1:length(data)){ + if(data[i]>0){ + sign[i]='+' + }else{ + sign[i]='-' + } +} +message(sign) +X=length(sign[ sign %in% '+'])#x for no of pluse sign +p=0.5#Probability +#P(X>9) +PX=1-pbinom(X-1,10,p) +message("P(X>9) = ",PX) +message("Since PX is less then 0.05 there for we reject the Null Hypothesis") +print("There for the safety program is effective") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.3/EX14_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.3/EX14_3.R new file mode 100644 index 00000000..b9e2ca21 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.3/EX14_3.R @@ -0,0 +1,24 @@ +#m0=Population are identical +#m1=population is not identical +Sand1<-c(0.63,0.17,0.35,0.49,0.18,0.43,0.12,0.20, +0.47,1.36,0.51,0.45,0.84,0.32,0.40) +Sand2<-c(1.13,0.54,0.96,0.26,0.39,0.88,0.92,0.53, +1.01,0.48,0.89,1.07,1.11,0.58) +Loc=0.01 +z.alpha=qnorm(0.01) +#reject mo if Zz.alpha +n1=15 +n2=14 +W1=162 +U1=W1-((n1*(n1+1))/2) +U1 +mu=n1*n2/2 +mu +sigma=n2*n1*(n1+n2+1)/12 +sigma +z=(U1-mu)/(sigma**0.5) +z +wilcox.test(Sand1,Sand2,exact = FALSE, correct = FALSE) +cat("Since z = ???2.75 is less than ???2.575, the null hypothesis must +be rejected at ?? = 0.01. The P-value = 0.0060 and we conclude that there is a +strong evidence of difference in the populations of grain size") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.4/EX14_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.4/EX14_4.R new file mode 100644 index 00000000..62f361ee --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.4/EX14_4.R @@ -0,0 +1,16 @@ +method_A<-c(54,66,67,71,74,77) +method_B<-c(41,52,59,60,62,64,65) +method_C<-c(47,49,52,56,69) +#Null Hypothesis=Population are identical +#Alternative Hypothesis=Population are not identical +Loc=0.05 +H.chi=qchisq(1-0.05,2) +H.chi +#reject mo if Chi>h.chi +dati = list(g1=method_A, g2=method_B, g3=method_C)#getting the list of different method +dati +#Chi square using Kruskal test +kruskal.test(dati) +print("since Chi exceed H.chi there for m0 is rejected") +print("there for preventative method against corrosion are not equally effective") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.5/EX14_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.5/EX14_5.R new file mode 100644 index 00000000..0103f7d4 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.5/EX14_5.R @@ -0,0 +1,14 @@ +#losses of worker-hours before and after safety programs in 10 industrial plants +Before<-c(45,73,46,12,43,57,83,34,26,17) +After<-c(36,60,44,19,35,51,77,29,24,11) +data<-cbind(Before,After) +#Ranks of the data +Ri<-rank(Before) +Si<-rank(After) +n=10 +#Calculate the Rs(rho) value with text case +cor.test(Ri,Si,method=c("spearman")) +cat('This large positive value indicates strong association along an increasing curve') + + + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.6/EX14_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.6/EX14_6.R new file mode 100644 index 00000000..aeac7ab4 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.6/EX14_6.R @@ -0,0 +1,13 @@ +#randomness +#install.packages(tseries) +#library(tseries) +#Null hypothesis: Arrangement is random. +#Alternative hypothesis: Arrangement is not random +z=alpha=qnorm(1-0.01) +#Criterion: Reject the null hypothesis if Z < -2.32 or Z > 2.32 +arr<-as.factor(c('n','n','n','n','n','d','d','d','d','n','n','n','n','n','n','n','n' + ,'n','n','d','d','n','n','d','d','d','d')) +runs.test(arr) +cat("Since z = -3.20 is less than -2.32, the null hypothesis must be +rejected. We conclude that the arrangement is not random") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.7/EX14_7.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.7/EX14_7.R new file mode 100644 index 00000000..3ae0a84f --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH14/EX14.7/EX14_7.R @@ -0,0 +1,23 @@ +#install.package(tseries) +library(tseries) +lathdata<-c(0.261,0.258,0.249,0.251,0.247,0.256,0.250,0.247,0.255,0.243, + 0.252,0.250,0.253,0.247,0.251,0.243,0.258,0.251,0.245,0.250, + 0.248,0.252,0.254,0.250,0.247,0.253,0.251,0.246,0.249,0.252, + 0.247,0.250,0.253,0.247,0.249,0.253,0.246,0.251,0.249,0.253) +LOC=0.01#level of significance +#mo=Arragment of sample data is random(null hypothesis) +#m1=There is frequently alternating pattern(alternative hypothesis) +z.alpha=qnorm(1-0.01) +#reject mo if z>z.alpha +data<-c() +mu=0.25 +lathdata=lathdata[!lathdata %in% mu] +for(i in 1:length(lathdata)){ + if(lathdata[i]>mu){ + data[i]='a'} + if(lathdata[i] mu0 hours +#Level of significance: = 0.05 +#Criterion: Reject the null hypothesis if f Tr >(mu0*Chi0.05)/2 +#Calculating the value +result=(mu0*Chi0.05)/2 +result +cat("Since T10 = 43,410 exceeds the critical value, we must reject the +null hypothesis, concluding that the mean lifetime exceeds 2,500 hours, or, +equivalently, that the failure rate is less than 0.40 failure per thousand hours") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.1/EX2_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.1/EX2_1.R new file mode 100644 index 00000000..c86b1000 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.1/EX2_1.R @@ -0,0 +1,6 @@ +#The industrial engineer records the maximum +#amount of bacteria present along the production line, in the units Aerobic Plate +#Count per square inch (APC/in2), for n = 7 day +Data<-c(96.3,155.6,3408.0,333.3,122.2,38.9,58.0)#7 day data +stripchart(Data,method ="stack", + at = c(0.1),las=1,xlab = "Bacteria Count (APC/sq.in)",pch=20) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.11/EX2_11.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.11/EX2_11.R new file mode 100644 index 00000000..b7dc95d2 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.11/EX2_11.R @@ -0,0 +1,12 @@ +#Variance +time<-c(0.6,1.2,0.9,1.0,0.6,.8) +xbar=mean(time) +xbar#Mean +diff=time-xbar +diffsq=diff**2 +diffsum=sum(diffsq) +n=length(time) +var1=diffsum/(n-1) +cat("Variance is",var1) +#using function +var(time) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.12/EX2_12.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.12/EX2_12.R new file mode 100644 index 00000000..e7ec69d9 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.12/EX2_12.R @@ -0,0 +1,3 @@ +Time = c(0.6, 1.2,0.9, 1,0.6,0.8)#delay Time +sd=sd(Time) +message("standard deviation is : ",sd," min") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.13/EX2_13.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.13/EX2_13.R new file mode 100644 index 00000000..2012f038 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.13/EX2_13.R @@ -0,0 +1,18 @@ +#Coefficient of varience +#a)first micrometer observation +mean=3.92 +sd=0.015 +CV=sd/mean*100 +CV +#a)second micrometer observation +mean2=1.54 +sd2=0.008 +CV2=sd2/mean2*100 +CV2 +if(CV2>CV) + { + print("measurment mead by first micrometer is more precise") +}else +{ + print("measurment mead by second micrometer is more precise") +} \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.14/EX2_14.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.14/EX2_14.R new file mode 100644 index 00000000..cb64e769 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.14/EX2_14.R @@ -0,0 +1,14 @@ +#quantile and percentile +data<-c(136,143,147,151,158,160, + 161,163,165,167,173,174, + 181,181,185,188,190,205) +options(digits = 1) +data2=quantile(data,c(.25,.5,.75)) +Q1=data2[1] +Q2=data2[2] +Q3=data2[3] +percentile=data[ceiling(0.1*18)] +cat("first quartile is",Q1) +cat("second quartile is",Q2) +cat("third quartile is",Q3) +cat("10% percentile is",percentile) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.15/EX2_15.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.15/EX2_15.R new file mode 100644 index 00000000..6ee19d7d --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.15/EX2_15.R @@ -0,0 +1,10 @@ +#Range and interquartile range +Data<-c(136,143,147,151,158,160, + 161,163,165,167,173,174, + 181,181,185,188,190,205) +min=min(Data) +max=max(Data) +range=max-min +interrange=IQR(Data) +message("range : ",range," Mpa") +message("interquartile range : ",interrange,"Mpa") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.16/EX2_16.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.16/EX2_16.R new file mode 100644 index 00000000..4a0eb880 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.16/EX2_16.R @@ -0,0 +1,18 @@ +time<-c(.021,.107,.179,.190,.196,.283,.580,.854,1.18,2.00,7.30) +boxplot(time, horizontal = TRUE,ylim=c(0,8),xlab='Time(s)') +quantile=quantile(time,probs = c(0,0.25,.5,.75,1)) +#minimum +min=quantile[1] +min +#maimum +max=quantile[5] +max +#Q1 +Q1=0.179 +Q1 +#Q3 +Q3=1.18 +Q3 +#interquartile range is +inter=Q3-Q1 +inter diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.18/EX2_18.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.18/EX2_18.R new file mode 100644 index 00000000..7ad678eb --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.18/EX2_18.R @@ -0,0 +1,8 @@ +#20 test runs performed on urban roads with an intermediate-size car. +data<-c(19.7,21.5,22.5,22.2,22.6 + ,21.9,20.5,19.3,19.9,21.7 + ,22.8,23.2,21.4,20.8,19.4 + ,22.0,23.0,21.1,20.9,21.3) +xbar=mean(data) +var=var(data) +message("mean : ",xbar," mpg ","standard deviation ",var," mpg") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.19/EX2_19.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.19/EX2_19.R new file mode 100644 index 00000000..dd314e62 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.19/EX2_19.R @@ -0,0 +1,10 @@ +#Variance and mean of group data +xi=c(225,265,305,345,385) +options(digits = 2) +fi=c(3,11,23,9,4) +n=sum(fi) +mean=weighted.mean(xi,fi) +var=(sum(xi^2*fi)-sum(xi*fi)^2/n)/(n-1) +sd=sqrt(var) +cat("mean: ",mean," var: ",var," sd: ",sd) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.2/EX2_2.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.2/EX2_2.R new file mode 100644 index 00000000..56db06e2 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.2/EX2_2.R @@ -0,0 +1,13 @@ +#Two Production heats of welding Material +heat1<-c(0.27,0.35,0.37) +heat2<-c(0.23,0.15,0.25,0.24,0.30,0.33,0.26) +data<-list(heat1,heat2) +stripchart(data, + xlab="Copper Content", + col=c("orange","red"), + pch=16, + method ="stack", + cex=1, + xlim=c(0.15,0.40), + las=1 +) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.3/EX2_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.3/EX2_3.R new file mode 100644 index 00000000..d8b6a0bd --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.3/EX2_3.R @@ -0,0 +1,5 @@ +#class mark and class intervals +message("Class marks are : ") +message((205+245)/2," ",(245+285)/2," ,",(285+325)/2," ,",(325+365)/2,", ",(365+405)/2) +print("Class Interval is") +message(405-365) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.4/EX2_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.4/EX2_4.R new file mode 100644 index 00000000..ecb10f05 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.4/EX2_4.R @@ -0,0 +1,12 @@ +#Data of 50 nanopillars +Data<-c(245,333,296,304,276,336,289,234,253,292, + 366,323,309,284,310,338,297,314,305,330, + 266,391,315,305,290,300,292,311,272,312, + 315,355,346,337,303,265,278,276,373,271, + 308,276,364,390,298,290,308,221,274,343) +breaks = seq(205, 405, by=40) +Data.cut = cut(Data, breaks, right=TRUE) +Data.freq = table(Data.cut) +cumfreq = cumsum(Data.freq) +message("Cumulative Frequency of data") +cbind(cumfreq) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.6/EX2_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.6/EX2_6.R new file mode 100644 index 00000000..20b8e20c --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.6/EX2_6.R @@ -0,0 +1,10 @@ +#Histogram of interrequest time data +data=c(2808,4201,3848,9112,2082,5913,1620,6719,21657, + 3072,2949,11768,4731,14211,1583,9853,78811,6655, + 1803,7012,1892,4227,6583,15147,4740,8528,10563, + 43003,16723,2613,26463,34867,4191,4030,2472,28840, + 24487,14001,15241,1643,5732,5419,28608,2487,995, + 3116,29508,11440,28336,3440 +) +#It has an long-right data tail +hist(data,ylab="Class frequency", xlab="time") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.7/EX2_7.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.7/EX2_7.R new file mode 100644 index 00000000..2593c402 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.7/EX2_7.R @@ -0,0 +1,11 @@ +#density histogram +#58 specimens of new aluminum alloy undergoing development +data<-c(66.4,67.7,68.0,68.0,68.3,68.4,68.6,68.8,68.9,69.0,69.1, + 69.2,69.3,69.3,69.5,69.5,69.6,69.7,69.8,69.8,69.9,70.0, + 70.0,70.1,70.2,70.3,70.3,70.4,70.5,70.6,70.6,70.8,70.9, + 71.0,71.1,71.2,71.3,71.3,71.5,71.6,71.6,71.7,71.8,71.8, + 71.9,72.1,72.2,72.3,72.4,72.6,72.7,72.9,73.1,73.3,73.5, + 72.4,74.5,75.3 +) +hist(data,freq=FALSE,xlab="Teansile Strength") +lines(density(data)) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.8/EX2_8.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.8/EX2_8.R new file mode 100644 index 00000000..a9b52543 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.8/EX2_8.R @@ -0,0 +1,11 @@ +#Mean and variance +data<-c(100,45,60,130,30)#this is a university students responded for time in social media +#Using function +mean(data) +median(data) +#Without function +xbar=sum(data)/length(data) +xbar +med=data[ceiling(length(data)/2)] +med +cat("mean and median of data is",xbar,'and',med) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.9/EX2_9.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.9/EX2_9.R new file mode 100644 index 00000000..9c66cde4 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH2/EX2.9/EX2_9.R @@ -0,0 +1,10 @@ +?stripchart() +data<-c(11,9,17,19,4,15) +mean(data) +median(data) +stripchart(data,method ="stack", + at = c(0.1), + cex=1,pch=20, + xlim=c(0,20), + las=1, + main="Data",xlab = "Email - Request") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.1/EX3_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.1/EX3_1.R new file mode 100644 index 00000000..3f27b74c --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.1/EX3_1.R @@ -0,0 +1,15 @@ +library(sets)#To import the library for set +s=set(pair(0,0),pair(0,1),pair(1,0),pair(2,0),pair(1,1),pair(0,2))#Sample space +s +C=set(pair(1,0),pair(0,1.0)) +C +D=set(pair(0,0),pair(0,1),pair(0,2)) +D +E=set(pair(0,0),pair(1,1)) +E +#Union of the Sets +set_union(C,E) +#Intersection of the set +cset_intersection(C,D) +#Complement of the set +set_complement(D,s) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.11/EX3_11.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.11/EX3_11.R new file mode 100644 index 00000000..46137ae5 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.11/EX3_11.R @@ -0,0 +1,4 @@ +#Total no of ways to select ace from well-shuffled deck of card +n=52#Total no of cards +s=4#Total ace +message("Total probability of drawing an ace from deck of card is : ",s/n) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.13/EX3_13.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.13/EX3_13.R new file mode 100644 index 00000000..8be70e6c --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.13/EX3_13.R @@ -0,0 +1,3 @@ +n=300#Total insulator +t=294#Total insulater withstand the thermal shock +message("The Probability that any untested insulator will be able to withstand the thermal shock is : ",t/n) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.14/EX3_14.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.14/EX3_14.R new file mode 100644 index 00000000..c603e022 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.14/EX3_14.R @@ -0,0 +1,34 @@ +#Permissibility of probability +#if +#1)0<=p(A)<=1 for each event A in S +#2)P(S)=1 +#3)A and B are Mutually Exclusive in event +#Ans:- +#Given There is Three Mutually exClusive event A,B and c +#a) +permissibility<-function(c){ + Flag=TRUE + i=1 + while(i<=length(c)){ + + if(c[i]<0){ + Flag=FALSE + return(" negative value not permissible") + } + i=i+1 + } + if(Flag==TRUE && sum(c)==1){ + return("Permissibile") + }else{ + return(" Not Permissibile") + } +} +prob1=c(1/3,1/3,1/3) +prob2=c(0.64,.38,-.02) +prob3=c(0.35,0.52,0.26) +prob4=c(0.57,0.24,0.19) +permissibility(prob1) +permissibility(prob2) +permissibility(prob3) +permissibility(prob4) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.15/EX3_15.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.15/EX3_15.R new file mode 100644 index 00000000..9cba1bf0 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.15/EX3_15.R @@ -0,0 +1,15 @@ +#Probabity that it Rating is +vp=0.07#Very Poor +P=0.12#Poor +fair=0.17 +good=0.32 +vgood=0.21 +excellent=0.11 +#(a) probabity that it will rate vp,p,fair,good +#The Possiblity are all mutually excluive +probabilty=vp+p+fair+good +message("The Probability is : ",probabilty) +#(a) probabity that it will rate good ,vgood,excellent +#The Possiblity are all mutually excluive +probabilty=good+vgood+excellent +message("The Probability is : ",probabilty) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.16/EX3_16.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.16/EX3_16.R new file mode 100644 index 00000000..620bc0df --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.16/EX3_16.R @@ -0,0 +1,7 @@ +#find P(M1),P(P1),P(C3)ETC FROM diagram +PM1= 0.03+0.06+0.07+0.02+0.01+0.01# P(M1) +PP1=0.03 + 0.06 + 0.07 + 0.09 + 0.16 + 0.10 + 0.05+0.05 + 0.14# P(P1) +PC3= 0.07 + 0.01 + 0.10 + 0.06 + 0.14 + 0.02# P(C3) +M1INTP1=0.03 + 0.06 + 0.07#M1 intersection with P1 +M1IntC3=0.07 + 0.01#M1 intersection with C3 +message(PM1," ",PP1," ",PC3," ",M1INTP1," ",M1IntC3) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.17/EX3_17.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.17/EX3_17.R new file mode 100644 index 00000000..9d44f90f --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.17/EX3_17.R @@ -0,0 +1,6 @@ +M1=0.20#P(M1) +C3=0.4#P(C3) +M1andC3=0.08#M1 intersect with C3 +#By addtion Rule +M1ORC3=M1+C3-M1andC3 +cat("Probability is",EORC) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.18/EX3_18.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.18/EX3_18.R new file mode 100644 index 00000000..494280c1 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.18/EX3_18.R @@ -0,0 +1,6 @@ +#Probability taht the car require repair on engine,drive train or both +P1=0.87 +P2=0.36 +P1INTP2=0.29 +P1UNIONP2=P1+P2-P1INTP2 +message("Proabaility that it require bothe kind of repair is : ",P1UNIONP2) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.19/EX3_19.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.19/EX3_19.R new file mode 100644 index 00000000..42d7a0a6 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.19/EX3_19.R @@ -0,0 +1,10 @@ +M1=0.20#probability that car will have low mileage +C3=0.4#Probability that car is expensive to operate +#(a)the probability that a used car will not have low mileage +M1bar=1-M1 +cat('probability that lawn mower is not easy to opratable is ',M1bar) +#b)the probability that a used car will either not have low mileage or not be +#expensive to operate +M1andC3=0.08 +AbarorBbar=1-M1andC3 +cat('probability that lawn mower is not easy to opratable or not have high coat',AbarorBbar) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.20/EX3_20.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.20/EX3_20.R new file mode 100644 index 00000000..28984d75 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.20/EX3_20.R @@ -0,0 +1,7 @@ +#A=Communication system have high fideality +#B=Communication system have high selectivity +#Given p(A)=0.81,p(A ??? B)=0.18,find=p(B/A)=p(A ??? B)/p(A) +pA=0.81 +inter=0.18 +result=inter/pA +cat("Probability that system have high fideality will also have selectivity is",result) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.21/EX3_21.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.21/EX3_21.R new file mode 100644 index 00000000..ba3c3f13 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.21/EX3_21.R @@ -0,0 +1,7 @@ +#Conditional Probability +#Given +M1IntC3=0.08#E1 INTERSECTION C1 +PC3=0.4#probability of C1 +#PrObability is: +P=M1IntC3/PC3 +message("There for the probability is : ",P) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.22/EX3_22.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.22/EX3_22.R new file mode 100644 index 00000000..e732269c --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.22/EX3_22.R @@ -0,0 +1,9 @@ +N=20#tOTAL GROUP OF WORKER +n1=12#Worker favor the regulation +n2=8#workers against the regulation +#Find the probability that if two worker select are against the regulation +F1=(n2/N)#For the first selection +F2=(n2-1)/(N-1)#the second selection from n2-1 and N-1 +P=F1*F2#PROBABILITY +print("The probablity that the two selected worker are against the regulation is,") +P \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.24/EX3_24.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.24/EX3_24.R new file mode 100644 index 00000000..970ecdbd --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.24/EX3_24.R @@ -0,0 +1,8 @@ +N=52#Total cards +k=2#two card are selected at rendom +T=4#Total aces in 52 cards +#Find the probability of getting aces +#(a) first card is replaced before second card +message("Probability is : ",(4/52)*(4/52)) +#(b) first card is not replaced before second card +message("Probability is : ",(4/52)*(3/51)) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.25/EX3_25.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.25/EX3_25.R new file mode 100644 index 00000000..c2b6a544 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.25/EX3_25.R @@ -0,0 +1,11 @@ +#Find where C and D is Independ events +C=0.65#p(C) +D=0.4#P(D) +CandD=0.24 +#if C and D are Independ events then CandD=p(C).P(D) +result=C*D +if(result==CandD){ + print("Events are independent") +}else{ + print("Events are dependent") +} \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.26/EX3_26.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.26/EX3_26.R new file mode 100644 index 00000000..13de17ec --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.26/EX3_26.R @@ -0,0 +1,7 @@ +#A=the event that raw material available when needed +#B=The event that the machining time is less than 1 hours +PA=0.8#P(A) +PB=0.7#P(B) +#Proababilty of A intersection B +AIntB=PA*PB +AIntB diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.28/EX3_28.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.28/EX3_28.R new file mode 100644 index 00000000..261d0fb7 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.28/EX3_28.R @@ -0,0 +1,12 @@ +#Many companies must moniter the effluent that is discharged gfrom there plants into river and waterway. +p=0.01 #XProbability that the measurement on a test specimen will exceed L(limit) +#a)Find the probability of fail for to test +q=1-p#Probability of fail +#Both process is independent +#Ther for by product rule +prob=q*q +message("The Probability is ",prob) +#b) probability that test is free of contantminant conducted for two year one day a week +#total weeks in two year is 104 ther for +prob=q^104 +message("The Probability is ",prob) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.29/EX3_29.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.29/EX3_29.R new file mode 100644 index 00000000..094a08a9 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.29/EX3_29.R @@ -0,0 +1,20 @@ +#There is two ways of data transmissio 1st is one digit transmission 2nd is three digit transmission method +#a)Evaluate the probability that the transmitted 1 will recevied 1 only by three digit scheme +#Where the probability are +p1=0.01 +p2=0.02 +p3=0.05 +#if we send 111 there is probability for all three digit are (1-p)*(1-p)*(1-p) +#Also the Probability of receving 011 is p*(1-p)*(1-p) +#so the probability of 0 is 3*p*(1-p)*(1-p) +#By rule +prob1=(1-p1)^3+3*p1*(1-p1)*(1-p1)#Probability of getting correct +message("Probability is : ",prob1) +prob2=(1-p2)^3+3*p2*(1-p2)*(1-p2)#Probability of getting correct +message("Probability is : ",prob2) +prob3=(1-p3)^3+3*p3*(1-p3)*(1-p3)#Probability of getting correct +message("Probability is : ",prob3) +#check where digit 1 and 0 are receved correcly in the prob of 0.05 +#in part on the probability under 0.05 is 0.99275 +message("The Total probability is : ",prob3*prob3) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.30/EX3_30.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.30/EX3_30.R new file mode 100644 index 00000000..6ca33885 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.30/EX3_30.R @@ -0,0 +1,12 @@ +#Baye's theorem +B1=0.2#Prabaility of janet +B2=0.6#Prabaility of tom +B3=0.15#Prabaility of georgin +B4=0.05#Prabaility of peter +AbyB1=1/20 +AbyB2=1/10 +AbyB3=1/10 +AbyB4=1/20 +#Prabability tah intial repaire made by janet +B1byA=(B1*AbyB1)/(B1*AbyB1+B2*AbyB2+B3*AbyB3+B4*AbyB4) +B1byA \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.31/EX3_31.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.31/EX3_31.R new file mode 100644 index 00000000..ee92345e --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.31/EX3_31.R @@ -0,0 +1,21 @@ +B1= 1700#message is spam +B2=3300#message is normal +#A is words in the list +M=5000#TOtal messages +#Probability for spam message +PB1=B1/M +message("The Probability is: ",PB1) +#Probability for normal message +PB2=B2/M +message("The Probability is: ",PB2) +#Among the spam messages,1343 contain words in the list +B1IntA=1343 +# from normal messages only 297 contain words in the list +B2IntA=297 +#Conditional Probability +PAB1=B1IntA/B1#P(A|B1) +PAB2=B2IntA/B2#P(A|B2) +#There for by Bayes' Theorem +PB1A=(PAB1*B1)/(PAB1*B1+PAB2*B2)#P(B1|A)=P(A|B1)*P(B1)/(P(A|B1)*P(B1)+P(A|B2)*P(B2)) +PB1A +print("Since the probability is large there for the message is spam") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.5/EX3_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.5/EX3_5.R new file mode 100644 index 00000000..5b54a9e8 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.5/EX3_5.R @@ -0,0 +1,4 @@ +#There are total 12 true-false question in how many way the student can mark the question paper +#Since each question can answer in two ways,there are altogether +Possibility=2^12 +message("The student can marks the question in :",Possibility," possible ways") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.6/EX3_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.6/EX3_6.R new file mode 100644 index 00000000..2e156d5e --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH3/EX3.6/EX3_6.R @@ -0,0 +1,8 @@ +#(a) +n1=4#Total operator +n2=3#Total Machines +Pair=n1*n2 +message("Total operator-machine pairs are:",Pair) +#(b) +n3=8#test speciment +message("Total test speciment required for the entire production is :",n3*Pair) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.1/EX4_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.1/EX4_1.R new file mode 100644 index 00000000..a1e912d0 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.1/EX4_1.R @@ -0,0 +1,35 @@ +#Checking for probability distribution(PD) +#a) +probability <- function(f) { + print(f) + i=1;flag=FALSE + while (i1 +prob=1 - ppois(0, 1.3)#1-P(X=0) +prob +#(c)the probability of at least two but no more than four particles +prob=ppois(4,lambda)-ppois(1,lambda) +prob +#(d)vaiance +print("For Poisson the variance equal to lambda i.e 1.3") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.22/EX4_22.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.22/EX4_22.R new file mode 100644 index 00000000..1f3f98c5 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.22/EX4_22.R @@ -0,0 +1,7 @@ +#(a)the formula for the binomial distribution +x = 2 +n = 100 +p = 0.05 +dbinom(x,n,p) +#(b)the Poisson approximation to the binomial distribution. +dpois(2,5) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.24/EX4_24.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.24/EX4_24.R new file mode 100644 index 00000000..71f210e7 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.24/EX4_24.R @@ -0,0 +1,14 @@ +alpha=6 +#4 bad check for any one day +x=4 +T=1 +lambda=alpha*T +prob=dpois(x,lambda) +cat("THER FOR th e probability that 4 bad check on any day is",prob) +#For 10 bad check on Two Consecutive dayes +T=2 +x=10 +lambda=alpha*T +prob=ppois(x,lambda) - ppois(x-1,lambda) +cat("THER FOR th e probability that 10 bad check on any two day is",prob) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.25/EX4_25.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.25/EX4_25.R new file mode 100644 index 00000000..a4f246c9 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.25/EX4_25.R @@ -0,0 +1,21 @@ +#Here in this example ppios() for Poisson distribution +alpha=0.2 +#one interruption in 3 weeks +x=1 +T=3 +lambda=alpha*T +prob=ppois(x,lambda)-ppois(0,lambda) +prob +cat("probability is",prob) +#at least two interruptions in 5 weeks +T=5 +x=1 +lambda=alpha*T +prob=1-ppois(x,lambda) +cat("probability is",prob) +#For at most one imperfaction in 15 week +T=15 +x=1 +lambda=alpha*T +prob=ppois(x,lambda) +cat("probability is",prob) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.26/EX4_26.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.26/EX4_26.R new file mode 100644 index 00000000..2c228c7c --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.26/EX4_26.R @@ -0,0 +1,12 @@ +#Geometric Distribution +#it deals with the number of trials required for a single success +#the geometric distribution is a negative binomial distribution +options(digits = 2) +p=0.05 +x=6 +#by function +dgeom(x, prob = p) +#by formula +g=p*(1-p)^(x-1) +g +cat("Probability that 6 measuring device show excessive brift is",g) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.27/EX4_27.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.27/EX4_27.R new file mode 100644 index 00000000..1c813516 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.27/EX4_27.R @@ -0,0 +1,5 @@ +#Multinomial Distribution +#(X1, . . . , Xk) ??? multinom(size = n, prob = pk×1) +x<-c(2,5,1) +prob<-c(0.3,0.5,0.2) +dmultinom(x, size = 8, prob, log = FALSE) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.3/EX4_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.3/EX4_3.R new file mode 100644 index 00000000..ddcd8e59 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.3/EX4_3.R @@ -0,0 +1,15 @@ +#(a) List all possible outcomes in terms of success, S, repaired within one hour, and +#failure, F, not repaired within one hour. +list=c('FFF','FFS',' FSS',' SSS','FSF','SFS','SFF',' SSF') +cat("The Possible outcome is: ",list) +#(b) Find the probability distribution of the number of successes, X, among the +#3 repairs. +#X=0 +cat("The Probability is: ",0.1*0.1*0.1) +#X=1 +cat("The Probability is: ",3 * 0.009) +#X=2 +cat("The Probability is: ",3*(0.1 * 0.9 * 0.9 ) ) +#X=3 +cat("The Probability is: ",0.9* 0.9* 0.9) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.4/EX4_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.4/EX4_4.R new file mode 100644 index 00000000..d49fe72b --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.4/EX4_4.R @@ -0,0 +1,12 @@ +#a) +n=5#no of trail +r=4#no of successor +p=0.6#probability of success +# Create the binomial distribution. +prob <- dbinom(r,n,p)#This function gives the +#probability density distribution at each point +cat("The probability is",prob) +#b) +#at least four of five installations +prob=dbinom(4,5,p)+dbinom(5,n,p) +cat("The probability bill reduce by one third is",prob) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.5/EX4_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.5/EX4_5.R new file mode 100644 index 00000000..1a6267fa --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.5/EX4_5.R @@ -0,0 +1,6 @@ +P=0.05#probability +n=16 +#(a)at most two will fail +pbinom(2,16,P) +#(b) at least four will fail +1-pbinom(3,16,P) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.6/EX4_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.6/EX4_6.R new file mode 100644 index 00000000..44ff0070 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.6/EX4_6.R @@ -0,0 +1,11 @@ +p=0.65 +n=15 +#probability for 11 will be written by the algorithm +prob=dbinom(11, 15, 0.65) +message("probability is : ",prob) +#probability for at least 10 will be written by the algorithm +prob=1-pbinom(9,15,0.65 ) +message("probability is : ",prob) +#probability between 8 and 11 inclusive will be written by the algorithm +prob=pbinom( 11, 15, 0.65 ) - pbinom( 7, 15, 0.65 ) +message("probability is : ",prob) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.7/EX4_7.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.7/EX4_7.R new file mode 100644 index 00000000..1fe987ab --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.7/EX4_7.R @@ -0,0 +1,7 @@ +#Claim:10% of his machine require repair within the warranty period of 12 month +p=0.10#Probability +n=20#Total fax machine +#P>5 probability for 5 or more machine require repairs +prob=1-pbinom(4,n,p) +message("Probability : ",prob) +message("Since The probability is to small there for we reject the claim") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.8/EX4_8.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.8/EX4_8.R new file mode 100644 index 00000000..faabb883 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.8/EX4_8.R @@ -0,0 +1,8 @@ +#hypergeometric distribution +#for sample without replacement +x=2#successer in n +n=10#sample size +N=20#lot Size (Population size) +a=5#succeser in N +h=(choose(a,x)*choose(N-a,n-x))/choose(N,n) +cat("probabilit is",h) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.9/EX4_9.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.9/EX4_9.R new file mode 100644 index 00000000..09da5bdd --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH4/EX4.9/EX4_9.R @@ -0,0 +1,11 @@ +#binomial distribution(bd) and hypergeometric distribution(hd) +n=10#sample +x=2#2 defective out of 10 +#a)hd +a=25#total defective +N=100#Toale tape +h=(choose(a,x)*choose(N-a,n-x))/choose(N,n) +message("probabilit is ",h) +#b)using bd +p=0.25#probability +dbinom(2,10,p) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.1/EX5_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.1/EX5_1.R new file mode 100644 index 00000000..c82dbd97 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.1/EX5_1.R @@ -0,0 +1,7 @@ +library(distr)#PDF +#f(x)=2e^-2x for x >0 +f=function(x) 2*exp(1)^(-2*x) +#P(10.5) +integrate(f, lower = 0.5, upper = Inf) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.10/EX5_10.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.10/EX5_10.R new file mode 100644 index 00000000..ae68f624 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.10/EX5_10.R @@ -0,0 +1,6 @@ +mu = 11.6 +sigma = 3.3 +#what is the probability that there will be at least 8 outages in any one month? +#we take 7.5 instand of 8 +Z=1-pnorm((7.5-mu)/sigma) +Z \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.11/EX5_11.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.11/EX5_11.R new file mode 100644 index 00000000..e755309e --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.11/EX5_11.R @@ -0,0 +1,12 @@ +#We take the probability p = 0.056 which is the value estimated from the physics experiment +p = 0.056 +n=300 +#(a) find the mean and standard deviation of the number which will disappear +mean=n*p +sd=sqrt(n*p*(1-p)) +mean +sd +#(b) Approximate the probability that 12 or more will disappear. +1-pnorm((11.5-mean)/sd) +#(c) Approximate the probability of exactly 12 +pnorm((12.5-mean)/sd)-pnorm((11.5-mean)/sd) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.12/EX5_12.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.12/EX5_12.R new file mode 100644 index 00000000..de53a6a7 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.12/EX5_12.R @@ -0,0 +1,5 @@ +#Log-normal Distribution +alpha=2#mean +beta=0.1#variance +#Find the Probaility between 8.1 to 6.1 +plnorm(8.2,2,0.1)-plnorm(6.1,2,0.1) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.13/EX5_13.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.13/EX5_13.R new file mode 100644 index 00000000..e2815657 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.13/EX5_13.R @@ -0,0 +1,10 @@ +#Histogram of interrequest time data +data=c(2208,4201,3848,9112,2082,5913,1620,6719,21657, + 3072,2949,11768,4731,14211,1583,9853,78811,6655, + 1803,7012,1892,4227,6583,15147,4740,8528,10563, + 43003,16723,2613,26463,34867,4191,4030,2472,28840, + 24487,14001,15241,1643,5732,5419,28608,2487,995, + 3116,29508,11440,28336,3440 +) +hist(data, freq = FALSE,xlab = "Time") +lines(density(data), col="blue", lwd=2) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.14/EX5_14.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.14/EX5_14.R new file mode 100644 index 00000000..78a58bca --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.14/EX5_14.R @@ -0,0 +1,6 @@ +alpha=4 +beta=0.3 +a=33 +#log norm probability +P=1-plnorm(a,alpha,beta) +P diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.15/EX5_15.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.15/EX5_15.R new file mode 100644 index 00000000..a5703047 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.15/EX5_15.R @@ -0,0 +1,10 @@ +alpha=2 +beta=0.1 +#mean +mu=exp(1)^(alpha+((beta)^2)/2) +mu +cat("mean is",mu) +#variance +var=exp(1)^((2*alpha+beta^2))*(exp(1)^(beta^2)-1) +var +cat("variance is",var) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.16/EX5_16.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.16/EX5_16.R new file mode 100644 index 00000000..40e0770e --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.16/EX5_16.R @@ -0,0 +1,11 @@ +data<-c(0.894,0.991,0.061,0.186,0.311,0.817,2.267,0.091,0.139,0.083, + 0.235,0.424,0.216,0.579,0.429,0.612,0.143,0.055,0.752,0.188, + 0.071,0.195,0.082,1.653,2.010,0.158,0.527,1.033,2.863,0.365, + 0.459,0.431,0.092,0.830,1.718,0.099,0.162,0.076,0.107,0.278, + 0.100,0.919,0.900,0.093,0.041,0.712,0.994,0.149,0.866,0.054) +#decay Time is represented by histogram +h<-hist(data, breaks=10, col="red",xlab = "Millisecond" ,prob = TRUE) +xfit<-seq(0,max(data),length=50) +yfit<-dnorm(xfit,mean=mean(data),sd=sd(data)) +yfit <- yfit*diff(h$mids[1:2])*length(data) +lines(xfit, yfit, col="blue", lwd=2) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.17/EX5_17.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.17/EX5_17.R new file mode 100644 index 00000000..4fd02c10 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.17/EX5_17.R @@ -0,0 +1,6 @@ +f=function(x) 3*exp(1)^(-3*x) +#Assuming that the arrival follow possion process with alpha=3 and beta=1/3 +#a)less then 5 min +integrate(f,lower = 0,upper = 1/12) +#b)at least 45 min +integrate(f,lower = 3/4,upper = Inf) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.18/EX5_18.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.18/EX5_18.R new file mode 100644 index 00000000..0b404019 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.18/EX5_18.R @@ -0,0 +1,11 @@ +#beta distribution +#a)mean +alpha=3 +beta=2 +mu=alpha/(alpha+beta) +mu +cat("There for on average",mu*100,"% highway section require repaire") +#b) +F=pbeta(1/2,3,2) +plot(density(pbeta(seq(0,1/2,by=0.1),3,2))) +cat("The probability is",F) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.19/EX5_19.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.19/EX5_19.R new file mode 100644 index 00000000..194c593a --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.19/EX5_19.R @@ -0,0 +1,9 @@ +#weibull distribution +scale=0.5 +#mean lifetime +mu=(0.1)**(-2)*factorial((1+1/0.5)-1) +mu +#P(X>300) +g=function(x)(0.05)*x^(-0.5)*exp(1)^(-0.1*x^scale) +integrate(g, lower = 300, upper = Inf) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.2/EX5_2.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.2/EX5_2.R new file mode 100644 index 00000000..1f7c1ec0 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.2/EX5_2.R @@ -0,0 +1,3 @@ +#Distribution function for x=1 +f=function(x) 1-exp(1)^(-2*x) +f(1) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.20/EX5_20.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.20/EX5_20.R new file mode 100644 index 00000000..d951dd1a --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.20/EX5_20.R @@ -0,0 +1,12 @@ +#P(X1+X2>1) +P=0.2+0.1+0 +message("Probability is: ",P) +#P(Xi=xi) +p0=0.1+0.2#p(X=0) +p1=0.4+0.2#p(X=1) +p3=0.1+0#p(X=2) +message("Probabilits is: ") +p0 +p1 +p3 + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.21/EX5_21.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.21/EX5_21.R new file mode 100644 index 00000000..8d82680a --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.21/EX5_21.R @@ -0,0 +1,13 @@ +#Check the independency of X1 and X2 +#Conditional probability +#X2=1 +#f(0|1) +f1=0.2/0.4#f(0|1)/f2(1) +#f(1|1) +f2=0.2/0.4#f(1|1)/f2(1) +#f(2|1) +f3=0/0.4#f(2|1)/f2(1) +f1 +f2 +f3 +message("since f(0|1)!=f1(0) there for it's dependent") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.22/EX5_22.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.22/EX5_22.R new file mode 100644 index 00000000..6f8094b7 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.22/EX5_22.R @@ -0,0 +1,20 @@ +llimy <- 2; llimx=1 +ulimy <- 3 ; ulimx=2 +#the first random variable will take on a value between 1 and 2 and the second +#random variable will take on a value between 2 and 3 +f <- function(x1,x2)6*exp(1)^(-2*x1-3*x2) +integrate(function(x2) { + sapply(x2, function(x2) { + integrate(function(x1) f(x1,x2), llimx, ulimx)$value + }) +}, llimy, ulimy) +#(b) the first random variable will take on a value less than 2 and the second +#random variable will take on a value greater than 2 +llimy <- 2; llimx=0 +ulimy <- Inf ; ulimx=2 +f <- function(x1,x2)6*exp(1)^(-2*x1-3*x2) +integrate(function(x2) { + sapply(x2, function(x2) { + integrate(function(x1) f(x1,x2), llimx, ulimx)$value + }) +}, llimy, ulimy) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.23/EX5_23.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.23/EX5_23.R new file mode 100644 index 00000000..1fc2c0ea --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.23/EX5_23.R @@ -0,0 +1,4 @@ +F<-function(x,y){ + return (1 - exp(1)^-2*x)*(1 - exp(1)^-3*y) +} +F(1,1) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.3/EX5_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.3/EX5_3.R new file mode 100644 index 00000000..12a88d79 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.3/EX5_3.R @@ -0,0 +1,5 @@ +#f(x)=k*xe^-4*x^2,find K x>0 +f=function(x) x*exp(1)^(-4*x^2) +k=1/(integrate(f, lower = 0, upper = Inf))$value +message("Value of K is",k) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.31/EX5_31.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.31/EX5_31.R new file mode 100644 index 00000000..4cfa74aa --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.31/EX5_31.R @@ -0,0 +1,7 @@ +EX1=4 +EX2=-2 +VX1=9 +VX2=6 +#Calcuation +cat("E( 2X1+X2-5 ) = ",2*EX1+EX2-5) +cat("Var(2X1+X2-5 ) = ",2^2*VX1+VX2) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.4/EX5_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.4/EX5_4.R new file mode 100644 index 00000000..95f89d40 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.4/EX5_4.R @@ -0,0 +1,13 @@ +#f(x)=2e^(-2x) for x>0#is PDF +#MEAN +#f(x)=xf(x) +options(digits = 3) +f=function(x) 2*x*exp(1)^(-2*x) +mean <- integrate(f, lower =0, upper =Inf) +cat("Mean for PDF is",mean$value) +#variance +#var=E(X^2)-E(X)^2 +E=function(x) 2*(x^2)*exp(1)^(-2*x)#E(X^2) +E1=integrate(E, lower =0, upper =Inf) +var=E1$value-((mean$value)**2) +cat("Varience for PDF is",var) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.42/EX5_42.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.42/EX5_42.R new file mode 100644 index 00000000..dd2d2206 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.42/EX5_42.R @@ -0,0 +1,4 @@ +# Normal Scores plot of normalized data +Score=c(67, 48, 76, 81) +qqnorm(Score, ylab="Ordered observations", xlab="Normal Scores", main="") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.43/EX5_43.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.43/EX5_43.R new file mode 100644 index 00000000..ce099148 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.43/EX5_43.R @@ -0,0 +1,13 @@ +#Histogram to Normal Scores plot of normalized data +data=c(2208,4201,3848,9112,2082,5913,1620,6719,21657, + 3072,2949,11768,4731,14211,1583,9853,78811,6655, + 1803,7012,1892,4227,6583,15147,4740,8528,10563, + 43003,16723,2613,26463,34867,4191,4030,2472,28840, + 24487,14001,15241,1643,5732,5419,28608,2487,995, + 3116,29508,11440,28336,3440 +) +hist(data,ylab="Class frequency", xlab="time") +qqnorm(data, ylab="Interrquest time", xlab="Normal Scores", main="") +ln=log(data) +hist(ln,ylab="Class frequency", xlab="ln(time)") +qqnorm(ln, ylab="ln(Interrquest time)", xlab="Normal Scores", main="") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.44/EX5_44.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.44/EX5_44.R new file mode 100644 index 00000000..78ed2688 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.44/EX5_44.R @@ -0,0 +1,4 @@ +Data<-c(0.57,0.74,0.26,0.77,0.12) +alpha = 0.05 +beta = 2.0 +((-1/alpha)*log(1-Data))^(1/beta) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.45/EX5_45.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.45/EX5_45.R new file mode 100644 index 00000000..00643dda --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.45/EX5_45.R @@ -0,0 +1,14 @@ +mu=50 +sigma=5 +u1=0.253 +u2=0.531 +#standard normal values +z1=(-2*log(u2))**0.5*cos(2*pi*u1) +z1 +z2=(-2*log(u2))**0.5*sin(2*pi*u1) +z2 +#normal value +x1=50+5*z1 +x2=50+5*z2 +x1 +x2 diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.5/EX5_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.5/EX5_5.R new file mode 100644 index 00000000..1fd2978e --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.5/EX5_5.R @@ -0,0 +1,15 @@ +#Standered Normal Distribution +mean=0 +sd=1 +#a)area between 1.28 and 0.87 +a=pnorm(1.28) -pnorm(0.87) +a +#b)area between -0.34 and 0.62 +b=pnorm(0.62) -pnorm(-0.34) +b +#c)greater then 0.85 +c=pnorm(0.85,lower.tail = FALSE) +c +#c)greater then -0.65 +d=pnorm(-0.65,lower.tail = FALSE) +d diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.6/EX5_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.6/EX5_6.R new file mode 100644 index 00000000..4b2d7f03 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.6/EX5_6.R @@ -0,0 +1,4 @@ +#Find value of z0.01 and z0.05 +z0.01=qnorm(1-0.01) +z0.05=qnorm(1-0.05) +message("z0.01 is : ",z0.01," and z0.05 is : ",z0.05) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.7/EX5_7.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.7/EX5_7.R new file mode 100644 index 00000000..df0583f8 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.7/EX5_7.R @@ -0,0 +1,12 @@ +mu= 10.1 +sigma= 2.7 +#a) For the next food or product, what is the probability that its maximum +#attenuation is between 8.5 dB and 13.0 dB? +a=pnorm((13-mu)/sigma) -pnorm((8.5-mu)/sigma) +a +#b)According to the normal model, what proportion of the products have +#maximum attenuation between 8.5 dB and 13.0 dB? +cat("o 0.5801 as the proportion having maximum attenuation between +8.5 and 13.0 dB") +#c)What proportion of the products have maximum attenuation greater than 15.1 dB +1-pnorm((15.1-mu)/sigma) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.8/EX5_8.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.8/EX5_8.R new file mode 100644 index 00000000..4b13e97b --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.8/EX5_8.R @@ -0,0 +1,22 @@ +weight<-c(72.2,67.8,78.0,64.4,76.3,72.3,73.1,71.7,66.2,63.3,85.4,67.4, +66.3,76.3,57.7,50.3,77.4,63.1,73.9,67.4,74.7,68.2,87.4,86.4, +69.4,58.0,63.3,72.7,73.6,68.8,63.3,63.3,73.0,64.8,73.1,70.9, +85.9,74.4,75.9,72.3,84.3,61.8,79.2,64.3,65.4,66.7,77.2,50.0, +70.3,90.4,63.9,62.1,68.2,55.1,52.6,68.5,55.2,73.5,53.7,61.7, +47.9,72.3,61.1,71.8,83.1,71.2,58.8,61.8,86.8,64.5,52.3,58.3, +65.9,80.2,75.1,59.9,62.3,48.8,64.3,75.4) +n = 80 +mu=68.4 #pounds +sd = 9.6 #pounds +#(a) Find the probability of using 80 or more pounds of cheese. +1-pnorm((n-mu)/sd) +#Set a limit so that only 10 % of production runs have less than L pounds of cheese +Z0.1=qnorm(1-0.1)#probability closest to .1000 +L = mu - sd*Z0.1 +L #Pounds +#Determine a new mean for the distribution so that only 5 % of the runs have less than L pounds +Z0.05=1.645 +mu = L + 9.6 * Z0.05 +mu +cat("The mean must be increased by 3.5 pounds to decrease the percentage of units +below the limit L from 10% to 5%") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.9/EX5_9.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.9/EX5_9.R new file mode 100644 index 00000000..b451aba0 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH5/EX5.9/EX5_9.R @@ -0,0 +1,12 @@ +mu=4.6 +sigma=1.21 +X=log(0.0015) +value=(X+(mu))/sigma**0.5 +value +pnorm(value) +cord.x <- c(-3,seq(-3,value,0.01),value) +cord.y <- c(0,dnorm(seq(-3,value,0.01)),0) +curve(dnorm(x,0,1),xlim=c(-3,3),main='Standard Normal') +polygon(cord.x,cord.y,col='skyblue') +print('The Standard Normal Pobabability that obtain is smaller' ) + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX5.54/EX6_54.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX5.54/EX6_54.R new file mode 100644 index 00000000..2c48c58b --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX5.54/EX6_54.R @@ -0,0 +1,10 @@ +#Random sample size +n1=7 +n2=13 +#there for numerator and denominator degree of freedom is +v1=n1-1 +v2=n2-1 +1/df(0.05,v1,v2) +F0.05=qf(1-0.05,6,12) +F0.05 +print("There for the probability is 0.05") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.49/EX6_49.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.49/EX6_49.R new file mode 100644 index 00000000..7240cef0 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.49/EX6_49.R @@ -0,0 +1,6 @@ +#Find the population correction factor +#Given +n=10 +N=1000 +factor=(N-n)/(N-1) +message("There for the factor is : ",factor) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.51/EX6_51.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.51/EX6_51.R new file mode 100644 index 00000000..ea2b6d4a --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.51/EX6_51.R @@ -0,0 +1,12 @@ +#sampling distribution +options(digits = 3) +sd=1.20 +mean=1.82#mean +n=40 +Xbar<-c(1.65,2.04) +Xbar +z=(Xbar-mean)*(n**0.5)/(sd) +z +message("Probability is: ",pnorm(1.16)-pnorm(-0.896)) + + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.52/EX6_52.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.52/EX6_52.R new file mode 100644 index 00000000..4d933056 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.52/EX6_52.R @@ -0,0 +1,13 @@ +n = 20 +mu=40 #mg/l +xbar = 46 +s = 9.4 #mg/l +df=n-1 +t0.01=qt(1-0.01,df) +t0.01 +t=(xbar-mu)/(s/n^0.5) +message("t value is: ",t) +P=1 - pt(t,19) +message("probability is: ",P) +print("Sinces the t value exceed t0.01 there for we reject the claim") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.53/EX6_53.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.53/EX6_53.R new file mode 100644 index 00000000..92a82122 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.53/EX6_53.R @@ -0,0 +1,11 @@ +var=1.35#population variance +s=1.4#sample variance +n=20#total no of sample +chi=((n+2)*1.4*1.4)/1.2^2 +ceiling(chi) +qchisq(1-0.05,19) +1 -pchisq(30.6, 19) +cat("There for the probability that a good shipmeant +will erroneously be reject is less then 0.05") + + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.55/EX6_55.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.55/EX6_55.R new file mode 100644 index 00000000..e1d0c9dc --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH6/EX6.55/EX6_55.R @@ -0,0 +1,8 @@ +#F distribution +#left-hand tail probability +#a)by first method +df1=20#first degree of freedom +df2=10#second degree of freedom +data=qf(0.95,df1,df2)#quantile +Area=1/data +cat("Value under th area 0.95 is",Area) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.13/EX7_13.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.13/EX7_13.R new file mode 100644 index 00000000..bde98e51 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.13/EX7_13.R @@ -0,0 +1,9 @@ +#Poisson distribution of defective hard drive for ten day +Data<-c(7,3,1,2,4,1,2,3,1,2) +T=sum(Data) +lamda=T/10 +#the maximum likelihood estimate is +#P(X=0 or 1) +P=exp(1)^(-lamda)+(lamda*exp(1)^(-lamda)) +P +cat("There for there will be 1 or fewer defectives on just over one-quarter of the days.") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.15/EX7_15.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.15/EX7_15.R new file mode 100644 index 00000000..5a093657 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.15/EX7_15.R @@ -0,0 +1,10 @@ +#The yields of chemical rection is as +op<-c(5.57,5.76,4.18,4.64,7.02,6.62,6.33,7.24, + 5.57,7.89,4.67,7.24,6.43,5.59,5.39) +#(a) Obtain the maximum likelihood estimates of the mean yield and the variance +mean=mean(op) +cat(mean,"gal") +var=(1/length(op))*sum((op-mean)^2) +var +#Obtain the maximum likelihood estimate of the coefficient of variation ??/?? +cat("coefficient is : ",sqrt(var)/mean) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.18/EX7_18.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.18/EX7_18.R new file mode 100644 index 00000000..cf413bcf --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.18/EX7_18.R @@ -0,0 +1,10 @@ +xbar=3.9 +mu=4.5 +sigma=1.5 +n=25 +Z=(xbar-mu)/(sigma/sqrt(n)) +Z +P=pnorm(Z) +P +cat("There the probability that the value of z is -2 is 0.0227") +message("There for the p value is: ",2*P) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.19/EX7_19.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.19/EX7_19.R new file mode 100644 index 00000000..d01fa6a1 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.19/EX7_19.R @@ -0,0 +1,15 @@ +xbar = 68.45 +s = 9.583 +mu=71 +#Null hypothesis: mu = 71 pounds +#Alternative hypothesis: mu < 71 pounds +z.alpha=qnorm(0.01) +#Criterion: Since the probability of a Type I error is greatest when mu = 71 +#pounds, we proceed as if we were testing the null hypothesis mu = 71 pounds +#against the alternative hypothesis mu < 71 pounds at the 0.01 level of +#significance. Thus, the null hypothesis must be rejected if Z < -2.33, where +Z=(xbar-mu)/(s/sqrt(80)) +Z +#Decision: Since Z = -2.38 is less than -2.33, the null hypothesis must be +#rejected at level of significance 0.01. In other words, the suspicion that mu < 71 +#pounds is confirmed. \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.2/EX7_2.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.2/EX7_2.R new file mode 100644 index 00000000..85f52cd9 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.2/EX7_2.R @@ -0,0 +1,8 @@ +Data<-c(136,143,147,151,158,160, +161,163,165,167,173,174, +181,181,185,188,190,205) +Xbar=mean(Data) +s=sd(Data) +#standard error is +E=s/sqrt(length(Data)) +E diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.20/EX7_20.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.20/EX7_20.R new file mode 100644 index 00000000..0f8d6a77 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.20/EX7_20.R @@ -0,0 +1,14 @@ +#measurements of lead content( ?? g / L) are taken from twelve water specimens spiked with a known concentration +data<-c(2.4,2.9,2.7,2.6,2.9,2.0,2.8,2.2,2.4,2.4,2.0,2.5) +x = 2.483 +s = 0.3129 +#Null hypothesis: mu = 2.25 mig/L +#Alternative hypothesis: mu > 2.25 mig/L +mu=2.25 +#Criterion: Reject the null hypothesis if t > 2.201, where 2.201 is the value of +#t0.025 for 12-1 = 11 degrees of freedom +t0.025=qt(1-0.025,11) +t.test(data,mu=2.25, alt='greater',conf=.95) +cat("Decision: Since t = 2.58 is greater than 2.201, the null hypothesis must +be rejected. In other words, the mean lead content is above +2.25 mig/L.") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.22/EX7_22.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.22/EX7_22.R new file mode 100644 index 00000000..8ec5b309 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.22/EX7_22.R @@ -0,0 +1,14 @@ +sd=3.6#dB +mu0=75.2 +#null hypothesis mu0 = 75.20 +#alternative hypothesis mu0 > 75.20 +n=15#there are 15 machines +mu=77#dB +#The test is one-sided +alpha = 0.05 +z0.05 = qnorm(1-0.05) +Z=z0.05+sqrt(n)*((mu0-mu)/sd) +Z +P=pnorm(Z,lower.tail = FALSE) +P +cat("There for the probability for type 2 error is: ",1-P) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.23/EX7_23.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.23/EX7_23.R new file mode 100644 index 00000000..09a5a641 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.23/EX7_23.R @@ -0,0 +1,15 @@ +#The test is two-tailed +mean=2.000#cm +sd=0.050#cm +mu0=2 +#FIND THE PROBABILITY OF TYPE 2 ERROR +z0.025 = qnorm(1-0.025) +mu= 2.010 +n=30 +Z1=z0.025+sqrt(n)*((mu0-mu)/sd) +Z1 +Z2=-z0.025+sqrt(n)*((mu0-mu)/sd) +Z2 +P=pnorm(Z1,lower.tail = FALSE)+pnorm(Z2) +P +cat("The probability is: ",1-P) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.24/EX7_24.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.24/EX7_24.R new file mode 100644 index 00000000..ff26b4ab --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.24/EX7_24.R @@ -0,0 +1,10 @@ +mu0 =1600 +sigma = 192 +alpha= 0.05 +mu1=1680 +z0.05 = qnorm(1-0.05) +beta= 0.10 +z0.10 = 1.28 +n=(sigma*(z0.05+z0.10)/(mu0-mu1))^2 +n +cat("There for the sample size is: ",n) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.3/EX7_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.3/EX7_3.R new file mode 100644 index 00000000..e5886d20 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.3/EX7_3.R @@ -0,0 +1,7 @@ +n=150 +sigma=6.2 +Z0.05=2.575 +E=sigma*Z0.05/sqrt(n) +E +message("Thus, the engineer can assert with probability 0.99 that his error will be at +most 1.30.") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.4/EX7_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.4/EX7_4.R new file mode 100644 index 00000000..5b2b7ea0 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.4/EX7_4.R @@ -0,0 +1,8 @@ +# 98% confidence about the maximum error? +n = 6 +s = 1.14 +t0.01 =qt(1-0.01,5) +E=t0.01*s/sqrt(n) +E +message("Thus the chemist can assert with 98% confidence that his figure for the melting point +of the aluminum alloy is off by at most 1.566049 degrees") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.5/EX7_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.5/EX7_5.R new file mode 100644 index 00000000..d2fceba0 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.5/EX7_5.R @@ -0,0 +1,7 @@ +E = 0.50 +sigma = 1.6 +z0.025 = 1.96 +n=(sigma*z0.025/E)^2 +n +message("Thus, the research worker will have to time 40 mechanics performing the task of +rotating the tires of a car") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.6/EX7_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.6/EX7_6.R new file mode 100644 index 00000000..97f64f0a --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.6/EX7_6.R @@ -0,0 +1,8 @@ +n=100#random sample of size +sigma=5.1 +xbar=21.6 +z0.025=1.96 +#ther for 95% confidence interval for the population mean is +Int1=xbar-z0.025*(sigma/sqrt(n)) +Int2=xbar+z0.025*(sigma/sqrt(n)) +cat("There for confidence interval mean is :",Int1," < ",Int2) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.7/EX7_7.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.7/EX7_7.R new file mode 100644 index 00000000..8934868b --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.7/EX7_7.R @@ -0,0 +1,11 @@ +n =50 +x = 305.58#nm +var = 1366.86 +s = 36.97#nm +#construct a 99% confidence interval for the population mean of all nanopillars +z0.005 = 2.575 +Int1=x-z0.005*(s/sqrt(n)) +Int1 +Int2=x+z0.005*(s/sqrt(n)) +Int2 +message("There for the confidence interval is : ",Int1," < ",Int2) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.8/EX7_8.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.8/EX7_8.R new file mode 100644 index 00000000..69345e49 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH7/EX7.8/EX7_8.R @@ -0,0 +1,10 @@ +n = 18 +x = 22.6 +s = 15.7 +t0.025=qt(1-0.025,17) +Int1=x-t0.025*s/sqrt(n) +Int1 +Int2=x+t0.025*s/sqrt(n) +Int2 +cat("We are 95 % confident that the interval from 14.79 to 30.41 MJ/m3 contains the +mean toughness of all possible artificial fibers created by the current process.") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.10/EX8_10.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.10/EX8_10.R new file mode 100644 index 00000000..3d033bf5 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.10/EX8_10.R @@ -0,0 +1,16 @@ +#There are two types of catalyst for the chemical reaction +Catalyst1<-c(0.63,2.64,1.85,1.68,1.09,1.67,0.73,1.04,0.68) +Catalyst2<-c(3.71,4.09,4.11,3.75,3.49,3.27,3.72,3.49,4.26) +n1 = n2 = 9 +loc=0.05 +#Null hypothesis: mu1-mu2 = 0 +#Alternative hypothesis: mu1-mu2!= 0 +#We choose the Smith-Satterthwaite test statistic with delta0 = 0 +#The null hypothesis will be rejected if t< -t0.025 or t > t0.025, but the value +#of t0.025 depends on the estimated degrees of freedom. +df=11 +t0.025=qt(1-0.025,11) +t0.025 +t.test(Catalyst1,Catalyst2,alternative ="g") +cat("Decision: Since t= -9.71 is less than -2.201, the null hypothesis must be +rejected at level of significance 0.05") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.11/EX8_11.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.11/EX8_11.R new file mode 100644 index 00000000..b6fa9597 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.11/EX8_11.R @@ -0,0 +1,13 @@ +#There are two types of catalyst for the chemical reaction +Catalyst1<-c(0.63,2.64,1.85,1.68,1.09,1.67,0.73,1.04,0.68) +Catalyst2<-c(3.71,4.09,4.11,3.75,3.49,3.27,3.72,3.49,4.26) +# 95% confidence interval for delta = mu1 - mu2 +x =mean(Catalyst1) +s1 = sd(Catalyst1) +y =mean(Catalyst2) +s2=sd(Catalyst2) +df=11 +t0.025 =qt(1-0.025,df) +t.test(Catalyst1,Catalyst2) +cat("The mean product volume for the second catalyst is +greater than that of the first catalyst by 1.880 to 2.982 gallons") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.12/EX8_12.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.12/EX8_12.R new file mode 100644 index 00000000..d9f79c8a --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.12/EX8_12.R @@ -0,0 +1,13 @@ +before<-c(45,73,46,124,33,57,83,34,26,17) +After<-c(36,60,44,119,35,51,77,29,24,11) +#Null Hypothesis:mu=0#There is no difference in mean of data there for the program is not effective +#Alternative hypothesis: mu>0 the program is effective +l.o.c=0.05 +t0.05=qt(1-0.05,9) +t0.05 +#Criterion:Reject Null Hypothesis if t>t0.05 or 1.833 for df=9 +#t calculation +t.test(before,After,paired=TRUE) +print("hence we reject Null hypothesis because t>t0.05") +print("There for the safety program is effective") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.13/EX8_13.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.13/EX8_13.R new file mode 100644 index 00000000..f7d8f4e1 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.13/EX8_13.R @@ -0,0 +1,8 @@ +#measurment of toxic level of chemical +data<-c(1.26,1.34,1.82,0.55,0.73,0.78,1.10) +n = 7 #Sample size +t.alpha=qt(1-0.025,6) +# the 95% confidence formula for mu becomes +t.test(data) +cat("We are 95% confident that the interval from 0.68 to 1.49 +contains the mean change in the red color component") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.14/EX8_14.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.14/EX8_14.R new file mode 100644 index 00000000..ff8066de --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.14/EX8_14.R @@ -0,0 +1,8 @@ +#11 observation of lab +Commercial_lab<-c(27,23,64,44,30,75,26,124,54,30,14) +State_lab<-c(15,13,22,29,31,64,30,64,56,20,21) +t0.025=qt(1-0.025,10) +t0.025 +t.test(Commercial_lab,State_lab,paired=TRUE) +cat("This 95% confidence interval just covers 0, so no difference is indicated with this +small sample size") \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.3/EX8_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.3/EX8_3.R new file mode 100644 index 00000000..116dd446 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.3/EX8_3.R @@ -0,0 +1,21 @@ +#After changing the electrical pricing during peak hours for user havingair-conditioning +#and with-out it to study the variance ; +#n1=45 homes with Air-Conditioning +n1=45 +mean1=204.4 +var1=13825.3 +#n2=55 home without it +n2=55 +mean2=130.0 +var2=8632.0 +#Obtain a 95% confidence interval for delta = mu1 - mu2 +alpha=0.05 +z.alphahalf=qnorm(1-0.025) +#Hence the Confidence interval is, +Int1=mean1-mean2-z.alphahalf*sqrt((var1/n1)+(var2/n2)) +Int1 +Int2=mean1-mean2+z.alphahalf*sqrt((var1/n1)+(var2/n2)) +Int2 +cat("hence The mean on-peak usage for homes with air-conditioning +is higher than for homes without") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.4/EX8_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.4/EX8_4.R new file mode 100644 index 00000000..ccbe3ee0 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.4/EX8_4.R @@ -0,0 +1,21 @@ +#Test for two types of Drivers +#Drivers with 0 Blood Alcohol +n1 = 54 +xbar = 1.63 +s1 = 0.177 +#Drivers with 0.1 % Blood Alcohol +n2 = 54 +ybar = 1.77 +s2 = 0.183 +z.alpha=qnorm(0.01) +z.alpha +#delta = mu1 - mu2 +#Null hypothesis: delta = 0 there is no difference in mean of drivers +#Alternative hypothesis: delta != 0 there is difference in means of driver +#Level of significance= 0.02 +#Criterion: Reject the null hypothesis if Z < -2.33 or Z > 2.33. +Z=(xbar-ybar)/sqrt((s1^2/n1)+(s2^2/n2)) +Z +cat("Since z = -4.04 is less than -2.33, the null hypothesis must be +rejected at level of significance 0.02") + diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.5/EX8_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.5/EX8_5.R new file mode 100644 index 00000000..907957fc --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.5/EX8_5.R @@ -0,0 +1,19 @@ +#We testing the claim that the resistance of electric wire can be reduced by more than +#0.050 ohm by alloying +n1=n2=32 +#For Standard wire +xbar = 0.136#ohm +s1 = 0.004 #ohm +#For alloyed wire +ybar = 0.083#ohm +s2 = 0.005#ohm +loc=0.05 +#Null hypothesis: mu1-mu2 = 0.050 +#Alternative hypothesis: mu1- mu2 > 0.050 +z.alpha=qnorm(1-0.05) +z.alpha +#Criterion: Reject the null hypothesis if Z > 1.645, where Z is given as +Z=(xbar-ybar-loc)/sqrt((s1^2/n1)+(s2^2/n2)) +Z +cat("Since z = 2.65 exceeds 1.645, the null hypothesis must be rejected; +that is, the data substantiate the claim") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.6/EX8_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.6/EX8_6.R new file mode 100644 index 00000000..21a3c29c --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.6/EX8_6.R @@ -0,0 +1,8 @@ +deltabar=0.054 +delta0=0.05 +segma_square=0.000041 +n=32 +z.alpha=1.645 +Z=z.alpha+sqrt(n)*(delta0-deltabar)/sqrt(segma_square) +P=pnorm(Z, lower.tail = FALSE)#P-value for P( Z > -1.889) +message("The Type II error probability is ",(1-P)) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.7/EX8_7.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.7/EX8_7.R new file mode 100644 index 00000000..8e812438 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.7/EX8_7.R @@ -0,0 +1,14 @@ +#recycled materials Data for two different location +Loc1<-c(707,632,604,652,669,674) +Loc2<-c(552,554,484,630,648,610) +#there is Measurements of 6 specimens of recycled materials +n1=n2=6 +#delta=mu1-mu2 # where delta is difference in mean strength for materials from the two locations +#Null hypothesis: delta = 0#Same strength +#Alternative hypothesis: delta!= 0#differnt in strength +t0.025=qt(1-0.025,10) +t0.025 +#Criterion: Reject the null hypothesis if t < -t0.025 or t > t0.025 where +#t0.025 = 2.228 for 6 + 6 - 2 = 10 degrees of freedom +t.test(Loc1,Loc2) +print("since the value of t is greater then t0.025 there for we reject the null hypothesis") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.8/EX8_8.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.8/EX8_8.R new file mode 100644 index 00000000..c423a582 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.8/EX8_8.R @@ -0,0 +1,16 @@ +Alloy<-c(66.4,67.7,68.0,68.0,68.3,68.4,68.6,68.8,68.9,69.0,69.1, +69.2,69.3,69.3,69.5,69.5,69.6,69.7,69.8,69.8,69.9,70.0, +70.0,70.1,70.2,70.3,70.3,70.4,70.5,70.6,70.6,70.8,70.9, +71.0,71.1,71.2,71.3,71.3,71.5,71.6,71.6,71.7,71.8,71.8, +71.9,72.1,72.2,72.3,72.4,72.6,72.7,72.9,73.1,73.3,73.5, +74.2,74.5,75.3) +stem(Alloy) +Alloy2<-c(71.2,71.8,72.6,72.8,73.7,73.7,73.9,74.4,74.9,75.5, + 75.9,76.3,76.5,76.7,76.9,77.1,77.3,77.6,77.7,77.8, + 78.1,78.2,78.4,78.6,79.0,79.3,79.8) +stem(Alloy2) +n1=58#Alloy of 58 material +n2=27#Alloy of 27 material +t0.025 =qt(1-0.025,83) #for 83 degrees of freedom +print("T") +t.test(Alloy,Alloy2) diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.9/EX8_9.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.9/EX8_9.R new file mode 100644 index 00000000..54fbf938 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH8/EX8.9/EX8_9.R @@ -0,0 +1,24 @@ +# 95% large sample confidence interval +Alloy<-c(66.4,67.7,68.0,68.0,68.3,68.4,68.6,68.8,68.9,69.0,69.1, + 69.2,69.3,69.3,69.5,69.5,69.6,69.7,69.8,69.8,69.9,70.0, + 70.0,70.1,70.2,70.3,70.3,70.4,70.5,70.6,70.6,70.8,70.9, + 71.0,71.1,71.2,71.3,71.3,71.5,71.6,71.6,71.7,71.8,71.8, + 71.9,72.1,72.2,72.3,72.4,72.6,72.7,72.9,73.1,73.3,73.5, + 74.2,74.5,75.3) + +Alloy2<-c(71.2,71.8,72.6,72.8,73.7,73.7,73.9,74.4,74.9,75.5, + 75.9,76.3,76.5,76.7,76.9,77.1,77.3,77.6,77.7,77.8, + 78.1,78.2,78.4,78.6,79.0,79.3,79.8) +xbar=mean(Alloy) +ybar=mean(Alloy2) +s1=sd(Alloy) +s2=sd(Alloy2) +n1=58 +n2=27 +z.alpha=qnorm(1-0.025) +Int1=xbar-ybar-z.alpha*sqrt(s1^2/n1+s2^2/n2) +Int1 +Int2=xbar-ybar+z.alpha*sqrt(s1^2/n1+s2^2/n2) +Int2 +print("The 95% Confidence Interval is") +cat(Int1," < ",Int2) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.1/EX9_1.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.1/EX9_1.R new file mode 100644 index 00000000..1acba150 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.1/EX9_1.R @@ -0,0 +1,9 @@ +#Data from chapter 8 and Example 7 +location<-c(707,632,604,652,669,674) +n=6 +d2=2.534#With refered to the table +min=604 +max=707 +R=max-min +sigma=R/d2 +message("sigma for the resiliency modulus of recycled materials is: ",sigma) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.2/EX9_2.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.2/EX9_2.R new file mode 100644 index 00000000..fb08d598 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.2/EX9_2.R @@ -0,0 +1,20 @@ +#From Example 8, it is very reasonable to assume that the population is normal +weight<-c(72.2 ,67.8 ,78.0 ,64.4 ,76.3 ,72.3 ,73.1 ,71.7 ,66.2 ,63.3 ,85.4 ,67.4, + 66.3 ,76.3 ,57.7 ,50.3 ,77.4 ,63.1 ,73.9 ,67.4 ,74.7 ,68.2 ,87.4 ,86.4, + 69.4 ,58.0 ,63.3 ,72.7 ,73.6 ,68.8 ,63.3 ,63.3 ,73.0 ,64.8 ,73.1 ,70.9, + 85.9 ,74.4 ,75.9 ,72.3 ,84.3 ,61.8 ,79.2 ,64.3 ,65.4 ,66.7 ,77.2 ,50.0, + 70.3 ,90.4 ,63.9 ,62.1 ,68.2 ,55.1 ,52.6 ,68.5 ,55.2 ,73.5 ,53.7 ,61.7, + 47.9 ,72.3 ,61.1 ,71.8 ,83.1 ,71.2 ,58.8 ,61.8 ,86.8 ,64.5 ,52.3 ,58.3, + 65.9,80.2,75.1,59.9,62.3,48.8,64.3,75.4) +n=80 +df=n-1 +chi1=qchisq(1-0.975,df) +chi2=qchisq(1-0.025,df) +s=sd(weight) +#Substituting into the formula for the confidence interval for sigma_square yields +Int1=df*(s^2)/chi2 +Int2=df*(s^2)/chi1 +message(Int1," < sigma_square <",Int2) +message(sqrt(Int1)," < sigma <",sqrt(Int2)) +cat("This means we are 95% confident that the interval from 8.29 to 11.35 pounds +contains sigma") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.3/EX9_3.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.3/EX9_3.R new file mode 100644 index 00000000..827bbd86 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.3/EX9_3.R @@ -0,0 +1,15 @@ +#sigma=0.5 null hypothesis thickness is equal to 0.5mil +#sigma>0.5 alternative hypothesis +sigma=0.5 +LOC=0.05#level of significance +X.chi=qchisq(1-0.05,14) +#Reject the null hypothesis if chi.seq>X.chi if degree if freedom is 14 +n=15#total die cut +s=0.64#standard deviation +chi.seq=((n-1)*s**2)/sigma**2 +chi.seq +if(chi.seq>X.chi){ + print("Reject null hypothesis") +}else{ + print("accept null hypothesis") +} \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.4/EX9_4.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.4/EX9_4.R new file mode 100644 index 00000000..28ba3777 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.4/EX9_4.R @@ -0,0 +1,12 @@ +#Null Hypothesis:sigma_seq1 = sigma_seq2 +#Alternative Hypothesis:sigma_seq1 < sigma_seq2 +alpha=0.05#loc +F0.05=qf(1-0.05,11,11)#df1=11,df2=11 +F0.05 +#reject null hypothesis if F>F0.05 for 11 and 11 degrees of freedom +s1=0.035 +s2=0.062 +F=s2**2/s1**2 +F +print("hence the null hypothesis is rejectecd ") +#there for plating done by company 1 is less variable that done by company 2 diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.5/EX9_5.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.5/EX9_5.R new file mode 100644 index 00000000..fc3134a4 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.5/EX9_5.R @@ -0,0 +1,13 @@ +#dealing with the strength of recycled materials for use in pavements +loca1<-c(707,632,604,652,669,674) +loca2<-c(552,554,484,630,648,610) +L.O.C=0.02 +S1=var(loca1) +S2=var(loca2) +#Null Hypothesis:=sigma_seq1=sigma_seq2 +#Alterative Hypothesis:=sigma_seq1 != sigma_seq2 +F0.01=qf(1-0.01,5,5) +#reject null hypothesis if F>F0.01 for 4 and 5 degrees of freedom +F=(S2)/(S1) +F +print("Since F doesn't exceed F0.01 there for null hypothesis can't be rejected") diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.6/EX9_6.R b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.6/EX9_6.R new file mode 100644 index 00000000..8e27df90 --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/CH9/EX9.6/EX9_6.R @@ -0,0 +1,11 @@ +n1=n2=9 +s1=0.4548 +s2=0.1089 +#Obtain a 98% confidence interval for Sigma_square2/Sigma_square1 +df1=8 +df2=8 +F=qf(1-0.01,df1,df2) +F0.99=1/F +Int1=F0.99*(s2/s1) +Int2=F*(s2/s1) +message("Interval 1: ",Int1," and Interval 2: ",Int2) \ No newline at end of file diff --git a/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/README.txt b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/README.txt new file mode 100644 index 00000000..1c5d463d --- /dev/null +++ b/Miller_And_Freund'S_Probability_And_Statistics_For_Engineers_by_Richard_A._Johnson/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Prakash Narayan Singh Rautela +Course: Bsc +Branch: Computer Science And Engineering +College/Institute/Organization: Vivekanand Education Society's College Of Arts Science & Commerce + +About The Book + +Book: Miller And Freund's Probability And Statistics For Engineers +Author: Richard A. Johnson +Publisher: Pearson, Usa +Year Of Publication: 2017 +ISBN: 978-0-321-98624-5 +Edition: 9 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH1/EX1.1/Ex1_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH1/EX1.1/Ex1_1.R new file mode 100644 index 00000000..a7ce6e60 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH1/EX1.1/Ex1_1.R @@ -0,0 +1,14 @@ +g=9.8 +#m/s^2; acceleration due to gravity +m=68.1 +#kg +c=12.5 +#kg/sec; drag coefficient +count=1 +v = matrix(0,1) +for (i in (seq(0,12,2))){ + v[count]=g*m*(1-exp(-c*i/m))/c + cat("v(m/s)=",v[count],"Time(s)=",i) + count=count+1; +} +cat("v(m/s)=",g*m/c,"Time(s)=","infinity") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.1/Ex14_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.1/Ex14_1.R new file mode 100644 index 00000000..fe81487a --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.1/Ex14_1.R @@ -0,0 +1,21 @@ +maxf = -1e+09 + +n=10000 +for (j in 1:n){ + Rnd=runif(2) + x = -2 + 4 * Rnd[1] + y = 1 + 2 * Rnd[2] + fn = y - x - (2 * (x ^ 2)) - (2 * x * y) - (y ^ 2) + if (fn > maxf){ + maxf = fn + maxx = x + maxy = y + } + if (mod(j,1000)==0){ + cat("Iteration:",j,"\n") + cat("x:",x,"\n") + cat("y:",y,"\n") + cat("function value:",fn,"\n") + cat("------------------------------------------\n") + } +} \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.2/Ex14_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.2/Ex14_2.R new file mode 100644 index 00000000..7d71402a --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.2/Ex14_2.R @@ -0,0 +1,11 @@ +f <- function(x,y) { + x*y*y +} + +p1<-c(2, 2) +elevation=f(p1[1],p1[2]) +dfx=p1[1]*p1[1] +dfy=2*p1[1]*p1[2] +theta=atan(dfy/dfx) +slope=(dfx^2 + dfy^2)^0.5 +cat("Elevation:",elevation,"Theta:",theta,"slope:",slope) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.3/Ex14_3.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.3/Ex14_3.R new file mode 100644 index 00000000..e05a99ce --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.3/Ex14_3.R @@ -0,0 +1,11 @@ +f <- function(x,y) { + 2*x*y + 2*x - x^2 - 2*y^2 +} + +x=-1 +y=1 +dfx=2*y+2-2*x +dfy=2*x-4*y +#the function can thus be expressed along h axis as +#f((x+dfx*h),(y+dfy*h)) +cat("The final equation is=","180*h^2 + 72*h - 7") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.4/Ex14_4.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.4/Ex14_4.R new file mode 100644 index 00000000..937b7326 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH14/EX14.4/Ex14_4.R @@ -0,0 +1,28 @@ +f <- function(x,y) { + 2*x*y + 2*x - x^2 - 2*y^2 +} + +x=-1 +y=1 +d2fx=-2 +d2fy=-4 +d2fxy=2 + +modH=d2fx*d2fy-(d2fxy)^2 + +for (i in 1:25){ + dfx=2*y+2-2*x + dfy=2*x - 4*y + #the function can thus be expressed along h axis as + #f((x+dfx*h),(y+dfy*h)) + g <- function(h) { + 2*(x+dfx*h)*(y+dfy*h) + 2*(x+dfx*h) - (x+dfx*h)^2 - 2*(y+dfy*h)^2 + } + #2*dfx*(y+dfy*h)+2*dfy*(x+dfx*h)+2*dfx-2*(x+dfx*h)*dfx-4*(y+dfy*h)*dfy=g'(h)=0 + #2*dfx*y + 2*dfx*dfy*h + 2*dfy*x + 2*dfy*dfx*h + 2*dfx - 2*x*dfx - 2*dfx*dfx*h - 4*y*dfy - 4*dfy*dfy*h=0 + #h(2*dfx*dfy+2*dfy*dfx-2*dfx*dfx-4*dfy*dfy)=-(2*dfx*y+2*dfy*x-2*x*dfx-4*y*dfy) + h=(2*dfx*y+2*dfy*x-2*x*dfx-4*y*dfy+2*dfx)/(-1*(2*dfx*dfy+2*dfy*dfx-2*dfx*dfx-4*dfy*dfy)) + x=x+dfx*h + y=y+dfy*h +} +cat("The final values are:",x,",", y) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.1/Ex15_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.1/Ex15_1.R new file mode 100644 index 00000000..f1c257f9 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.1/Ex15_1.R @@ -0,0 +1,13 @@ +regular<-c(7, 10, 9 ,150) +premium<-c(11, 8 ,6 ,175) +res_avail<-c(77, 80) +#total profit(to be maximized)=z=150*x1+175*x2 +#total gas used=7*x1+11*x2 (has to be less than 77 m^3/week) +#similarly other constraints are developed +cat("Maximize z=150*x1+175*x2") +cat("subject to") +cat("7*x1+11*x2<=77 (Material constraint)") +cat("10*x1+8*x2<=80 (Time constraint)") +cat("x1<=9 (Regular storage constraint)") +cat("x2<=6 (Premium storage constraint)") +cat("x1,x2>=0 (Positivity constraint)") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.2/Ex15_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.2/Ex15_2.R new file mode 100644 index 00000000..361e6a07 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.2/Ex15_2.R @@ -0,0 +1,23 @@ +x21<-matrix(0,8) +x22<-matrix(0,8) +x23<-matrix(0,8) +x24<-matrix(0,8) +x25<-matrix(0,8) +x26<-matrix(0,8) +for (x1 in 0:8){ + x21[x1+1]=-(7/11)*x1+7 + x22[x1+1]=(80-10*x1)/8 + x23[x1+1]=6 + x24[x1+1]=-150*x1/175 + x25[x1+1]=(600-150*x1)/175 + x26[x1+1]=(1400-150*x1)/175 +} +x1=0:8 + + +plot(x1,x24,main ='Z=0') +lines(x1,x25,main = 'Z=600') +lines(x1,x26,main = 'Z=1400') +plot(x1,x21,main = 'x2 vs x1') +plot(x1,x22,xlab = 'x1 (tonnes)') +plot(x1,x23,ylab = 'x2 (tonnes)') \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.3/Ex15_3.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.3/Ex15_3.R new file mode 100644 index 00000000..b2114c99 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.3/Ex15_3.R @@ -0,0 +1,27 @@ +x1<-c(4.888889, 3.888889) +x2<-c(7, 11) +x3<-c(10, 8) +x4<-c(150, 175) +x5<-c(77, 80, 9, 6) +profit<-c(x1[1]*x4[1], x1[2]*x4[2]) +total<-c(x1[1]*x3[1]+x1[2]*x3[2], x1[1]*x3[1]+x1[2]*x3[2], x1[1], x1[2], profit[1]+profit[2]) +e=1000 + +while (e>total[5]){ + if (total[1]<=x5[1]){ + if (total[2]<=x5[2]){ + if (total[3]<=x5[3]){ + if (total[4]<=x5[4]){ + l=1 + } + } + } + } +if (l==1){ + x1[1]=x1[1]+4.888889 + x1[2]=x1[2]+3.888889 + profit<-c(x1[1]*x4[1], x1[2]*x4[2]) + total[5]=profit[1]+profit[2] +} +} +cat("The maximized profit is=",total[5]) diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.4/Ex15_4.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.4/Ex15_4.R new file mode 100644 index 00000000..750493ab --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.4/Ex15_4.R @@ -0,0 +1,37 @@ +Mt=2000 +#kg +g=9.8 +#m/s^2 +c0=200 +#$ +c1=56 +#$/m +c2=0.1 +#$/m^2 +vc=20 +#m/s +kc=3 +#kg/(s*m^2) +z0=500 +#m +t=27 +r=2.943652 +n=6 +pi = 3.1415927 +A=2*pi*r*r +l=(2^0.5)*r +c=3*A +m=Mt/n + +f <- function(t) { + (z0+g*m*m/(c*c)*(1-exp(-c*t/m)))*c/(g*m) +} + +while (abs(f(t)-t)>0.00001){ + t=t+0.00001 +} +v=g*m*(1-exp(-c*t/m))/c +cat("The final value of velocity=",v,"\n") +cat("The final no. of load parcels=",n,"\n") +cat("The chute radius=",r,"m","\n") +cat("The minimum cost($)=",(c0+c1*l+c2*A*A)*n) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.5/Ex15_5.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.5/Ex15_5.R new file mode 100644 index 00000000..70611e5c --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.5/Ex15_5.R @@ -0,0 +1,12 @@ +library(neldermead) + +fx <- function(x) { + -(2*sin(x))+x^2/10 +} + +x=fminsearch(fx,0) +x$output$algorithm +x = x$optbase$xopt +cat("After maximization:\n") +cat("x=",x) +cat("f(x)=",fx(x),"\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.6/Ex15_6.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.6/Ex15_6.R new file mode 100644 index 00000000..c62a9e37 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.6/Ex15_6.R @@ -0,0 +1,9 @@ +library(neldermead) + +fx <- function(x) { + -(2*x[1]*x[2]+2*x[1]-x[1]^2-2*x[2]^2) +} + +x=fminsearch(fun = fx,x0 = c(-1,1)) +x = x$optbase$xopt +cat("After maximization:","\n","x=",x[1],",",x[2],"\n","f(x)=",fx(x),"\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.7/Ex15_7.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.7/Ex15_7.R new file mode 100644 index 00000000..44865b74 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH15/EX15.7/Ex15_7.R @@ -0,0 +1,7 @@ +fx <- function(x) { + -(2*sin(x)-x^2/10) +} + +x=fminsearch(fx,0) +x = x$optbase$xopt +cat("After maximization:","\n","x=",x,"\n","f(x)=",fx(x),"\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH17/EX17.3.a/Ex17_3_a.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH17/EX17.3.a/Ex17_3_a.R new file mode 100644 index 00000000..2106e0e7 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH17/EX17.3.a/Ex17_3_a.R @@ -0,0 +1,17 @@ +s<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) +v<-c(10,16.3,23,27.5,31,35.6,39,41.5,42.9,45,46,45.5,46,49,50) +g = 9.8 +#m/s^2 +m = 68.1 +#kg +c = 12.5 +#kg/s +v1<-matrix(0,15) +v2<-matrix(0,15) +for (i in 1:15){ + v1[i] = g*m*(1 - exp(-c*s[i]/m))/c + v2[i] = g*m*s[i]/(c*(3.75+s[i])) +} +cat("time = ",s,"\n","measured v =",v,"\n","using equation(1.10) v1 = ","\n",v1,"\n","using equation((17.3)) v2 =","\n",v2) +plot(v,v1) +lines(v,v1,main = 'v vs v1',xlab = 'v',ylab = 'v1') \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH17/EX17.3.b/Ex17_3_b.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH17/EX17.3.b/Ex17_3_b.R new file mode 100644 index 00000000..09b12849 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH17/EX17.3.b/Ex17_3_b.R @@ -0,0 +1,17 @@ +s<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) +v<-c(10,16.3,23,27.5,31,35.6,39,41.5,42.9,45,46,45.5,46,49,50) +g = 9.8 +#m/s^2 +m = 68.1 +#kg +c = 12.5 +#kg/s +v1<-matrix(0,15) +v2<-matrix(0,15) +for (i in 1:15){ + v1[i] = g*m*(1 - exp(-c*s[i]/m))/c + v2[i] = g*m*s[i]/(c*(3.75+s[i])) +} +cat("time = ",s,"\n","measured v =",v,"\n","using equation(1.10) v1 = ","\n",v1,"\n","using equation((17.3)) v2 =","\n",v2) +plot(v,v2) +lines(v,v2,main = 'v vs v2',xlab = 'v',ylab = 'v2') \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH18/EX18.5/Ex18_5.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH18/EX18.5/Ex18_5.R new file mode 100644 index 00000000..f926d262 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH18/EX18.5/Ex18_5.R @@ -0,0 +1,26 @@ +x<-c(1, 4, 6, 5, 3, 1.5, 2.5, 3.5) +y<-c(0, 1.3862944, 1.7917595, 1.6094379, 1.0986123, 0.4054641, 0.9162907, 1.2527630) +n=8 +fdd = matrix(0,nrow =n,ncol = n) +for (i in 1:n){ + fdd[i,1]=y[i] +} + +for (j in 2:n){ + for (i in 1:(n-j+1)){ + fdd[i,j]=(fdd[i+1,j-1]-fdd[i,j-1])/(x[i+j-1]-x[i]) + } +} +xterm=1 +yint<-matrix(0,1) +yint[1]=fdd[1,1] + +order<-matrix(0,n) +Ea<-matrix(0,n) +for (order in 2:n){ + xterm=xterm*(2-x[order-1]) + yint2=yint[order-1]+fdd[1,order]*xterm + Ea[order-1]=yint2-yint[order-1] + yint[order]=yint2 +} +cat("F(x)=",yint,"\n","Ea=",Ea) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.1/Ex19_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.1/Ex19_1.R new file mode 100644 index 00000000..48d586f2 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.1/Ex19_1.R @@ -0,0 +1,34 @@ +f <- function(t) { + 1.7+cos(4.189*t+1.0472) +} + +deltat=0.15 +t1=0 +t2=1.35 +omega=4.189 +del=(t2-t1)/9 +t<-matrix(0,10) +for (i in 1:10){ + t[i]=t1+del*(i-1) +} +sumy=0 +suma=0 +sumb=0 +y<-matrix(0,10) +a<-matrix(0,10) +b<-matrix(0,10) +for (i in 1:10){ + y[i]=f(t[i]) + a[i]=y[i]*cos(omega*t[i]) + b[i]=y[i]*sin(omega*t[i]) + sumy=sumy+y[i] + suma=suma+a[i] + sumb=sumb+b[i] +} +A0=sumy/10 +A1=2*suma/10 +B1=2*sumb/10 +cat("The least square fit is y=A0+A1*cos(w0*t)+A2*sin(w0*t), where","\n","A0=",A0,"\n","A1=",A1,"\n","B1=",B1,"\n") +theta=atan(-B1/A1) +C1=(A1^2 + B1^2)^0.5 +cat("Alternatively, the least square fit can be expressed as","\n","y=A0+C1*cos(w0*t + theta), where","\n","A0=",A0,"\n","Theta=",theta,"\n","C1=",C1,"\n","Or","\n","y=A0+C1*sin(w0*t + theta + pi/2), where","\n","A0=",A0,"\n","Theta=",theta,"\n","C1=",C1,"\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.2/Ex19_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.2/Ex19_2.R new file mode 100644 index 00000000..7272aedd --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.2/Ex19_2.R @@ -0,0 +1,13 @@ +a0=0 +#f(t)=-1 for -T/2 to -T/4 +#f(t)=1 for -T/4 to T/4 +#f(t)=-1 for T/4 to T/2 +#ak=2/T* (integration of f(t)*cos(w0*t) from -T/2 to T/2) +#ak=2/T*((integration of f(t)*cos(w0*t) from -T/2 to -T/4) + (integration of f(t)*cos(w0*t) from -T/4 to T/4) + (integration of f(t)*cos(w0*t) from T/4 to T/2)) +#Therefore, +#ak=4/(k*%pi) for k=1,5,9,..... +#ak=-4/(k*%pi) for k=3,7,11,..... +#ak=0 for k=even integers +#similarly we find the b's. +#all the b's=0 +cat("The fourier approximtion is:","\n","4/(%pi)*cos(w)*t) - 4/(3*%pi)*cos(3*(w)*t) + 4/(5*%pi)*cos(5*(w)*t) - 4/(7*%pi)*cos(7*(w)*t) + .....") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.4/Ex19_4.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.4/Ex19_4.R new file mode 100644 index 00000000..fd5aac82 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.4/Ex19_4.R @@ -0,0 +1,14 @@ +s<-c(0.0002, 0.0002, 0.0005, 0.0005, 0.001, 0.001) +r<-c(0.2, 0.5, 0.2, 0.5, 0.2, 0.5) +u<-c(0.25, 0.5, 0.4, 0.75, 0.5, 1) +logs=log10(s) +logr=log10(r) +logu=log10(u) +m<-matrix(0,nrow = 6,ncol = 3) +for (i in 1:6){ + m[i,1]=1 + m[i,2]=logs[i] + m[i,3]=logr[i] +} +a=qr.solve(m,transpose(logu)) +cat("alpha=",10^a[1],"sigma=",a[2],"rho=",a[3]) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.5/Ex19_5.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.5/Ex19_5.R new file mode 100644 index 00000000..28312b34 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.5/Ex19_5.R @@ -0,0 +1,22 @@ +#install.packages("signal",dependencies = TRUE) +library(signal) +x=0:10 +y=sin(x) +xi=seq(0,10,.25) +#part a +yi=interp1(x,y,xi) +plot(xi,yi,main = "y vs x (part a)",xlab = "x",ylab ="y" ) + +#part b +#fitting x and y in a fifth order polynomial +p<-c(0.0008, -0.0290, 0.3542, -1.6854, 2.586, -0.0915) + +for (i in 1:41){ + yi[i]=p[1]*(xi[i]^5)+p[2]*(xi[i]^4)+p[3]*(xi[i]^3)+p[4]*(xi[i]^2)+p[5]*(xi[i])+p[6] +} +plot(xi,yi,main = "y vs x (part b)",xlab = "x",ylab = "y") + +#part c +d = spline(x,y,method = "fmm",n = length(x)) +plot(x,d$y,main = "y vs x (part c)",xlab = "x",ylab = "y") +lines(x,d$y) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.6/Ex19_6.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.6/Ex19_6.R new file mode 100644 index 00000000..6b71fc80 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH19/EX19.6/Ex19_6.R @@ -0,0 +1,17 @@ +x<-c(0.05, 0.12, 0.15, 0.3, 0.45, 0.7, 0.84, 1.05) +y<-c(0.957, 0.851, 0.832, 0.72, 0.583, 0.378, 0.295, 0.156) +sx=sum(x) +sxx=sum(x*x) +sx3=sum(x*x*x) +sx4=sum(x*x*x*x) +sx5=sum(x*x*x*x*x) +sx6=sum(x*x*x*x*x*x) +n=8 +sy=sum(y) +sxy=sum(x*y) +sx2y=sum(x*x*y) +sx3y=sum(x*x*x*y) +m<-matrix(data = c(n, sx, sxx, sx3,sx, sxx, sx3, sx4,sxx, sx3, sx4, sx5,sx3, sx4, sx5, sx6),nrow = 4,ncol = 4,byrow = TRUE) +p<-matrix(data = c(sy,sxy,sx2y,sx3y),nrow = 4,ncol = 1,byrow = TRUE) +a=solve(m,p) +cat("The cubic polynomial is y=a0 + a1*x + a2*x^2 + a3*x^3, where a0, a1, a2 and a3 are","\n",a[1],"\n",a[2],"\n",a[3],"\n",a[4],"\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.1/Ex21_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.1/Ex21_1.R new file mode 100644 index 00000000..06d2f96b --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.1/Ex21_1.R @@ -0,0 +1,28 @@ +f <- function(x) { + (0.2+25*x-200*x^2+675*x^3-900*x^4+400*x^5) +} + +tval=1.640533 +a=0 +b=0.8 +fa=f(a) +fb=f(b) +l=(b-a)*((fa+fb)/2) +Et=tval-l +#error +et=Et*100/tval +#percent relative error + +#by using approximate error estimate + +#the second derivative of f + +g <- function(x) {-400+4050*x-10800*x^2+8000*x^3} +ans = integrate(f = g,lower = 0,upper = 0.8) + +f2x = ans$value/(b-a) +#average value of second derivative + +Ea=-(1/12)*(f2x)*(b-a)^3 + +cat("The Error Et=",Et,"\n","The percent relative error et=",et,"%","\n","The approximate error estimate without using the true value=",Ea) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.2/Ex21_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.2/Ex21_2.R new file mode 100644 index 00000000..9192a76e --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.2/Ex21_2.R @@ -0,0 +1,31 @@ +f <- function(x) { + (0.2+25*x-200*x^2+675*x^3-900*x^4+400*x^5) +} + +a=0 +b=0.8 +tval=1.640533 +n=2 +h=(b-a)/n +fa=f(a) +fb=f(b) +fh=f(h) +l=(b-a)*(fa+2*fh+fb)/(2*n) +Et=tval-l +#error +et=Et*100/tval +#percent relative error + +#by using approximate error estimate + +#the second derivative of f +g <- function(x) { + -400+4050*x-10800*x^2+8000*x^3 +} +ans = integrate(f = g,lower = 0,upper = 0.8) + +f2x = ans$value/(b-a) +#average value of second derivative + +Ea=-(1/12)*(f2x)*(b-a)^3/(n^2); +cat("The Error Et=",Et,"\n","The percent relative error et=",et,"%","\n","The approximate error estimate without using the true value=",Ea) diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.3/Ex21_3.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.3/Ex21_3.R new file mode 100644 index 00000000..c14c3ba5 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH21/EX21.3/Ex21_3.R @@ -0,0 +1,145 @@ +g=9.8 +#m/s^2; acceleration due to gravity + +m=68.1 +#kg + +c=12.5 +#kg/sec; drag coefficient + +f <- function(t) { + g*m*(1-exp(-c*t/m))/c +} + +tval=289.43515 +#m + +a=0 +b=10 +fa=f(a) +fb=f(b) + +for (i in seq(10,20,10)){ + n=i + h=(b-a)/n + cat("No. of segments=",i,"\n","Segment size=",h,"\n") + j=a+h + s=0 + while (j0.1){ + maxim=b[1] + for (i in 2:3){ + if (abs(b[i])>abs(maxim)){ + maxim=b[i] + } + } + eigen[count]=maxim + b=a %*%(b/maxim) + if (count==1){ + ea=20 + count=count+1 + } else { + ea=abs(eigen[count]-eigen[count-1])*100/abs(eigen[count]) + count=count+1 + } +} +cat("The largest eigen value",eigen[count-1]) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.8/Ex27_8.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.8/Ex27_8.R new file mode 100644 index 00000000..1dc58afe --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.8/Ex27_8.R @@ -0,0 +1,24 @@ +a<-matrix(c(3.556, -1.668, 0, -1.778, 3.556, -1.778, 0, -1.778, 3.556),nrow = 3,ncol = 3,byrow = TRUE) +b<-matrix(c(1.778,0,1.778),nrow = 3,ncol = 1,byrow = TRUE) +ea=100 +count=1 +eigen<-matrix(0,100) +ai=solve(a) +while (ea>4){ + maxim=b[1] + for (i in 2:3){ + if (abs(b[i])>abs(maxim)){ + maxim=b[i] + } + } + eigen[count]=maxim + b=ai%*%(b/maxim) + if (count==1){ + ea=20 + count=count+1 + } else { + ea=abs(eigen[count]-eigen[count-1])*100/abs(eigen[count]) + count=count+1 + } +} +cat("The smallest eigen value",(1/eigen[count-1])^0.5) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.9/Ex27_9.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.9/Ex27_9.R new file mode 100644 index 00000000..b5cbf79e --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH27/EX27.9/Ex27_9.R @@ -0,0 +1,17 @@ +library(deSolve) + +predprey <- function(t,y,parms) { + a = 1.2*y[1]-0.6*y[1]*y[2] + b = -0.8*y[2]+0.3*y[1]*y[2] + list(c(a,b)) +} +t=seq(0,20,0.1) +y0<-c(2, 1) +sol=ode(y = y0,parms = NULL,times = t,func = predprey) +sol<-data.frame(sol) +plot(t,sol$X1,main = "y vs t", xlab = "t",ylab = "y") +lines(t,sol$X1) +lines(t,sol$X2) + +plot(sol$X1,sol$X2,main = "space-space plot (y1 vs y2)", xlab = "y1",ylab = "y2") +lines(sol$X1,sol$X2) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.1/Ex3_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.1/Ex3_1.R new file mode 100644 index 00000000..d21d1955 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.1/Ex3_1.R @@ -0,0 +1,26 @@ +lbm=9999 +#cm, measured length of bridge +lrm=9 +#cm, measured length of rivet +lbt=10000 +#cm, true length of bridge +lrt=10 +#cm,true length of rivet + +#calculating true error below; +Etb=lbt-lbm +#cm, true error in bridge +Etr=lrt-lrm +#cm, true error in rivet + +#calculating percent relative error below +etb=Etb*100/lbt +#percent relative error for bridge +etr=Etb*100/lrt +#percent relative error for rivet +cat("a. The true error is") +cat(Etb,"cm","for the bridge") +cat(Etr,"cm","for the rivet") +cat("b. The percent relative error is") +cat(etb,"%","for the bridge") +cat(etr,"%","for the rivet") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.2/Ex3_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.2/Ex3_2.R new file mode 100644 index 00000000..2ee879db --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.2/Ex3_2.R @@ -0,0 +1,25 @@ +n=3 +#number of significant figures +es=0.5*(10^(2-n)) +#percent, specified error criterion +x=0.5; +f = matrix(0,1) +f[1]=1 +#first estimate f=e^x = 1 +ft=1.648721 +#true value of e^0.5=f +et = matrix(0,1) +et[1]=(ft-f[1])*100/ft +ea = matrix(0,1) +ea[1]=100; +i=2 +while (ea[i-1]>=es){ + f[i]=f[i-1]+(x^(i-1))/(factorial(i-1)) + et[i]=(ft-f[i])*100/ft + ea[i]=(f[i]-f[i-1])*100/f[i] + i=i+1 +} +for (j in 1:i-1){ + cat("term number=",j,"\n","Result=",f[j],"\n","True % relative error=",et[j],"\n","Approximate estimate of error(%)=",ea[j],"\n") + cat("---------------------------------------------------------------\n") +} \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.3/Ex3_3.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.3/Ex3_3.R new file mode 100644 index 00000000..aa848f40 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.3/Ex3_3.R @@ -0,0 +1,7 @@ +n=16 +#no of bits +num=0 +for (i in 0:(n-2)){ + num=num+(1*(2^i)) +} +cat("Thus a 16-bit computer word can store decimal integers ranging from",(-1*num),"to",num) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.4/Ex3_4.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.4/Ex3_4.R new file mode 100644 index 00000000..065dde64 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.4/Ex3_4.R @@ -0,0 +1,9 @@ +n=7 +#no. of bits +#the maximum value of exponents is given by +Max=1*(2^1)+1*(2^0) +#mantissa is found by +mantissa=1*(2^-1)+0*(2^-3)+0*(2^-3) +num=mantissa*(2^(Max*-1)) +#smallest possible positive number for this system +cat("The smallest possible positive number for this system is",num) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.5/Ex3_5.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.5/Ex3_5.R new file mode 100644 index 00000000..4cd76947 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.5/Ex3_5.R @@ -0,0 +1,7 @@ +b=2 +#base +t=3 +#number of mantissa bits +E=2^(1-t) +#epsilon +cat("value of epsilon=",E) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.6/Ex3_6.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.6/Ex3_6.R new file mode 100644 index 00000000..ff3de6d6 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.6/Ex3_6.R @@ -0,0 +1,13 @@ +readinteger <- function() +{ + n <- readline(prompt="Input a number: ") + return(as.integer(n)) +} + +num<-readinteger() + +sum=0 +for (i in 1:100000){ + sum=sum+num +} +cat("The number summed up 100,000 times is=",sum) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.7/Ex3_7.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.7/Ex3_7.R new file mode 100644 index 00000000..95c5aae9 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.7/Ex3_7.R @@ -0,0 +1,8 @@ +a=1 +b=3000.001 +c=3 +#the roots of the quadratic equation x^2+3000.001*x+3=0 are found as +D=(b^2)-4*a*c +x1=(-b+(D^0.5))/(2*a) +x2=(-b-(D^0.5))/(2*a) +cat("The roots of the quadratic equation (x^2)+(3000.001*x)+3=0 are = ",x1,"and",x2) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.8/Ex3_8.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.8/Ex3_8.R new file mode 100644 index 00000000..5d9ee5a2 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH3/EX3.8/Ex3_8.R @@ -0,0 +1,19 @@ +f <- function(x) { + exp(x) +} + +sum=1 +test=0 +i=0 +term=1 +x1= 10 +x2= -10 +while (sum~=test){ + cat("sum:",sum,"\n","term:",term,"\n","i:",i,"\n","-------------------------------------\n") + i=i+1 + term=term*x/i + test=sum + sum=sum+term +} +cat("Exact Value",f(x1)) +cat("Exact Value",f(x2)) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH31/EX31.1/Ex31_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH31/EX31.1/Ex31_1.R new file mode 100644 index 00000000..c238099c --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH31/EX31.1/Ex31_1.R @@ -0,0 +1,24 @@ +#d2T/dx2=-10; equation to be solved +#T(0,t)=40; boundary condition +#T(10,t)=200; boundary condition +#f(x)=10; uniform heat source +#we assume a solution T=a*X^2 + b*x +c +#differentiating twice we get d2T/dx2=2*a +a=-10/2 +#using first boundary condition +c=40 +#using second boundary condtion +b=66 +#hence final solution T=-5*x^2 + 66*x + 40 +f <- function(x) { + -5*x^2 + 66*x + 40 +} +T<-matrix(0,110) +count=1 +for (i in seq(0,11,0.1)){ + T[count]=f(i) + count=count+1 +} +x<-seq(0,11,0.1) +plot(x,T,main = "Temperature(T) vs distance(x)",xlab = "x (cm)",ylab = "T (units)") +lines(x,T) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH31/EX31.2/Ex31_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH31/EX31.2/Ex31_2.R new file mode 100644 index 00000000..72c0b80b --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH31/EX31.2/Ex31_2.R @@ -0,0 +1,18 @@ +xf=10 +#cm +xe=2.5 +#cm +#T(0,t)=40; boundary condition +#T(10,t)=200; boundary condition +#f(x)=10; uniform heat source +f <- function(x) { + 10*(xe-x)/xe +} +int1=integrate(f = f,lower = 0,upper = xe) + +g <- function(x) { + 10*(x-0)/xe +} +int2=integrate(f = g,lower = 0,upper = xe) + +cat("The results are:","\n","0.4*T1-0.4*T2=-(dT/dx)*x1 + c1","\n","where c1=",int1$value,"\n","and","\n","-0.4*T1+0.4*T2=-(dT/dx)*x2 + c2","\n","where c2=",int2$value,"\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.1/Ex4_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.1/Ex4_1.R new file mode 100644 index 00000000..d2064071 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.1/Ex4_1.R @@ -0,0 +1,91 @@ +DD <- function(expr, name, order = 1) { + if(order < 1) stop("'order' must be >= 1") + if(order == 1) D(expr, name) + else DD(D(expr, name), name, order - 1) +} + +f <- function(x) { + return(-0.1*x^4-0.15*x^3-0.5*x^2-0.25*x+1.2) +} + +xi=0 +xf=1 +h=xf-xi +fi=f(xi) +#function value at xi +ffa=f(xf) +#actual function value at xf + +#for n=0, i.e, zero order approximation +ff=fi +Et = matrix(0,5) +Et[1]=ffa-ff +#truncation error at x=1 +cat("The value of f at x=0 :",fi,"\n", + "The value of f at x=1 due to zero order approximation :",ff,"\n", + "Truncation error :",Et[1],"\n", + "----------------------------------------------\n") + +#for n=1, i.e, first order approximation +f1 <- function(x) { + return(eval(DD(expr = expression(-0.1*x^4-0.15*x^3-0.5*x^2-0.25*x+1.2),"x",1))) +} + +f1i=f1(xi) +#value of first derivative of function at xi +f1f=fi+f1i*h +#value of first derivative of function at xf +Et[2]=ffa-f1f +#truncation error at x=1 +cat("The value of first derivative of f at x=0 :",f1i,"\n", + "The value of f at x=1 due to first order approximation :",f1f,"\n", + "Truncation error :",Et[2],"\n", + "----------------------------------------------\n") + + +#for n=2, i.e, second order approximation +f2 <- function(x) { + return(eval(DD(expr = expression(-0.1*x^4-0.15*x^3-0.5*x^2-0.25*x+1.2),"x",2))) +} + + +f2i=f2(xi) +#value of second derivative of function at xi +f2f=f1f+f2i*(h^2)/factorial(2) +#value of second derivative of function at xf +Et[3]=ffa-f2f +#truncation error at x=1 +cat("The value of first derivative of f at x=0 :",f2i,"\n", + "The value of f at x=1 due to first order approximation :",f2f,"\n", + "Truncation error :",Et[3],"\n", + "----------------------------------------------\n") + +#for n=3, i.e, third order approximation +f3 <- function(x) { + return(eval(DD(expr = expression(-0.1*x^4-0.15*x^3-0.5*x^2-0.25*x+1.2),"x",3))) +} +f3i=f3(xi) +#value of third derivative of function at xi +f3f=f2f+f3i*(h^3)/factorial(3) +#value of third derivative of function at xf +Et[4]=ffa-f3f +#truncation error at x=1 +cat("The value of first derivative of f at x=0 :",f3i,"\n", + "The value of f at x=1 due to first order approximation :",f3f,"\n", + "Truncation error :",Et[4],"\n", + "----------------------------------------------\n") + +#for n=4, i.e, fourth order approximation +f4 <- function(x) { + return(eval(DD(expr = expression(-0.1*x^4-0.15*x^3-0.5*x^2-0.25*x+1.2),"x",4))) +} +f4i=f4(xi) +#value of fourth derivative of function at xi +f4f=f3f+f4i*(h^4)/factorial(4) +#value of fourth derivative of function at xf +Et[5]=ffa-f4f +#truncation error at x=1 +cat("The value of first derivative of f at x=0 :",f4i,"\n", + "The value of f at x=1 due to first order approximation :",f4f,"\n", + "Truncation error :",Et[5],"\n", + "----------------------------------------------\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.2/Ex4_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.2/Ex4_2.R new file mode 100644 index 00000000..4563925b --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.2/Ex4_2.R @@ -0,0 +1,113 @@ +DD <- function(expr, name, order = 1) { + if(order < 1) stop("'order' must be >= 1") + if(order == 1) D(expr, name) + else DD(D(expr, name), name, order - 1) +} + +f <- function(x) { + return(cos(x)) +} + +pi = 3.1415927 +et = matrix(0,7) + +xi=pi/4 +xf=pi/3 +h=xf-xi +fi=f(xi) +#function value at xi +ffa=f(xf) +#actual function value at xf + +#for n=0, i.e, zero order approximation +ff=fi; +et[1]=(ffa-ff)*100/ffa +#percent relative error at x=1 +cat("The value of f at x=1 due to zero order approximation :",ff,"\n", + "% relative error :",et[1],"\n", + "----------------------------------------------\n") + + +#for n=1, i.e, first order approximation +f1 <- function(x) { + return(eval(DD(expr = expression(cos(x)),"x",1))) +} +f1i=f1(xi) +#value of first derivative of function at xi +f1f=fi+f1i*h +#value of first derivative of function at xf +et[2]=(ffa-f1f)*100/ffa +#% relative error at x=1 +cat("The value of f at x=1 due to first order approximation :",f1f,"\n", + "% relative error :",et[2],"\n", + "----------------------------------------------\n") + + +#for n=2, i.e, second order approximation +f2 <- function(x) { + return(eval(DD(expr = expression(cos(x)),"x",2))) +} +f2i=f2(xi) +#value of second derivative of function at xi +f2f=f1f+f2i*(h^2)/factorial(2) +#value of second derivative of function at xf +et[3]=(ffa-f2f)*100/ffa +#% relative error at x=1 +cat("The value of f at x=1 due to second order approximation :",f2f,"\n", + "% relative error :",et[3],"\n", + "----------------------------------------------\n") + +#for n=3, i.e, third order approximation +f3 <- function(x) { + return(eval(DD(expr = expression(cos(x)),"x",3))) +} +f3i=f3(xi) +#value of third derivative of function at xi +f3f=f2f+f3i*(h^3)/factorial(3) +#value of third derivative of function at xf +et[4]=(ffa-f3f)*100/ffa +#% relative error at x=1 +cat("The value of f at x=1 due to third order approximation :",f3f,"\n", + "% relative error :",et[4],"\n", + "----------------------------------------------\n") + +#for n=4, i.e, fourth order approximation +f4 <- function(x) { + return(eval(DD(expr = expression(cos(x)),"x",4))) +} +f4i=f4(xi) +#value of fourth derivative of function at xi +f4f=f3f+f4i*(h^4)/factorial(4) +#value of fourth derivative of function at xf +et[5]=(ffa-f4f)*100/ffa +#% relative error at x=1 +cat("The value of f at x=1 due to fourth order approximation :",f4f,"\n", + "% relative error :",et[5],"\n", + "----------------------------------------------\n") + + +#for n=5, i.e, fifth order approximation +f5i=(f4(1.1*xi)-f4(0.9*xi))/(2*0.1) +#value of fifth derivative of function at xi (central difference method) +f5f=f4f+f5i*(h^5)/factorial(5) +#value of fifth derivative of function at xf +et[6]=(ffa-f5f)*100/ffa +#% relative error at x=1 +cat("The value of f at x=1 due to fifth order approximation :",f5f,"\n", + "% relative error :",et[6],"\n", + "----------------------------------------------\n") + + +#for n=6, i.e, sixth order approximation +f6 <- function(x) { + return(eval(DD(expr = expression(cos(x)),"x",4))) +} +f6i=(f4(1.1*xi)-2*f4(xi)+f4(0.9*xi))/(0.1^2) +#value of sixth derivative of function at xi (central difference method) +f6f=f5f+f6i*(h^6)/factorial(6) +#value of sixth derivative of function at xf +et[7]=(ffa-f6f)*100/ffa +#% relative error at x=1 +cat("The value of f at x=1 due to sixth order approximation :",f6f,"\n", + "% relative error :",et[7],"\n", + "----------------------------------------------\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.4/Ex4_4.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..6ffa8e01 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,51 @@ +DD <- function(expr, name, order = 1) { + if(order < 1) stop("'order' must be >= 1") + if(order == 1) D(expr, name) + else DD(D(expr, name), name, order - 1) +} + +f <- function(x) { + return(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2) +} + +x=0.5 +h= 0.5 +x1=x-h +x2=x+h +#forward difference method +fdx1=(f(x2)-f(x))/h +#derivative at x +et1=abs((fdx1-eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))/eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))*100 +#backward difference method +fdx2=(f(x)-f(x1))/h +#derivative at x +et2=abs((fdx2-eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))/eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))*100 +#central difference method +fdx3=(f(x2)-f(x1))/(2*h) +#derivative at x +et3=abs((fdx3-eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))/eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))*100 +cat("For h=",h,"\n", + "Derivative at x by forward difference method=",fdx1,"and percent error=",et1,"\n", + "Derivative at x by backward difference method=",fdx2,"and percent error=",et2,"\n", + "Derivative at x by central difference method=",fdx3,"and percent error=",et3,"\n") + + +h= 0.25 +x1=x-h +x2=x+h +#forward difference method +fdx1=(f(x2)-f(x))/h +#derivative at x +et1=abs((fdx1-eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))/eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))*100 +#backward difference method +fdx2=(f(x)-f(x1))/h +#derivative at x +et2=abs((fdx2-eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))/eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))*100 +#central difference method +fdx3=(f(x2)-f(x1))/(2*h) +#derivative at x +et3=abs((fdx3-eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))/eval(DD(expr = expression(-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2),name = "x",order = 1)))*100 +cat("For h=",h,"\n", + "Derivative at x by forward difference method=",fdx1,"and percent error=",et1,"\n", + "Derivative at x by backward difference method=",fdx2,"and percent error=",et2,"\n", + "Derivative at x by central difference method=",fdx3,"and percent error=",et3,"\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.5/Ex4_5.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..7f939a4e --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,11 @@ +DD <- function(expr, name, order = 1) { + if(order < 1) stop("'order' must be >= 1") + if(order == 1) D(expr, name) + else DD(D(expr, name), name, order - 1) +} + +x=2.5 +delta=0.01 +deltafx=abs(eval(DD(expr = expression(x^3),name = "x",order = 1)))*delta +fx=f(x) +cat("true value is between",fx-deltafx,"and",fx+deltafx) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.6/Ex4_6.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.6/Ex4_6.R new file mode 100644 index 00000000..2795075d --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.6/Ex4_6.R @@ -0,0 +1,56 @@ +library(Deriv) + +DD <- function(expr, name, order = 1) { + if(order < 1) stop("'order' must be >= 1") + if(order == 1) D(expr, name) + else DD(D(expr, name), name, order - 1) +} + +f <- function(F,L,E,I) { + (F*(L^4))/(8*E*I) +} + +Fbar=50 +#lb/ft +Lbar=30 +#ft +Ebar=1.5*(10^8) +#lb/ft^2 +Ibar=0.06 +#ft^4 +deltaF=2 +#lb/ft +deltaL=0.1 +#ft +deltaE=0.01*(10^8) +#lb/ft^2 +deltaI=0.0006 +#ft^4 +ybar=(Fbar*(Lbar^4))/(8*Ebar*Ibar) + +f1 <- function(F) { + (F*(Lbar^4))/(8*Ebar*Ibar) +} +f_1<-Deriv(f1) +f2 <- function(L) { + (Fbar*(L^4))/(8*Ebar*Ibar) +} +f_2<-Deriv(f2) +f3 <- function(E) { + (Fbar*(Lbar^4))/(8*E*Ibar) +} +f_3<-Deriv(f3) +f4 <- function(I) { + (Fbar*(Lbar^4))/(8*Ebar*I) +} +f_4<-Deriv(f4) +deltay=abs(f_1(Fbar))*deltaF+ + abs(f_2(Lbar))*deltaL+ + abs(f_3(Ebar))*deltaE+ + abs(f_4(Ibar))*deltaI; + +cat("The value of y is between:",ybar-deltay,"and",ybar+deltay) +ymin=((Fbar-deltaF)*((Lbar-deltaL)^4))/(8*(Ebar+deltaE)*(Ibar+deltaI)); +ymax=((Fbar+deltaF)*((Lbar+deltaL)^4))/(8*(Ebar-deltaE)*(Ibar-deltaI)); +cat("ymin is calculated at lower extremes of F, L, E, I values as =",ymin) +cat("ymax is calculated at higher extremes of F, L, E, I values as =",ymax) diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.7/Ex4_7.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.7/Ex4_7.R new file mode 100644 index 00000000..5e12477e --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH4/EX4.7/Ex4_7.R @@ -0,0 +1,23 @@ +library(Deriv) + +f <- function(x) { + tan(x) +} + +f_ = Deriv(f) + +pi = 3.1415927 +x1bar=(pi/2)+0.1*(pi/2) +x2bar=(pi/2)+0.01*(pi/2) +#computing condition number for x1bar +condnum1=x1bar*f_(x1bar)/f(x1bar) +cat("The condition number of function for x=",x1bar,"is:",condnum1) +if (abs(condnum1)>1){ + cat("Function is ill-conditioned for x=",x1bar) +} +#computing condition number for x2bar +condnum2=x2bar*f_(x2bar)/f(x2bar) +cat("The condition number of function for x=",x2bar,"is:",condnum2) +if (abs(condnum2)>1){ + cat("Function is ill-conditioned for x=",x2bar) +} \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.1/Ex5_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.1/Ex5_1.R new file mode 100644 index 00000000..67a2e209 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.1/Ex5_1.R @@ -0,0 +1,25 @@ +m=68.1 +#kg +v=40 +#m/s +t=10 +#s +g=9.8 +#m/s^2 + +f <- function(c) { + g*m*(1-exp(-c*t/m))/c - v +} + +cat("For various values of c and f(c) is found as:") +i=0 +fc = matrix(0,5) +for (c in seq(4,20,4)){ + i=i+1 + bracket=c(c, f(c)) + cat(bracket) + fc[i]=f(c) +} +c<-c(4, 8, 12, 16, 20) +plot(c,fc,main = 'f(c) vs c',xlab = 'c',ylab = 'f(c) (m/s)') +lines(c,fc) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.2/Ex5_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.2/Ex5_2.R new file mode 100644 index 00000000..a09c5676 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.2/Ex5_2.R @@ -0,0 +1,14 @@ +f <- function(x) { + sin(10*x)+cos(3*x) +} + +count=1 +val = matrix(0,100) +func = matrix(0,100) +for (i in seq(1,5,0.05)){ + val[count]=i + func[count]=f(i) + count=count+1 +} +plot(val,func,main = "x vs f(x)",xlab = 'x',ylab = 'f(x)') +lines(val,func) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.3/Ex5_3.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.3/Ex5_3.R new file mode 100644 index 00000000..5f0e9298 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.3/Ex5_3.R @@ -0,0 +1,38 @@ +m=68.1 +#kg +v=40 +#m/s +t=10 +#s +g=9.8 +#m/s^2 + +f <- function(c) { + g*m*(1-exp(-c*t/m))/c - v +} + +x1=12 +x2=16 +xt=14.7802 +#true value +#"enter the tolerable true percent error=" +e=2 +xr=(x1+x2)/2 +etemp=abs(xr-xt)/xt*100 +#error +while (etemp>e){ + if (f(x1)*f(xr)>0){ + x1=xr + xr=(x1+x2)/2 + etemp=abs(xr-xt)/xt*100 + } + if (f(x1)*f(xr)<0){ + x2=xr + xr=(x1+x2)/2 + etemp=abs(xr-xt)/xt*100 + } + if (f(x1)*f(xr)==0) { + break + } +} +cat("The result is=",xr) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.4/Ex5_4.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.4/Ex5_4.R new file mode 100644 index 00000000..9fb250a0 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.4/Ex5_4.R @@ -0,0 +1,57 @@ +m=68.1 +#kg +v=40 +#m/s +t=10 +#s +g=9.8 +#m/s^2 + +f <- function(c) { + g*m*(1-exp(-c*t/m))/c - v +} + +x1=12 +x2=16 +xt=14.7802 +#true value +#"enter the tolerable approximate error=" +e=0.5 +xr=(x1+x2)/2 +i=1 +et=abs(xr-xt)/xt*100 +#error +cat("Iteration:",i) +cat("xl:",x1) +cat("xu:",x2) +cat("xr:",xr) +cat("et(%):",et) +cat("----------------------------------------") +etemp=100 + +while (etemp>e){ + if (f(x1)*f(xr)>0){ + x1=xr + xr=(x1+x2)/2 + etemp=abs(xr-x1)/xr*100 + et=abs(xr-xt)/xt*100 + } + if (f(x1)*f(xr)<0){ + x2=xr + xr=(x1+x2)/2 + etemp=abs(xr-x2)/xr*100 + et=abs(xr-xt)/xt*100 + } + if (f(x1)*f(xr)==0){ + break + } + i=i+1 + cat("Iteration:",i) + cat("xl:",x1) + cat("xu:",x2) + cat("xr:",xr) + cat("et(%):",et) + cat("ea(%)",etemp) + cat("----------------------------------------") +} +cat("The result is=",xr) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.5/Ex5_5.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.5/Ex5_5.R new file mode 100644 index 00000000..fa12ffbb --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.5/Ex5_5.R @@ -0,0 +1,38 @@ +m=68.1 +#kg +v=40 +#m/s +t=10 +#s +g=9.8 +#m/s^2 + +f <- function(c) { + g*m*(1-exp(-c*t/m))/c - v +} + +x1=12 +x2=16 +xt=14.7802 +#true value +#"enter the tolerable true percent error=" +e= +xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1)) +etemp=abs(xr-xt)/xt*100 +#error +while (etemp>e){ + if (f(x1)*f(xr)>0){ + x1=xr + xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1)) + etemp=abs(xr-xt)/xt*100 + } + if (f(x1)*f(xr)<0){ + x2=xr + xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1)) + etemp=abs(xr-xt)/xt*100 + } + if (f(x1)*f(xr)==0){ + break + } +} +cat("The result is=",xr) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.6/Ex5_6.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.6/Ex5_6.R new file mode 100644 index 00000000..7a4e2fec --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH5/EX5.6/Ex5_6.R @@ -0,0 +1,74 @@ +f <- function(x) { + x^10 - 1 +} + +x1=0 +x2=1.3 +xt=1 + +#using bisection method +cat("BISECTION METHOD:") +xr=(x1+x2)/2 +et=abs(xr-xt)/xt*100 +#error +cat("Iteration:",1,"\n","xl:",x1,"\n","xu:",x2,"\n","xr:",xr,"\n","et(%):",et,"\n","----------------------------------------\n") + +for (i in 2:5){ + if (f(x1)*f(xr)>0){ + x1=xr + xr=(x1+x2)/2 + ea=abs(xr-x1)/xr*100 + et=abs(xr-xt)/xt*100 + } else if (f(x1)*f(xr)<0){ + x2=xr + xr=(x1+x2)/2 + ea=abs(xr-x2)/xr*100 + et=abs(xr-xt)/xt*100 + } + + if (f(x1)*f(xr)==0){ + break + } +cat("Iteration:",i,"\n") +cat("xl:",x1,"\n") +cat("xu:",x2,"\n") +cat("xr:",xr,"\n") +cat("et(%):",et,"\n") +cat("ea(%)",ea,"\n") +cat("----------------------------------------\n") +} + +#using false position method +cat("FALSE POSITION METHOD:") +x1=0 +x2=1.3 +xt=1 +xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1)) +et=abs(xr-xt)/xt*100 +#error +cat("Iteration:",1,"\n","xl:",x1,"\n","xu:",x2,"\n","xr:",xr,"\n","et(%):",et,"\n","----------------------------------------") + +for (i in 2:5){ + if (f(x1)*f(xr)>0){ + x1=xr + xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1)) + ea=abs(xr-x1)/xr*100 + et=abs(xr-xt)/xt*100 + } + else if (f(x1)*f(xr)<0){ + x2=xr + xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1)) + ea=abs(xr-x2)/xr*100 + et=abs(xr-xt)/xt*100 + } + if (f(x1)*f(xr)==0){ + break + } +cat("Iteration:",i,"\n") +cat("xl:",x1,"\n") +cat("xu:",x2,"\n") +cat("xr:",xr,"\n") +cat("et(%):",et,"\n") +cat("ea(%)",ea,"\n") +cat("----------------------------------------\n") +} \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH6/EX6.11/Ex6_11.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH6/EX6.11/Ex6_11.R new file mode 100644 index 00000000..8f349e7c --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH6/EX6.11/Ex6_11.R @@ -0,0 +1,23 @@ +u <- function(x,y) { + x^2+x*y-10 +} + +v <- function(x,y) { + y+3*x*y^2-57 +} + +x=1.5 +y=3.5 +e<-c(100, 100) +while (e[1]>0.0001 & e[2]>0.0001){ + J=matrix(data = c(2*x+y, x, 3*y^2, 1+6*x*y),nrow = 2,ncol = 2,byrow = TRUE) + deter=det(J) + u1=u(x,y) + v1=v(x,y) + x=x-((u1*J[2,2]-v1*J[1,2])/deter) + y=y-((v1*J[1,1]-u1*J[2,1])/deter) + e[1]=abs(2-x) + e[2]=abs(3-y) +} +bracket<-c(x, y) +cat(bracket) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.1/Ex7_1.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.1/Ex7_1.R new file mode 100644 index 00000000..3f73c341 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.1/Ex7_1.R @@ -0,0 +1,18 @@ +f <- function(x) { + (x-4)*(x+6) +} + +n=2 +a = matrix(0,3) +a[1]=-24 +a[2]=2 +a[3]=1 +t=4 +r=a[3] +a[3]=0 +for (i in seq(n,1,-1)){ + s=a[i] + a[i]=r + r=s+r*t + } +cat("The quptient is a(1)+a(2)*x where :","a(1)=",a[1],"a(2)=",a[2],"remainder=",r) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.2/Ex7_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.2/Ex7_2.R new file mode 100644 index 00000000..7db45948 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.2/Ex7_2.R @@ -0,0 +1,36 @@ +f <- function(x) { + x^3 - 13*x - 12 +} + +x1t=-3 +x2t=-1 +x3t=4 +x0=4.5 +x1=5.5 +x2=5 + +cat("iteration:",0,"\n","xr:",x2,"---------------------------------------------\n") + +for (i in 1:4){ + h0=x1-x0 + h1=x2-x1 + d0=(f(x1)-f(x0))/(x1-x0) + d1=(f(x2)-f(x1))/(x2-x1) + a=(d1-d0)/(h1+h0) + b=a*h1+d1 + c=f(x2) + d=(b^2 - 4*a*c)^0.5 + if (abs(b+d)>abs(b-d)){ + x3=x2+((-2*c)/(b+d)) +}else { + x3=x2+((-2*c)/(b-d)) + } + ea=abs(x3-x2)*100/x3 + x0=x1 + x1=x2 + x2=x3 + cat("iteration:",i,"\n") + cat("xr:",x2,"\n") + cat("ea(%):",ea,"\n") + cat("---------------------------------------------\n") +} \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.3/Ex7_3.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.3/Ex7_3.R new file mode 100644 index 00000000..68867651 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.3/Ex7_3.R @@ -0,0 +1,41 @@ +f <- function(x) { + x^5-3.5*x^4+2.75*x^3+2.125*x^2-3.875*x+1.25 +} + +r=-1 +s=-1 +es=1 +#% +n=6 +count=1 +ear=100 +eas=100 +a<-c(1.25, -3.875, 2.125, 2.75, -3.5, 1) +b<-matrix(0,n) +c<-matrix(0,n) +while ((ear>es) & (eas>es)){ + b[n]=a[n] + b[n-1]=a[n-1]+r*b[n] + for (i in seq(n-2,1,-1)){ + b[i]=a[i]+r*b[i+1]+s*b[i+2] + } + c[n]=b[n] + c[n-1]=b[n-1]+r*c[n] + for (i in seq((n-2),2,-1)){ + c[i]=b[i]+r*c[i+1]+s*c[i+2] + } +#c(3)*dr+c(4)*ds=-b(2) +#c(2)*dr+c(3)*ds=-b(1) +ds=((-b[1])+(b[2]*c[2]/c[3]))/(c[3]-(c[4]*c[2]/c[3])) +dr=(-b[2]-c[4]*ds)/c[3] +r=r+dr +s=s+ds +ear=abs(dr/r)*100 +eas=abs(ds/s)*100 +cat("Iteration:",count,"\n","delata r:",dr,"\n","delata s:",ds,"\n","r:",r,"\n","s:",s,"\n","Error in r:",ear,"\n","Error in s:",eas,"\n","-----------------------------------------------------\n") +count=count+1; +} +x1=(r+(r^2 + 4*s)^0.5)/2 +x2=(r-(r^2 + 4*s)^0.5)/2 +bracket<-c(x1, x2) +cat("The roots are:",bracket,"The quotient is:","x^3 - 4*x^2 + 5.25*x - 2.5","\n","-----------------------------------------------------\n") diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.4/Ex7_4.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.4/Ex7_4.R new file mode 100644 index 00000000..fadd24da --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.4/Ex7_4.R @@ -0,0 +1,22 @@ +f <- function(x) { + x-cos(x) +} + +x1=0 + +if (f(x1)<0){ + x2=x1+0.001 + while (f(x2)<0){ + x2=x2+0.001 + } + } else if(f(x1)>0){ + x2=x1+0.001 + while (f(x2)>0){ + x2=x2+0.001 + } + } else{ + cat("The root is=",x1) + } + +x=x2-(x2-x1)*f(x2)/(f(x2)-f(x1)) +cat("The root is=",x) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.5/Ex7_5.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.5/Ex7_5.R new file mode 100644 index 00000000..623a4bcc --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.5/Ex7_5.R @@ -0,0 +1,16 @@ +u <- function(x,y) { + x^2+x*y-10 +} + +v <- function(x,y) { + y+3*x*y^2-57 +} + +x=1 +y=3.5 +while (u(x,y)!=v(x,y)){ + x=x+1 + y=y-0.5 +} +cat("x=",x) +cat("y=",y) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.6/Ex7_6.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.6/Ex7_6.R new file mode 100644 index 00000000..ceee74a8 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.6/Ex7_6.R @@ -0,0 +1,6 @@ +library(pracma) +fun <- function (x) x^10 -1 +fzero(f = fun,x = c(0,4)) +fzero(f = fun,x = c(0,1.3)) +fzero(f = fun,x = c(-1.3,0)) +fzero(f = fun,x = c(-1.28, 0.9051)) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.7/Ex7_7.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.7/Ex7_7.R new file mode 100644 index 00000000..f5c710c2 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.7/Ex7_7.R @@ -0,0 +1,17 @@ +library(pracma) +library(polynom) + +fun <- function (x) (x^5 - (3.5*x^4) +(2.75*x^3) +(2.125*x^2) - (3.875*x) + 1.25) +fzero(f = fun,x =1) +Deriv::Deriv(f = fun,x = "x") + +b<-c(1,0.5,-0.5) +a<-c(1,-3.5,2.75,2.125,-3.875,1.25) +answer = deconv(a,b) +d = answer$q +e = answer$r +polyroot(a) +polyroot(d) +conv(d,b) +a<-conv(d,b) +polyroot(a) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.8/Ex7_8.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.8/Ex7_8.R new file mode 100644 index 00000000..18506e5c --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH7/EX7.8/Ex7_8.R @@ -0,0 +1,22 @@ +f <- function(x) { + x-cos(x) +} + +x1=0 +if (f(x1)<0){ + x2=x1+0.00001 + while (f(x2)<0){ + x2=x2+0.00001 + } +} else if (f(x1)>0){ + x2=x1+0.00001 + while (f(x2)>0){ + x2=x2+0.00001 + } +} else { + cat("The root is=",x1) +} + + +x=x2-(x2-x1)*f(x2)/(f(x2)-f(x1)) +cat("The root is=",x) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.11/Ex9_11.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.11/Ex9_11.R new file mode 100644 index 00000000..79b7094b --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.11/Ex9_11.R @@ -0,0 +1,4 @@ +a<-matrix(c(70, 1, 0,60, -1, 1,40, 0 ,-1),nrow = 3,ncol = 3,byrow = TRUE) +b<-matrix(c(636,518,307),nrow = 3,ncol = 1,byrow = TRUE) +x=abs(solve(a,b)) +cat("a=",x[1],"m/s^2","\n","T=",x[2],"N","\n","R=",x[3],"N","\n") \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.2/Ex9_2.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.2/Ex9_2.R new file mode 100644 index 00000000..f3ce0919 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.2/Ex9_2.R @@ -0,0 +1,12 @@ +#For fig9.1 +a= matrix(data = c(3, 2,-1, 2),nrow = 2,ncol = 2,byrow = TRUE) +cat("The value of determinant for system repesented in fig 9.1 =",det(a)) +#For fig9.2 (a) +a= matrix(data = c(-0.5, 1,-0.5, 1),nrow = 2,ncol = 2,byrow = TRUE) +cat("The value of determinant for system repesented in fig 9.2 (a) =",det(a)) +#For fig9.2 (b) +a= matrix(data = c(-0.5, 1,-1, 2),nrow = 2,ncol = 2,byrow = TRUE) +cat("The value of determinant for system repesented in fig 9.2 (b) =",det(a)) +#For fig9.2 (c) +a= matrix(data = c(-0.5, 1,-2.3/5, 1),nrow = 2,ncol = 2,byrow = TRUE) +cat("The value of determinant for system repesented in fig 9.2 (c) =",det(a)) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.3/Ex9_3.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.3/Ex9_3.R new file mode 100644 index 00000000..5a00b330 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.3/Ex9_3.R @@ -0,0 +1,20 @@ +#the matrix or the system +b1=-0.01 +b2=0.67 +b3=-0.44 +a<-matrix(data = c(0.3, 0.52, 1,0.5, 1, 1.9,0.1, 0.3, 0.5),nrow = 3,ncol = 3,byrow = TRUE) +a1<-matrix(data = c(a[2,2], a[2,3],a[3,2], a[3,3]),nrow = 2,ncol = 2,byrow = TRUE) +A1=det(a1) +a2<-matrix(data = c(a[2,1], a[2,3],a[3,1], a[3,3]),nrow = 2,ncol = 2,byrow = TRUE) +A2=det(a2) +a3<-matrix(data = c(a[2,1], a[2,2],a[3,1], a[3,2]),nrow = 2,ncol = 2,byrow = TRUE) +A3=det(a3) +D=a[1,1]*A1-a[1,2]*A2+a[1,3]*A3 +p<-matrix(data = c(b1, 0.52, 1,b2, 1, 1.9,b3, 0.3, 0.5),nrow = 3,ncol = 3,byrow = TRUE) +q<-matrix(data = c(0.3, b1, 1,0.5, b2, 1.9,0.1, b3, 0.5),nrow = 3,ncol = 3,byrow = TRUE) +r<-matrix(data = c(0.3, 0.52, b1,0.5, 1 ,b2,0.1, 0.3, b3),nrow = 3,ncol = 3,byrow = TRUE) + +x1=det(p)/D +x2=det(q)/D +x3=det(r)/D +cat("The values are:","x1=",x1,",x2=",x2,",x3=",x3) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.4/Ex9_4.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.4/Ex9_4.R new file mode 100644 index 00000000..5771fad7 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.4/Ex9_4.R @@ -0,0 +1,13 @@ +#the equations are: +#3*x1+2*x2=18 +#-x1+2*x2=2 +a11=3 +a12=2 +b1=18 +a21=-1 +a22=2 +b2=2 +x1=(b1*a22-a12*b2)/(a11*a22-a12*a21) +x2=(b2*a11-a21*b1)/(a11*a22-a12*a21) +cat("x1=",x1) +cat("x2=",x2) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.5/Ex9_5.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.5/Ex9_5.R new file mode 100644 index 00000000..50b15a28 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.5/Ex9_5.R @@ -0,0 +1,24 @@ +n=3 +b<-matrix(c(7.85,-19.3,71.4), nrow = 1, ncol = 3) +a<-matrix(data = c(3, -0.1, -0.2,0.1, 7 ,-0.3,0.3, -0.2, 10),nrow = 3,ncol = 3,byrow = TRUE) +for (k in 1:1){ + for (i in 2:3){ + fact=a[i,k]/a[k,k] + for (j in 2:3){ + a[i,j]=a[i,j]-fact*a[k,j] + } + b[i]=b[i]-fact*b[k] + print(b) + } +} +x<-matrix(0,3) +x[3]=b[3]/a[3,3] +for (i in seq(2,1,-1)){ + s=b[i] + for (j in (i+1):3){ + s=s-a[i,j]*x[j] + print(s) + } + x[i]=b[i]/a[i,i] +} +cat("x1=",x[1],",x2=",x[2],",x3=",x[3]) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.6/Ex9_6.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.6/Ex9_6.R new file mode 100644 index 00000000..b500ed92 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.6/Ex9_6.R @@ -0,0 +1,13 @@ +a11=1 +a12=2 +b1=10 +a21=1.1 +a22=2 +b2=10.4 +x1=(b1*a22-a12*b2)/(a11*a22-a12*a21) +x2=(b2*a11-a21*b1)/(a11*a22-a12*a21) +cat("For the original system:","x1=",x1,",x2=",x2) +a21=1.05 +x1=(b1*a22-a12*b2)/(a11*a22-a12*a21) +x2=(b2*a11-a21*b1)/(a11*a22-a12*a21) +cat("For the new system:","x1=",x1,",x2=",x2) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.7/Ex9_7.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.7/Ex9_7.R new file mode 100644 index 00000000..ecc2f99b --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.7/Ex9_7.R @@ -0,0 +1,15 @@ +#part a +a<-matrix(c(3, 2,-1, 2), nrow = 2, ncol = 2,byrow = TRUE) +b1=18 +b2=2 +cat("The determinant for part(a)=",det(a)) +#part b +a<-matrix(c(1, 2,1.1, 2), nrow = 2, ncol = 2,byrow = TRUE) +b1=10 +b2=10.4 +cat("The determinant for part(b)=",det(a)) +#part c +a1=a*10 +b1=100 +b2=104 +cat("The determinant for part(c)=",det(a1)) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.8/Ex9_8.R b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.8/Ex9_8.R new file mode 100644 index 00000000..2767852c --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/CH9/EX9.8/Ex9_8.R @@ -0,0 +1,14 @@ +#part a +a<-matrix(c(1, 0.667,-0.5, 1), nrow = 2, ncol = 2,byrow = TRUE) +b1=6 +b2=1 +cat("The determinant for part(a)=",det(a)) +#part b +a<-matrix(c(0.5, 1,0.55, 1), nrow = 2, ncol = 2,byrow = TRUE) +b1=5 +b2=5.2 +cat("The determinant for part(b)=",det(a)) +#part c +b1=5 +b2=5.2 +cat("The determinant for part(c)=",det(a)) \ No newline at end of file diff --git a/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/README.txt b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/README.txt new file mode 100644 index 00000000..46795764 --- /dev/null +++ b/Numerical_Methods_For_Engineers_by_S._C._Chapra_And_R._P._Canale/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Bhushan Manjarekar +Course: Be +Branch: Electronics Engineering +College/Institute/Organization: Mumbai University + +About The Book + +Book: Numerical Methods For Engineers +Author: S. C. Chapra And R. P. Canale +Publisher: Mcgraw Hill, New York +Year Of Publication: 2006 +ISBN: 0071244298 +Edition: 5 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH10/EX10.4/Ex10_4.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH10/EX10.4/Ex10_4.R new file mode 100644 index 00000000..825300ba --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH10/EX10.4/Ex10_4.R @@ -0,0 +1,61 @@ +require(varbvs) +require(pracma) +require(zeallot) +OptFolioMC<-function(W0,S0,mu,sigma,r,T,NScen,utilf){ + muT = (mu - 0.5*sigma^2)*T + sigmaT = sigma*sqrt(T) + R = exp(r*T) + NormSamples = muT + sigmaT*randn(NScen,1) + ExcessRets = exp(NormSamples) - R + MExpectedUtility<-function(x){ + -mean(utilf(W0*((x*ExcessRets) + R))) + } + share = fminbnd(MExpectedUtility, 0, 1) + return(share) +} +set.seed(294) +share = OptFolioMC(1000,50,0.1,0.4,0.05,1,10000,log) +share$xmin + + +set.seed(2947) +share = OptFolioMC(1000,50,0.1,0.4,0.05,1,5000000,log) +share$xmin + +OptFolioGauss<-function(W0,S0,mu,sigma,r,T,NScen,utilf){ + muT = (mu - 0.5*sigma^2)*T + sigmaT = sigma*sqrt(T) + R = exp(r*T) + print(GaussHermite(muT,sigmaT^2,NScen)) + c(x,w) %<-% GaussHermite(muT,sigmaT^2,NScen) + ExcessRets = exp(x) - R + MExpectedUtility<-function(x){ + - Re(dot(Re(w), utilf(W0*((Re(x)*ExcessRets) + R)))) + } + share = fminbnd(MExpectedUtility, 0, 1) +} + + +GaussHermite<-function(mu,sigma2,N){ + HPoly1 = c(1/pi^0.25) + HPoly2 = c(sqrt(2) / pi^0.25, 0) + for (j in 1:(N-1)){ + HPoly3 = c(sqrt(2/(j+1)) * HPoly2 , 0) - c(0, 0, sqrt(j/(j+1))*HPoly1) + HPoly1 = HPoly2 + HPoly2 = HPoly3 + } + x1 = polyroot(HPoly3) + w1 = matrix(0,N,1) + for (i in 1:N){ + w1[i] = 1/(N)/(polyval(HPoly1, x1[i]))^2 + } + x = sort(x1*sqrt(2*sigma2)+mu) + index= order(x1*sqrt(2*sigma2)+mu) + w = w1[index]/sqrt(pi) + return(list(x,w)) +} + +share = OptFolioGauss(1000,50 ,0.1, 0.4, 0.05,1,2,log) +share + +#different answers as R polyroot function calculating different roots than matlab. \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.10/Ex2_10.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.10/Ex2_10.R new file mode 100644 index 00000000..ab50e447 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.10/Ex2_10.R @@ -0,0 +1,111 @@ +library(FinCal) +mypvvar <- function(cf,r) { + # get number of periods + n = length(cf) + #1 get vector of discount factors + df<-matrix(0,n) + for (i in 0:n-1){ + df[i+1] = 1/(1+r)^(i) + } + #compute result + pv = cf*df +} + +cfdur <- function(cf,yld) { + # CFDUR Cash flow duration and modified duration. + # [D,MD] = CFDUR(CF,YLD) calculates the duration D and modified duration + # (volatility) MD of a cash flow given the cash flow, CF, and the periodic + # yield, YLD. + # + # For example, nine payments of $2.50 and a final payment of $102.50 with + # a yield of 2.5% returns a duration of 8.97 periods and a modified duration + # of 8.75 periods. + # + # See also BONDCONV, BONDDUR, CFCONV. + # Copyright 1995-2006 The MathWorks, Inc. + x<-dim(cf) + rowcf = x[1] + colcf = x[2] + if (rowcf == 1){ + cf = t(cf) + colcf = 1 + } + + if (colcf > 1 ){ + if (length(yld) == 1){ + yld = yld*matrix(1,colcf) + } + } + + pv = matrix(0,colcf) + d = pv + md = pv + m = length(cf[,1]) + fac = t((1:m)) + for (loop in 1:colcf){ + # Compound the yield + rates = (matrix(data = 1,ncol = m,nrow = 1)*(1+yld[loop]))^fac + # find the net present value + pv[loop] = sum(mypvvar(c(0,cf[,loop]),yld[loop])) + # duration + d[loop] = sum(cf[,loop]/(rates)*fac)/pv[loop] + # modified duration + md[loop] = d[loop]/(1+yld[loop]) + } + cat("Duration of cash flow:",d,"\n") + cat("Modified Duration (volatility) of cash flow:",md,"\n") + return(list(d=d,dm=md)) +} + +cfconv <- function(cf,yld) { + # CFCONV Cash flow convexity. + # CX = CFCONV(CF,YLD) calculates the convexity C of a cash flow + # given the cash flow, CF, and the periodic yield, YLD. + # + # For example, nine payments of $2.50 and a final payment of $102.50 + # with a yield of 2.5% returns a convexity of 90.45 periods. + # + # See also BONDCONV, BONDDUR, CFDUR. + + # Copyright 1995-2006 The MathWorks, Inc. + x<-dim(cf) + rowcf = x[1] + colcf = x[2] + if (rowcf == 1){ + cf = t(cf) + colcf = 1 + } + + if (colcf > 1 ){ + if (length(yld) == 1){ + yld = yld*matrix(1,colcf) + } + } + + pv = matrix(0,colcf) + cx = pv + m = length(cf[,1]) + fac = t((1:m)) + for (loop in 1:colcf){ + #Compound the yield + rates = (matrix(data = 1,ncol = m,nrow = 1)*(1+yld[loop]))^fac + #find the net present value + pv[loop] = sum(mypvvar(c(0,cf[,loop]),yld[loop])) + cx[loop] = sum(cf[,loop]/(rates)*fac*(fac+1))/((1+yld[loop])^2*pv[loop]) + } + cat("Cash flow convexity:",cx,"\n") + return(cx) +} + +cf<-c(10,10,10,10) +p1=abs(pv.uneven(0.05,cf)) +p2=abs(pv.uneven(0.055,cf)) +(p2-p1) +cf<-matrix(cf,nrow = 1,ncol = 4) +yld<-matrix(data = c(0.05),nrow = 1,ncol = 1) +x<-cfdur(cf,yld) +d<-x$d +dm<-x$dm +cv=cfconv(cf,yld) +-dm*p1*0.005 +-dm*p1*0.005+0.5*cv*p1*(0.005)^2 \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.24/Ex2_24.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.24/Ex2_24.R new file mode 100644 index 00000000..dfac3cd8 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.24/Ex2_24.R @@ -0,0 +1,8 @@ +#install.packages("OptionPricing") +require(OptionPricing) +C0 = BS_EC(T = 5/12, K = 50, r = 0.1, sigma = 0.3, S0 = 50) +dS = 2 +C1 = BS_EC(T = 5/12, K = 50, r = 0.1, sigma = 0.3, S0 = 50+dS) +C0[1]+ C0[2]*dS + 0.5*C0[3]*dS-2 + +#Answer differs in last line as the value of C0 gamma is different than the book \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.7/Ex2_7.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.7/Ex2_7.R new file mode 100644 index 00000000..6bafbe2f --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.7/Ex2_7.R @@ -0,0 +1,21 @@ +mypvvar <- function(cf,r) { + # get number of periods + n = length(cf) + #1 get vector of discount factors + df<-matrix(0,n) + for (i in 0:n-1){ + df[i+1] = 1/(1+r)^(i) + } + #compute result + pv = cf*df +} + +cf<-c(0, 8, 8, 8, 8, 108) +pv = mypvvar (cf ,0.08) +sum(pv) + +pv = mypvvar (cf ,0.09) +sum(pv) + +pv = mypvvar (cf ,0.07) +sum(pv) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.8/Ex2_8.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.8/Ex2_8.R new file mode 100644 index 00000000..03c63f45 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.8/Ex2_8.R @@ -0,0 +1,10 @@ +#install.packages("FinCal") +library("FinCal") +cf<-c(-100, 8, 8, 8, 8, 108) +h=polyroot(cf[length(cf):1]) +h +rho=1/h-1 +rho +index = which((abs(Im(rho)) < 0.001) != 0) +rho[index] +irr(cf) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.9/Ex2_9.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.9/Ex2_9.R new file mode 100644 index 00000000..c4325da1 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH2/EX2.9/Ex2_9.R @@ -0,0 +1,42 @@ +mypvvar <- function(cf,r) { + # get number of periods + n = length(cf) + #1 get vector of discount factors + df<-matrix(0,n) + for (i in 0:n-1){ + df[i+1] = 1/(1+r)^(i) + } + #compute result + pv = cf*df +} + +r1=0.08 +r2=0.09 +P1=100/(1+r1)^5 +P1 +P2=100/(1+r2)^5 +P2 +(P2-P1)/P1 + +P1=100/(1+r1)^20 +P1 +P2=100/(1+r2)^20 +P2 +(P2-P1)/P1 + +cf1<-c(0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 108) +cf2<-c(0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 104) +P1=mypvvar(cf1,0.08) +P1 = sum(P1) +P1 +P2=mypvvar(cf1,0.09) +P2 = sum(P2) +P2 +(P2-P1)/P1 +P1=mypvvar(cf2,0.08) +P1 = sum(P1) +P1 +P2=mypvvar(cf2,0.09) +P2 = sum(P2) +P2 +(P2-P1)/P1 \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.11/Ex3_11.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.11/Ex3_11.R new file mode 100644 index 00000000..34b4720f --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.11/Ex3_11.R @@ -0,0 +1,10 @@ +require(Matrix) +A<-matrix(c(1, 4, -2, -3,9, 8, 5 ,1,-6),nrow = 3,ncol = 3,byrow = TRUE) +tmp=expand(lu(Matrix(A))) +tmp$L +tmp$U +tmp$P +b <-matrix(c(1,2,3),nrow = 3,ncol = 1,byrow = T) +solve(A,b) +tmp_P<-matrix(c(0,0,1,0,1,0,1,0,0),nrow = 3,ncol = 3,byrow = T) +x = solve(tmp$U,solve(tmp$L,(tmp_P%*%b))) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.12/Ex3_12.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.12/Ex3_12.R new file mode 100644 index 00000000..f623b856 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.12/Ex3_12.R @@ -0,0 +1,6 @@ +A<-matrix(c(3, 1, 4, 1, 5, 3, 4, 3,7),nrow = 3,ncol = 3,byrow = T) +eigen(A) +B<-matrix(c(1,2,3),nrow = 3,ncol = 1,byrow = T) +U = chol(A) +U +solve(U,(solve(t(U),B))) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.13/Ex3_13.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.13/Ex3_13.R new file mode 100644 index 00000000..8d30fda2 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.13/Ex3_13.R @@ -0,0 +1,30 @@ +Jacobi <- function(A,b,x0,eps,MaxIter) { + dA = diag(A) + C = A - diag(dA) + Dinv = diag(1/dA) + B = - Dinv %*% C + b1 = Dinv %*% b + oldx = x0 + + for (i in 1:MaxIter){ + x = B %*% oldx + b1 + if (norm(x-oldx) < eps*norm(matrix(oldx))){ + break + } + oldx = x + } + cat("Case of Matrix:",A,"\n") + cat("Terminated after iterations:",i,"\n") + cat("Jacobi:",x,"\n") + cat("Exact:",solve(A,b),"\n") +} + +A1 <-matrix(c(3, 1, 1, 0, 1, 5, - 1, 2, 1, 0, 3, 1, 0, 1, 1, 4),nrow = 4,ncol = 4,byrow = T) +b<-matrix(c(1, 4, -2, 1),nrow = 4,ncol = 1,byrow = T) +Jacobi(A1,b,rep(0,4),1e-08,10000) + +A2 <-matrix(c(2.5, 1, 1, 0, 1, 4.1, -1, 2, 1, 0, 2.1, 1, 0, 1, 1, 2.1),nrow = 4,ncol = 4,byrow = T) +Jacobi(A2,b,rep(0,4),1e-08,10000) + +A3 <-matrix(c(2, 1, 1, 0, 1, 3.5, -1, 2, 1, 0, 2.1, 1, 0, 1, 1, 2.1),nrow = 4,ncol = 4,byrow = T) +Jacobi(A3,b,rep(0,4),1e-08,10000) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.14/Ex3_14.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.14/Ex3_14.R new file mode 100644 index 00000000..55504513 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH3/EX3.14/Ex3_14.R @@ -0,0 +1,32 @@ +SORGaussSeidel <- function(A, b,x0, omega, eps,MaxIter) { + oldx = x0 + x = x0 + N = length(x0) + omega1 = 1 - omega + for (k in 1:MaxIter){ + for (i in 1:(N-1)){ + z = (b[i] - sum(A[i,(1:i-1)]) * x[1:(i-1)]) - sum(A[i,(i+1):N] * x[(i+1):N]) / A[i,i] + x[i] = omega * z + omega1 * oldx[i] + } + if(norm(matrix(x-oldx)) K1) & (Stocks < K2)); + In2 = which((Stocks >= K2) & (Stocks < K3)); + Payoff = exp(-r*T)*matrix(c((Stocks[In1]-K1), (K3-Stocks[In2]), matrix(0,(NRepl - length(In1) - length(In2)),1))) + parameter_estimation<-.normFit(Payoff) + ci<-norm.interval(Payoff) + final<-list(parameter_estimation,ci) + return(final) +} + +MCAVButterfly <- function(S0,r,T,sigma,NPairs,K1,K2,K3) { + nuT = (r-0.5*sigma^2)*T; + siT = sigma*sqrt(T); + Veps = rnorm(NPairs); + Stocks1 = S0*exp(nuT + siT*Veps); + Stocks2 = S0*exp(nuT - siT*Veps); + Payoff1 = matrix(0,NPairs,1); + Payoff2 = matrix(0,NPairs,1); + In = which((Stocks1 > K1) & (Stocks1 < K2)); + Payoff1[In] = (Stocks1[In] - K1); + In = which((Stocks1 >= K2) & (Stocks1 < K3)); + Payoff1[In] = (K3 - Stocks1[In]); + In = which((Stocks2 > K1) & (Stocks2 < K2)); + Payoff2[In] = (Stocks2[In] - K1); + In = which((Stocks2 >= K2) & (Stocks2 < K3)); + Payoff2[In] = (K3 - Stocks2[In]); + Payoff = 0.5 * exp(-r*T) * (Payoff1 + Payoff2); + parameter_estimation<-.normFit(Payoff) + ci<-norm.interval(Payoff) + final<-list(parameter_estimation,ci) + return(final) +} + +set.seed(3374) +Y<-BlsMC2(50,50 ,0.05,1, 0.4,200000) +#from parameter estimation, value of mean = 9.11143 +(Y[[2]][2]-Y[[2]][1])/9.11143 + +Z<-BlsMCAV(50,50,0.05,1,0.4,100000) +#from parameter estimation, value of mean = 9.020972 +(Z[[2]][2]-Z[[2]][1])/9.020972 + +set.seed(39489378) +SO = 60; +K1 = 55; +K2 = 60; +K3 = 65; +T = 5/12; +r = 0.1; +sigma = 0.4; +a<-MCButterfly(SO,r,T,sigma,100000,K1,K2,K3); +#from parameter estimation, value of mean = 0.6104167 +(a[[2]][2]-a[[2]][1])/0.6104167 + +set.seed(72725) +b<-MCAVButterfly(SO,r ,T, sigma,50000,K1 ,K2,K3) +#from parameter estimation, value of mean = 0.6154077 +(b[[2]][2]-b[[2]][1])/0.6154077 \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.14/Ex4_14.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.14/Ex4_14.R new file mode 100644 index 00000000..be8195af --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.14/Ex4_14.R @@ -0,0 +1,35 @@ +estpi <- function(m) { + z=sqrt(1-runif(m)^2) ; + out = 4*sum(z)/m; + return(out) +} +set.seed(483272) +estpi(1000) +estpi(1000) +estpi(1000) + +estpiIS <- function(m,L) { + s= seq(0,1-1/L,1/L) + 1/(2*L) + hvals = matrix(sqrt(1 - s^2)) + # get cumulative probabilities + cs=apply(hvals,2,cumsum); + est = matrix(0,m) + for (j in 1:m){ + # locate sub-interval + loc=sum(runif(1)*cs[L] > cs) +1; + # sample uniformly within sub-interval + x=(loc-1)/L + runif(1)/L; + p=hvals[loc]/cs[L]; + est[j] = sqrt(1 - x^2)/(p*L); + } + plot(est) + z = 4*sum(est)/m; + return(z) +} + +estpiIS(1000,10) +estpiIS(1000,10) +estpiIS(1000,10) +estpiIS(1000,100) +estpiIS(1000,100) +estpiIS(1000,100) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.15/Ex4_15.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.15/Ex4_15.R new file mode 100644 index 00000000..d9862388 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.15/Ex4_15.R @@ -0,0 +1,69 @@ +#require(fBasics) +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} + +BlsMCIS <- function(S0,K,r,T,sigma,NRepl) { + nuT = (r - 0.5*sigma^2)*T; + siT = sigma * sqrt(T); + ISnuT = log(K/S0) - 0.5*sigma^2*T; + Veps = rnorm(NRepl); + VY = ISnuT + siT*Veps; + ISRatios = exp( (2*(nuT - ISnuT)*VY - nuT^2 + ISnuT^2)/2/siT^2); + DiscPayoff = exp(-r*T)*pmax(0, (S0*exp(VY)-K)); + parameter_estimation<-.normFit(DiscPayoff*ISRatios) + ci<-norm.interval(DiscPayoff*ISRatios) + final<-list(parameter_estimation,ci) + return(final) +} + +Halton <- function(n,b) { + n0 = n; + h = 0; + f = 1/b; + while (n0 > 0){ + n1 = floor(n0/b); + r = n0 - n1*b; + h = h+f*r; + f = f/b; + n0=n1; + } + return(h) +} + +seq = matrix(0,10) +for (i in 1:10){ + seq[i] = Halton(i,2); +} + +GetHalton <- function(HowMany, Base) { + Seq = matrix(0,HowMany,1) + NumBits = 1+round(log(HowMany)/log(Base)); + VetBase = Base^(-(1:NumBits)); + WorkVet = matrix(0,1,NumBits); + for (i in 1:HowMany){ + j = 1; + ok = 0; + while (ok == 0){ + WorkVet[j] = WorkVet[j]+1; + if (WorkVet[j] < Base){ + ok = 1; + } + else{ + WorkVet[j] = 0; + j = j+1; + } + } + Seq[i] = sum(WorkVet * VetBase) + } + return(Seq) +} + + + +plot(runif(100) ,runif(100)) +plot(GetHalton(100,2) ,GetHalton (100,7)) +plot(GetHalton(100,2), GetHalton(100,4)) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.16/Ex4_16.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.16/Ex4_16.R new file mode 100644 index 00000000..04169984 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.16/Ex4_16.R @@ -0,0 +1,64 @@ +require(pracma) +f <- function(x,y) { + exp(-x*y) *(sin(6*pi*x)+cos(8*pi*y)) +} + +dblquad(f = f,xa = 0,xb = 1,ya = 0,yb = 1) + +n <- seq(0,1,0.01) +multiarray = list(); +multiarray <- meshgrid(n,n) +Z<-f(multiarray$X,multiarray$Y) + + +persp(multiarray$X[1,],multiarray$Y[,1],Z,theta=30, phi=30, expand=0.6,col='lightblue', shade=0.75, ltheta=120,ticktype='detailed') + +set.seed(4837) +mean(f(runif(10000),runif(10000))) +mean(f(runif(10000),runif(10000))) +mean(f(runif(10000),runif(10000))) + +GetHalton <- function(HowMany, Base) { + Seq = matrix(0,HowMany,1) + NumBits = 1+round(log(HowMany)/log(Base)); + VetBase = Base^(-(1:NumBits)); + WorkVet = matrix(0,1,NumBits); + for (i in 1:HowMany){ + j = 1; + ok = 0; + while (ok == 0){ + WorkVet[j] = WorkVet[j]+1; + if (WorkVet[j] < Base){ + ok = 1; + } + else{ + WorkVet[j] = 0; + j = j+1; + } + } + Seq[i] = sum(WorkVet * VetBase) + } + return(Seq) +} + +seq2 = GetHalton(10000,2) +seq4 = GetHalton(10000,4) +seq5 = GetHalton(10000,5) +seq7 = GetHalton(10000,7) +mean(f(seq2,seq5)) +mean(f(seq2,seq4)) +mean(f(seq2,seq7)) +mean(f(seq5,seq7)) + +set.seed(327439) +mean(f(runif(100),runif(100))) +mean(f(runif(500),runif(500))) +mean(f(runif(1000),runif(1000))) +mean(f(runif(1500),runif(1500))) +mean(f(runif(2000),runif(2000))) + +mean(f(seq2[1:100],seq7[1:100])) +mean(f(seq2[1:500],seq7[1:500])) +mean(f(seq2[1:1000],seq7[1:1000])) +mean(f(seq2[1:1500],seq7[1:1500])) +mean(f(seq2[1:2000],seq7[1:2000])) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.17/Ex4_17.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.17/Ex4_17.R new file mode 100644 index 00000000..96dd25bb --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.17/Ex4_17.R @@ -0,0 +1,92 @@ +require(pracma) +require(fBasics) +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} + +GetHalton <- function(HowMany, Base) { + Seq = matrix(0,HowMany,1) + NumBits = 1+round(log(HowMany)/log(Base)); + VetBase = Base^(-(1:NumBits)); + WorkVet = matrix(0,1,NumBits); + for (i in 1:HowMany){ + j = 1; + ok = 0; + while (ok == 0){ + WorkVet[j] = WorkVet[j]+1; + if (WorkVet[j] < Base){ + ok = 1; + } + else{ + WorkVet[j] = 0; + j = j+1; + } + } + Seq[i] = sum(WorkVet * VetBase) + } + return(Seq) +} + +BlsHaltonBM <- function(S0,K,r,T,sigma,NPoints,Base1,Base2) { + nuT = (r - 0.5*sigma^2)*T; + siT = sigma * sqrt(T); + H1 = GetHalton(ceiling(NPoints/2),Base1); + H2 = GetHalton(ceiling(NPoints/2),Base2); + VLog = sqrt(-2*log(H1)) + Norm1 = VLog * cos(2*pi*H2) + Norm2 = VLog * sin(2*pi*H2) + Norm = rbind(Norm1,Norm2) + DiscPayoff = exp(-r*T) * pmax( 0 , S0*exp(nuT+siT*Norm) - K); + Price = mean(DiscPayoff); + return(Price) +} + +BlsHaltonBM(50,52,0.1,5/12,0.4,5000,2,7) +BlsHaltonBM(50,52,0.1,5/12,0.4,5000,11,7) +BlsHaltonBM(50,52,0.1,5/12,0.4,5000,2,4) + +BlsMC2 <- function(S0,K,r,T,sigma,NRepl) { + nuT = (r - 0.5*sigma^2)*T; + siT = sigma * sqrt(T); + DiscPayoff = exp(-r*T)*pmax(0, S0*exp(nuT+siT*rnorm(NRepl))-K); + parameter_estimation<-.normFit(DiscPayoff) + ci<-norm.interval(DiscPayoff) + final<-list(parameter_estimation,ci) + return(final) +} + +set.seed(3726) +BlsMC2(50,52,0.1,5/12,0.4,5000) +BlsMC2(50,52,0.1,5/12,0.4,5000) +BlsMC2(50,52,0.1,5/12,0.4,5000) + +BlsHaltonINV <- function(S0,X,r,T,sigma,NPoints,Base) { + nuT = (r - 0.5*sigma^2)*T; + siT = sigma * sqrt(T); + # Use inverse transform to generate standard normals + H = GetHalton(NPoints,Base); + Veps = qnorm(H); + DiscPayoff = exp(-r*T)*pmax(0,S0*exp(nuT+siT*Veps)-X); + Price = mean(DiscPayoff); + return(Price) +} + +BlsHaltonINV(50,52,0.1,5/12,0.4,1000,2) +BlsHaltonINV(50,52,0.1,5/12,0.4,2000,2) +BlsHaltonINV(50,52,0.1,5/12,0.4,5000,2) +BlsHaltonINV(50,52,0.1,5/12,0.4,1000,2) +BlsHaltonINV(50,52,0.1,5/12,0.4,10000,2) +BlsHaltonINV(50,52,0.1,5/12,0.4,50000,2) + +GetHalton(17,17) + +BlsHaltonINV(50,52,0.1,5/12,0.4,1000,499) +BlsHaltonINV(50,52,0.1,5/12,0.4,2000,499) +BlsHaltonINV(50,52,0.1,5/12,0.4,5000,499) +BlsHaltonINV(50,52 ,0.1,5/12,0.4,10000,499) +BlsHaltonINV(50,52,0.1,5/12,0.4,50000,499) + +plot(GetHalton(1000,109), GetHalton(1000,113)) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.18/Ex4_18.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.18/Ex4_18.R new file mode 100644 index 00000000..85d897a5 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.18/Ex4_18.R @@ -0,0 +1,23 @@ +require(bitops) +GetDirNumbers <- function(p,m0,n) { + degree = length(p)-1; + p = p[2:degree]; + m = cbind(m0 , matrix(0,1,n-degree)) + for (i in (degree+1):n){ + m[i] = bitXor(m[i-degree], 2^degree * m[i-degree]) + for (j in 1:(degree-1)){ + m[i] = bitXor(m[i], 2^j * p[j] * m[i-j]); + } + } + v=m/(2^(1:length(m))) + final<-list() + final$v<-v + final$m<-m + return(final) +} + +p <-matrix(c(1,0, 1, 1),nrow = 1,ncol = 4) +m0 <-matrix(c(1,3, 7),nrow = 1,ncol = 3) +ans<-GetDirNumbers(p,m0, 6) +ans$v +ans$m \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.19/Ex4_19.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.19/Ex4_19.R new file mode 100644 index 00000000..883abfe0 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.19/Ex4_19.R @@ -0,0 +1,6 @@ +require(bitops) +gray<-function(x) bitXor(x,bitShiftR(x,1)) +codes = matrix(0,16,4); +for (i in 1:16){ + print(intToBits(gray(i-1)) [4:1]) +} \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.2/Ex4_2.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.2/Ex4_2.R new file mode 100644 index 00000000..2fb52c58 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.2/Ex4_2.R @@ -0,0 +1,7 @@ +set.seed(12345) +mean(exp(runif(10))) +mean(exp(runif(10))) +mean(exp(runif(10))) +mean(exp(runif(1000000))) +mean(exp(runif(1000000))) +mean(exp(runif(1000000))) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.20/Ex4_20.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.20/Ex4_20.R new file mode 100644 index 00000000..44586ea7 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.20/Ex4_20.R @@ -0,0 +1,47 @@ +require(bitops) +options(warn=-1) + +GetDirNumbers <- function(p,m0,n) { + degree = length(p)-1; + p = p[2:degree]; + m = cbind(m0 , matrix(0,1,n-degree)) + for (i in (degree+1):n){ + m[i] = bitXor(m[i-degree], 2^degree * m[i-degree]) + for (j in 1:(degree-1)){ + m[i] = bitXor(m[i], 2^j * p[j] * m[i-j]); + } + } + v=m/(2^(1:length(m))) + final<-list() + final$v<-v + final$m<-m + return(final) +} + +p <-matrix(c(1,0, 1, 1),nrow = 1,ncol = 4) +m0 <-matrix(c(1,3, 7),nrow = 1,ncol = 3) +ans<-GetDirNumbers(p,m0, 6) +ans$v +ans$m + +GetSobol <- function(GenNumbers, x0, HowMany) { + Nbits = 20; + factor = 2^Nbits; + BitNumbers = GenNumbers * factor; + SobSeq = matrix(0,HowMany + 1, 1); + SobSeq[1] = as.integer(x0*factor); + for (i in 1:HowMany){ + c = pmin(which( intToBits(i-1) [1:16] == 0 )); + SobSeq[i+1] = bitXor(SobSeq[i], BitNumbers[c]); + } + SobSeq = SobSeq / factor; + return(SobSeq) +} +GetSobol(ans$v,0,10) + + +p <-matrix(c(1,0, 1, 1,1,1),nrow = 1,ncol = 6) +m0 <-matrix(c(1,3, 5, 9, 11),nrow = 1,ncol = 5) +ans<-GetDirNumbers(p,m0, 10) + +GetSobol(ans$v,0.124,10) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.3/Ex4_3.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.3/Ex4_3.R new file mode 100644 index 00000000..68241de1 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.3/Ex4_3.R @@ -0,0 +1,19 @@ +BlsMC1 <- function(S0, K , r , T , sigma, NRepl) { + nuT = (r - 0.5*sigma**2)*T + siT = sigma * sqrt(T) + DiscPayoff = exp(-r*T) *pmax(0,(S0*exp(nuT+siT*rnorm(NRepl))-K)) + Price = mean(DiscPayoff) + return(Price) +} +S0=50 +K=60 +r=0.05 +T=1 +sigma=0.2 +set.seed(547) +BlsMC1(S0,K,r ,T, sigma, 1000) +BlsMC1(S0,K,r ,T, sigma, 1000) +BlsMC1(S0,K,r ,T, sigma, 1000) +BlsMC1(S0,K,r ,T, sigma, 1000000) +BlsMC1(S0,K,r ,T, sigma, 1000000) +BlsMC1(S0,K,r ,T, sigma, 1000000) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.4/Ex4_4.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..81fa4865 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,18 @@ +LCG <- function(a,c,m,seed,N) { + ZSeq <-matrix(0,N,1) + USeq <-matrix(0,N,1) + for (i in 1:N){ + seed = (a*seed+c) %% m + ZSeq[i] = seed + USeq[i] = seed/m + } + result<-list(ZSeq,USeq) + return(result) +} + +a = 5 +c = 3 +m = 16 +seed = 7 +N = 20 +LCG(a,c,m,seed,N) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.5/Ex4_5.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..f11e98b9 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,24 @@ +LCG <- function(a,c,m,seed,N) { + ZSeq <-matrix(0,N,1) + USeq <-matrix(0,N,1) + for (i in 1:N){ + seed = (a*seed+c) %% m + ZSeq[i] = seed + USeq[i] = seed/m + } + result<-list(ZSeq,USeq) + return(result) +} + +m = 2048; +a = 65; +c = 1; +seed = 0; +U = LCG(a,c,m,seed, 2048); +plot(unlist(U[1])[1:m-1],unlist(U[2])[2:m]) +plot(unlist(U[1])[1:511],unlist(U[2])[2:512]) + +a=1365; +c=1 ; +U = LCG(a,c,m,seed, 2048) +plot(unlist(U[1])[1:m-1],unlist(U[2])[2:m]) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.6/Ex4_6.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.6/Ex4_6.R new file mode 100644 index 00000000..a1350330 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.6/Ex4_6.R @@ -0,0 +1,18 @@ +set.seed(64657) +rexp(1, 1/1) + +EmpiricalDrnd <- function(values, probs, howmany) { + cumprobs = cumsum(probs) + N = length(probs) + samples = matrix(0,howmany, 1) + for (k in 1:howmany){ + loc=sum(runif(1)*cumprobs[N] > cumprobs) + 1; + samples[k]=values[loc] + } + return(samples) +} + +values=1:5 +probs<-c(0.1, 0.2, 0.4, 0.2, 0.1) +samples=EmpiricalDrnd(values ,probs ,10000) +hist(x = samples) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.8/Ex4_8.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.8/Ex4_8.R new file mode 100644 index 00000000..fdd1737e --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.8/Ex4_8.R @@ -0,0 +1,28 @@ +LCG <- function(a,c,m,seed,N) { + ZSeq <-matrix(0,N,1) + USeq <-matrix(0,N,1) + for (i in 1:N){ + seed = (a*seed+c) %% m + ZSeq[i] = seed + USeq[i] = seed/m + } + result<-list(ZSeq,USeq) + return(result) +} + +m = 2048; +a = 1229; +c = 1; +N = m-2; +seed = 0; +U = LCG(a,c,m,seed,N); +index<-seq(1,N-1,2) +U1 = unlist(U[2])[index] +index<-seq(2,N,2) +U2 = unlist(U[2])[index] +X=sqrt(-2*log(U1))* cos(2*pi*U2); +Y=sqrt(-2*log(U1))* sin(2*pi*U2); +plot(X,Y) +X=sqrt(-2*log(U2))* cos(2*pi*U1); +Y=sqrt(-2*log(U2))* sin(2*pi*U1); +plot(X,Y) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.9/Ex4_9.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.9/Ex4_9.R new file mode 100644 index 00000000..474614e7 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH4/EX4.9/Ex4_9.R @@ -0,0 +1,20 @@ +Sigma<-matrix(c(4, 1, -2, 1, 3, 1, -2, 1, 5),nrow = 3,ncol = 3,byrow = TRUE) +mu<-matrix(c(8,6,10),nrow = 3,ncol = 1,byrow = TRUE) +eigen(Sigma)$values +set.seed(2392) + +MultiNormrnd <- function(mu,sigma,howmany) { + n = length(mu) + Z = matrix(0,howmany,n) + U = chol(sigma) + for (i in 1:howmany){ + Z[i,] = t(mu) + t(matrix(rnorm(n))) %*% U + } + return(Z) +} + +Z = MultiNormrnd(mu,Sigma,10000) +mean(Z[1]) +mean(Z[2]) +mean(Z[3]) +cov(Z) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.1/Ex5_1.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.1/Ex5_1.R new file mode 100644 index 00000000..12b807da --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.1/Ex5_1.R @@ -0,0 +1,63 @@ +require(PopED) + +transport <- function(xmin, dx, xmax, dt, tmax, c, f0) { + N = ceiling((xmax - xmin) / dx); + xmax = xmin + N*dx; + M = ceiling(tmax/dt); + k1 = 1 - dt*c/dx; + k2 = dt*c/dx; + solution = matrix(0,N+1,M+1); + vetx = seq(xmin,xmax,dx) + for (i in 1:N+1) { + solution[i,1] = feval(f0,vetx[i]); + } + fixedvalue = solution[1,1]; + # this is needed because of finite domain + plot(solution[,1]) + for (j in 1:M){ + solution[,j+1] = k1*solution[,j] + k2* c(fixedvalue,solution[1:N,j]); + lines(solution[,j]) + } + return(solution) +} + +f0transp <- function(x) { + if(x < (-1)){ + y = 0 + } else if (x <= 0){ + y=x+1; + } else{ + y = 1; + } +} + +xmin = -2; +xmax = 3; +dx = 0.05; +tmax = 2; +dt = 0.01; +c = 1; +sol = transport(xmin, dx, xmax, dt, tmax, c ,f0transp) + +TransportPlot <- function(xmin, dx, xmax, times, sol) { + par(mfrow=c(2,2)) + plot(seq(xmin,xmax,dx), sol[,times[1]]) + lines(seq(xmin,xmax,dx), sol[,times[1]]) + plot(seq(xmin,xmax,dx), sol[,times[2]]) + lines(seq(xmin,xmax,dx), sol[,times[2]]) + plot(seq(xmin,xmax,dx), sol[,times[3]]) + lines(seq(xmin,xmax,dx), sol[,times[3]]) + plot(seq(xmin,xmax,dx), sol[,times[4]]) + lines(seq(xmin,xmax,dx), sol[,times[4]]) +} + +TransportPlot(xmin, dx, xmax, c(1, 51, 101, 201), sol) + +dx = 0.01 +sol = transport(xmin, dx, xmax, dt, tmax, c ,f0transp) +TransportPlot(xmin, dx, xmax, c(1, 51, 101, 201), sol) + +#Blow-outs +dx = 0.005 +sol = transport(xmin, dx, xmax, dt, tmax, c ,f0transp) +TransportPlot(xmin, dx, xmax, c(1, 51, 101, 201), sol) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.3/Ex5_3.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.3/Ex5_3.R new file mode 100644 index 00000000..52b08a0f --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.3/Ex5_3.R @@ -0,0 +1,33 @@ +HeatExpl <- function(deltax, deltat, tmax) { + N = round(1/deltax) + M = round(tmax/deltat) + sol = matrix(0,N+1,M+1) + rho = deltat / (deltax)^2 + rho2 = 1-2*rho + vetx = seq(0,1,deltax) + for (i in 2:ceiling((N+1)/2)){ + sol[i,1] = 2*vetx[i] + sol[N+2-i,1] = sol[i,1] + } + for (j in 1:M){ + for (i in 2:N){ + sol[i,j+1] = rho*sol[i-1,j] + rho2*sol[i,j] + rho*sol[i+1,j] + } + } + return(sol) +} + +dx = 0.1; +dt = 0.001; +tmax = dt*100; +sol=HeatExpl(dx, dt , tmax) + +par(mfrow=c(2,2)) +plot(seq(0,1,dx), sol[,1]) +lines(seq(0,1,dx), sol[,1]) +plot(seq(0,1,dx), sol[,11]) +lines(seq(0,1,dx), sol[,11]) +plot(seq(0,1,dx), sol[,51]) +lines(seq(0,1,dx), sol[,51]) +plot(seq(0,1,dx), sol[,101]) +lines(seq(0,1,dx), sol[,101]) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.4/Ex5_4.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.4/Ex5_4.R new file mode 100644 index 00000000..15de05c6 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH5/EX5.4/Ex5_4.R @@ -0,0 +1,31 @@ +HeatImpl <- function(deltax, deltat, tmax) { + N = round(1/deltax) + M = round(tmax/deltat) + sol = matrix(0,N+1,M+1) + rho = deltat / (deltax)^2 + B = diag(c((1+2*rho) * array(1,c(N-1,1)))) - diag(c(0,rho*array(1,c(N-1,1))))[2:100,1:99] - diag(c(0,rho*array(1,c(N-1,1))))[1:99,2:100] + vetx = seq(0,1,deltax) + for (i in 2:ceiling((N+1)/2)){ + sol[i,1] = 2*vetx[i] + sol[N+2-i,1] = sol[i,1] + } + for (j in 1:M){ + sol[2:N,j+1] = solve(B,sol[2:N,j]) + } + return(sol) +} + +deltax=dx=0.01 +deltat=dt=0.001 +tmax=dt*100 +sol=HeatImpl(dx,dt,tmax) + +par(mfrow=c(2,2)) +plot(seq(0,1,dx),sol[,1]) +lines(seq(0,1,dx),sol[,1]) +plot(seq(0,1,dx),sol[,11]) +lines(seq(0,1,dx),sol[,11]) +plot(seq(0,1,dx),sol[,51]) +lines(seq(0,1,dx),sol[,51]) +plot(seq(0,1,dx),sol[,101]) +lines(seq(0,1,dx),sol[,101]) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.1/Ex6_1.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.1/Ex6_1.R new file mode 100644 index 00000000..9482a9d7 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.1/Ex6_1.R @@ -0,0 +1,26 @@ +require(signal) +require("ucminf") + +g <- function(x) { + polyval(c(1, -10.5, 39, -59.5, 30), x) +} +xvet=seq(1,4,0.05) +plot(xvet,g(xvet)) +lines(xvet,g(xvet)) + +x<-ucminf(c(0),g)$par +x +fval<-ucminf(c(0),g)$value +fval + +x<-ucminf(c(5),g)$par +x +fval<-ucminf(c(5),g)$value +fval + +f <- function(x) { + polyval(c(1, -8, 22, -24, 1), x) +} +xvet=seq(0,4,0.05) +plot(xvet,f(xvet)) +lines(xvet,f(xvet)) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.12/Ex6_12.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.12/Ex6_12.R new file mode 100644 index 00000000..15a49015 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.12/Ex6_12.R @@ -0,0 +1,13 @@ +A <- matrix(data=c(-1, 1, 1, -1, 0, 0, 1, 0, 4, 0, 0, 0, 2, 2, 1), nrow=3, ncol=5, byrow=TRUE) +b <- matrix(data=c(1, 3, 1), nrow=3, ncol=1, byrow=FALSE) +asvd = svd(A) +adiag = diag(1/asvd$d) +solution = asvd$v %*% adiag %*% t(asvd$u) %*% b +Check = A %*% solution + +# This solution does not match with the book, +# but in any case it's NOT FEASIBLE either as values present are less than ZERO + +# Book solution check +X<-matrix(data = c(0,3,-2,0,5),nrow = 5,ncol = 1,byrow = TRUE) +A %*% X \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.3/Ex6_3.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.3/Ex6_3.R new file mode 100644 index 00000000..eb291740 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.3/Ex6_3.R @@ -0,0 +1,6 @@ +require(lpSolve) +f.obj <- c(2, 3, 3) +f.con <- matrix (c(1, 2, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1), nrow=5, byrow=TRUE) +f.dir <- c("=", ">=", ">=", ">=", ">=") +f.rhs <- c(3, 3, 0, 0, 0) +lpSolve::lp(direction = "min",objective.in = f.obj,const.mat = f.con,const.dir = f.dir,const.rhs = f.rhs) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.5/Ex6_5.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.5/Ex6_5.R new file mode 100644 index 00000000..ab1ebb07 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.5/Ex6_5.R @@ -0,0 +1,10 @@ +require(pracma) +f <- function(sigma,x,y) { + (x-1.5)^2+(y-0.5)^2+sigma/(1-x)+sigma/(1-y) +} +X<-meshgrid(x = seq(0.1,.99,.01))$X +Y<-meshgrid(x = seq(0.1,.99,.01))$Y +contour(f(0.1,X,Y)) +contour(f(0.01,X,Y)) +contour(f(0.001,X,Y)) +contour(f(0.0001,X,Y)) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.8/Ex6_8.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.8/Ex6_8.R new file mode 100644 index 00000000..19c07986 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH6/EX6.8/Ex6_8.R @@ -0,0 +1,7 @@ +require(quadprog) +H = 2*eye(2) +f<-c(0,0) +Aeq<-matrix(c(1,1),nrow = 1) +beq<-4 +lb<-matrix(c(0,3),ncol =1,nrow = 2) +quadprog(C = H,d = f,Aeq = Aeq,beq = beq,lb = lb)$xmin \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.1/Ex7_1.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.1/Ex7_1.R new file mode 100644 index 00000000..3abb657b --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.1/Ex7_1.R @@ -0,0 +1,20 @@ +LatticeEurCall <- function(S0,K,r,T,sigma,N) { + deltaT = T/N + u=exp(sigma * sqrt(deltaT)) + d=1/u + p=(exp(r*deltaT) - d)/(u-d) + lattice = matrix(0,N+1,N+1) + for(i in 0:N){ + lattice[i+1,N+1]=max(0,S0*(u^i)*(d^(N-i))-K) + } + for(j in (N-1):0){ + for (i in 0:j){ + lattice[i+1,j+1] = exp(-r*deltaT) * (p * lattice[i+2,j+2] + (1-p) * lattice[i+1,j+2]) + } + } + return(lattice[1,1]) +} +call=LatticeEurCall(50,50,0.1,5/12,0.4,5) +call +call=LatticeEurCall(50,50,0.1,5/12,0.4,500) +call \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.2/Page_409_CompLatticeBLS.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.2/Page_409_CompLatticeBLS.R new file mode 100644 index 00000000..69e32657 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.2/Page_409_CompLatticeBLS.R @@ -0,0 +1,31 @@ +require(OptionPricing) +LatticeEurCall <- function(S0,K,r,T,sigma,N) { + deltaT = T/N + u=exp(sigma * sqrt(deltaT)) + d=1/u + p=(exp(r*deltaT) - d)/(u-d) + lattice = matrix(0,N+1,N+1) + for(i in 0:N){ + lattice[i+1,N+1]=max(0,S0*(u^i)*(d^(N-i))-K) + } + for(j in (N-1):0){ + for (i in 0:j){ + lattice[i+1,j+1] = exp(-r*deltaT) * (p * lattice[i+2,j+2] + (1-p) * lattice[i+1,j+2]) + } + } + return(lattice[1,1]) +} +S0 = 50 +K = 50 +r = 0.1 +sigma = 0.4 +T = 5/12 +N=50 +BlsC = BS_EC(K = K, r = r, sigma = sigma, T = T, S0 = S0)['price'] +LatticeC = matrix(0,1,N) +for (i in 1:N){ + LatticeC[i] = LatticeEurCall(S0, K , r , T, sigma, i) +} +plot(1:N, matrix(1,1,N)*BlsC) +lines(1:N, matrix(1,1,N)*BlsC) +lines(1:N, LatticeC) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.3/Page_411_Luenberger_Investment Science_Ex13_11.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.3/Page_411_Luenberger_Investment Science_Ex13_11.R new file mode 100644 index 00000000..aff8fb29 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.3/Page_411_Luenberger_Investment Science_Ex13_11.R @@ -0,0 +1,24 @@ +require(pracma) +L11 <- function(premium,S0,K,r,sigma,T,N) { + deltaT = T/N + u=exp(sigma * sqrt (deltaT)) + d=1/u + p=(exp(r*deltaT) - d)/(u-d) + lattice = matrix(0,N+1,N+1) + for (i in 0:N){ + if (S0*(u^i)*(d^(N-i)) >= K){ + lattice[i+1,N+1]=S0*(u^i)*(d^(N-i)) - K - premium + } + } + for (j in (N-1):0){ + for (i in 0:j){ + lattice[i+1, j+1] = p*lattice[i+2, j+2] + (1-p)*lattice[i+1, j+2] + } + } + return(lattice[1,1]) +} + +f <- function(P) { + L11(premium = P,S0 = 12,K = 14,r = 0.1, sigma = 0.2, T = 10/12, N = 10) +} +fzero(f = f,x = 2)$x \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.4/Page_413_SmartEurLattice.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.4/Page_413_SmartEurLattice.R new file mode 100644 index 00000000..9e12841d --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.4/Page_413_SmartEurLattice.R @@ -0,0 +1,57 @@ +require(OptionPricing) +require(tictoc) +LatticeEurCall <- function(S0,K,r,T,sigma,N) { + deltaT = T/N + u=exp(sigma * sqrt(deltaT)) + d=1/u + p=(exp(r*deltaT) - d)/(u-d) + lattice = matrix(0,N+1,N+1) + for(i in 0:N){ + lattice[i+1,N+1]=max(0,S0*(u^i)*(d^(N-i))-K) + } + for(j in (N-1):0){ + for (i in 0:j){ + lattice[i+1,j+1] = exp(-r*deltaT) * (p * lattice[i+2,j+2] + (1-p) * lattice[i+1,j+2]) + } + } + return(lattice[1,1]) +} +SmartEurLattice <- function(S0,K,r,T,sigma,N) { + # Precompute invariant quantities + deltaT = T/N + u=exp(sigma * sqrt(deltaT)) + d=1/u + p=(exp(r*deltaT) - d)/(u-d) + discount = exp(-r*deltaT) + p_u = discount*p + p_d = discount*(1-p) + # set up S values + SVals = matrix(0,2*N+1,1) + SVals[1] = S0*d^N + for (i in 2:(2*N+1)){ + SVals[i] = u*SVals[i-1] + } + # set up terminal CALL values + CVals = matrix(0,2*N+1,1) + for (i in seq(1,2*N+1,2)){ + CVals[i] = max(SVals[i]-K,0) + } + # work backwards + for (tau in 1:N){ + for (i in seq((tau+1),(2*N+1-tau),2)){ + CVals[i] = p_u*CVals[i+1] + p_d*CVals[i-1] + } + } + return(CVals[N+1]) +} +tic() +BS_EC(S0 = 50, K = 50, r = 0.1, sigma = 0.4, T = 5/12)['price'] +toc() + +tic() +LatticeEurCall(S0 = 50, K = 50, r = 0.1, sigma = 0.4, T = 5/12,N = 2000) +toc() + +tic() +SmartEurLattice(S0 = 50, K = 50, r = 0.1, sigma = 0.4, T = 5/12,N = 2000) +toc() \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.5/Page_416_AmPutLattice.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.5/Page_416_AmPutLattice.R new file mode 100644 index 00000000..997f77f2 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.5/Page_416_AmPutLattice.R @@ -0,0 +1,32 @@ +AmPutLattice <- function(S0,K,r,T,sigma,N) { + # Precompute invariant quantities + deltaT = T/N + u=exp(sigma * sqrt(deltaT)) + d=1/u + p=(exp(r*deltaT) - d)/(u-d) + discount = exp(-r*deltaT) + p_u = discount*p + p_d = discount*(1-p) + # set up S values + SVals = matrix(0,2*N+1,1) + SVals[N+1] = S0 + for (i in 1:N){ + SVals[N+1+i] = u*SVals[N+i] + SVals[N+1-i] = d*SVals[N+2-i] + } + # set up terminal values + PVals = matrix(0,2*N+1,1) + for (i in seq(1,2*N+1,2)){ + PVals[i] = max(K-SVals[i],0) + } + # work backwards + for (tau in 1:N){ + for (i in seq((tau+1),(2*N+1-tau),2)){ + hold = p_u*PVals[i+1] + p_d*PVals[i-1] + PVals[i] = max(hold, K-SVals[i]) + } + } + return(PVals[N+1]) +} + +AmPutLattice(S0 = 50,K = 50,r = 0.05,T = 5/12, sigma = 0.4, N = 1000) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.6/Page_420_AmSpreadLattice.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.6/Page_420_AmSpreadLattice.R new file mode 100644 index 00000000..fcd9c017 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.6/Page_420_AmSpreadLattice.R @@ -0,0 +1,43 @@ +AmSpreadLattice <- function(S10,S20,K,r,T,sigma1,sigma2,rho,q1,q2,N) { + # Precompute invariant quantities + deltaT = T/N + nu1 = r - q1 - 0.5*sigma1^2 + nu2 = r - q2 - 0.5*sigma2^2 + u1 = exp(sigma1*sqrt(deltaT)) + d1 = 1/u1 + u2 = exp(sigma2*sqrt(deltaT)) + d2 = 1/u2 + discount = exp(-r*deltaT) + p_uu = discount*0.25*(1 + sqrt(deltaT)*(nu1/sigma1 + nu2/sigma2) + rho) + p_ud = discount*0.25*(1 + sqrt(deltaT)*(nu1/sigma1 - nu2/sigma2) - rho) + p_du = discount*0.25*(1 + sqrt(deltaT)*(-nu1/sigma1 + nu2/sigma2) - rho) + p_dd = discount*0.25*(1 + sqrt(deltaT)*(-nu1/sigma1 - nu2/sigma2) + rho) + # set up S values + S1vals = matrix(0,2*N+1,1) + S2vals = matrix(0,2*N+1,1) + S1vals[1] = S10*d1^N + S2vals[1] = S20*d2^N + for (i in 2:(2*N+1)){ + S1vals[i] = u1*S1vals[i-1] + S2vals[i] = u2*S2vals[i-1] + } + # set up terminal values + Cvals = matrix(0,2*N+1,2*N+1) + for (i in seq(1,2*N+1,2)){ + for (j in seq(1,2*N+1,2)){ + Cvals[i,j] = max(S1vals[i]-S2vals[j]-K,0) + } + } + # roll back + for (tau in 1:N){ + for (i in seq((tau+1),(2*N+1-tau),2)){ + for (j in seq((tau+1),(2*N+1-tau),2)){ + hold = p_uu * Cvals[i+1,j+1] + p_ud * Cvals[i+1,j-1] + p_du * Cvals[i-1,j+1] + p_dd * Cvals[i-1,j-1] + Cvals[i,j] = max(hold, S1vals[i] - S2vals[j] - K) + } + } + } + return(Cvals[N+1,N+1]) +} + +AmSpreadLattice(S10 = 100, S20 = 100, K = 1, r = 0.06, T = 1, sigma1 =0.2, sigma2 = 0.3, rho = 0.5, q1 = 0.03, q2 = 0.04, N = 3) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.7/Page_424_EuCallTrinomial.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.7/Page_424_EuCallTrinomial.R new file mode 100644 index 00000000..f79631d1 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH7/EX7.7/Page_424_EuCallTrinomial.R @@ -0,0 +1,37 @@ +require(OptionPricing) +EuCallTrinomial <- function(S0,K,r,T,sigma,N,deltaX) { + # Precompute invariant quantities + deltaT = T/N + nu = r - 0.5*sigma^2 + discount = exp(-r*deltaT) + p_u = discount*0.5*((sigma^2*deltaT+nu^2*deltaT^2)/deltaX^2 + nu*deltaT/deltaX) + p_m = discount*(1 - (sigma^2*deltaT+nu^2*deltaT^2)/deltaX^2) + p_d = discount*0.5*((sigma^2*deltaT+nu^2*deltaT^2)/deltaX^2 - nu*deltaT/deltaX) + # set up S values (at maturity) + Svals = matrix(0,2*N+1,1) + Svals[1] = S0*exp(-N*deltaX) + exp_dX = exp(deltaX) + for (j in 2:(2*N+1)){ + Svals[j] = exp_dX*Svals[j-1] + } + # set up lattice and terminal values + Cvals = matrix(0,2*N+1,2) + t = mod(N,2)+1 + for (j in 1:(2*N+1)){ + Cvals[j,t] = max(Svals[j]-K,0) + } + for (t in (N-1):0){ + know = mod(t,2)+1 + knext = mod(t+1,2)+1 + for (j in (N-t+1):(N+t+1)){ + Cvals[j,know] = p_d*Cvals[j-1,knext]+p_m*Cvals[j,knext]+p_u*Cvals[j+1,knext] + } + } + return(Cvals[N+1,1]) +} +BS_EC(S0 = 100, K = 100, r = 0.06, sigma = 0.3, T = 1)['price'] +EuCallTrinomial(S0 = 100, K = 100, r = 0.06, T = 1, sigma = 0.3, N = 3, deltaX = 0.2) +EuCallTrinomial(S0 = 100, K = 100, r = 0.06, T = 1, sigma = 0.3, N = 100, deltaX = 0.2) +EuCallTrinomial(S0 = 100, K = 100, r = 0.06, T = 1, sigma = 0.3, N = 100, deltaX = 0.5) +EuCallTrinomial(S0 = 100, K = 100, r = 0.06, T = 1, sigma = 0.3, N = 100, deltaX = 0.3*sqrt (1/100)) +EuCallTrinomial(S0 = 100, K = 100, r = 0.06, T = 1, sigma = 0.3, N = 1000, deltaX = 0.3*sqrt (1/1000)) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.1/Page_433_AssetPaths.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.1/Page_433_AssetPaths.R new file mode 100644 index 00000000..270f0491 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.1/Page_433_AssetPaths.R @@ -0,0 +1,18 @@ +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} +set.seed(37456) +paths=AssetPaths(50,0.1,0.3,1,365,3) +plot(1:length(paths[3,]) ,paths[3,],type = 'l') +lines(1:length(paths[1,]) ,paths[1,],type = 'l') +lines(1:length(paths[2,]) ,paths[2,],type = 'l') \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.10/Page_449_D0PutMCCond.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.10/Page_449_D0PutMCCond.R new file mode 100644 index 00000000..ff27755f --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.10/Page_449_D0PutMCCond.R @@ -0,0 +1,63 @@ +require(OptionPricing) +require(fBasics) +require(fOptions) +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} + +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} + +is.integer0 <- function(x) +{ + is.integer(x) && length(x) == 0L +} + +DOPutMCCond <- function(S0,K,r,T,sigma,Sb,NSteps,NRepl) { + dt = T/NSteps; + Call = GBSOption(TypeFlag = "c", S = S0, X = K, Time = T, r = r, sigma = sigma, b =r) + Put = GBSOption(TypeFlag = "p", S = S0, X = K, Time = T, r = r, sigma = sigma, b =r) + # Generate asset paths and payoffs for the down and in option + NCrossed = 0 + Payoff = matrix(0,NRepl,1) + Times = matrix(0,NRepl,1) + StockVals = matrix(0,NRepl,1) + for (i in 1:NRepl){ + Path=AssetPaths(S0,r,sigma,T,NSteps,1) + tcrossed = pmin(which(Path <= Sb)) + if (!(is.integer0(tcrossed))){ + NCrossed = NCrossed + 1 + Times[NCrossed,] = (length(tcrossed) - 1) * dt + StockVals[NCrossed,] = Path[,length(tcrossed)] + } + } + Paux<-matrix() + f <- function(S0,K,r,T,sigma) { + GBSOption(TypeFlag = "p", S = S0, X = K, Time = T, r = r, sigma = sigma, b =r) + } + if (NCrossed > 0){ + for (j in 1:NCrossed){ + Paux[j] = f(StockVals[j],K,r,(T-Times[j]),sigma)@price + Payoff[j] = exp(-r*Times[j]) * Paux[j] + } + } + parameter_estimation<-.normFit(Put@price - Payoff) + ci<-norm.interval(Put@price - Payoff) + return(c(parameter_estimation,ci,NCrossed)) +} + +DOPutMCCond(50,52,0.1,2/12,0.4,30,60,200000) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.11/Page_453_DOPutMCCondIS.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.11/Page_453_DOPutMCCondIS.R new file mode 100644 index 00000000..25500d19 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.11/Page_453_DOPutMCCondIS.R @@ -0,0 +1,76 @@ +require(OptionPricing) +require(fBasics) +require(fOptions) +require(varbvs) +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} + +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} + +is.integer0 <- function(x) +{ + is.integer(x) && length(x) == 0L +} + +DOPutMCCondIS <- function(S0,K,r,T,sigma,Sb,NSteps,NRepl,bp){ + dt = T/NSteps + nudt = (r-0.5*sigma^2)*dt + b = bp*nudt + sidt = sigma*sqrt(dt) + Call = GBSOption(TypeFlag = "c", S = S0, X = K, Time = T, r = r, sigma = sigma, b =r) + Put = GBSOption(TypeFlag = "p", S = S0, X = K, Time = T, r = r, sigma = sigma, b =r) + # Generate asset paths and payoffs for the down and in option + NCrossed = 0 + Payoff = matrix(0,NRepl,1) + Times = matrix(0,NRepl,1) + StockVals = matrix(0,NRepl,1) + ISRatio = matrix(0,NRepl,1) + for (i in 1:NRepl){ + # generate normals + vetZ = nudt - b + sidt*randn(1,NSteps) + LogPath = apply(cbind(log(S0), vetZ),1,cumsum) + Path = exp(LogPath) + jcrossed = pmin(which(Path <= Sb )) + if (!(is.integer0(jcrossed))){ + jcrossed = min(jcrossed) + NCrossed = NCrossed + 1 + TBreach = jcrossed - 1 + Times[NCrossed,] = TBreach * dt + StockVals[NCrossed,] = Path[jcrossed] + ISRatio[NCrossed,] = exp( TBreach*b^2/2/sigma^2/dt + b/sigma^2/dt*sum(vetZ[1:TBreach]) - TBreach*b/sigma^2*(r - sigma^2/2)) + } + } + Paux<-matrix() + f <- function(S0,K,r,T,sigma) { + GBSOption(TypeFlag = "p", S = S0, X = K, Time = T, r = r, sigma = sigma, b =r) + } + if (NCrossed > 0){ + for (j in 1:NCrossed){ + Paux[j] = f(StockVals[j],K,r,(T-Times[j]),sigma)@price + Payoff[j] = exp(-r*Times[j])* Paux[j] * ISRatio[j] + } + } + parameter_estimation<-.normFit(Put@price - Payoff) + ci<-norm.interval(Put@price - Payoff) + return(c(parameter_estimation,ci,NCrossed)) +} +DOPutMCCondIS(50,52,0.1,2/12,0.4,30,60,10000,0) +DOPutMCCondIS(50,52,0.1,2/12,0.4,30,60,10000,20) +DOPutMCCondIS(50,52,0.1,2/12,0.4,30,60,10000,50) +DOPutMCCondIS(50,52,0.1,2/12,0.4,30,60,10000,200) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.12/Page_455_AsianMC.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.12/Page_455_AsianMC.R new file mode 100644 index 00000000..10a0ee19 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.12/Page_455_AsianMC.R @@ -0,0 +1,37 @@ +require(OptionPricing) +require(fBasics) +require(fOptions) +require(varbvs) +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} +AsianMC<-function(S0,K,r,T,sigma,NSamples,NRepl){ + Payoff = matrix(0,NRepl,1) + for (i in 1:NRepl){ + Path=AssetPaths(S0,r,sigma,T,NSamples,1) + Payoff[i] = max(0, mean(Path[2:(NSamples+1)]) - K) + } + parameter_estimation<-.normFit(exp(-r*T) * Payoff) + ci<-norm.interval(exp(-r*T) * Payoff) + return(c(parameter_estimation,ci)) +} +set.seed(28282) +X<-AsianMC(50,50,0.1,5/12,0.4,5,50000) +X +X[[3]]-X[[2]] \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.13/Page_456_AsianMCCV.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.13/Page_456_AsianMCCV.R new file mode 100644 index 00000000..0248d459 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.13/Page_456_AsianMCCV.R @@ -0,0 +1,52 @@ +require(OptionPricing) +require(fBasics) +require(fOptions) +require(varbvs) +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} +AsianMCCV<-function(S0,K,r,T,sigma,NSamples,NRepl,NPilot){ + # pilot replications to set control parameter + TryPath=AssetPaths(S0,r,sigma,T,NSamples,NPilot) + StockSum<-matrix() + PP<-matrix() + TryPayoff<-matrix() + for (i in 1:length(TryPath[,1])){ + StockSum[i] = sum(TryPath[i,]) + PP[i] = mean(TryPath[i,2:(NSamples+1)]) + TryPayoff[i] = exp(-r*T) * max(0, PP[i] - K) + } + MatCov = cov(cbind(StockSum, TryPayoff)) + c = - MatCov[1,2] / var(StockSum) + dt = T / NSamples + ExpSum = S0 * (1 - exp((NSamples + 1)*r*dt)) / (1 - exp(r*dt)) + # MC run + ControlVars = matrix(0,NRepl,1) + for (i in 1:NRepl){ + StockPath = AssetPaths(S0,r,sigma,T,NSamples,1) + Payoff = exp(-r*T) * max(0, mean(StockPath[2:(NSamples+1)]) - K) + ControlVars[i] = Payoff + c * (sum(StockPath) - ExpSum) + } + parameter_estimation<-.normFit(ControlVars) + ci<-norm.interval(ControlVars) + return(c(parameter_estimation,ci)) +} +X<-AsianMCCV(50,50 ,0.1,5/12,0.4,5,45000,5000) +X +X[[3]]-X[[2]] \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.14/Page_459_AsianMCGeoCV.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.14/Page_459_AsianMCGeoCV.R new file mode 100644 index 00000000..3847f459 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.14/Page_459_AsianMCGeoCV.R @@ -0,0 +1,69 @@ +require(OptionPricing) +require(fBasics) +require(fOptions) +require(varbvs) +require(lmom) +GeometricAsian<-function(S0,K,r,T,sigma,delta,NSamples){ + dT = T/NSamples + nu = r - sigma^2/2-delta + a = log(S0)+nu*dT+0.5*nu*(T-dT) + b = sigma^2*dT + sigma^2*(T-dT)*(2*NSamples-1)/6/NSamples + x = (a-log(K)+b)/sqrt(b) + P = exp(-r*T)*(exp(a+b/2)*cdfnor(x) - K*cdfnor(x-sqrt(b))) + return(P) +} +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} +AsianMCGeoCV<-function(S0,K,r,T,sigma,NSamples,NRepl,NPilot){ + # precompute quantities + DF = exp(-r*T) + GeoExact = GeometricAsian(S0,K,r,T,sigma,0,NSamples) + # pilot replications to set control parameter + GeoPrices = matrix(0,NPilot,1) + AriPrices = matrix(0,NPilot,1) + for (i in 1:NPilot){ + Path=AssetPaths(S0,r,sigma,T,NSamples,1) + GeoPrices[i]=DF*max(0,(prod(Path[,2:(NSamples+1)]))^(1/NSamples) - K) + AriPrices[i]=DF*max(0,mean(Path[,2:(NSamples+1)]) - K) + } + MatCov = cov(cbind(GeoPrices, AriPrices)) + c = - MatCov[1,2] / var(GeoPrices) + # MC run + ControlVars = matrix(0,NRepl,1) + for (i in 1:NRepl){ + Path = AssetPaths(S0,r,sigma,T,NSamples,1) + GeoPrice = DF*max(0, (prod(Path[2:(NSamples+1)]))^(1/NSamples) - K) + AriPrice = DF*max(0, mean(Path[2:(NSamples+1)]) - K) + ControlVars[i] = AriPrice + c * (GeoPrice - GeoExact) + } + parameter_estimation<-.normFit(ControlVars) + ci<-norm.interval(ControlVars) + return(c(parameter_estimation,ci)) +} +set.seed(2372) +S0 = 50 +K = 55 +r = 0.05 +sigma = 0.4 +T = 1 +NSamples = 12 +NRepl = 9000 +NPilot = 1000 +AsianMCGeoCV(S0,K,r,T,sigma,NSamples,NRepl,NPilot) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.15/Page_460_AsianHalton.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.15/Page_460_AsianHalton.R new file mode 100644 index 00000000..0a4927e8 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.15/Page_460_AsianHalton.R @@ -0,0 +1,86 @@ +require(gmp) +require(lmom) +require(lestat) + +GetHalton <- function(HowMany, Base) { + Seq = matrix(0,HowMany,1) + NumBits = 1+round(log(HowMany)/log(Base)); + VetBase = Base^(-(1:NumBits)); + WorkVet = matrix(0,1,NumBits); + for (i in 1:HowMany){ + j = 1; + ok = 0; + while (ok == 0){ + WorkVet[j] = WorkVet[j]+1; + if (WorkVet[j] < Base){ + ok = 1; + } + else{ + WorkVet[j] = 0; + j = j+1; + } + } + Seq[i] = sum(WorkVet * VetBase) + } + return(Seq) +} + +myprimes<-function(N){ + found = 0 + trynumber = 2 + p <- matrix() + while (found < N){ + if (isprime(trynumber)){ + p <-c(p , trynumber) + found = found + 1 + } + trynumber = trynumber + 1 + } + return(p) +} + +HaltonPaths<-function(S0,mu,sigma,T,NSteps,NRepl){ + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + # Use inverse transform to generate standard normals + NormMat = matrix(0,NRepl, NSteps) + Bases = myprimes(NSteps) + RandMat<-matrix(0,NRepl,NSteps) + H <- matrix() + for (i in 2:(NSteps+1)){ + H = GetHalton(NRepl,Bases[i]) + for (j in 1:length(H)){ + RandMat[j,i-1] = invcdf(normal(),H[j]) + } + } + Increments = nudt + sidt*RandMat + LogPaths = apply(cbind(log(S0)*matrix(1,NRepl,1),Increments),1,cumsum) + LogPaths = t(LogPaths) + SPaths = exp(LogPaths) + SPaths[,1] = S0 + return(SPaths) +} + +AsianHalton<-function(S0,K,r,T,sigma,NSamples,NRepl){ + Payoff = matrix(0,NRepl,1) + Path=HaltonPaths(S0,r,sigma,T,NSamples,NRepl) + Payoff<-matrix(0,NSamples,1) + for(k in 1:length(Path[,1])){ + Payoff[k] = max(0, mean(Path[k,2:(NSamples+1)]) - K) + } + P = mean( exp(-r*T) * matrix(Payoff)) + return(P) +} + +set.seed(3226) +AsianHalton(50,50,0.1,5/12,0.4,5,1000) +AsianHalton(50,50,0.1,5/12,0.4,5,3000) +AsianHalton(50,50,0.1,5/12,0.4,5,10000) +AsianHalton(50,50,0.1,5/12,0.4,5,50000) + +AsianHalton(50,50,0.1,2,0.4,24,1000) +AsianHalton(50,50,0.1,2,0.4,24,5000) +AsianHalton(50,50,0.1,2,0.4,24,50000) + + diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.16/Page_464_GBMHaltonBridge.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.16/Page_464_GBMHaltonBridge.R new file mode 100644 index 00000000..5993b55b --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.16/Page_464_GBMHaltonBridge.R @@ -0,0 +1,121 @@ +require(gmp) +require(lmom) +require(lestat) +require(matrixStats) + +myprimes<-function(N){ + found = 0 + trynumber = 2 + p <- matrix() + while (found < N){ + if (isprime(trynumber)){ + p <-c(p , trynumber) + found = found + 1 + } + trynumber = trynumber + 1 + } + return(p) +} + +GetHalton <- function(HowMany, Base) { + Seq = matrix(0,HowMany,1) + NumBits = 1+round(log(HowMany)/log(Base)); + VetBase = Base^(-(1:NumBits)); + WorkVet = matrix(0,1,NumBits); + for (i in 1:HowMany){ + j = 1; + ok = 0; + while (ok == 0){ + WorkVet[j] = WorkVet[j]+1; + if (WorkVet[j] < Base){ + ok = 1; + } + else{ + WorkVet[j] = 0; + j = j+1; + } + } + Seq[i] = sum(WorkVet * VetBase) + } + return(Seq) +} + +WienerHaltonBridge<-function(T, NSteps, NRepl, Limit){ + NBisections = log2(NSteps) + if (round(NBisections) != NBisections){ + cat('ERROR in WienerHB: NSteps must be a power of 2','\n') + return + } + # Generate standard normal samples + NormMat = matrix(0,NRepl, NSteps) + Bases = myprimes(NSteps) + for (i in 2:(NSteps+1)){ + H = GetHalton(NRepl,Bases[i]) + for (j in 1:length(H)){ + NormMat[j,i-1] = invcdf(normal(),H[j]) + } + } + # Initialize extreme points of paths + WSamples = matrix(0,NRepl,NSteps+1) + WSamples[,1] = 0 + WSamples[,NSteps+1] = sqrt(T)*NormMat[,1] + # Fill paths + HUse = 2 + TJump = T + IJump = NSteps + for (k in 1:NBisections){ + left = 1 + i = IJump/2 + 1 + right = IJump + 1 + for (l in 1:(2^(k-1))){ + a = 0.5*(WSamples[,left] + WSamples[,right]) + b = 0.5*sqrt(TJump) + if (HUse <= Limit){ + WSamples[,i] = a + b*NormMat[,HUse] + } else { + WSamples[,i] = a + b*rnorm(NRepl) + } + right = right + IJump + left = left + IJump + i = i + IJump + } + IJump = IJump/2 + TJump = TJump/2 + HUse = HUse + 1 + } + return(WSamples) +} + +GBMHaltonBridge<-function(S0,mu,sigma,T,NSteps,NRepl,Limit){ + if (round(log2(NSteps)) != log2(NSteps)){ + cat('ERROR in GBMBridge: NSteps must be a power of 2','\n') + return + } + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + W = WienerHaltonBridge(T,NSteps,NRepl,Limit) + Increments = nudt + sigma*t(diff(t(W))) + LogPaths = apply(cbind(log(S0)*matrix(1,NRepl,1),Increments),1,cumsum) + LogPaths = t(LogPaths) + Paths = exp(LogPaths) + Paths[,1] = S0 + return(Paths) +} + +set.seed(271782) +NRepl = 10000 +T = 5 +NSteps = 16 +Limit = NSteps +S0 = 50 +mu = 0.1 +sigma = 0.4 +Paths = GBMHaltonBridge(S0, mu, sigma, T, NSteps, NRepl, Limit) +r = mu +NSamples = NSteps +K = 55 +Payoff<-matrix() +for(p in 1:length(Paths[,1])){ + Payoff[p] = max(0, mean(Paths[p,2:(NSamples+1)]) - K) +} +P = mean( exp(-r*T) * matrix(Payoff)) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.17/Page_470_BlsDeltaMCNaive.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.17/Page_470_BlsDeltaMCNaive.R new file mode 100644 index 00000000..96ae1d5b --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.17/Page_470_BlsDeltaMCNaive.R @@ -0,0 +1,31 @@ +require(varbvs) +require(fBasics) +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} +BlsDeltaMCNaive<-function(S0,K,r,T,sigma,dS,NRepl){ + nuT = (r - 0.5*sigma^2)*T + siT = sigma * sqrt(T) + Payoff1<-matrix() + Payoff2<-matrix() + for (i in 1:NRepl){ + Payoff1[i] = max(0, S0*exp(nuT+siT*randn(1,1))-K) + Payoff2[i] = max(0, (S0+dS)*exp(nuT+siT*randn(1,1))-K) + } + SampleDiff = exp(-r*T)*(Payoff2 - Payoff1)/dS + parameter_estimation<-.normFit(SampleDiff) + ci<-norm.interval(SampleDiff) + return(c(parameter_estimation,ci)) +} +set.seed(762567) +S0=50 +K=52 +r=0.05 +T=5/12 +sigma = 0.4 +NRepl=50000 +dS = 0.5 +BlsDeltaMCNaive(S0,K,r,T,sigma,dS,NRepl) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.18/Page_472_BlsDeltaMCPath.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.18/Page_472_BlsDeltaMCPath.R new file mode 100644 index 00000000..2d0449dc --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.18/Page_472_BlsDeltaMCPath.R @@ -0,0 +1,30 @@ +require(varbvs) +require(fBasics) +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} + +BlsDeltaMCPath<-function(S0,K,r,T,sigma,NRepl){ + nuT = (r - 0.5*sigma^2)*T + siT = sigma * sqrt(T) + VLogn<-matrix() + for (i in 1:NRepl){ + VLogn[i] = exp(nuT+siT*randn(1,1)) + } + SampleDelta = exp(-r*T) * VLogn * (S0*VLogn > K) + parameter_estimation<-.normFit(SampleDelta) + ci<-norm.interval(SampleDelta) + return(c(parameter_estimation,ci)) +} + +set.seed(3725678) +S0=50 +K=52 +r=0.05 +T=5/12 +sigma = 0.4 +NRepl=50000 +BlsDeltaMCPath(S0,K,r,T,sigma,NRepl) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.2/Page_434_AssetPathsV.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.2/Page_434_AssetPathsV.R new file mode 100644 index 00000000..1910ecff --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.2/Page_434_AssetPathsV.R @@ -0,0 +1,39 @@ +require(varbvs) +require(tictoc) +AssetPathsV <- function(S0,mu,sigma,T,NSteps,NRepl) { + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + Increments = nudt + sidt*randn(NRepl, NSteps) + LogPaths = apply(cbind(matrix(log(S0)*matrix(1,NRepl,1)),Increments),2,cumsum) + SPaths = exp(LogPaths) + SPaths[,1] = S0 + return(SPaths) +} +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} +Paths = AssetPathsV(50,0.1,0.3,1,100,1000) + +N = dim(Paths)[2] +for (i in 1:N){ + plot(Paths[,i],type = 'l') +} + +tic() +AssetPaths(50,0.1,0.3,1,100,1000) +toc() + +tic() +AssetPathsV(50,0.1,0.3,1,100,1000) +toc() \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.3/Page_436_StopLoss.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.3/Page_436_StopLoss.R new file mode 100644 index 00000000..b6c4024f --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.3/Page_436_StopLoss.R @@ -0,0 +1,63 @@ +require(pracma) +require(tictoc) +StopLoss <- function(S0,K,mu,sigma,r,T,Paths) { + NRepl = dim(Paths)[1] + NSteps = dim(Paths)[2] + NSteps = NSteps - 1 + # true number of steps + Cost = matrix(0,NRepl,1) + dt = T/NSteps + DiscountFactors = exp(-r*(seq(0,NSteps,1)*dt)) + for (k in 1:NRepl){ + CashFlows = matrix(0,NSteps+1,1) + if (Paths[k,1] >= K){ + Covered = 1 + CashFlows[1] = -Paths[k,1] + } else { + Covered = 0 + } + for (t in 2:(NSteps+1)){ + if ((Covered == 1) & (Paths[k,t] < K)){ + # Sell + Covered = 0 + CashFlows[t] = Paths[k,t] + } else if ((Covered == 0) & (Paths[k,t] > K)){ + # Buy + Covered = 1 + CashFlows[t] = -Paths[k,t] + } + } + if (Paths[k,NSteps + 1] >= K){ + # Option is exercised + CashFlows[NSteps + 1] = CashFlows[NSteps + 1] + K + } + Cost[k] = - dot(DiscountFactors,CashFlows) + } + return(mean(Cost)) +} +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} +S0 = 50 +K = 50 +mu = 0.1 +sigma = 0.4 +r = 0.05 +T = 5/12 +NRepl =100000 +NSteps = 10 +set.seed(39473) +Paths=AssetPaths(S0,mu, sigma,T,NSteps,NRepl) +tic() +StopLoss(S0,K,mu,sigma,r,T,Paths) +toc() \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.4/Page_437_StopLossV.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.4/Page_437_StopLossV.R new file mode 100644 index 00000000..721c4d5a --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.4/Page_437_StopLossV.R @@ -0,0 +1,83 @@ +require(pracma) +require(tictoc) +StopLoss <- function(S0,K,mu,sigma,r,T,Paths) { + NRepl = dim(Paths)[1] + NSteps = dim(Paths)[2] + NSteps = NSteps - 1 + # true number of steps + Cost = matrix(0,NRepl,1) + dt = T/NSteps + DiscountFactors = exp(-r*(seq(0,NSteps,1)*dt)) + for (k in 1:NRepl){ + CashFlows = matrix(0,NSteps+1,1) + if (Paths[k,1] >= K){ + Covered = 1 + CashFlows[1] = -Paths[k,1] + } else { + Covered = 0 + } + for (t in 2:(NSteps+1)){ + if ((Covered == 1) & (Paths[k,t] < K)){ + # Sell + Covered = 0 + CashFlows[t] = Paths[k,t] + } else if ((Covered == 0) & (Paths[k,t] > K)){ + # Buy + Covered = 1 + CashFlows[t] = -Paths[k,t] + } + } + if (Paths[k,NSteps + 1] >= K){ + # Option is exercised + CashFlows[NSteps + 1] = CashFlows[NSteps + 1] + K + } + Cost[k] = - dot(DiscountFactors,CashFlows) + } + return(mean(Cost)) +} +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} +S0 = 50 +K = 50 +mu = 0.1 +sigma = 0.4 +r = 0.05 +T = 5/12 +NRepl =100000 +NSteps = 10 +set.seed(39473) +Paths=AssetPaths(S0,mu, sigma,T,NSteps,NRepl) + +StopLossV <- function(S0,K,mu,sigma,r,T,Paths) { + NRepl = dim(Paths)[1] + NSteps = dim(Paths)[2] + NSteps = NSteps - 1 + Cost = matrix(0,NRepl,1) + CashFlows = matrix(0,NRepl,NSteps+1) + dt = T/NSteps + DiscountFactors = exp(-r*(seq(0,NSteps,1))*dt) + OldPrice = cbind(matrix(0,NRepl,1), Paths[,1:NSteps]) + UpTimes = which(OldPrice < K & Paths >= K) + DownTimes = which(OldPrice >= K & Paths < K) + CashFlows[UpTimes] = -Paths[UpTimes] + CashFlows[DownTimes] = Paths[DownTimes] + ExPaths = which(Paths[,NSteps+1] >= K) + CashFlows[ExPaths,NSteps+1] = CashFlows[ExPaths,NSteps+1] + K + Cost = -CashFlows %*%(matrix(DiscountFactors)) + return(mean(Cost)) +} + +tic() +StopLossV(S0,K,mu,sigma,r,T,Paths) +toc() \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.5/Page_438_DeltaHedging.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.5/Page_438_DeltaHedging.R new file mode 100644 index 00000000..9de3232f --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.5/Page_438_DeltaHedging.R @@ -0,0 +1,87 @@ +f<-function(T, Path){ + BS_EC(S0 = Path,K = K,r = r,sigma = sigma,T = T)['delta'] +} +require(OptionPricing) +DeltaHedging <- function(S0,K,mu,sigma,r,T,Paths) { + NRepl = dim(Paths)[1] + NSteps = dim(Paths)[2] + NSteps = NSteps - 1 + Cost = matrix(0,NRepl,1) + CashFlows = matrix(0,1,NSteps+1) + dt = T/NSteps + DiscountFactors = exp(-r*(seq(0,NSteps,1)*dt)) + for (i in 1:NRepl){ + Path = Paths[i,] + Position = 0 + Deltas = matrix() + for (k in 1:NSteps){ + Deltas[k] = f(T = T-(k-1)*dt, Path = Path[k]) + } + for (j in 1:NSteps){ + CashFlows[j] = (Position - Deltas[j])*Path[j] + Position = Deltas[j] + } + if (Path[NSteps+1] > K){ + CashFlows[NSteps+1] = K - (1-Position)*Path[NSteps+1] + } else { + CashFlows[NSteps+1] = Position*Path[NSteps+1] + } + Cost[i] = -CashFlows %*% DiscountFactors + } + return(mean(Cost)) +} + +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} + +StopLossV <- function(S0,K,mu,sigma,r,T,Paths) { + NRepl = dim(Paths)[1] + NSteps = dim(Paths)[2] + NSteps = NSteps - 1 + Cost = matrix(0,NRepl,1) + CashFlows = matrix(0,NRepl,NSteps+1) + dt = T/NSteps + DiscountFactors = exp(-r*(seq(0,NSteps,1))*dt) + OldPrice = cbind(matrix(0,NRepl,1), Paths[,1:NSteps]) + UpTimes = which(OldPrice < K & Paths >= K) + DownTimes = which(OldPrice >= K & Paths < K) + CashFlows[UpTimes] = -Paths[UpTimes] + CashFlows[DownTimes] = Paths[DownTimes] + ExPaths = which(Paths[,NSteps+1] >= K) + CashFlows[ExPaths,NSteps+1] = CashFlows[ExPaths,NSteps+1] + K + Cost = -CashFlows %*%(matrix(DiscountFactors)) + return(mean(Cost)) +} + +S0 = 50 +K = 52 +mu = 0.1 +sigma = 0.4 +r = 0.05 +T = 5/12 +NRepl =10000 +NSteps = 10 +C = BS_EC(K = K, r = r, sigma = sigma, T = T, S0 = S0)['price'] +set.seed(3872) +Paths=AssetPaths(S0,mu,sigma,T,NSteps,NRepl) +True_Price = BS_EC(S0 = S0,K = K,r = r,sigma = sigma,T = T)['price'] +SL = StopLossV(S0,K,mu,sigma,r,T,Paths) +DC = DeltaHedging(S0,K,mu,sigma,r,T,Paths) + +#NSteps = 100 +#set.seed(38232) +#Paths=AssetPaths(S0,mu,sigma,T,NSteps,NRepl) +#True_Price = BS_EC(S0 = S0,K = K,r = r,sigma = sigma,T = T)['price'] +#SL = StopLossV(S0,K,mu,sigma,r,T,Paths) +#DC = DeltaHedging(S0,K,mu,sigma,r,T,Paths) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.6/Page_442_WienerBridge.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.6/Page_442_WienerBridge.R new file mode 100644 index 00000000..81d84c10 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.6/Page_442_WienerBridge.R @@ -0,0 +1,54 @@ +WienerBridge <- function(T, NSteps) { + NBisections = log2(NSteps) + if (round(NBisections) != NBisections){ + cat('ERROR in WienerBridge: NSteps must be a power of 2','\n') + return + } + WSamples = matrix(0,NSteps+1,1) + WSamples[1] = 0 + WSamples[NSteps+1] = sqrt(T)*rnorm(1) + TJump = T + IJump = NSteps + for (k in 1:NBisections){ + left = 1 + i = IJump/2 + 1 + right = IJump + 1 + for (j in 1:(2^(k-1))){ + a = 0.5*(WSamples[left] + WSamples[right]) + b = 0.5*sqrt(TJump) + WSamples[i] = a + b*rnorm(1) + right = right + IJump + left = left + IJump + i = i + IJump + } + IJump = IJump/2 + TJump = TJump/2 + } + return(WSamples) +} + + +# CheckBridge.m +set.seed(3826) +NRepl = 100000 +T = 1 +NSteps = 4 +WSamples = matrix(0,NRepl, 1+NSteps) +for (i in 1:NRepl){ + WSamples[i,] =WienerBridge(T, NSteps) +} +a <- function(X) { + mean(X) +} +b <- function(X) { + sqrt(var(X)) +} +m = matrix() +sdev = matrix() +for (z in 2:(1+NSteps)){ + m[z-1] = a(WSamples[,z]) + sdev[z-1] = b(WSamples[,z]) +} +m +sdev +sqrt((1:NSteps)*T/NSteps) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.7/Page_444_Exchange.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.7/Page_444_Exchange.R new file mode 100644 index 00000000..a310d1a1 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.7/Page_444_Exchange.R @@ -0,0 +1,17 @@ +require(lmom) +Exchange <- function(V0,U0,sigmaV,sigmaU,rho,T,r) { + sigmahat = sqrt(sigmaU^2 + sigmaV^2 - 2*rho*sigmaU*sigmaV) + d1 = (log(V0/U0) + 0.5*T*sigmahat^2)/(sigmahat*sqrt(T)) + d2 = d1 - sigmahat*sqrt(T) + p = V0*cdfnor(d1) - U0*cdfnor(d2) + return(p) +} + +VO = 50 +UO = 60 +sigmaV = 0.3 +sigmaU = 0.4 +rho = 0.7 +T = 5/12 +r = 0.05 +Exchange(VO ,UO, sigmaV, sigmaU, rho, T ,r) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.8/Page_445_ExchangeMC.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.8/Page_445_ExchangeMC.R new file mode 100644 index 00000000..b3b170bc --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.8/Page_445_ExchangeMC.R @@ -0,0 +1,32 @@ +require(fBasics) +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} +f <- function(r,T,VT,UT) { + exp(-r*T)*max(VT-UT, 0) +} +ExchangeMC <- function(V0,U0,sigmaV,sigmaU,rho,T,r,NRepl) { + eps1 = rnorm(NRepl) + eps2 = rho*eps1 + sqrt(1-rho^2)*rnorm(NRepl) + VT = V0*exp((r - 0.5*sigmaV^2)*T + sigmaV*sqrt(T)*eps1) + UT = U0*exp((r - 0.5*sigmaU^2)*T + sigmaU*sqrt(T)*eps2) + DiscPayoff = matrix() + for(i in 1:length(VT)){ + DiscPayoff[i] = f(r,T,VT[i],UT[i]) + } + parameter_estimation<-.normFit(DiscPayoff) + ci<-norm.interval(DiscPayoff) + return(c(parameter_estimation,ci)) +} +VO = 50 +UO = 60 +sigmaV = 0.3 +sigmaU = 0.4 +rho = 0.7 +T = 5/12 +r = 0.05 +NRepl = 200000 +ExchangeMC(VO,UO,sigmaV,sigmaU,rho,T,r,NRepl) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.9/Page_446_DOPutMC.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.9/Page_446_DOPutMC.R new file mode 100644 index 00000000..203ed038 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH8/EX8.9/Page_446_DOPutMC.R @@ -0,0 +1,41 @@ +require(OptionPricing) +AssetPaths <- function(S0,mu,sigma,T,NSteps,NRepl) { + SPaths = matrix(0,NRepl, 1+NSteps) + SPaths[,1] = S0 + dt = T/NSteps + nudt = (mu-0.5*sigma^2)*dt + sidt = sigma*sqrt(dt) + for (i in 1:NRepl){ + for (j in 1:NSteps){ + SPaths[i,j+1]=SPaths[i,j]*exp(nudt + sidt*rnorm(1)) + } + } + return(SPaths) +} +norm.interval = function(data, variance = var(data), conf.level = 0.95) { + z = qnorm((1 - conf.level)/2, lower.tail = FALSE) + xbar = mean(data) + sdx = sqrt(variance/length(data)) + c(xbar - z * sdx, xbar + z * sdx) +} +DOPutMC<-function(S0,K,r,T,sigma,Sb,NSteps,NRepl){ + # Generate asset paths + Call = BS_EC(S0,K,r,T,sigma) + Put = BS_EP(S0,K,r,T,sigma) + Payoff = matrix(0,NRepl,1) + NCrossed = 0 + for (i in 1:NRepl){ + Path=AssetPaths(S0,r,sigma,T,NSteps,1) + crossed = any(Path <= Sb) + if (crossed == 0){ + Payoff[i] = max(0, K - Path[NSteps+1]) + } else{ + Payoff[i] = 0 + NCrossed = NCrossed + 1 + } + } + parameter_estimation<-.normFit(exp(-r*T) * Payoff) + ci<-norm.interval(exp(-r*T) * Payoff) + return(c(parameter_estimation,ci)) +} +DOPutMC(50,50,0.1,2/12,0.4,40,60,50000) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.3/Page_479_EuPutExpl.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.3/Page_479_EuPutExpl.R new file mode 100644 index 00000000..f8ba5024 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.3/Page_479_EuPutExpl.R @@ -0,0 +1,36 @@ +require(pracma) + +EuPutExpl<-function(S0,K,r,T,sigma,Smax,dS,dt){ + # set up grid and adjust increments if necessary + M = round(Smax/dS) + dS = Smax/M + N = round(T/dt) + dt = T/N + matval = matrix(0,M+1,N+1) + vetS = seq(0,Smax,length=M+1) + veti = 0:M + vetj = 0:N + # set up boundary conditions + for (k in 1:(M+1)){ + matval[k,N+1] = max(K-vetS[k],0) + } + matval[1,] = K*exp(-r*dt*(N-vetj)) + matval[M+1,] = 0 + # set up coefficients + a = 0.5*dt*(sigma^2*veti - r)*veti + b = 1- dt*(sigma^2*veti^2 + r) + c = 0.5*dt*(sigma^2*veti + r)*veti + # solve backward in time + for (j in N:1){ + for (i in 2:M){ + matval[i,j] = a[i]*matval[i-1,j+1] + b[i]*matval[i,j+1]+ c[i]*matval[i+1,j+1] + } + } + # return price, possibly by linear interpolation outside the grid + price = interp1(vetS, matval[,1], S0) + return(price) +} +EuPutExpl(50,50,0.1,5/12,0.4,100,2,5/1200) +EuPutExpl(50,50,0.1,5/12,0.3,100,2,5/1200) +EuPutExpl(50,50,0.1,5/12,0.3,100,1.5,5/1200) +EuPutExpl(50,50,0.1,5/12,0.3,100,1,5/1200) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.4/Page_484_EuPutImpl.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.4/Page_484_EuPutImpl.R new file mode 100644 index 00000000..7e229c08 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.4/Page_484_EuPutImpl.R @@ -0,0 +1,38 @@ +require(pracma) + +EuPutImpl<-function(S0,K,r,T,sigma,Smax,dS,dt){ + # set up grid and adjust increments if necessary + M = round(Smax/dS) + dS = Smax/M + N = round(T/dt) + dt = T/N + matval = matrix(0,M+1,N+1) + vetS = seq(0,Smax,length=M+1) + veti = 0:M + vetj = 0:N + # set up boundary conditions + for (k in 1:(M+1)){ + matval[k,N+1] = max(K-vetS[k],0) + } + matval[1,] = K*exp(-r*dt*(N-vetj)) + matval[M+1,] = 0 + # set up the tridiagonal coefficients matrix + a = 0.5*(r*dt*veti-sigma^2*dt*(veti^2)) + b = 1+sigma^2*dt*(veti^2)+r*dt + c = -0.5*(r*dt*veti+sigma^2*dt*(veti^2)) + zero<-matrix(0,1,M-1) + coeff = (diag(c(0,a[3:M],0)))[1:M-1,2:M] + diag(b[2:M]) + (rbind(diag(c[2:M-1]),zero))[2:M,1:(M-1)] + L = lu(coeff)$L + U = lu(coeff)$U + # solve the sequence of linear systems + aux = matrix(0,M-1,1) + for (j in N:1){ + aux[1] = - a[2] * matval[1,j] + # other term from BC is zero + matval[2:M,j] = solve(U,(solve(L,(matval[2:M,j+1] + aux)))) + } + # return price, possibly by linear interpolation outside the grid + price = interp1(vetS, matval[,1], S0) + return(price) +} +EuPutImpl(50,50,0.1,5/12,0.4,100,0.5,5/2400) diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.5/Page_487_DOPutCK.R b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.5/Page_487_DOPutCK.R new file mode 100644 index 00000000..6f85d23d --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/CH9/EX9.5/Page_487_DOPutCK.R @@ -0,0 +1,36 @@ +require(pracma) + +DOPutCK<-function(S0,K,r,T,sigma,Sb,Smax,dS,dt){ + # set up grid and adjust increments if necessary + M = round((Smax-Sb)/dS) + dS = (Smax-Sb)/M + N = round(T/dt) + dt = T/N + matval = matrix(0,M+1,N+1) + vetS = seq(Sb,Smax,length = M+1) + veti = vetS / dS + vetj = 0:N + # set up boundary conditions + for (k in 1:(M+1)){ + matval[k,N+1] = max(K-vetS[k],0) + } + matval[1,] = 0 + matval[M+1,] = 0 + # set up the coefficients matrix + alpha = 0.25*dt*( sigma^2*(veti^2) - r*veti) + beta = -dt*0.5*( sigma^2*(veti^2) + r ) + gamma = 0.25*dt*( sigma^2*(veti^2) + r*veti ) + zero<-matrix(0,1,M-1) + M1 = -(diag(c(0,alpha[3:M],0)))[1:M-1,2:M] + diag(1-beta[2:M]) - (rbind(diag(gamma[2:M-1]),zero))[2:M,1:(M-1)] + L = lu(M1)$L + U = lu(M1)$U + M2 = (diag(c(0,alpha[3:M],0)))[1:M-1,2:M] + diag(1+beta[2:M]) + (rbind(diag(gamma[2:M-1]),zero))[2:M,1:(M-1)] + # solve the sequence of linear systems + for (j in N:1){ + matval[2:M,j] = solve(U,solve(L,(M2%*%matval[2:M,j+1]))) + } + # return price, possibly by linear interpolation outside the grid + price = interp1(vetS, matval[,1], S0) + return(price) +} +DOPutCK(50,50,0.1,5/12,0.4,40,100,0.5,1/120) \ No newline at end of file diff --git a/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/README.txt b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/README.txt new file mode 100644 index 00000000..9cb7e7c8 --- /dev/null +++ b/Numerical_Methods_In_Finance_And_Economics:_A_Matlab-Based_Introduction_by_Paolo_Brandimarte/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Bhushan Sahadeo Manjarekar +Course: Be Electronics And Telecommunications Engineering +Branch: Others +College/Institute/Organization: University Of Mumbai + +About The Book + +Book: Numerical Methods In Finance And Economics: A Matlab-based Introduction +Author: Paolo Brandimarte +Publisher: John Wiley & Sons, Inc., Hoboken, New Jersey +Year Of Publication: 2006 +ISBN: 0471745030 +Edition: 2 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH10/EX10.1/Ex10_1.R b/Numerical_Methods_by_E_Balaguruswamy/CH10/EX10.1/Ex10_1.R new file mode 100644 index 00000000..1dfe5184 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH10/EX10.1/Ex10_1.R @@ -0,0 +1,30 @@ +# Example 1 Chapter 10 Page no.: 326 +# Straight Line fitting + +x<-c(1,2,3,4,5) # Define table +y<-c(3,4,5,6,8) +#Square of X values +x2<-x^2 +#Product of X and Y +xy<-x*y +#Sum of X +sx<-sum(x) +#Sum of y +sy<-sum(y) +#Sum of x^2 +sx2<-sum(x2) +#Sum of x*y +sxy<-sum(xy) +# number of elements +n =5 +# calculating slope +b <- ((n*sxy) -(sx*sy))/((n*sx2)-(sx^2)) +# calculating intercept +a <- (sy)/n - (b*(sx))/n + +cat("The Linear equation y=",a,"+",b,"x") + +#Plotting curve and fitting the Straight line +plot(x,y) + +abline(a=a,b=b) diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.5/Ex11_5.R b/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.5/Ex11_5.R new file mode 100644 index 00000000..78868bc6 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.5/Ex11_5.R @@ -0,0 +1,39 @@ +# Example 5 Chapter 11 Page no.: 358 +# Estimating velocity + +T <- c(5,6,7,8,9) # Time +S <- c(10.0,14.5,19.5,25.5,32.0) # Distance + +#distance time function +ss <- function(t1){ + s <- S[t1-4] + return(s) +} + +#Difference value h +h1 <- 1 + +# We have velocity as the first derivative of distance +v <- function(t,h){ + return(((-3*ss(t))+(4*ss(t+h))-ss(t+2*h))/(2*h)) +} + +#First given time is 5s +t2 <- 5 +cat("Velocity of car at t=5s is",v(t2,h1),"km/s") + +# Central difference formula gives +vcf <- function(t,h){ + return((ss(t+h)-ss(t-h))/(2*h)) +} +#second time given is 7s +t3 <- 7 +cat("Velocity of car at t=",t3,"s is",vcf(t3,h1),"km/s") + +# Backward diffeerence formula +vb <- function(t,h){ + return(((3*ss(t))-(4*ss(t-h))+ss(t-2*h))/(2*h)) +} +#Third given time is 9s +t4 <- 9 +cat("Velocity of car at t=",t4,"s is",vb(t4,h1),"km/s") \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.6/Ex11_6.R b/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.6/Ex11_6.R new file mode 100644 index 00000000..fb55e716 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.6/Ex11_6.R @@ -0,0 +1,25 @@ +# Example 6 Chapter 11 Page no.: 359 +# Estimating Acceleration + +T <- c(5,6,7,8,9) # Time +S <- c(10.0,14.5,19.5,25.5,32.0) # Distance + +#distance time function +ss <- function(t1){ + s <- S[t1-4] + return(s) +} + +#Difference value h +h1 <- 1 + +#Acceleration is given by second derivative of distance + +a <- function(t,h){ + return((ss(t+h)-(2*ss(t))+ss(t-h))/(h^2)) +} + +h1 <- 1 +t1 <- 7 # given time + +cat("Acceleration of car at t=",t1,"s is",a(t1,h1),"km/s^2") \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8/Ex11_8.R b/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8/Ex11_8.R new file mode 100644 index 00000000..fad41028 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8/Ex11_8.R @@ -0,0 +1,40 @@ +# Example 8 Chapter 11 Page no.: 364 +# Richardson Extrapolation + +f <- function(x){ + return(exp(x)) +} +h1<- 0.5 +r1 <- 1/2 +x1<- 0.5 + +#First order forward difference formula +D1 <- function(x,h) { + return((f(x+h) - f(x-h))/(2*h)) +} + +Dr1 <- function(x,r,h){ + return((f(x+(r*h)) - f(x-(r*h)))/(2*r*h)) +} + +f1 <- function(x,r,h){ + return((Dr1(x,r,h)-(r^2)*D1(x,h))/(1-(r^2))) +} +F <- signif(f1(x1,r1,h1), digits = 5) + +cat("The value of function e^x at",x1," with parameters") +cat("h=",h1) +cat("r=",r1) +cat("is",F) + +# The value deviates slighly from the value of the textbook becaues of approximation in the text + +r2 <- 2 +F1 <- signif(f1(x1,r2,h1), digits = 5) + +cat("The value of function e^x at",x1," with parameters") +cat("h=",h1) +cat("r=",r2) +cat("is",F1) + +cat(" This shows that estimate with r=",r1,"is better than the estimate with r=",2) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R new file mode 100644 index 00000000..30ce157f --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.10/Ex12_10.R @@ -0,0 +1,22 @@ +# Example 10 Chapter 12 Page no.: 400 +#Gauss-Legendre Three point formula + +# Installing and attaching 'pracma' library +install.packages("pracma") +library("pracma") + +#Gauss-Legendre nodes and weights +f <- function(x) { + (x^4)+1 +} + +# Given values +n1 = 3 +a1 = 2 +b1 = 4 + +cc <- gaussLegendre(n1, a1, b1) +Q <- sum(cc$w * f(cc$x)) +cat("The Gauss-Legendre Three point integral of (x^4)+1 is", Q) + +# The value in the textbook and the calculated value vary slightly due to approximations assumed in textbook. \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.3/Ex12_3.R b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.3/Ex12_3.R new file mode 100644 index 00000000..afc5ab90 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.3/Ex12_3.R @@ -0,0 +1,39 @@ +# Example 3 Chapter 12 Page no.: 381 +# Simpson's 1/3 Rule + +#CASE A + +#Given Function +f <- function(x){ + exp(x) +} + +a1 <- -1 +b1 <- 1 +h1 <- (b1-a1)/2 + +Is <- function(a,b,h){ + return((h/3)*(f(a)+f(b)+4*f((a+b)/2))) +} + +Is1 <- Is(a1,b1,h1) +cat("The Integrant value of e^x between -1 and 1 is", Is1) + + +#CASE B + +#Given function +ff <- function(x){ + sqrt(sin(x)) +} + +a2 <- 0 +b2 <- pi/2 +h2 <- (b2-a2)/2 + +Isp <- function(k,l,m){ + return((m/3)*(ff(k)+ff(l)+4*ff((k+l)/2))) +} + +Is2 <- Isp(a2,b2,h2) +cat("The Integrant value of sqrt(sin(x)) between 0 and pi/2 is", Is2) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.5/Ex12_5.R b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.5/Ex12_5.R new file mode 100644 index 00000000..eb7c657d --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.5/Ex12_5.R @@ -0,0 +1,40 @@ +# Example 5 Chapter 12 Page no.: 386 +#Simpson's 3/8 Rule + +#CASE A +#Given Function +f <- function(x){ + return((x^3)+1) +} + +a1 <- 1 +b1 <- 2 +h1 <- (b1-a1)/3 #Since there are 4 sampling points the value of n is 3 + +# Simpson's 3/8 function + +Is <- function(a,b,h){ + return(((3*h)/8)*(f(a)+f(b)+(3*f((a+h)))+(3*f((a+(2*h)))))) +} + +Is1 <- Is(a1,b1,h1) +cat("The Integrant value of (x^3)+1 between 1 and 2 is", Is1) + +# CASE B +# Given Function +ff <- function(x){ + return(sqrt(sin(x))) +} + +a2 <- 0 +b2 <- pi/2 +h2 <- (b2-a2)/3 #Since there are 4 sampling points the value of n is 3 + +# Simpson's 3/8 function + +IS <- function(a,b,h){ + return(((3*h)/8)*(ff(a)+ff(b)+(3*ff((a+h)))+(3*ff((a+(2*h)))))) +} + +IS1 <- IS(a2,b2,h2) +cat("The Integrant value of sqrt(sin(x)) between 0 and pi/2 is", signif(IS1, digits = 6)) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.6/Ex12_6.R b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.6/Ex12_6.R new file mode 100644 index 00000000..c2fa7c5e --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.6/Ex12_6.R @@ -0,0 +1,20 @@ +# Example 6 Chapter 12 Page no.: 387 +#Boole's five point Formula + +#Given function +f <- function(x){ + sqrt(sin(x)) +} + +a1 <- 0 +b1 <- pi/2 +h1 <- (b1-a1)/4 #Since there are 5 sampling points the value of n is 4 + +# Boole's function + +Bl <- function(a,b,h){ + return(((2*h)/45)*((7*f(a))+(7*f(b))+(32*f(a+h))+(12*f(a+(2*h)))+(32*f(a+(3*h))))) +} + +BL1 <- Bl(a1,b1,h1) +cat("The Boole integrant value of sqrt(sin(x)) between 0 and pi/2 is", signif(BL1, digits = 6)) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.7/Ex12_7.R b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.7/Ex12_7.R new file mode 100644 index 00000000..45c19d99 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.7/Ex12_7.R @@ -0,0 +1,16 @@ +# Example 7 Chapter 12 Page no.: 391 +# Romberg Estimation + +# Installing and importing 'pracma' library +install.packages("pracma") +library("pracma") + +#Given function +f <- function(x){ + return(1/x) +} + +#Romberg function +u <- romberg(f,1 ,2) + +cat("The value of Romberg integration of 1/x is",u$value,"and relative error is",u$rel.error,"completed in",u$iter,"iterations" ) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.8/Ex12_8.R b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.8/Ex12_8.R new file mode 100644 index 00000000..a7d66c5d --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.8/Ex12_8.R @@ -0,0 +1,17 @@ +# Example 8 Chapter 12 Page no.: 397 +#Gauss-Legendre Two point formula + +#Given functions and values +f <- function(x){ + exp(x) +} +a1 <- -1 +b1 <- 1 + +#Gauss-Legendre Two point formula +I <- function(a,b){ + return(f(a/sqrt(3))+f(b/sqrt(3))) +} + +I1 <- I(a1,b1) +cat("The Gauss-Legendre two point integral of exp(x) is", signif(I1, digits = 8)) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.9/Ex12_9.R b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.9/Ex12_9.R new file mode 100644 index 00000000..c6d4b401 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH12/EX12.9/Ex12_9.R @@ -0,0 +1,20 @@ +# Example 9 Chapter 12 Page no.: 398 +#Gaussian Two point formula + +# Installing and attaching 'pracma' library +install.packages("pracma") +library("pracma") + +#Gauss-Legendre nodes and weights +f <- function(x) { + exp(-x/2) +} + +# Given values +n1 = 2 +a1 =-2 +b1 = 2 + +cc <- gaussLegendre(n1, a1, b1) +Q <- sum(cc$w * f(cc$x)) +cat("The Gaussian two point integral of exp(-x/2) is", signif(Q, digits = 9)) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.10/Ex13_10.R b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.10/Ex13_10.R new file mode 100644 index 00000000..320eae02 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.10/Ex13_10.R @@ -0,0 +1,53 @@ +# Example 10 Chapter 13 Page no.: 446 +# Milne-Simpson predictor-corrector method + +#for the solution +cat(" Milne and Simpson method") +h <- 0.25 +y <- c() +x <- c() +x[1] = 1 +y[1] = 2 + +cat("h=",h) +cat("x=",x) +cat("y=",y) + +f <- function(x,y){ + 2 * y / x +} + +#Creating algorithm and displaying +for (i in 2:10) { + + print(signif(y[i-1],3)) + m1 <- f(x[i-1],y[i-1]) + m2 <- f(x[i-1] + 0.5*h, y[i-1] + 0.5*h*m1) + m3 <- f(x[i-1] + 0.5*h, y[i-1] + 0.5*h*m2) + m4 <- f(x[i-1] + h, y[i-1] + h*m3) + x[i] <- x[i-1] + h + y[i] <- y[i-1] + h * (m1 + m4 + 2*m2 + 2*m3) / 6 + + +} + +g <- c() + +for (i in 1:3) { + g[i] <- f(x[i+1],y[i+1]) + print(g[i]) + +} + +#Milne's formula +Y1 <- y[1] + 4*h * (2*g[1] - g[2] + 2*g[3]) /3 +cat("Solution obtained using Milne's method is", Y1,3) + +g[4] <- f(x[5],Y1) +print(g[4]) + +#Simpson formula +Y2 <- y[3] + h * ( g[2] + 4*g[3] + g[4]) /3 +cat("Solution obtained using Simpson's method is", Y2,3) + +#Values are not approximated here ao value slightly differs from the textbook value \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R new file mode 100644 index 00000000..22d907da --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.4/Ex13_4.R @@ -0,0 +1,40 @@ +# Example 4 Chapter 13 Page no.: 420 +# Euler Method + +#for the first solution +cat("Case A:") +h <- 0.5 +x <- 1 +y <- 2 +cat("h=",h) +#Creating algorithm and displaying +for (i in 1:2) { + + dy <- (3 * (x *x)) + 1 + y <- y + (h * dy) + x <- x + h + cat("y(",x,")= ",y,"\n") +} + +#for the second solution +cat("Case B:") +h <- 0.25 +x <- 1 +y <- 2 +cat("h=",h) + +print(x) +print(y) + +#Creating algorithm and displaying +for (i in 1:5) { + + cat("y(",x,")= ",y,"\n") + x <- x + h + dy <- (3 * ((x-h)^2)) + 1 + y <- y + (h * dy) + + +} + +#For Case B, textbook answer is false. \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.6/Ex13_6.R b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.6/Ex13_6.R new file mode 100644 index 00000000..63140ef0 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.6/Ex13_6.R @@ -0,0 +1,43 @@ +# Example 6 Chapter 13 Page no.: 427 +# Heun Method and Euler Method + +#for the solution - Euler method +cat("Case A: Euler's Method") +h <- 0.25 +x <- 1 +y <- 2 +cat("h=",h) +cat("x=",x) +cat("y=",y) + +#Creating euler algorithm and displaying +for (i in 1:5) { + + cat("y(",x,")= ",y,"\n") + x <- x + h + f <- (2 * y / (x-h)) + y <- y + (h * f) + +} + +#for the solution - Heun's method +cat("Case B: Heun's Method") +h <- 0.25 +x <- 1 +y <- 2 +cat("h=",h) + +#Creating heun algorithm and displaying +for (i in 1:4) { + + + f1 <- (2 * y / (x)) + m <- y + h*f1 + f2 <- (2 * m / (x+h)) + y <- y + ((h/2) * (f1 + f2)) + x <- x + h + cat("y(",x,")= ",y,"\n") + +} + +#Values slightly differ but are more precise than what is given in the textbook \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.7/Ex13_7.R b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.7/Ex13_7.R new file mode 100644 index 00000000..f5a9d53e --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.7/Ex13_7.R @@ -0,0 +1,21 @@ +# Example 7 Chapter 13 Page no.: 433 +# Polygon Method + +#for the solution +cat("Polygon Method") +h <- 0.25 +x = 1 +y = 2 +cat("h=",h) +cat("x=",x) +cat("y=",y) + +#Creating algorithm and displaying +for (i in 1:3) { + + cat("y(",x,")= ",signif(y,3),"\n") + f1 <- (2 * y / x) + f2 <- (2 * (y + ( h * f1 / 2 ) ) / (x + ( h / 2 ) )) + x <- x + h + y <- y + (h * f2) +} diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.8/Ex13_8.R b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.8/Ex13_8.R new file mode 100644 index 00000000..40f50985 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH13/EX13.8/Ex13_8.R @@ -0,0 +1,30 @@ +# Example 8 Chapter 13 Page no.: 439 +# Classic Runge Kutta Method + +#for the solution +cat("Classic Runge Kutta Method") +h <- 0.2 +x = 0 +y = 0 + +cat("h=",h) +cat("x=",x) +cat("y=",y) + +#Given Function +f <- function(x,y){ + x^2 + y^2 +} + +#Creating algorithm and displaying +for (i in 1:2) { + + m1 <- f(x,y) + m2 <- f(x + 0.5*h, y + 0.5*h*m1) + m3 <- f(x + 0.5*h, y + 0.5*h*m2) + m4 <- f(x + h, y + h*m3) + x <- x + h + y <- y + h * (m1 + m4 + 2*m2 + 2*m3) / 6 + cat("y(",x,")= ", signif(y,6),"\n") + +} diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6/Ex14_6.R b/Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6/Ex14_6.R new file mode 100644 index 00000000..a8f0c2ac --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6/Ex14_6.R @@ -0,0 +1,25 @@ +# Example 6 Chapter 14 Page no.: 478 +# Power method + +# Include "matlib" library +install.packages("matlib") +library(matlib) + +#Given Matrix +A<-matrix(c(1,2,0,2,1,0,0,0,-1),nrow = 3,ncol = 3,byrow = TRUE) +A +eigen<-powerMethod(A) + +EigenVector<-(eigen$vector[,1]-eigen$vector[3,1]) + +EigenVector<-matrix(EigenVector,nrow = 3,ncol = 1,byrow = TRUE) + +EigenVector<-(EigenVector/EigenVector[1]) #This is Eigen vector Corresponding to largest Eigen Value. + +EigenValue<-eigen$value #This is Largest Eigen Value. + +sprintf("The largest eigen value Lampda1=%g",EigenValue) + +print("The Eigen Vector corresponding to eigen value") + +print(EigenVector) diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.1/Ex3_1.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.1/Ex3_1.R new file mode 100644 index 00000000..30dba568 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.1/Ex3_1.R @@ -0,0 +1,32 @@ +# Example 1 Chapter 3 Page no.: 45 +# Binary number to Decimal + +#Importing 'DescTools' library +#install.packages("DescTools") +library(DescTools) + +a <- 1101 # Integer part of binary number +b <- 0.1101 # Decimal part of binary number + +# conversion of Decimal part of binary +f <- function(x){ + length(gregexpr("[[:digit:]]", as.character(x))[[1]]) +} + +k <- f(b) -1 +A <- ((b %% 1)*(10^k)) +# Converting into vector +A <- as.numeric(strsplit(as.character(A), "")[[1]]) +m <- length(A) +d <- 0.5 +p1 <- c() +for (i in 1:(m+1)) { + p <- signif(A[i]*d, digits = 10) + p1[i] <- p + p <- sum(p1, na.rm = TRUE) + d <- d*0.5 +} + +D <- p + BinToDec(a) + +cat(" The Decimal equivalent of 1101.1101 is",D) diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.10/Ex3_10.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.10/Ex3_10.R new file mode 100644 index 00000000..c8973134 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.10/Ex3_10.R @@ -0,0 +1,12 @@ +# Example 10 Chapter 3 Page no.: 52 +# Floating point notation + +x <- 0.00596 +y <- 65.7452 +z <- -486.8 + +cat(x,"is expressed as 0.596*10^(-2)") + +cat(y,"is expressed as 0.657452*10^(2)") + +cat(z,"is expressed as -0.4868*10^(3)") \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.11/Ex3_11.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.11/Ex3_11.R new file mode 100644 index 00000000..8d21e8a1 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.11/Ex3_11.R @@ -0,0 +1,12 @@ +# Example 11 Chapter 3 Page no.: 53 +# Integer Arithmetics + +a <- 25 +b <- 12 + +cat("Addition :",a,"+",b,"=",a+b) +cat("Subtraction :",a,"-",b,"=",a-b) +cat(" :",b,"-",a,"=",b-a) +cat("Multiplication :",a,"x",b,"=",a*b) +cat("Division :",a,"/",b,"=",as.integer(a/b)) +cat("Division :",b,"/",a,"=",as.integer(b/a)) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.12/Ex3_12.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.12/Ex3_12.R new file mode 100644 index 00000000..90b861a7 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.12/Ex3_12.R @@ -0,0 +1,18 @@ +# Example 12 Chapter 3 Page no.: 53 +# Aritmetic rule + +cat(" Let a=5,b=7 and c=3") + +a=5 +b=7 +c=3 + +k <- (a+b)/c +j <- as.integer(a/c)+as.integer(b/c) + +if(k != j){ + cat("(a+b)/c =",k,"\nWhich is not equal to (a/c)+(b/c)=",j) + cat(". \nThus, this Arithmetic rule fails.") +}else{ + cat("Both the results are same") +} \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.2/Ex3_2.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.2/Ex3_2.R new file mode 100644 index 00000000..617ac2bc --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.2/Ex3_2.R @@ -0,0 +1,6 @@ +# Example 2 Chapter 3 Page no.: 46 +# COnversion of Hexadecimal number to Decimal number + +x<-'12af' #input value +a<-strtoi(x,16L) +cat("The Hex number 12AF is",a,"in Decimal system") \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.4/Ex3_4.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.4/Ex3_4.R new file mode 100644 index 00000000..a414df5a --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.4/Ex3_4.R @@ -0,0 +1,8 @@ +# Example 4 Chapter 3 Page no.: 48 +# COnversion of Decimal number to Octal number + +x<-163 +a<-as.octmode(x) +cat("The number 163 is ") +a +cat("in Octal system") diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R new file mode 100644 index 00000000..e1dfbb14 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R @@ -0,0 +1,21 @@ +# Example 6 Chapter 3 Page no.: 49 +# Octal Number to Hexadecimal + + +oct <- 243 # Octal number +decimalNumber <- 0 +i=0 + +#Algorithm for Conversion of octal to decimal +while(oct != 0) +{ + decimalNumber = decimalNumber + (oct %% 10)*(8^i) + i =i+1 + oct = as.integer(oct/10) +} + +H <- as.hexmode(decimalNumber[1]) + +cat("The number 243 in Octal system is") +H +cat("in Hexadecimal system.") diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.8/Ex3_8.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.8/Ex3_8.R new file mode 100644 index 00000000..4fdb5091 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.8/Ex3_8.R @@ -0,0 +1,12 @@ +# Example 8 Chapter 3 Page no.: 50 +# COnversion of integer to Binary + + +x <- -13 + +install.packages("binaryLogic") +library("binaryLogic") + +y <- as.binary(x, size=0.7, n=0, logic=FALSE) + +cat("The integer",x,"can be represented as",print(y),"in binary format") diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.9/Ex3_9.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.9/Ex3_9.R new file mode 100644 index 00000000..605a63de --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.9/Ex3_9.R @@ -0,0 +1,12 @@ +# Example 9 Chapter 3 Page no.: 51 +# COnversion of integer to 16 bit Binary + + +x <- -32768 + +install.packages("binaryLogic") +library("binaryLogic") + +y <- as.binary(x, size=2, n=0, logic=FALSE) + +cat("The integer",x,"can be represented as",print(y),"in 16 Bit binary format") diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.10/Ex4_10.R b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.10/Ex4_10.R new file mode 100644 index 00000000..b2d8c768 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.10/Ex4_10.R @@ -0,0 +1,35 @@ +# Example 10 Chapter 4 Page no.: 77 +# Error propagation + +# Given Values +x <- 2.35 +y <- 6.74 +z <- 3.45 + +#Given Arithmetic operation +w <- x*y +z + +#Roundoff error in x,y &z +erx <- 5E-3 +ery <- 5E-3 +erz <- 5E-3 + +cat("Roundoff error in x,y &z is",erx,",",ery,"&",erz) + +#Error in x,y&z + +ex <- x*erx +ey <- y*ery +ez <- z*erz +cat("Error in x=",ex) +cat("Error in y=",ey) +cat("Error in z=",ez) + +# Error in x*y +exy <- x*ey + y*ex +cat("Absolute Error in x*y=",exy) + +# Absolute error in computing w +ew <- exy + ez +cat("Absolute error in computing w=",ew) + diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.3/Ex4_3.R b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.3/Ex4_3.R new file mode 100644 index 00000000..328cea79 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.3/Ex4_3.R @@ -0,0 +1,29 @@ +# Example 3 Chapter 4 Page no.: 64 +# Error in Conversion + +# Given Binary values +x0.1 <- 0.00011001 +x0.4 <- 0.01100110 + +#length of number +f <- function(x){ + length(gregexpr("[[:digit:]]", as.character(x))[[1]]) +} + +S <- x0.4 + x0.1 +k <- f(S) -1 +A <- ((S %% 1)*(10^k)) +# Converting into vector +A <- as.numeric(strsplit(as.character(A), "")[[1]]) +m <- length(A) +d <- 0.5 +p1 <- c() +for (i in (m+1):1) { + p <- signif(A[i]*d, digits = 10) + p1[i] <- p + p <- sum(p1, na.rm = TRUE) + d <- d*0.5 +} +cat("The decimal obtained when summing the binary is:",p) +cat("But the true value is 0.5 when 0.4 and 0.1 are added together.") +cat("Error:",0.5-p) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.4/Ex4_4.R b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..9da6415f --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,17 @@ +# Example 4 Chapter 4 Page no.: 66 +# Roundoff error + +x <- 752.6835 #Given value + +tx1 <- 0.7526*(10^3) #using 4 mantissa to store value +tx2 <- 0.835*(10^-1) #using 4 mantissa to store value + +Tx <- tx1+tx2 # True value + +cat("CHOPPING METHOD") +cat("Approximate x=",tx1,"\n Error=",tx2) + +cat("Symmetric Rounding") +cat("Error = (g(x)-1)*(10^-1) \n"," =",(tx2*10 -1)*10^-1) + +cat("Approximate x=0.7527*(10^3)") \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.5/Ex4_5.R b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..ef801a79 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,31 @@ +# Example 5 Chapter 4 Page no.: 68 +# Truncation error + +install.packages("pracma") +library("pracma") + +x <- 1/5 + +# Numerical Error function +e <- function(x,n){ + E <- 0 + for (i in n:6) { + E <- E + (x^i)/fact(i) + } + return(E) +} +cat(" CASE A:") +n1 <-3 +cat("When first 3 terms are added n=",n1) +cat("Truncation error =", e(x,n1)) + +cat(" CASE B:") +n2 <-4 +cat("When first",n2,"terms are added, n=",n2) +cat("Truncation error =", e(x,n2)) + +cat(" CASE C:") +n3 <-5 +cat("When first",n3,"terms are added n=",n3) +cat("Truncation error =", e(x,n3)) + diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.6/Ex4_6.R b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.6/Ex4_6.R new file mode 100644 index 00000000..0cd4e14e --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.6/Ex4_6.R @@ -0,0 +1,31 @@ +# Example 6 Chapter 4 Page no.: 68 +# Truncation error + +install.packages("pracma") +library("pracma") + +x <- -(1/5) + +# Numerical Error function +e <- function(x,n){ + E <- 0 + for (i in n:6) { + E <- E + (x^i)/fact(i) + } + return(E) +} +cat(" CASE A:") +n1 <-3 +cat("When first 3 terms are added n=",n1) +cat("Truncation error =", e(x,n1)) + +cat(" CASE B:") +n2 <-4 +cat("When first",n2,"terms are added, n=",n2) +cat("Truncation error =", e(x,n2)) + +cat(" CASE C:") +n3 <-5 +cat("When first",n3,"terms are added n=",n3) +cat("Truncation error =", e(x,n3)) + diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.7/Ex4_7.R b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.7/Ex4_7.R new file mode 100644 index 00000000..949c7046 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.7/Ex4_7.R @@ -0,0 +1,33 @@ +# Example 7 Chapter 4 Page no.: 71 +# Absolute and Relative Error + +# Height of building as measured +H1 <- 2950 +cat("Height of building as measured by Civil engineer =",H1,"cm.") + +#True Height of Building +H2 <- 2945 +cat("True Height of Building=",H2,"cm.") + +# Height of each beam as measured +B1 <- 35 +cat("Height of each beam as measured by Civil engineer=",B1,"cm.") + +# True Height of beam +B2 <- 30 +cat("True Height of beam",B2,"cm.") + +#Absolute error in measuring building height +e1 <- H1-H2 +cat("Absolute error in measuring building height=",e1,"cm") + +#Relative error +er1 <- signif((e1/H2)*100, digits = 2) +cat("Relative error in measuring building height",er1,"%") + +#Absolute error in measuring Beam height +e2 <- B1-B2 +cat("Absolute error in measuring Beam height=",e2,"cm") +#Relative error +er2 <- signif((e2/B2)*100, digits = 2) +cat("Relative error in measuring Beam height",er2,"%") diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.9/Ex4_9.R b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.9/Ex4_9.R new file mode 100644 index 00000000..dcc46913 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH4/EX4.9/Ex4_9.R @@ -0,0 +1,28 @@ +# Example 9 Chapter 4 Page no.: 75 +# Error propagation + +# Given Values +x <- 0.1234E4 +y <- 0.1232E4 + +#Given Arithmetic operation +z <- x-y + +#Roundoff error in x & y +erx <- 0.5E-3 +ery <- 0.5E-3 +cat("Roundoff error in x & y is",erx,"&",ery) +#Absolute Error in x & y +ex <- x*erx +ey <- y*ery +cat("Absolute Error in x=",ex) +cat("Absolute Error in y=",ey) + +# Absolute error in computing z +ez <- ex+ey +cat("Absolute error in computing z=",ez) + + +#Relative Error in computing z +Erz <- (ez/z)*100 +cat("Relative Error in computing z is",Erz,"%.") diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.1/Ex6_1.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.1/Ex6_1.R new file mode 100644 index 00000000..59b7fac0 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.1/Ex6_1.R @@ -0,0 +1,22 @@ +# Example 1 Chapter 6 Page no.: 126 +# Initial Guess Value + +#Given Polynomial +f <- function(x){ + 2*(x^4)-8*(x^2)+2*x+12 +} + +n1 <- 4 +a1 <- c(12,2,-8,2) +x1 <- -a1[3]/2 + +cat("The Maximum possible root is",x1) + +#Function to find root intervals +f1 <-function(a,n){ + xMax <- sqrt(((a[n-1]/a[n])^2)-2*(a[n-2]/a[n])) +} + +mr <- f1(a1,n1) + +cat(" Real roots lie in the interval (",-mr,",",mr,").") diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.11/Ex6_11.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.11/Ex6_11.R new file mode 100644 index 00000000..f36ea8e8 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.11/Ex6_11.R @@ -0,0 +1,21 @@ +# Example 11 Chapter 6 Page no.: 161 +# Fixed point method + +# Installing and importing package 'spuRs' +install.packages("spuRs") +library("spuRs") + +#Given function when converted in terms of 'x' +f <- function(x){ + 2-(x^2) +} +cat("Let initial value be 0") +x0 <- 0 + +F1 <- fixedpoint(f,x0) +cat("Root is",F1) + +cat(" Let us assume x0=-1") +x0 <-1 +F2 <- fixedpoint(f,x0) +cat("Another Root is",F2) diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R new file mode 100644 index 00000000..9c9499fa --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R @@ -0,0 +1,46 @@ +# Example 12 Chapter 6 Page no.: 162 +# Fixed point method Convergence and Divergence + +# Installing and importing package 'spuRs' +install.packages("spuRs") +library("spuRs") + +#Given function when converted in terms of 'x' +f <- function(x){ + 5/x +} +cat("Let initial value be 1") +x0 <- 1 + +F1 <- fixedpoint(f,x0) +cat("This type of divergence is called OSCILLATORY DIVERGENCE") + +cat(" Let us assume another function x=(x^2)+x-5") +f1 <- function(x){ + (x^2)+x-5 +} +cat("Let initial value be 0") +x0 <- 0 +F2 <- fixedpoint(f1,x0) + +cat("This type of divergence is called MONOTONE DIVERGENCE as it diverges rapidly") + +#********************************************* + +# Error May occour when calculating convergence on f1. +# It is due to rapid divergance. + +#********************************************* + +cat(" Let us assume another function 2x=(5/x)+x") +f3 <- function(x){ + (x+(5/x))/2 +} +cat("Let initial value be 1") +x0 <- 1 +F3 <- fixedpoint(f3,x0) + +cat("This time the function converges rapidly") +cat("The square root of 5 is",signif(F3,digits = 5)) + + diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.14/Ex6_14.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.14/Ex6_14.R new file mode 100644 index 00000000..554c0ecf --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.14/Ex6_14.R @@ -0,0 +1,37 @@ +# Example 14 Chapter 6 Page no.: 172 +# Newton-Raphson Method for system of nonlinear equations + + +#First function +u <- function(x,y) { + x^2+x*y-6 +} +#Second function +v <- function(x,y) { + (x^2)-(y^2) -3 +} + +#Initial values +x=1 +y=1 + +#Error +e<-c(100, 100) + +#Computing roots +while (e[1]>0.00001 & e[2]>0.00001){ + J=matrix(data = c(2*x+y, x, 2*x, -2*y),nrow = 2,ncol = 2,byrow = TRUE) + deter=det(J) + u1=u(x,y) + v1=v(x,y) + x=x-((u1*J[2,2]-v1*J[1,2])/deter) + y=y-((v1*J[1,1]-u1*J[2,1])/deter) + e[1]=abs(2-x) + e[2]=abs(3-y) +} + +Roots<-c(x, y) +cat("Value of x converges to",Roots[1]) +cat("Value of y converges to",Roots[2]) + +#Only 2 iterations has been shown in the textbook. diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.15/Ex6_15.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.15/Ex6_15.R new file mode 100644 index 00000000..3e21417a --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.15/Ex6_15.R @@ -0,0 +1,22 @@ +# Example 15 Chapter 6 Page no.: 176 +# Finding Quotient polynomial + +#Given Functon +p <- function(x){ + (x^3)-7*(x^2)+15*x-9 +} + +a <- c() +b <- c() +# It is given that p(x)=(x-3)q(x) +x1 <-3 +a[4] <- 1 +a[3] <- -7 +a[2] <-15 +a[1] <--9 +b[4] <- 0 +for (i in 4:2) { + b[i-1] = a[i] + x1*b[i] +} + +cat("The required polynomial q(x) is",b[3],"*x^2",b[2],"*x +",b[1],"=0") \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.16/Ex6_16.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.16/Ex6_16.R new file mode 100644 index 00000000..9324bde3 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.16/Ex6_16.R @@ -0,0 +1,48 @@ +# Example 16 Chapter 6 Page no.: 187 +# Bairstow's method + +#Given function +f <- function(x) { + (x^3)+x+10 +} + +#Given values +u= 1.8 +v= -1 + +es=1 +#% +n=4 + +count=1 + +ear=100 +eas=100 + +a<-c(10,1,0,1) +b<-matrix(0,n) +c<-matrix(0,n) + +while ((ear>es) & (eas>es)){ + b[n]=a[n] + b[n-1]=a[n-1]+u*b[n] + for (i in seq(n-2,1,-1)){ + b[i]=a[i]+u*b[i+1]+v*b[i+2] + } + c[n]=b[n] + c[n-1]=b[n-1]+u*c[n] + for (i in seq((n-2),2,-1)){ + c[i]=b[i]+u*c[i+1]+v*c[i+2] + } +dv=((-b[1])+(b[2]*c[2]/c[3]))/(c[3]-(c[4]*c[2]/c[3])) +du=(-b[2]-c[4]*dv)/c[3] +u=u+du +v=v+dv +ear=abs(du/u)*1000 +eas=abs(dv/v)*1000 +cat("Iteration:",count,"\n u: ",u,"\n","v:",v,"\n","************************************\n") +count=count+1; +} +cat("Final value of Quadratic quotients u & v are:\n","u: ",u,"\n v:",v,"\n","************************************\n") + +# Value in the textbook is of one iteration only and it is clearly given that the final answers are 2 and -5 \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.17/Ex6_17.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.17/Ex6_17.R new file mode 100644 index 00000000..fff9affb --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.17/Ex6_17.R @@ -0,0 +1,39 @@ +# Example 17 Chapter 6 Page no.: 197 +# Muller's method + +#Given function + +f <- function(x) { + return((x^3)+2*(x^2)+10*x-20) + } + +#Initial values +x0=0 +x1=1 +x2=2 + +cat("iteration:",0,"\n","xr:",x2,"************************\n") + +for (i in 1:6){ + h0=x1-x0 + h1=x2-x1 + d0=(f(x1)-f(x0))/(x1-x0) + d1=(f(x2)-f(x1))/(x2-x1) + a=(d1-d0)/(h1+h0) + b=a*h1+d1 + c=f(x2) + d=(b^2 - 4*a*c)^0.5 + if (abs(b+d)>abs(b-d)){ + x3=x2+((-2*c)/(b+d)) + }else { + x3=x2+((-2*c)/(b-d)) + } + x0=x1 + x1=x2 + x2=x3 + cat("iteration:",i,"\n") + cat("Value:", signif(x2,digits = 9) ,"\n") + cat("************************\n") +} + +cat("The value of the function stablized at",i,"th iteration and was found to be",signif(x2,digits=9)) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.4/Ex6_4.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.4/Ex6_4.R new file mode 100644 index 00000000..63473184 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.4/Ex6_4.R @@ -0,0 +1,41 @@ +# Example 4 Chapter 6 Page no.: 132 +# Bisection Method + +#Given Function +f <- function(x) { + (x^2)-(4*x)-10 +} + +curve(f, xlim=c(-3,3), col='blue', lwd=2, lty=2) +abline(h=0) +abline(v=0) + +#Values are chosen where curver crosses the x axis +x1=-2 +x2=-1 + +#using bisection method +cat("BISECTION METHOD:") +xr=(x1+x2)/2 +cat("Iteration:",1,"\n","xl:",x1,"\n","xu:",x2,"\n","xr:",xr,"\n","****************************************\n") + +for (i in 2:7){ + if (f(x1)*f(xr)>0){ + x1=xr + xr=(x1+x2)/2 + } else if (f(x1)*f(xr)<0){ + x2=xr + xr=(x1+x2)/2 + } + + if (f(x1)*f(xr)==0){ + break + } + cat("Iteration:",i,"\n") + cat("xl:",x1,"\n") + cat("xu:",x2,"\n") + cat("xr:",xr,"\n") + cat("****************************************\n") +} + +# The slight variation in answer is due to approximation \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.5/Ex6_5.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.5/Ex6_5.R new file mode 100644 index 00000000..eb9d2313 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.5/Ex6_5.R @@ -0,0 +1,37 @@ +# Example 5 Chapter 6 Page no.: 140 +# False Position Method + +#Given Function +f <- function(x) { + (x^2)-(x)-2 +} + +# Given Values +x1=1 +x2=3 + +# False Position Function + +xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1)) +cat("Iteration:",1,"\n","xl:",x1,"\n","xu:",x2,"\n","*************************") + +for (i in 2:11){ + if (f(x1)*f(xr)>0){ + x1=xr + xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1)) + } + else if (f(x1)*f(xr)<0){ + x2=xr + xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1)) + } + if (f(x1)*f(xr)==0){ + break + } + cat("Iteration:",i,"\n") + cat("xlow:",x1,"\n") + cat("xup: ",x2,"\n") + cat("xcur:",xr,"\n") + cat("*************************\n") +} + +cat("After",i,"th iteration","the root approximation stablized and the root is",xr) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.7/Ex6_7.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.7/Ex6_7.R new file mode 100644 index 00000000..8212cef0 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.7/Ex6_7.R @@ -0,0 +1,54 @@ +# Example 7 Chapter 6 Page no.: 147 +# Newton-Raphson Method + +install.packages("numDeriv") +library("numDeriv") + +# Given Function +u <- function(x) { + x^2-3*x+2 +} + +curve(u, xlim=c(-5,5), col='blue', lwd=2, lty=2, ylab='f(x)') +abline(h=0) +abline(v=0) + +# From the curve the points in the vicinity are noted +a <- 0 +b <-1 + +newton.raphson <- function(f, a, b, tol = 1e-5, n = 1000) { + require(numDeriv) # Package for computing f'(x) + + x0 <- a # Set start value to supplied lower bound + k <- n # Initialize for iteration results + + # Check the upper and lower bounds to see if approximations result in 0 + fa <- f(a) + if (fa == 0.0) { + return(a) + } + + fb <- f(b) + if (fb == 0.0) { + return(b) + } + + for (i in 1:n) { + dx <- genD(func = f, x = x0)$D[1] # First-order derivative f'(x0) + x1 <- x0 - (f(x0) / dx) + k[i] <- x1 + # Checking difference between values + if (abs(x1 - x0) < tol) { + root.approx <- tail(k, n=1) + res <- list('root approximation' = root.approx, 'iterations' = k) + return(res) + } + # If Newton-Raphson has not yet reached convergence set x1 as x0 and continue + x0 <- x1 + } + print('Too many iterations in method') +} + +N <- newton.raphson(u, a, b) +cat("The root closer to the point x=0 is",N) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH7/EX7.1/Ex7_1.R b/Numerical_Methods_by_E_Balaguruswamy/CH7/EX7.1/Ex7_1.R new file mode 100644 index 00000000..31f25f49 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH7/EX7.1/Ex7_1.R @@ -0,0 +1,12 @@ +# Example 1 Chapter 7 Page no.: 211 +# Solving System of Equations + +#Define Sysytem of Equations in Matrix form +A<-matrix(c(3,2,1,2,3,2,1,2,3),nrow = 3,ncol = 3,byrow = TRUE) +A +b<-matrix(c(10,14,14),nrow = 3,ncol = 1) +b + +k <- solve(A,b) +cat("Solution:\n x=",k[1],"\n y=",k[2],"\n z=",k[3]) + diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH7/EX7.5/Ex7_5.R b/Numerical_Methods_by_E_Balaguruswamy/CH7/EX7.5/Ex7_5.R new file mode 100644 index 00000000..58ded1ad --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH7/EX7.5/Ex7_5.R @@ -0,0 +1,29 @@ +# Example 5 Chapter 7 Page no.: 234 +# Dolittle Algorithm + +#import 'matrixcalc' library +install.packages("matrixcalc") +library(matrixcalc) + +#Define system of equations in matrix form +A<-matrix(c(3,2,1,2,3,2,1,2,3),nrow = 3,ncol = 3,byrow = TRUE) +A +B<-matrix(c(10,14,14),nrow = 3,ncol = 1) +B + +#LU Decomposition +luA<-lu.decomposition(A) +L<-luA$L +L +U<-luA$U +U + +z1<-B[1] +z2<-B[2]-L[2,1]*z1 +z3<-B[3]-L[3,1]*z1-L[3,2]*z2 + +#By Back Substitution we get, +x3=z3/(U[3,3]) +x2=(z2-U[2,3]*x3)/U[2,2] +x1=(z1-U[1,2]*x2-U[1,3]*x3)/U[1,1] +sprintf("Values of x1, x2 and x3 are %f,%f and %f",x1,x2,x3) diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.1/Ex8_1.R b/Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.1/Ex8_1.R new file mode 100644 index 00000000..86ec80bc --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.1/Ex8_1.R @@ -0,0 +1,19 @@ +# Example 1 Chapter 8 Page no.: 254 +# Jacobi Iteration Method + +# Installing and importing 'pracma' library +install.packages("pracma") +library("pracma") + +#System of equations in matrix form +A1 <- matrix(c(2,1,1,3,5,2,2,1,4), nrow = 3, byrow = T) +B1 <- c(5,15,8) + +#Jacobi method +C <- c() +C <- itersolve(A1, B1, x0 = NULL, nmax = 4, tol = 1e-05 , method = "Jacobi") +cat("The values given in the text is only upto 4 iterations, which are:", C[["x"]]) + +C1 <- c() +C1 <-itersolve(A1, B1, x0 = NULL, nmax = 1000, tol = 1e-05 , method = "Jacobi") +cat("The final solution after",C1[["iter"]],"iterations are:", C1[["x"]]) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.2/Ex8_2.R b/Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.2/Ex8_2.R new file mode 100644 index 00000000..759154a8 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.2/Ex8_2.R @@ -0,0 +1,19 @@ +# Example 2 Chapter 8 Page no.: 261 +# Gauss-Seidel Iteration + +# Installing and importing 'pracma' library +install.packages("pracma") +library("pracma") + +#System of equations in matrix form +A1 <- matrix(c(2,1,1,3,5,2,2,1,4), nrow = 3, byrow = T) +B1 <- c(5,15,8) + +#Gauss-Siedel method +C <- c() +C <- itersolve(A1, B1, x0 = NULL, nmax = 2, tol = 1e-05 , method = "Gauss-Seidel") +cat("The values given in the text is only upto 2 iterations, which are:", C[["x"]]) + +C1 <- c() +C1 <-itersolve(A1, B1, x0 = NULL, nmax = 1000, tol = 1e-07 , method = "Gauss-Seidel") +cat("The final solution after",C1[["iter"]],"iterations are:", C1[["x"]]) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.3/Ex8_3.R b/Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.3/Ex8_3.R new file mode 100644 index 00000000..ffaee94d --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH8/EX8.3/Ex8_3.R @@ -0,0 +1,16 @@ +# Example 3 Chapter 8 Page no.: 269 +# Gauss-Seidel method + +# Installing and importing 'pracma' library +install.packages("pracma") +library("pracma") + +#System of equations in matrix form +A1 <- matrix(c(3,1,1,-3), nrow = 2, byrow = T) +B1 <- c(5,5) +x1 <- c(0,0) +#Gauss-Siedel method +C1 <- c() +C1 <-itersolve(A1, B1, x0 = x1, nmax = 1000, tol = 1e-04 , method = "Gauss-Seidel") +cat("The final solution after",C1[["iter"]],"iterations are:", C1[["x"]]) +cat("Which can be approximated to x1= 2 and x2= -1") diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.1/Ex9_1.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.1/Ex9_1.R new file mode 100644 index 00000000..9174a43d --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.1/Ex9_1.R @@ -0,0 +1,40 @@ +#Example 1 Chapter 9 Page no.: 277 +# Polynomial Forms + +#Consider the power form of p(x) for n=1, p(x)=a0 + a1*X, + +#Given that p(100)= +3/7, p(101)= -4/7 +p_100= 3/7 +p_101= -4/7 + + +cat(paste(p_100,"is the given p(100) and",p_101,"is the given p(101)")) + + +A<- matrix(c(1,100,1,101), nrow=2,ncol=2, byrow=T) +A +b<-matrix(c(p_100,p_101)) +b +sol= solve(A,b) +a0<-round(sol[1], 1) +a1<-sol[2] +print(paste("a0 is :",a0 )) +print(paste("a1 is :",a1 )) + +#comparing calculated value with given ones +print("power form equation : ") +substitute(a0+a1*x, list(a0=sol[1], a1=sol[2])) + +#substitue x=100 +x1<-100 +substitute(a0+a1*x, list(a0=a0, a1=a1, x=x1)) +New_p100 = a0 + (a1*x1) +#substitute x=101 +x2<-101 +substitute(a0+a1*x, list(a0=a0, a1=a1, x=x2)) +New_p101= a0 + (a1*x2) + +cat(paste(signif(New_p100,5),"is the new p(100) and", signif(New_p101,5),"is the new p(101)")) + + + diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.11/Ex9_11.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.11/Ex9_11.R new file mode 100644 index 00000000..31463be2 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.11/Ex9_11.R @@ -0,0 +1,24 @@ +#Example 11 Chapter 9 Page no.: 306 +#Cubic splines + +#Installing and importing library 'pracma' +install.packages("pracma") +library("pracma") + +#Given Data +mydata<-data.frame(i= c(0,1,2), + xi= c(4,9,16), + fi= c(2,3,4), +stringsAsFactors = TRUE + +) +mydata + +x<-mydata$xi +f<-mydata$fi + +#function to find spline at xi +C <- signif(cubicspline(x, f, xi = 7),5) + +cat("Cubic spline of f(7) is :",C) + diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.12/Ex9_12.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.12/Ex9_12.R new file mode 100644 index 00000000..715cf2d7 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.12/Ex9_12.R @@ -0,0 +1,22 @@ +#Example 12 Chapter 9 Page no.: 313 +#Estimating Function values using Cubic splines. + +#Installing and importing library 'pracma' +install.packages("pracma") +library("pracma") + +#Given Data +mydata<-data.frame(i= c(0,1,2,3), + xi= c(1,2,3,4), + fi= c(0.5, 0.3333, 0.25, 0.20), + stringsAsFactors = TRUE +) +mydata + +x<-mydata$xi +f<-mydata$fi + +#function to find spline at xi +C <- signif(cubicspline(x, f, xi = 2.5),5) + +cat("Cubic spline of f(2.5) is :",C) \ No newline at end of file diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.2/Ex9_2.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.2/Ex9_2.R new file mode 100644 index 00000000..a7267959 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.2/Ex9_2.R @@ -0,0 +1,40 @@ +#Example 2 Chapter 9 Page no.: 278 +# Shifted Power form + +#p(x)= a0+ a1(x-C) + +print("Given: ") +C=100 +p_100= 3/7 +p_101= -4/7 +#solving for x=100 and x=101 +x1=100 +x2=101 + +substitute(a0+a1(x-Centre), list(Centre=C)) + +A<-matrix(c(1,(x1-C),1,c(x2-C)),nrow=2,ncol=2,byrow=T ) +A +b<-matrix(c(p_100,p_101)) +b +sol<-solve(A,b) + +a0=sol[1] +a1=sol[2] + +substitute(a0+ a1*(x-Centre), list(a0=a0,a1=a1,Centre=C)) +#solving for new equations +New_p100<- a0+ a1*(x1-C) +cat("New p(100) is: ", signif(New_p100,5)) +New_p101<- a0+ a1*(x2-C) +cat("New p(101) is: ", signif(New_p101,5)) + +#Verifiying the new polynomial values obtained with older values") +all.equal(New_p100,p_100) +all.equal(New_p101,p_101) + + + + + + diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.3/Ex9_3.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.3/Ex9_3.R new file mode 100644 index 00000000..11388f7a --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.3/Ex9_3.R @@ -0,0 +1,29 @@ +#Example 3 Chapter 9 Page no.: 280 +#Determining square root using linear interpolation + + +#GIven table +mydata<- data.frame(x=c(1,2,3,4,5), + fx=c(sqrt(1), sqrt(2), sqrt(3), sqrt(4), sqrt(5)), + stringsAsFactors = TRUE +) +mydata + +val<-mydata$x +fun<-mydata$fx + +#since 2.5 lie between 2 & 3; +var=2.5 +x1<- val[2] +x2<- val[3] +f1<- fun[2] +f2<- fun[3] + +Ans<- signif(f1 + (var-x1)*((f2-f1)/(x2-x1)),5) +cat("Calculated square root of 2.5 is :", Ans) + +Original<- signif(sqrt(var),5) +cat("Original square root of 2.5 is :", Original) + +error<- Original-Ans +cat("Error is :", error) diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.4/Ex9_4.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.4/Ex9_4.R new file mode 100644 index 00000000..68eda725 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.4/Ex9_4.R @@ -0,0 +1,38 @@ +#Example 4 Chapter 9 Page no.: 282 +#Determining square root using Lagrange's interpolation + +#Given Table +mydata<- data.frame(x=c(1,2,3,4,5), + fx=c(sqrt(1), sqrt(2), sqrt(3), sqrt(4), sqrt(5)), + stringsAsFactors = TRUE +) +mydata + +val<-mydata$x +fun<-mydata$fx + +x0<-val[2] +x1<-val[3] +x2<-val[4] + +f0<-fun[2] +f1<-fun[3] +f2<-fun[4] + +var=2.5 + +I0<- ((var-x1)*(var-x2))/((x0-x1)*(x0-x2)) +I0 +I1<- ((var-x0)*(var-x2))/((x1-x2)*(x1-x0)) +I1 +I2<-((var-x0)*(var-x1))/((x2-x0)*(x2-x1)) +I2 + +Ans<- signif((f0*I0) + (f1*I1) + (f2*I2),5) +cat("Calculated square root of 2.5 is :", Ans) + +Original<- signif(sqrt(var),5) +cat("Original square root of 2.5 is :", Original) + +error<- Original-Ans +cat("Error is :", error) diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.5/Ex9_5.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.5/Ex9_5.R new file mode 100644 index 00000000..1813dcb5 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.5/Ex9_5.R @@ -0,0 +1,39 @@ +#Example 5 Chapter 9 Page no.: 283 +#Lagrange's Polynomial + +# Installing and importing required packages + +install.packages("polynom") +install.packages("stats") +library("polynom") +library("stats") + +#Given data +mydata<- data.frame( i=c(0,1,2,3), + xi=c(0,1,2,3), + ex=c(0,1.7183,6.3891,19.0855), + + stringsAsFactors = TRUE +) +mydata + +q<-poly.calc(mydata$xi, mydata$ex) #function to calculate lagrange interpolation polynomial +q +beta<-coef(q) #obtain coefficients +beta +y1<-beta[2] +y2<-beta[3] +y3<-beta[4] + +#substituting x=1.5 in above equation : +x=1.5 +uno<-x +cube<-x*x*x +square<-x*x + +pot<-(y3*cube)+ (y2*square) + (y1*uno) +pot +Ans<- pot+1 + +cat("Value of e^1.5 is :", signif(Ans,5)) + diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.8/Ex9_8.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.8/Ex9_8.R new file mode 100644 index 00000000..af1fb019 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.8/Ex9_8.R @@ -0,0 +1,58 @@ +#Example 8 Chapter 9 Page no.: 297 +#Newton-Gregory forward difference formula + +#Given Data +mydata<- data.frame(t=c(10,20,30,40,50), + s=c(0.1736, 0.3420, 0.5000, 0.6428, 0.7660), + stringsAsFactors = TRUE +) +mydata + +theta<-mydata$t +sin<- mydata$s +s0<-sin[1] +s1<-sin[2] +s2<-sin[3] +s3<-sin[4] +s4<-sin[5] + +x0<-theta[1] +x1<-theta[2] +x2<-theta[3] +x3<-theta[4] +x4<-theta[5] + +h=x1-x0 +h + +x=25 +a1<- (x-x0)/h #for forward interpolation ,start from top +a2<- (x-x1)/h +a3<- (x-x2)/h +a4<- (x-x3)/h + +f1<-s1-s0 +f2<-s2-s1 +f3<-s3-s2 +f4<-s4-s3 +delta1<- f2-f1 +delta2<- f3-f2 +delta3<- f4-f3 + +get1<-delta1-delta2 +get2<-delta2-delta3 + +last<- get2-get1 + +p1<- s0+ a1*(f1)/1 +p1 +p2<- p1+ a1*a2*(delta1)/2 +p2 +p3<- p2+ a1*a2*a3*(get1) +p3 +p4<- p3+ a1*a2*a3*a4*(last) +p4 + +cat("using Newton-Gregory forward difference formula value of sin(25) was obtained to be :",p4) + +#Differed value in textbook is due to approximation upto 4 decimal places. diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.9/Ex9_9.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.9/Ex9_9.R new file mode 100644 index 00000000..ee3dd35e --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.9/Ex9_9.R @@ -0,0 +1,61 @@ +#Example 9 Chapter 9 Page no.: 299 +#Newton-Gregory backward difference formula + +#Given Data +mydata<- data.frame(t=c(10,20,30,40,50), + s=c(0.1736, 0.3420, 0.5000, 0.6428, 0.7660), + stringsAsFactors = TRUE +) +mydata + +theta<-mydata$t +sin<- mydata$s +s0<-sin[1] +s1<-sin[2] +s2<-sin[3] +s3<-sin[4] +s4<-sin[5] + +x0<-theta[1] +x1<-theta[2] +x2<-theta[3] +x3<-theta[4] +x4<-theta[5] + +h=x1-x0 +h + +x=25 +a1<- (x-x4)/h #for backward interpolation ,start from bottom +a2<- (x-x3)/h +a3<- (x-x2)/h +a4<- (x-x1)/h +a5<- (x-x0)/h + +f1<-s1-s0 +f2<-s2-s1 +f3<-s3-s2 +f4<-s4-s3 +delta1<- f2-f1 +delta2<- f3-f2 +delta3<- f4-f3 + +get1<-delta1-delta2 +get2<-delta2-delta3 + +last<- get2-get1 + +p1<- s4+ a1*(f4)/1 +p1 +p2<- p1+ a1*a2*(delta3)/2 +p2 +p3<- p2+ a1*a2*a3*(get2) +p3 +p4<- p3+ a1*a2*a3*a4*(last) +p4 + +cat("using Newton-Gregory Backward difference formula value of sin(25) was obtained to be :",p4) + +#Differed value in textbook is due to approximation upto 4 decimal places. + + diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.3.1/10.3.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.3.1/10.3.1.R new file mode 100644 index 00000000..c078e953 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.3.1/10.3.1.R @@ -0,0 +1,13 @@ +##Chapter 10 : Travelling Salesman Problem +##Example 3-1 : Page 438 + +#TSP library +library("TSP") +#Distance matrix +dij<-matrix(c(Inf,10,3,6,9,5,Inf,5,4,2,4,9,Inf,7,8,7,1,3,Inf,4,3,2,6,5,Inf),nrow=5,byrow = T) +#making a asymetric TSP instance +atsp<-ATSP(dij) +#Solve TSP +d=solve_TSP(atsp,method = "nearest_insertion",control = list(start,"1")) +d +d[1:5] diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.3.2/10.3.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.3.2/10.3.2.R new file mode 100644 index 00000000..548ea6ea --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.3.2/10.3.2.R @@ -0,0 +1,13 @@ +##Chapter 10 : Travelling Salesman Problem +##Example 3-2 : Page 441 + +#TSP library +library("TSP") +#Distance matrix +dij<-matrix(c(Inf,13,21,26,10,Inf,29,20,30,20,Inf,5,12,30,7,Inf),nrow=4,byrow = T) +#making a asymetric TSP instance +atsp<-ATSP(dij) +#Solve TSP +d=solve_TSP(atsp,method = "nearest_insertion",control = list(start,"1")) +d +d[1:4] diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.4.1/10.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.4.1/10.4.1.R new file mode 100644 index 00000000..0e155049 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH10/EX10.4.1/10.4.1.R @@ -0,0 +1,21 @@ +##Chapter 10 : Travelling Salesman Problem +##Example 3-1 : Page 443 + +#Distance matrix +dij<-matrix(c(Inf,120,220,150,210,120,Inf,100,110,130,220,80,Inf,160,185,150,Inf,160,Inf,190,210,130,185,Inf,Inf),nrow=5,byrow = T) +#Source node +source=3 +#All edges leading to 3 has infinite length +dij[,3]=Inf +tour<-source +##Nearest neighbour heuristic +for(i in 1:4){ + #choose nearest neighbour to the node + mini<-which.min(dij[source,]) + #add it to the tour + tour<-c(tour,mini) + #make it as the source for next iteration + source=mini + #set all edges leading to current node as Inf + dij[,mini]=Inf +} \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH11/EX11.1.1/11.1.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH11/EX11.1.1/11.1.1.R new file mode 100644 index 00000000..80ee532d --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH11/EX11.1.1/11.1.1.R @@ -0,0 +1,24 @@ +##Chapter 11 : Deterministic Dynamic Programming +##Example 1-1 : Page 461 + +#Create a matrix with all Inf +d<-matrix(Inf,7,7) +#Add edge weights/lengths +d[8]=7;d[15]=8;d[22]=5;d[30:32]=c(12,8,7);d[38:39]=c(9,13);d[47:48]=c(9,6) +#Dynamic algorithm for Shortest path algorithm +ShortestDistance<-function(node,stage){ + + index<-which(d[1:7,node]!=Inf) + #if it is node 1 at stage 2, return 1 + if(c(1) %in% index & stage==2){ + return(d[1,node]) + #else return the minimum distance of all possible nodes from current node + }else{ + dist<-numeric() + for(i in 1:length(index)){ + dist[i]<-(min(d[index[i],node]+ShortestDistance(index[i],stage-1))) + } + return(min(dist)) + } +} +ShortestDistance(7,4) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.2.1/12.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.2.1/12.2.1.R new file mode 100644 index 00000000..e4aef1fc --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.2.1/12.2.1.R @@ -0,0 +1,19 @@ +##Chapter 12 : Deterministic Inventory Modelling +##Example 2-1 : Page 493 + +##Natural gas consumption details +d<-matrix(c(100,110,90,70,65,50,40,42,56,68,88,95,110,125,98,80,60,53,44,45,63,77,92,99,90,100, + 88,79,56,57,38,39,60,70,82,90,121,130,95,90,70,58,41,44,70,80,95,100,109,119,99,75, + 68,55,43,41,65,79,88,94,130,122,100,85,73,58,42,43,64,75,80,101,115,100,103,90,76, + 55,45,40,67,78,98,97,130,115,100,95,80,60,49,48,64,85,96,105,125,100,94,86,79,59,46, + 39,69,90,100,110,87,80,78,75,69,48,39,41,50,70,88,93),byrow=T,ncol=12) +#row and coloumn names +rownames(d)<-1990:1999 +colnames(d)<-month.abb + +#assigns mean,standards deviation and median to a dataframe +tmp <- do.call(data.frame, + list(mean = apply(d, 2, mean), + sd = apply(d, 2, sd), + median = apply(d, 2, median))) +rbind(d,t(tmp)) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.3.1/12.3.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.3.1/12.3.1.R new file mode 100644 index 00000000..ea66a218 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.3.1/12.3.1.R @@ -0,0 +1,20 @@ +##Chapter 12 : Deterministic Inventory Modelling +##Example 3-1 : Page 495 + +#input parametres +D=100 +K=100 +h=0.02 +L=12 +#optimal quantity +y=sqrt(2*K*D/h) + +print(paste("EOQ =",y,"units")) +#cycle length +t=y/D +print(paste("Cycle length =",t,"days")) +#number of cycles +L0=L- floor(L/t)*t + +print(paste("Reorder point =",L0*D,"units")) +print(paste("Daily inventory cost = $",(K*D/y)+h*y/2)) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.3.2/12.3.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.3.2/12.3.2.R new file mode 100644 index 00000000..208915b8 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.3.2/12.3.2.R @@ -0,0 +1,25 @@ +##Chapter 12 : Deterministic Inventory Modelling +##Example 3-2 : Page 501 + +#input parameters +D=187.5 +h=0.02 +K=20 +L=2 +c1=3 +c2=2.5 +q=1000 +#optimal quantity +ym=sqrt(2*K*D/h) +#function to calculate the least cost +if(qq){ + Y=q + }else{ + Y=ym + } +} +Y \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.4.1/12.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.4.1/12.4.1.R new file mode 100644 index 00000000..ec8ef590 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH12/EX12.4.1/12.4.1.R @@ -0,0 +1,49 @@ +##Chapter 12 : Deterministic Inventory Modelling +##Example 4-1 : Page 508 + +#Setting up initial cost matrix and other values +cost<-matrix(Inf,8,5) +for(i in 1:4){ + for (j in i:4){ + cost[2*i-1,j]=6 + (j-i)*0.1 + cost[2*i,j]=9 + (j-i)*0.1 + } +} +cost[,5]=0 +totalcost=0 +Regular=c(90,100,120,110) +Overtime=c(50,60,80,70) +Demand=c(100,190,210,160,20) +Supply= c(rbind(Regular,Overtime)) + +#Setting up the resultant table +rown=numeric() +for(i in 1:4){rown=c(rown,paste("R",i,sep = ""),paste("O",i,sep = ""))} +allocation=matrix(0,8,5,dimnames = list(rown,c(1:4,"Surplus"))) + + +for(i in 1:5){ + + while(Demand[i]>0){ + minindex=which.min(cost[,i]) + #if it can still meet the demand + if(Supply[minindex]>0){ + #allocate min of demand or supply + allocation[minindex,i]=min(Demand[i],Supply[minindex]) + #calculate cost + totalcost=totalcost+allocation[minindex,i]*cost[minindex,i] + ##Subtract the allocated form supply and demand + tmp=Demand[i] + Demand[i]=Demand[i]-min(Demand[i],Supply[minindex]) + Supply[minindex]=Supply[minindex]-min(tmp,Supply[minindex]) + cost[minindex,i]=Inf + #else set all cost of that week to Inf so that it doesnt get chosen again + }else{ + cost[minindex,]=Inf + } + + + } +} +allocation +totalcost \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.1/13.1.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.1/13.1.1.R new file mode 100644 index 00000000..352d82c6 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.1/13.1.1.R @@ -0,0 +1,29 @@ +##Chapter 13 : Decision Analysis and Games +##Example 1-1 : Page 527 + +#Setting up input values +LocationC=c(12.9,27.2,59.4) +ReputationC=c(54.5,27.3,18.2) +LocationP=0.17 +ReputationP=0.83 +Criteria=c(LocationP,ReputationP) +#composite weights +Choice=Criteria%*%rbind(LocationC,ReputationC) + +colnames(Choice)<-c("UofA","UofB","UofC") + + +#Setting up the data tree for the particular problem +#If you have trouble installing the package/library, please reinstall R form the following link:https://cran.r-project.org/bin/ +library(data.tree) +SelectAUniversity <- Node$new("Select a University") + Location<-SelectAUniversity$AddChild(paste("Location",LocationP)) + for(child in 1:3){ + Location$AddChild(paste("Uof",LETTERS[child],LocationC[child])) + } + Reputation<-SelectAUniversity$AddChild(paste("Reputation",ReputationP)) + for(child in 1:3){ + Reputation$AddChild(paste("Uof",LETTERS[child],LocationC[child])) + } +print(SelectAUniversity) +print(Choice) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.2/13.1.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.2/13.1.2.R new file mode 100644 index 00000000..d812d7fd --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.2/13.1.2.R @@ -0,0 +1,9 @@ +##Chapter 13 : Decision Analysis and Games +##Example 1-2 : Page 530 + +A=matrix(c(1,0.2,5,1),nrow = 2,byrow = T) +rowMeans(sweep(A,2,colSums(A),`/`)) +AL=matrix(c(1,0.5,0.2,2,1,0.5,5,2,1),nrow = 3,byrow = T) +rowMeans(sweep(AL,2,colSums(AL),`/`)) +AR=matrix(c(1,2,3,0.5,1,1.5,1/3,2/3,1),nrow = 3,byrow = T) +rowMeans(sweep(AR,2,colSums(AR),`/`)) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.3/13.1.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.3/13.1.3.R new file mode 100644 index 00000000..1fa5b825 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.1.3/13.1.3.R @@ -0,0 +1,13 @@ +##Chapter 13 : Decision Analysis and Games +##Example 1-3 : Page 533 + +AL=matrix(c(1,0.5,0.2,2,1,0.5,5,2,1),nrow = 3,byrow = T) +wi=round(rowMeans(sweep(AL,2,colSums(AL),`/`)),3) +nmax=sum(round((AL%*%wi),4)) +#Consistency index +CI=(nmax-3)/2 +#random consistency of A +RI=1.98/3 +#Consistency ratio +CR=CI/RI +CR \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.2.1/13.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.2.1/13.2.1.R new file mode 100644 index 00000000..b9febd4e --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.2.1/13.2.1.R @@ -0,0 +1,12 @@ +##Chapter 13 : Decision Analysis and Games +##Example 2-1 : Page 538 + +CompanyA=c(5000,-2000) +CompanyB=c(1500,500) +#Probability of occurance +POfOccurance=c(0.6,0.4) +#Espected return of stock A and B +ExpectedStockA=POfOccurance%*%CompanyA +ExpectedStockB=POfOccurance%*%CompanyB +ExpectedStockA +ExpectedStockB \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.2.2/13.2.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.2.2/13.2.2.R new file mode 100644 index 00000000..84b9a749 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.2.2/13.2.2.R @@ -0,0 +1,23 @@ +##Chapter 13 : Decision Analysis and Games +##Example 2-2 : Page 544 + +#Probability matrix +CondP=matrix(c(0.9,0.1,0.5,0.5),nrow=2,byrow = T) + +PriorP=c(0.6,0.4) +JointP=CondP*PriorP +AbsP=colSums(JointP) +BayesP=sweep(JointP,2,AbsP,`/`) + +CompanyA=c(5000,-2000) +CompanyB=c(1500,500) + +ExpectedStockAat4=BayesP[,1]%*%CompanyA +ExpectedStockBat5=BayesP[,1]%*%CompanyB +ExpectedStockAat6=BayesP[,2]%*%CompanyA +ExpectedStockBat7=BayesP[,2]%*%CompanyB + +ExpectedStockAat4 +ExpectedStockBat5 +ExpectedStockAat6 +ExpectedStockBat7 \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.3.1/13.3.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.3.1/13.3.1.R new file mode 100644 index 00000000..4429af2b --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.3.1/13.3.1.R @@ -0,0 +1,22 @@ +##Chapter 13 : Decision Analysis and Games +##Example 3-1 : Page 553 + +#Cost matrix +costmatrix<-matrix(c(5,10,18,25,8,7,12,23,21,18,12,21,30,22,19,15),nrow = 4,byrow = T) + +#Laplace criterion +print("Laplace") +P=1/4 +E=rowSums(costmatrix)*P +min(E)*1000 + +#Minimax criterion +print("Minimax") +E=apply(costmatrix,1,max) +min(E)*1000 + +#Savage criterion +print("Savage") +r=sweep(costmatrix,2,apply(costmatrix,2,min)) +E=apply(r,1,max) +min(E) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.4.1/13.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.4.1/13.4.1.R new file mode 100644 index 00000000..70131e0f --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.4.1/13.4.1.R @@ -0,0 +1,13 @@ +##Chapter 13 : Decision Analysis and Games +##Example 4-1 : Page 556 + +#payoff matrix +payoffmatrix=matrix(c(8,-2,9,-3,6,5,6,8,-2,4,-9,5),nrow = 3,byrow = T) + +RowMin=apply(payoffmatrix,1,min) +print("Maximin") +max(RowMin) + +ColMax=apply(payoffmatrix,2,max) +print("Maximin") +min(ColMax) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.4.3/13.4.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.4.3/13.4.3.R new file mode 100644 index 00000000..d5affd5c --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH13/EX13.4.3/13.4.3.R @@ -0,0 +1,24 @@ +##Chapter 13 : Decision Analysis and Games +##Example 4-3 : Page 559 + +#plot an empty graph +plot(1, type="n", axes=F,xlab = "x1", ylab = "x2", xlim = c(-0.5,1.5), ylim = c(-2,7), col = "red", + yaxs= "i", xaxs = "i") + +#Add custom axis on sides 1 and 2 +axis(side = 1,pos = 0,at = seq(0,1,0.25)) +axis(side = 2,pos = 1,at = seq(-2,9,2),padj=3.5) +axis(side = 2,pos = 0,at = seq(-2,9,2)) + +#Add line segments for the constriants +segments (0,6,1,-1,col = "red") +segments (0,4,1,2,col = "yellow") +segments (0,3,1,2,col = "green") +segments (0,2,1,3,col = "blue") +#adding a line segment to indicate the maximum +segments (0.5,0,0.5,2.5,col = "black",lwd = 1.5) +#Adding the name of the constriants on the graph +text(0,4,"B1",pos=4,cex=0.5) +text(0,3,"B2",pos=4,cex=0.5) +text(0,2,"B3",pos=4,cex=0.5) +text(0,6,"B4",pos=4,cex=0.5) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH14/EX14.1.1/14.1.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH14/EX14.1.1/14.1.1.R new file mode 100644 index 00000000..944c588c --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH14/EX14.1.1/14.1.1.R @@ -0,0 +1,20 @@ +##Chapter 14 : Probabilistic Inventory Models +##Example 1-1 : Page 575 + +#Daily demand +D=100 +#standard deviation +dev=10 +#probability of running out of stock +alpha=0.05 +#lead time +L=2 +#average demand during lead time +muL=D*L +#standard deviation of demand during lead time +devL=sqrt((dev**2)*L) +#optimal inventory level for reordering +x=qnorm(0.05,100,10,lower.tail = F) +z=(x-D)/dev +B=devL*z +B \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH14/EX14.2.1/14.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH14/EX14.2.1/14.2.1.R new file mode 100644 index 00000000..351db004 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH14/EX14.2.1/14.2.1.R @@ -0,0 +1,21 @@ +##Chapter 14 : Probabilistic Inventory Models +##Example 2-1 : Page 582 + +#holding cost +h=25 +#penalty cost +p=45 +#critical ratio +CR=p/(p+h) + +D=matrix(c(200,220,300,320,340,0.1,0.2,0.4,0.2,0.1),nrow = 2,byrow = T) + +#The demand is a normal distribuion +print("Case A") +ystar=qnorm(0.643,300,20) + +#The demand is a discrete PDF +print("Case B") +CDF=numeric() +for(i in 1:5){CDF[i]=sum(D[2,1:i])} +rbind(D,CDF) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.2.1/15.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.2.1/15.2.1.R new file mode 100644 index 00000000..4078b9f7 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.2.1/15.2.1.R @@ -0,0 +1,17 @@ +##Chapter 15 : Markov Chain +##Example 2-1 : Page 596 + +#Library expm is needed to get element-wise power of a matrix +library(expm) +P=matrix(c(0.3,0.6,0.1,0.1,0.6,0.3,0.05,0.4,0.55),nrow = 3,byrow = T) +P8=P%^%8 +P16=P%^%16 + +#Steady-state probabilities +a1=c(1,0,0)%*%P +a8=c(1,0,0)%*%P8 +a16=c(1,0,0)%*%P16 + +a1 +a8 +a16 \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.3.1/15.3.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.3.1/15.3.1.R new file mode 100644 index 00000000..de9bea66 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.3.1/15.3.1.R @@ -0,0 +1,8 @@ +##Chapter 15 : Markov Chain +##Example 3-1 : Page 598 + +##Editing mistake in textbook +##The last element of P should be one as (sum over j)(p)=1 for all i +P=matrix(c(0.2,0.5,0.3,0,0.5,0.5,0,0,1),nrow = 3,byrow = T) +library(expm) +P%^%100 \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.3.2/15.3.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.3.2/15.3.2.R new file mode 100644 index 00000000..1ea8c129 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.3.2/15.3.2.R @@ -0,0 +1,14 @@ +##Chapter 15 : Markov Chain +##Example 3-2 : Page 599 + +#transition matrix +P=matrix(c(0,0.6,0.4,0,1,0,0.6,0.4,0),nrow = 3,byrow = T) +library(expm) +#n=2 +P%^%2 +#n=3 +P%^%3 +#n=4 +P%^%4 +#n=5 +P%^%5 \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.4.1/15.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.4.1/15.4.1.R new file mode 100644 index 00000000..019ccbc7 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.4.1/15.4.1.R @@ -0,0 +1,12 @@ +##Chapter 15 : Markov Chain +##Example 4-1 : Page 601 + +#transition matrix +A=matrix(c(0.6,-0.4,0.4,0.1,0.3,-0.45,1,1,1),nrow = 3,byrow = T) +b=c(rep(0,2),1) +#solve the linear equations +pi=solve(A,b) +pi +#mean recurrance time +mu=1/pi +mu \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.4.2/15.4.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.4.2/15.4.2.R new file mode 100644 index 00000000..23617cf3 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.4.2/15.4.2.R @@ -0,0 +1,15 @@ +##Chapter 15 : Markov Chain +##Example 4-2 : Page 602 + +#transition matrix +A=matrix(c(0.6,-0.4,0.4,0.1,0.3,-0.45,1,1,1),nrow = 3,byrow = T) +b=c(rep(0,2),1) + +#solve the linear equations +pi=solve(A,b) +#mean recurrance time +mu=1/pi + +#expected abbual cost of fertilizer +bagsOfFertilizer=c(2,2*1.25,2*1.6) +sum(bagsOfFertilizer*50*pi) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.5.1/15.5.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.5.1/15.5.1.R new file mode 100644 index 00000000..9cd9068f --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.5.1/15.5.1.R @@ -0,0 +1,8 @@ +##Chapter 15 : Markov Chain +##Example 5-1 : Page 606 + +#transition matrix +P=matrix(c(0.3,0.6,0.1,0.1,0.6,0.3,0.05,0.4,0.55),nrow = 3,byrow = T) +N1=P[-1,-1] +#mean first-passage time +mu=solve(diag(2)- N1)%*%rep(1,2) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.6.1/15.6.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.6.1/15.6.1.R new file mode 100644 index 00000000..b93c6644 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH15/EX15.6.1/15.6.1.R @@ -0,0 +1,13 @@ +##Chapter 15 : Markov Chain +##Example 6-1 : Page 610 + +#transition matrix +P=matrix(c(0,0.95,0,0,0.05,0,0.07,0,0.9,0,0.03,0,0,0,0,0.95,0.05,0,0,0,0.07,0,0.03,0.9,0,0,0,0,1,0,0,0,0,0,0,1),nrow=6,byrow = T) +N=P[1:4,1:4] +A=P[1:4,5:6] +#Espexted time of absorption +ExpT=solve(diag(4)-N) +#Pobability of absorption +POfAbsorption=ExpT %*% A +ExpT +POfAbsorption \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.4.1/16.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.4.1/16.4.1.R new file mode 100644 index 00000000..34d3a45b --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.4.1/16.4.1.R @@ -0,0 +1,13 @@ +##Chapter 16 : Queuing Systems +##Example 4-1 : Page 629 + +#birth-rate per day +lambdaday=24*60/12 +#birth-rate per year +lambdayear=lambdaday*365 +#probability of no births during a day +P=((lambdaday*1)^0 * exp(-120*1))/factorial(0) +P +#probability of issuing 50 birth certificate in 3 hrs given that 40 certificates were issued during the first 2 hrs off 3 hr period +P1=((60/12 *1)^10 *exp(-5*1))/factorial(10) +P1 \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.4.2/16.4.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.4.2/16.4.2.R new file mode 100644 index 00000000..71c14f4f --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.4.2/16.4.2.R @@ -0,0 +1,31 @@ +##Chapter 16 : Queuing Systems +##Example 4-1 : Page 632 + +#probability of placing an order in any one day of the week +Pfunction <- function(mu,t,n,Slimit){ + #empty matrix for the table + A<-matrix(0,nrow = 3,ncol = 7) + p0=0 + for(t in 1:7){ + P=p0 + for(n in 1:5){ + P=P+((mu*t)^(Slimit-n) *exp(-mu*t))/factorial(Slimit-n) + } + #appending to the table + A[1,t]=t + A[2,t]=mu*t + A[3,t]=round(P,digits = 4) + } + return(A) +} +Pfunction(3,7,5,18) + +#average number of dozen roses discarded at the end of the week +discardedRoses<-function(N,mu,n,t){ + P=0 + for(i in 1:n){ + P=P+i*((mu*t)^(N-i) * exp(-mu*t))/factorial(N-i) + } + return(P) +} +discardedRoses(18,3,18,7) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.1/16.6.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.1/16.6.1.R new file mode 100644 index 00000000..74777a40 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.1/16.6.1.R @@ -0,0 +1,55 @@ +##Chapter 16 : Queuing Systems +##Example 6-1 : Page 642 + +#Function to calculate p0 +P0<-function(n,servers,temp){ + x=1 + for(i in 1:n){ + if (i<6){ + x=x+(temp^i)/factorial(i) + }else{ + x=x+(temp^i)/(factorial(servers)*servers^(i-servers)) + } + } + return(1/x) +} +p0=P0(8,5,3) +p0 + +#calculate Pn +temp=3 +servers=5 +A=matrix(0,2,8) +for(i in 1:8){ + if (i<6){ + A[1,i]=i + A[2,i]=p0*(3^i)/factorial(i) + }else{ + A[1,i]=i + A[2,i]=p0*(temp^i)/(factorial(servers)*servers^(i-servers)) + } +} +A +#arrival rate +lambda=6 +#arrivals lost +lambdalost=lambda*A[2,8] +lambdalost +#effective arrivals +lamdaeff=lambda-lambdalost +lamdaeff +#average lengths in the systems +Ls=0*p0+sum(1:8*A[2,]) +Ls +#waiting time in the systems +Ws=Ls/lamdaeff +Ws +#average lengths in the queue +Wq=Ws-1/2 +Wq +#average number of occupied spaces +cbar=lamdaeff/2 +cbar +#parking lot utilization +utilization=cbar/servers +utilization \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.2/16.6.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.2/16.6.2.R new file mode 100644 index 00000000..a5e605cc --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.2/16.6.2.R @@ -0,0 +1,16 @@ +##Chapter 16 : Queuing Systems +##Example 6-2 : Page 645 + +#Queueing library to process different queueing models +library(queueing) +#creating a MM1 instance with the following parameters +x=NewInput.MM1(lambda=4, mu=6,n=25) +#Solving the model which returns a list +y=QueueingModel(x) +#probability of each of the n customers in the system +P=y$Pn + +#number of parking spaces such that an arriving car finds a place atleast 90% of times +cummP=numeric() +for(i in 1:length(P)){cummP[i]=sum(P[1:i])} +min(which(cummP > 0.9))-1 \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.4/16.6.4.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.4/16.6.4.R new file mode 100644 index 00000000..7dd734f3 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.4/16.6.4.R @@ -0,0 +1,10 @@ +##Chapter 16 : Queuing Systems +##Example 6-4 : Page 649 + +#Queueing library to process different queueing models +library(queueing) +#creating a MMK instance with the following parameters +x=NewInput.MM1K(lambda=4, mu=6,k=5) +#Solving the model which returns a list +y=QueueingModel(x) +summary(y) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.5/16.6.5.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.5/16.6.5.R new file mode 100644 index 00000000..08a8ddfd --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.5/16.6.5.R @@ -0,0 +1,17 @@ +##Chapter 16 : Queuing Systems +##Example 6-5 : Page 653 + +#Queueing library to process different queueing models +library(queueing) + +#creating a MMc instance with the following parameters +x=NewInput.MMC(lambda=8, mu=5,c=2) +#Solving the model which returns a list +y=QueueingModel(x) +summary(y) + +#creating a MMc instance with the following parameters +x=NewInput.MMC(lambda=16, mu=5,c=4) +#Solving the model which returns a list +y=QueueingModel(x) +summary(y) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.6/16.6.6.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.6/16.6.6.R new file mode 100644 index 00000000..e4a692e5 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.6/16.6.6.R @@ -0,0 +1,11 @@ +##Chapter 16 : Queuing Systems +##Example 6-6 : Page 657 + +#Queueing library to process different queueing models +library(queueing) + +#creating a MMc instance with the following parameters +x=NewInput.MMCK(lambda=16, mu=5,c=4,k=10) +#Solving the model which returns a list +y=QueueingModel(x) +summary(y) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.7/16.6.7.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.7/16.6.7.R new file mode 100644 index 00000000..0cbdcbad --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.7/16.6.7.R @@ -0,0 +1,13 @@ +##Chapter 16 : Queuing Systems +##Example 6-7 : Page 660 + +#Queueing library to process different queueing models +library(queueing) +#creating a MMc instance with the following parameters +x=NewInput.MMInf(lambda=12, mu=0.333) +#Solving the model which returns a list +y=QueueingModel(x) +summary(y) +estimate=(0.25*round(y$L)*1000)*(1-0.2)+(0.75*round(y$L)*1000)*(1+0.12) +estimate +##The answer for the estimate is given wrong in the book \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.8/16.6.8.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.8/16.6.8.R new file mode 100644 index 00000000..d19a8be4 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.6.8/16.6.8.R @@ -0,0 +1,20 @@ +##Chapter 16 : Queuing Systems +##Example 6-8 : Page 662 + +#Queueing library to process different queueing models +library(queueing) + +#Empty matrix table for Machine productivity +McProductivity=matrix(0,2,4) +#Making a matrix for different number of repairpersons +for(i in 1:4){ + #creating a MMc instance with the following parameters + x=NewInput.MMCKK(lambda=0.5, mu=5, c=i, k=22) + #Solving the model which returns a list + y=QueueingModel(x) + McProductivity[1,i]=(22-y$L)*100/22 + if(i>1){ + McProductivity[2,i]=McProductivity[1,i]-McProductivity[1,i-1] + } +} +McProductivity \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.7.1/16.7.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.7.1/16.7.1.R new file mode 100644 index 00000000..47355393 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.7.1/16.7.1.R @@ -0,0 +1,21 @@ +##Chapter 16 : Queuing Systems +##Example 7-1 : Page 664 + +#arrival rate +lambda=4 +#Expectation of arrival +EOfT=1/6 +#variance of arrival +VarOfT=0 +#Length of the system +Ls=lambda*EOfT+((lambda^2 *(EOfT^2 + VarOfT))/(2*(1-lambda*EOfT))) +#Length of the queue +Lq=Ls-lambda*EOfT +#Waiting time in the system +Ws=Ls/lambda +#Waiting time in the queue +Wq=Lq/lambda +Ls +Lq +Ws +Wq \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.1/16.9.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.1/16.9.1.R new file mode 100644 index 00000000..bb2907f2 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.1/16.9.1.R @@ -0,0 +1,35 @@ +##Chapter 16 : Queuing Systems +##Example 9-1 : Page 667 + +#Queueing library to process different queueing models +library(queueing) +#inputs +Speed=c(30,36,50,66) +OperatingCost=c(15,20,24,27) + +#service rate for each model +ServiceRate=numeric() +for(i in 1:4){ + ServiceRate[i]=24/(10000/(Speed[i]*60)) +} +ServiceRate +Ls=numeric() + +#length of system for each model +for(i in 1:4){ + #creating a MMc instance with the following parameters + y=NewInput.MM1(lambda=4, mu=ServiceRate[i]) + #Solving the model which returns a list + z=QueueingModel(y) + Ls[i]=z$L +} +Ls +#cost for the 4 models +cost=matrix(0,4,3) +colnames(cost)=c("EOC","EWC","ETC") +for(i in 1:4){ + cost[i,1]=24*OperatingCost[i] + cost[i,2]=80*Ls[i] + cost[i,3]=cost[i,1]+cost[i,2] +} +cost \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.2/16.9.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.2/16.9.2.R new file mode 100644 index 00000000..48cb5735 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.2/16.9.2.R @@ -0,0 +1,17 @@ +##Chapter 16 : Queuing Systems +##Example 9-2 : Page 670 + +#Queueing library to process different queueing models +library(queueing) + +Ls=numeric() +ETC=numeric() +for (c in 2:6){ + #creating a MMc instance with the following parameters + y=NewInput.MMC(lambda=17.5, mu=10,c) + #Solving the model which returns a list + z=QueueingModel(y) + Ls[c]=z$L + ETC[c]=12*c + 50*Ls[c] +} +ETC[2:6] \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.3/16.9.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.3/16.9.3.R new file mode 100644 index 00000000..4dfb15de --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH16/EX16.9.3/16.9.3.R @@ -0,0 +1,20 @@ +##Chapter 16 : Queuing Systems +##Example 9-3 : Page 672 + +#Queueing library to process different queueing models +library(queueing) +Ws=numeric() +RO=numeric() + + +for (c in 2:8){ + #creating a MMc instance with the following parameters + y=NewInput.MMC(lambda=17.5, mu=10,c) + #Solving the model which returns a list + z=QueueingModel(y) + #waiting time in the system + Ws[c]=z$W*60 + #idleness percentage of the system + RO[c]=(1-z$RO)*100 +} +rbind(Ws,RO)[,2:8] \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.1.1/17.1.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.1.1/17.1.1.R new file mode 100644 index 00000000..beab8202 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.1.1/17.1.1.R @@ -0,0 +1,23 @@ +##Chapter 17 : Simulation Modelling +##Example 1-1 : Page 681 + +#number of trials +n=1000 +#Setting up parameters for the plot +par(pty="s") +#plot empty graph +plot(1, axes=T,asp = 1, xlim = c(-4, 6),ylim = c(-3, 7)) +#getting a sample of 1000 random uniform numbers within the given range +x=-4+(10)*runif(n) +y=-3+10*runif(n) +#counting the number of true values for the give expression +m=sum((x-1)^2+(y-2)^2<25) +#plotting the points on the graph +points(x, y) +#plotting the circle +symbols(x=1,y=2,circles = 5,add = T,inches = F) +#plotting the square +symbols(x=1,y=2,squares =10,add = T,inches = F) +#Area of the circle +ApproxArea=m*100/n +ApproxArea \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.3.3/17.3.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.3.3/17.3.3.R new file mode 100644 index 00000000..6afaf4c8 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.3.3/17.3.3.R @@ -0,0 +1,10 @@ +##Chapter 17 : Simulation Modelling +##Example 3-3 : Page 691 + +#Function which returns an erlang distribution +erlang=function(m,lambda){ + R=c(0.0589,0.6733,0.4799) + y=-log(prod(R))/lambda + return(y) +} +erlang(3,4) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.4.1/17.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.4.1/17.4.1.R new file mode 100644 index 00000000..7e9b6b28 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH17/EX17.4.1/17.4.1.R @@ -0,0 +1,19 @@ +##Chapter 17 : Simulation Modelling +##Example 3-3 : Page 691 + +#inputs for the random number generator +b=9 +c=5 +m=12 + + +u=numeric() +#initial random number +u[1]=11 + +R=numeric() +for(i in 2:4){ + u[i]=(b*u[i-1]+c)%%m + R[i-1]=u[i]/m +} +R \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH18/EX18.1.1/18.1.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH18/EX18.1.1/18.1.1.R new file mode 100644 index 00000000..1b36b601 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH18/EX18.1.1/18.1.1.R @@ -0,0 +1,19 @@ +##Chapter 18 : Classical Optimization theory +##Example 1-1 : Page 714 + +#Function to be given as input to optim function +minimize<-function(x){ + x1=x[1] + x2=x[2] + x3=x[3] + return(-(x1+2*x2+x2*x3-x1^2-x2^2-x3^2)) +} + +#Calculates the optimal value +optim(c(0,0,0),minimize,hessian = T ) +#the Jacobian for each +f=expression(x1+2*x2+x2*x3-x1^2-x2^2-x3^2) +for(i in 1:3){ + x=D(f,paste("x",i,sep = "")) + print(x) +} \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH18/EX18.1.3/18.1.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH18/EX18.1.3/18.1.3.R new file mode 100644 index 00000000..e0cd7523 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH18/EX18.1.3/18.1.3.R @@ -0,0 +1,9 @@ +##Chapter 18 : Classical Optimization theory +##Example 1-3 : Page 717 + +#The function expression has to be given as function to nlm function +g<-function(x){ + return((3*x-2)^2 * (2*x-3)^2) +} +#calling nlm function with function g and initial guess 0 +nlm(g,0) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.2.1/2.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.2.1/2.2.1.R new file mode 100644 index 00000000..6d4d8fb8 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.2.1/2.2.1.R @@ -0,0 +1,56 @@ +##Chapter 2 : Modelling with Linear Programming +##Example 2-1 : Page 16 + +#To plot the line, we have to consider them as equation instead of inequality and express/ +#them in terms of x2 : + +#Constraint 1 : 6 * x1 + 4 * x2 <= 24 +#Con1 : x2 = (24 - 6 * x1)/4 +con1 <- function(x1) (24 - 6 * x1)/4 +plot (con1, xlab = "x1", ylab = "x2", xlim = c(0,7), ylim = c(0,7), col = "red", + main = "Example 2-1", yaxs= "i", xaxs = "i") +#xlab & ylab : x and y label respectively +#xlim : limits of x value on the plot +#ylim : limits of y value on the plot +#col : color of the line +#main : Title of the plot +#yaxs & xaxs : the style of axis interval calculation to be used by R. The default +#value is a 4% gap at each end of axis + +#Constraint 2 : x1 + 2 * x2 <=6 +#Con2 : x2 = (6 - x1)/2 +con2 <- function(x1) (6 - x1)/2 +plot (con2, add=T, xlim = c(0,7), ylim = c(0,7), col = "blue") +#add : adds to an existing plot + + +#Constraint 3 : -x1 + x2 <= 1 +#Con3 : x2 = (1 + x1) +con3 <- function(x1) (1 + x1) +plot (con3, add=T, xlim = c(0,7), ylim = c(0,7), col = "green") + +#Constraint 4 : x2 <= 2 +#Con4 : x2 = 2 +con4 <- function(x1) (2 + 0*x1) +plot (con4, add=T, xlim = c(0,7), ylim = c(0,7), col = "green") +#h : horizontal line at y=2 + +#Points of intersections of constraints : (0,1),(1,2),(2,2),(2,1.5),(4,0) +points(c(0,1,2,3,4),c(1,2,2,1.5,0)) + +#Add a shaded area +polygon(c(0,1,2,3,4,0),c(1,2,2,1.5,0,0), col = rgb(0.48, 0.46, 0.46, 0.5), + border=NA) +#border : option to add border to the shaded area + +#Adding "solution space" text to the shaded area at (2,1) +text(2,1,"Solution \nSpace") + +##Objective function :Max 5 *x1 + 4 * x2 +# maximum objective is 21, Therefore 5 *x1 + 4 * x2 =21 +# Obj : x2 = (21 - 5*x1)/4 +Obj <- function(x1) (21 - 5*x1)/4 +plot (Obj, add=T, xlim = c(0,7), ylim = c(0,7), lty =2 ) +#lty : option to set the type of line,2 for dashed line + +text(3,3,"x1 = 3 \nx2 = 1.5 \n z=21") diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.2.2/2.2.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.2.2/2.2.2.R new file mode 100644 index 00000000..d2c0db6c --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.2.2/2.2.2.R @@ -0,0 +1,50 @@ +##Chapter 2 : Modelling with Linear Programming +##Example 2-2 : Page 24 + +#To plot the line, we have to consider them as equation instead of inequality and express/ +#them in terms of x2 : + +#Constraint 1 : x1 + x2 <= 800 +#Con1 : x2 = (800 - x1) +con1 <- function(x1) (800 - x1) +plot (con1, xlab = "x1", ylab = "x2", xlim = c(0,1500), ylim = c(0,1500), col = "red", + main = "Example 2-2", yaxs= "i", xaxs = "i") +#xlab & ylab : x and y label respectively +#xlim : limits of x value on the plot +#ylim : limits of y value on the plot +#col : color of the line +#main : Title of the plot +#yaxs & xaxs : the style of axis interval calculation to be used by R. The default +#value is a 4% gap at each end of axis + +#Constraint 2 : 0.21 * x1 - 0.3 * x2 <= 0 +#Con2 : x2 = (0.21 * x1)/0.3 +con2 <- function(x1) (0.21 * x1)/0.3 +plot (con2, add=T, xlim = c(0,1500), ylim = c(0,1500), col = "blue") +#add : adds to an existing plot + + +#Constraint 3 : 0.03 * x1 - 0.01 * x2 >= 0 +#Con3 : x2 = (0.03 * x1)/0.01 +con3 <- function(x1) (0.03 * x1)/0.01 +plot (con3, add=T, xlim = c(0,1500), ylim = c(0,1500), col = "green") + +#Points of intersections of constraints : (0,1),(1,2),(2,2),(2,1.5),(4,0) +points(c(470.6,200),c(329.4,600)) + +#Add a shaded area +polygon(c(470.6,200,500,15000/7),c(329.4,600,1500,1500), col = rgb(0.48, 0.46, 0.46, 0.5), + border=NA) +#border : option to add border to the shaded area + +#Adding "solution space" text to the shaded area at (750,1000) +text(750,1000,"Solution \nSpace") + +##Objective function :Min 0.3 *x1 + 0.9 * x2 +# Minimum objective is 437.64, Therefore 0.3 *x1 + 0.9 * x2 = 437.64 +# Obj : x2 = (437.64 - 0.3 * x1)/0.9 +Obj <- function(x1) (437.64 - 0.3 * x1)/0.9 +plot (Obj, add=T, xlim = c(0,1500), ylim = c(0,1500), lty =2 ) +#lty : option to set the type of line,2 for dashed line + +text(1000,250,"x1 = 470.6 \nx2 = 329.4 \n z=437.64") diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.1/2.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.1/2.4.1.R new file mode 100644 index 00000000..dde1d2f2 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.1/2.4.1.R @@ -0,0 +1,26 @@ +##Chapter 2 : Modelling with Linear Programming +##Example 4-1 : Page 35 + +# Objective function :Max (0.126 * x1 +0.1209 * x2 + 0.1164 * x3 + 0.11875 * x4 + 0.098 * x5) +# - (0.1 * x1 + 0.07 * x2 + 0.03 * x3 + 0.05 * x4 + 0.02 * x5) +a <- c(0.126-0.1,0.1209-0.07,0.1164-0.03,0.11875-0.05,0.098-0.02) + +# Constraint 1 : x1 + x2 + x3 + x4 + x5 <=12 +C1 <- c(1,1,1,1,1) +bc1<- 12 + +# Constraint 2 : 0.4*x1 + 0.4*x2 + 0.4*x3 - 0.6*x4 - 0.6*x5 <=0 +C2 <- c(0.4,0.4,0.4,-0.6,-0.6) +bc2<-0 + +# Constraint 3 : 0.5 * x1 + 0.5 * x2 - 0.5 * x3 <=0 +C3 <- c(0.5,0.5,-0.5,0,0) +bc3<-0 + +# Constraint 4 : 0.06 * x1 + 0.03 * x2 - 0.01 * x3 +0.01 * x4 -0.02 * x5 <=0 +C4 <- c(0.06,0.03,-0.01,0.01,-0.02) +bc4<-0 + +library("boot") +##Simplex is a function which uses dual simplex method +simplex(a , A1 = rbind(C1, C2, C3, C4), b1 = c(bc1, bc2, bc3, bc4), maxi = TRUE) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.2/2.4.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.2/2.4.2.R new file mode 100644 index 00000000..dd9398c3 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.2/2.4.2.R @@ -0,0 +1,43 @@ +##Chapter 2 : Modelling with Linear Programming +##Example 4-2 : Page 41 + +# Objective function :Max (30 * x1 + 40 * x2 + 20 * x3 + 10 * x4) +# - (15 * s1 + 20 * s2 + 10 * s3 + 8 * s4) +a <- c(30,40,20,10,-15,-20,-10,-8) + +# Constraint 1 : 0.3 * x1 + 0.3 * x2 + 0.25 * x3 + 0.15 * x4 <= 1000 +C1 <- c(0.3,0.3,0.25,0.15,0,0,0,0) +bc1<- 1000 + +# Constraint 2 : 0.25 * x1 + 0.35 * x2 + 0.3 * x3 + 0.1 * x4 <= 1000 +C2 <- c(0.25,0.35,0.3,0.1,0,0,0,0) +bc2<-1000 + +# Constraint 3 : 0.45 * x1 + 0.5 * x2 + 0.4 * x3 + 0.22 * x4 <=1000 +C3 <- c(0.45,0.5,0.4,0.22,0,0,0,0) +bc3<-1000 + +# Constraint 4 : 0.15 * x1 + 0.15 * x2 + 0.1 * x3 + 0.05 * x4 <=0 +C4 <- c(0.15,0.15,0.1,0.05,0,0,0,0) +bc4<-1000 + +# Constraint 5 : x1 + s1 = 800 +C5 <- c(1,0,0,0,1,0,0,0) +bc5<-800 + +# Constraint 6 : x2 + s2 = 750 +C6 <- c(0,1,0,0,0,1,0,0) +bc6<-750 + +# Constraint 7: x3 + s3 = 600 +C7 <- c(0,0,1,0,0,0,1,0) +bc7<-600 + +# Constraint 8 : x4 + s4 = 500 +C8 <- c(0,0,0,1,0,0,0,1) +bc8<-500 + +library("boot") + +simplex(a , A1 = rbind(C1, C2, C3, C4), b1 = c(bc1, bc2, bc3, bc4), + A2=NULL, b2=NULL, A3 = rbind(C5,C6,C7,C8), b3 = c(bc5,bc6,bc7,bc8), maxi = TRUE) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.3/2.4.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.3/2.4.3.R new file mode 100644 index 00000000..df73e5a3 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.3/2.4.3.R @@ -0,0 +1,35 @@ +##Chapter 2 : Modelling with Linear Programming +##Example 4-3 : Page 41 + +# Objective function :Min (50 * x1 + 45 * x2 + 55 * x3 + 48 * x4 + 52 * x5 + 50 * x6) +# + 8(I1 +I2 +I3 +I4 + I5 + I6) +a <- c(50,45,55,48,52,50,8,8,8,8,8,8) + +# Constraint 1 : x1 -I1 = 100 +C1 <- c(1,0,0,0,0,0,-1,0,0,0,0,0) +bc1<- 100 + +# Constraint 2 : I1 + x2 - I2 = 250 +C2 <- c(0,1,0,0,0,0,1,-1,0,0,0,0) +bc2<-250 + +# Constraint 3 : I2 + x3 - I3 = 190 +C3 <- c(0,0,1,0,0,0,0,1,-1,0,0,0) +bc3<-190 + +# Constraint 4 : I3 + x4 - I4 = 140 +C4 <- c(0,0,0,1,0,0,0,0,1,-1,0,0) +bc4<-140 + +# Constraint 5 : I4 + x5 - I5 =220 +C5 <- c(0,0,0,0,1,0,0,0,0,1,-1,0) +bc5<-220 + +# Constraint 6 : I5 + x6 = 110 +C6 <- c(0,0,0,0,0,1,0,0,0,0,1,0) +bc6<-110 + +library("boot") + +simplex(a , A1=NULL,b1=NULL, A2=NULL, b2=NULL, A3 = rbind(C1, C2, C3, C4,C5,C6), + b3 = c(bc1, bc2, bc3, bc4,bc5,bc6), maxi = F) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.4/2.4.4.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.4/2.4.4.R new file mode 100644 index 00000000..c72cbd05 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.4/2.4.4.R @@ -0,0 +1,42 @@ +##Chapter 2 : Modelling with Linear Programming +##Example 4-4 : Page 43 + +# Objective function :Min 50(I1 + I2 + I3 + I4) + 200(Sm1 +Sm2 +Sm3 +Sm4) + 400(Sp1 +Sp2 +Sp3 +Sp4) +a <- c(0,0,0,0,50,50,50,50,200,200,200,200,400,400,400,400) + +# Constraint 1 : 10*x1 -I1 = 400 +C1 <- c(10,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0) +bc1<- 400 + +# Constraint 2 : I1 + 10 * x2 - I2 = 600 +C2 <- c(0,10,0,0,1,-1,0,0,0,0,0,0,0,0,0,0) +bc2<-600 + +# Constraint 3 : I2 + 10 * x3 - I3 = 400 +C3 <- c(0,0,10,0,0,0,1,-1,0,0,0,0,0,0,0,0) +bc3<-400 + +# Constraint 4 : I3 + 10 * x4 = 500 +C4 <- c(0,0,0,10,0,0,0,1,0,0,0,0,0,0,0,0) +bc4<-500 + +# Constraint 5 : x1 -Sm1 + Sp1 = 0 +C5 <- c(1,0,0,0,0,0,0,0,-1,0,0,0,1,0,0,0) +bc5<-0 + +# Constraint 6 : x2 -x1 -Sm2 +Sp2 = 0 +C6 <- c(-1,1,0,0,0,0,0,0,0,-1,0,0,0,1,0,0) +bc6<-0 + +# Constraint 7 : x3 -x2 -Sm3 +Sp3 = 0 +C7 <- c(0,-1,1,0,0,0,0,0,0,0,-1,0,0,0,1,0) +bc7<-0 + +# Constraint 8 : x4 -x3 -Sm4 +Sp4 = 0 +C8 <- c(0,0,-1,1,0,0,0,0,0,0,0,-1,0,0,0,1) +bc8<-0 + +library("boot") + +simplex(a , A1=NULL,b1=NULL, A2=NULL, b2=NULL, A3 = rbind(C1, C2, C3, C4, C5, C6, C7, C8), + b3 = c(bc1, bc2, bc3, bc4, bc5, bc6, bc7, bc8), maxi = F) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.5/2.4.5.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.5/2.4.5.R new file mode 100644 index 00000000..faf3d5eb --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.5/2.4.5.R @@ -0,0 +1,36 @@ +##Chapter 2 : Modelling with Linear Programming +##Example 4-5 : Page 50 + +# Objective function :Min x1 + x2 + x3 + x4 + x5 + x6 +a <- c(1,1,1,1,1,1) + +# Constraint 1 : x1 + x6 >= 4 +C1 <- c(1,0,0,0,0,1) +bc1<- 4 + +# Constraint 2 : x1 + x2 >= 8 +C2 <- c(1,1,0,0,0,0) +bc2<-8 + +# Constraint 3 : x2 + x3 >= 10 +C3 <- c(0,1,1,0,0,0) +bc3<-10 + +# Constraint 4 : x3 + x4 >= 7 +C4 <- c(0,0,1,1,0,0) +bc4<-7 + +# Constraint 5 : x4 + x5 >= 12 +C5 <- c(0,0,0,1,1,0) +bc5<-12 + +# Constraint 6 : x5 + x6 >= 4 +C6 <- c(0,0,0,0,1,1) +bc6<-4 + +library("lpSolve") + +solution=lp("min",a, rbind(C1, C2, C3, C4, C5, C6), rep(">=",6),c(bc1, bc2, bc3, bc4, bc5, bc6)) + +solution +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.6/2.4.6.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.6/2.4.6.R new file mode 100644 index 00000000..01fa516c --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.6/2.4.6.R @@ -0,0 +1,38 @@ +##Chapter 2 : Modelling with Linear Programming +##Example 4-6 : Page 52 + +# Objective function :Max 1000 * x1 + 1900 * x2 + 2700 * x3 + 3400 * x4 +a <- c(1000, 1900, 2700, 3400, 0) + +# Constraint 1 : 0.18 * x1 + 0.28 * x2 + 0.4 * x3 + 0.5 * x4 -0.2125 * x5 <= 0 +C1 <- c(0.18, 0.28, 0.4, 0.5, -0.2125) +bc1<- 0 + +# Constraint 2 : x5 <= 300 +C2 <- c(0,0,0,0,1) +bc2<-300 + +# Constraint 3 : -0.8 * x1 + 0.2 * x2 + 0.2 * x3 + 0.2 * x4 <= 0 +C3 <- c(-0.8, 0.2, 0.2, 0.2, 0) +bc3<-0 + +# Constraint 4 : 0.1 * x1 - 0.9 * x2 + 0.1 * x3 + 0.1 * x4 <= 0 +C4 <- c(0.1, -0.9, 0.1, 0.1, 0) +bc4<-7 + +# Constraint 5 : 0.25 * x1 + 0.25 * x2 - 0.75 * x3 - 0.75 * x4 <= 0 +C5 <- c(0.25,0.25,-0.75,-0.75,0) +bc5<-0 + +# Constraint 6 : 50 * x1 + 70 * x2 + 130 * x3 + 160 * x4 + 2* x5 <= 15000 +C6 <- c(50, 70, 130, 160, 2) +bc6<-15000 + +#to install the lpSolve package,run the following command +#install.packages("lpSolve") +library("lpSolve") + +solution = lp("max", a, rbind(C1, C2, C3, C4, C5, C6), rep("<=",6), + c(bc1, bc2, bc3, bc4, bc5, bc6)) +solution +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.7/2.4.7.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.7/2.4.7.R new file mode 100644 index 00000000..1f52bf01 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH2/EX2.4.7/2.4.7.R @@ -0,0 +1,45 @@ +##Chapter 2 : Modelling with Linear Programming +##Example 4-7 : Page 57 + +# Objective function :Max 6.7 * (x11 +x21) + 7.2 * (x12 + x22) + 8.1 * (x13 + x23) +a <- c(6.7, 7.2, 8.1, 6.7, 7.2, 8.1) + +# Constraint 1 : 5 *(x11 + x12 + x13) + 10 * (x21 + x22 + x23) <= 1500000 +C1 <- c(5, 5, 5, 10, 10, 10) +bc1<- 1500000 + +# Constraint 2 : 2 * (x21 + x22 + x23) <=200000 +C2 <- c(0, 0, 0, 2, 2, 2) +bc2<-200000 + +# Constraint 3 : (x11 + x21) <= 50000 +C3 <- c(1,0,0,1,0,0) +bc3<-50000 + +# Constraint 4 : (x12 + x22) <= 30000 +C4 <- c(0, 1, 0, 0, 1, 0) +bc4<-30000 + +# Constraint 5 : (x13 + x23) <= 40000 +C5 <- c(0, 0, 1, 0, 0, 1) +bc5<-40000 + +# Constraint 6 : 5 * x11 - 11 * x21 <= 0 +C6 <- c(5,0,0,-11,0,0) +bc6<-0 + +# Constraint 7 : 7* x12 - 9 * x22 <= 0 +C7 <- c(0, 7, 0, 0, -9, 0) +bc7<-0 +# Constraint 8 : 10 * x12 - 6 * x22 <= 0 +C8 <- c(0, 0, 10, 0, 0, -6) +bc8<-0 + +#to install the lpSolve package,run the following command +#install.packages("lpSolve") +library("lpSolve") + +solution = lp("max", a, rbind(C1, C2, C3, C4, C5, C6, C7, C8), rep("<=",8), + c(bc1, bc2, bc3, bc4, bc5, bc6, bc7, bc8)) +solution +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.2.1/3.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.2.1/3.2.1.R new file mode 100644 index 00000000..de3b94f2 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.2.1/3.2.1.R @@ -0,0 +1,51 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 2-1 : Page 83 + +#To plot the line, we have to consider them as equation instead of inequality and express/ +#them in terms of x2 : + +#Constraint 1 : 2 * x1 + x2 <= 4 +#Con1 : x2 = (4 - 2 * x1) +con1 <- function(x1) (4 - 2 * x1) +plot (con1, xlab = "x1", ylab = "x2", xlim = c(0,6), ylim = c(0,5), col = "red", + main = "Example 2-1", yaxs= "i", xaxs = "i") +#xlab & ylab : x and y label respectively +#xlim : limits of x value on the plot +#ylim : limits of y value on the plot +#col : color of the line +#main : Title of the plot +#yaxs & xaxs : the style of axis interval calculation to be used by R. The default +#value is a 4% gap at each end of axis + +#Constraint 2 : x1 + 2 * x2 <= 5 +#Con2 : x2 = (5 - x1)/2 +con2 <- function(x1) (5 - x1)/2 +plot (con2, add=T, xlim = c(0,6), ylim = c(0,5), col = "blue") +#add : adds to an existing plot + +#Points of intersections of constraints and the axis : (0,0),(0,2.5),(1,2),(2,0),(5,0),(0,4) +points(c(0,0,1,2,5,0),c(0,2.5,2,0,0,4)) + +#Inserting texts to name the points +text(c(0,0,1,2,5,0)+0.1,c(0,2.5,2,0,0,4)+0.2,LETTERS[1:6],cex = 0.7) +#First two arguments are x(+0.1) and y(+0.2) coordinates +#LETTERS : a stored array variable of all alphabets +#cex : ratio of modification to font size + +#Add a shaded area +polygon(c(0,0,1,2),c(0,2.5,2,0), col = rgb(0.48, 0.46, 0.46, 0.5), + border=NA) +#border : option to add border to the shaded area + +#Adding "solution space" text to the shaded area at (0.7,1) +text(0.7,1,"Solution \nSpace",cex = 0.9) + +##Objective function :Max 2 *x1 + 3 * x2 +# maximum objective is 8, Therefore 2 *x1 + 3 * x2 = 8 +# Obj : x2 = (8 - 2*x1)/3 +Obj <- function(x1) (8 - 2*x1)/3 +plot (Obj, add=T, xlim = c(0,6), ylim = c(0,5), lty =2 ) +#lty : option to set the type of line,2 for dashed line + +#Adding text at (3,3) +text(3,3,"x1 = 1 \nx2 = 2 \n z = 8") \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.3.1/3.3.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.3.1/3.3.1.R new file mode 100644 index 00000000..c4a1c11e --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.3.1/3.3.1.R @@ -0,0 +1,28 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 3-1 : Page 89 + +# Objective function :Max 5*x1 + 4*x2 + 0*s1 + 0*s2 + 0*s3 + 0*s4 +a <- c(5,4,0,0,0,0) + +# Constraint 1 : 6*x1 + 4*x2 +s1 = 24 +C1 <- c(6,4,1,0,0,0) +bc1<- 24 + +# Constraint 2 : x1 + 2*x2 + s2 = 6 +C2 <- c(1,2,0,1,0,0) +bc2<-6 + +# Constraint 3 : - x1 + x2 + s3 = 1 +C3 <- c(-1,1,0,0,1,0) +bc3<-1 + +# Constraint 4 : 1*x2 + s4 = 2 +C4 <- c(0,1,0,0,0,1) +bc4<-2 + +library("lpSolve") + +solution=lp("max",a, rbind(C1, C2, C3, C4), rep("=",4),c(bc1, bc2, bc3, bc4)) + +solution +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.4.1/3.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.4.1/3.4.1.R new file mode 100644 index 00000000..2f07f51f --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.4.1/3.4.1.R @@ -0,0 +1,22 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 4-1 : Page 100 + +# Objective function :Min 4 * x1 + x2 + M * R1 + M * R2 +BigM <- 1000 +a <- c(4,1,0,0,BigM,BigM) + +# Constraint 1 : 3*x1 + x2 + R1 = 3 +C1 <- c(3,1,0,0,1,0) +bc1<- 3 + +# Constraint 2 : 4*x1 + 3*x2 -x3 + R2 >= 6 +C2 <- c(4,3,-1,0,0,1) +bc2<-6 + +# Constraint 3 : x1 + 2*x2 +x4 <=4 +C3 <- c(1,2,0,1,0,0) +bc3<-4 + +library("boot") + +simplex(a,NULL,NULL,NULL,NULL, rbind(C1,C2,C3),c(bc1,bc2,bc3) ,maxi = F) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.4.2/3.4.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.4.2/3.4.2.R new file mode 100644 index 00000000..b241627c --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.4.2/3.4.2.R @@ -0,0 +1,32 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 4-2 : Page 105 + +# Objective function :Min 4 * x1 + x2 +a <- c(4,1) + +# Constraint 1 : 3*x1 + x2 = 3 +C1 <- c(3,1) +bc1<- 3 + +# Constraint 2 : 4*x1 + 3*x2 >= 6 +C2 <- c(4,3) +bc2<-6 + +# Constraint 3 : x1 + 2*x2 <=4 +C3 <- c(1,2) +bc3<-4 + +library("boot") + +simplex(a,C3,bc3,C2,bc2, C1,bc1 ,maxi = F) + +#The method employed by this function is the two phase tableau simplex method. +#If there are >= or equality constraints an initial feasible solution is not +#easy to find. To find a feasible solution an artificial variable is introduced +#into each >= or equality constraint and an auxiliary objective function is defined +#as the sum of these artificial variables. If a feasible solution to the set of +#constraints exists then the auxiliary objective will be minimized when all of the +#artificial variables are 0. These are then discarded and the original problem solved +#starting at the solution to the auxiliary problem. If the only constraints are of the +#<= form, the origin is a feasible solution and so the first stage can be omitted. +##Refrence : https://stat.ethz.ch/R-manual/R-devel/library/boot/html/simplex.html \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.1/3.5.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.1/3.5.1.R new file mode 100644 index 00000000..7fc0b664 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.1/3.5.1.R @@ -0,0 +1,19 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 5-1 : Page 108 + +# Objective function :Max 3 * x1 + 9 * x2 +a <- c(3,9) + +# Constraint 1 : x1 + 4 * x2 <= 8 +C1 <- c(1,4) +bc1<- 8 + +# Constraint 2 : x1 + 2*x2 <= 4 +C2 <- c(1,2) +bc2<-4 + + +library("boot") + +solution=simplex(a,rbind(C1,C2),c(bc1,bc2) ,maxi = T) +##The simplex function arbitrarily breaks the tie in minimum ratio for the leaving variable. diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.2/3.5.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.2/3.5.2.R new file mode 100644 index 00000000..7a36819d --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.2/3.5.2.R @@ -0,0 +1,19 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 5-2 : Page 112 + +# Objective function :Max 2 * x1 + 4 * x2 +a <- c(2,4) + +# Constraint 1 : 1 * x1 + 2 * x2 <= 5 +C1 <- c(1,2) +bc1<- 5 + +# Constraint 2 : x1 + x2 <= 4 +C2 <- c(1,1) +bc2<-4 + +library("boot") + +simplex(a,rbind(C1,C2),c(bc1,bc2) ,maxi = T) +#The simplex function as well as lpsolve stops as soon as a feasible optima is obtained and doesn't evaluate +#alternate optima \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.3/3.5.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.3/3.5.3.R new file mode 100644 index 00000000..0125f0d5 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.3/3.5.3.R @@ -0,0 +1,18 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 5-3 : Page 115 + +# Objective function :Max 2 * x1 + x2 +a <- c(2,1) + +# Constraint 1 : x1 - x2 <= 10 +C1 <- c(1,-1) +bc1<- 10 + +# Constraint 2 : 2 * x1 <= 40 +C2 <- c(2,0) +bc2<-40 + +library("lpSolve") + +solution = lp("max", a, rbind(C1, C2), rep("<=",2), c(bc1, bc2)) +#Error: status 3 implies that the model is unbounded \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.4/3.5.4.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.4/3.5.4.R new file mode 100644 index 00000000..fb64b0a6 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.5.4/3.5.4.R @@ -0,0 +1,18 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 5-4 : Page 116 + +# Objective function :Max 3 * x1 + 2 * x2 +a <- c(3,2) + +# Constraint 1 : 2 * x1 + x2 <= 2 +C1 <- c(2,1) +bc1<- 2 + +# Constraint 2 : 3 * x1 + 4 * x2 >= 12 +C2 <- c(3,4) +bc2<-12 + +library("lpSolve") + +lp("max", a, rbind(C1, C2), c("<=",">="), c(bc1, bc2)) +#Error: no feasible solution found \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.1/3.6.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.1/3.6.1.R new file mode 100644 index 00000000..d492cc34 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.1/3.6.1.R @@ -0,0 +1,26 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 6-1 : Page 118 + +# Objective function :Max 30 * x1 + 20 * x2 +a <- c(30,20) + +# Constraint 1 : 2 * x1 + x2 <= 8 +C1 <- c(2,1) +bc1<- 8 + +# Constraint 2 : x1 + 3 * x2 <= 8 +C2 <- c(1,3) +bc2<-8 + +library("lpSolve") + +solution=lp("max", a, rbind(C1, C2), rep("<=",2), c(bc1, bc2),compute.sens = 1) + +##Unit worth of resources in $/hr +solution$duals[1:2] + +##Lower limit of hours resource for respective machines for which dual prices are valid +solution$duals.from[1:2] + +##Upper limit of hours resource for respective machines for which dual prices are valid +solution$duals.to[1:2] diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.2/3.6.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.2/3.6.2.R new file mode 100644 index 00000000..5361ce61 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.2/3.6.2.R @@ -0,0 +1,22 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 6-2 : Page 121 + +# Objective function :Max 30 * x1 + 20 * x2 +a <- c(30,20) + +# Constraint 1 : 2 * x1 + x2 <= 8 +C1 <- c(2,1) +bc1<- 8 + +# Constraint 2 : x1 + 3 * x2 <= 8 +C2 <- c(1,3) +bc2<-8 + +library("lpSolve") + +solution=lp("max", a, rbind(C1, C2), rep("<=",2), c(bc1, bc2),compute.sens = 1) + +##Lower limit of respective Objective coefficient for which the objective value will not change +solution$sens.coef.from +##Upper limit of respective Objective coefficient for which the objective value will not change +solution$sens.coef.to diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.3/3.6.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.3/3.6.3.R new file mode 100644 index 00000000..360d7191 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH3/EX3.6.3/3.6.3.R @@ -0,0 +1,28 @@ +##Chapter 3 : The Simplex Method and Sensitivity Analysis +##Example 6-3 : Page 124 + +# Objective function :Max 3 * x1 + 2 * x2 + 5 * x3 +a <- c(3,2,5) + +# Constraint 1 : x1 + 2 * x2 + x3 <= 430 +C1 <- c(1,2,1) +bc1<- 430 + +# Constraint 2 : 3 * x1 + 2 * x3 <= 460 +C2 <- c(3,0,2) +bc2<-460 + +# Constraint 3 : 1 * x1 + 4 * x2 <= 420 +C3 <- c(1,4,0) +bc3<-420 + +library("lpSolve") +solution=lp("max", a, rbind(C1, C2, C3), rep("<=",3), c(bc1, bc2, bc3),compute.sens = 1) + +##Lower limit of hours resource for respective machines for which dual prices are valid +solution$duals.from + +##Upper limit of hours resource for respective machines for which dual prices are valid +solution$duals.to + +##Refer Footnote 10, Page 127 \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.1/4.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.1/4.2.1.R new file mode 100644 index 00000000..17537daf --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.1/4.2.1.R @@ -0,0 +1,22 @@ +##Chapter 4 : Duality and Post-optimality Analysis +##Example 2-1 : Page 160 + +# Objective function :Max 5 * x1 + 12 * x2 + 4 * x3 +a <- c(5,12,4) + +# Constraint 1 : x1 + 2 * x2 + x3 <= 10 +C1 <- c(1,2,1) +bc1<- 10 + +# Constraint 2 : 2 * x1 - x2 + 3 * x3 = 8 +C2 <- c(2,-1,3) +bc2<-8 + +library("linprog") + +solveLP(a,c(bc1, bc2), rbind(C1, C2), c("<=","="), maximum = T,lpSolve = T) + +## At the moment the dual problem can not be solved with equality constraints in the function solveLP +##Nevertheless we change the equality constrait to two inequality constraints. i.e. +## f1(x)=b ==> f1(x)<=b , f1(x)>=b +solveLP(a,c(bc1, bc2, bc2), rbind(C1, C2, C2), c("<=","<=",">="), maximum = T,lpSolve = T,solve.dual = T) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.2/4.2.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.2/4.2.2.R new file mode 100644 index 00000000..ccd13853 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.2/4.2.2.R @@ -0,0 +1,16 @@ +##Chapter 4 : Duality and Post-optimality Analysis +##Example 2-2 : Page 162 + +##Returns primal objective value +PrimalObj<-function(x1,x2,x3){ + return(5*x1+12*x2+4*x3) +} + +#Returns dual objective value +DualObj<-function(y1,y2){ + return(10*y1+8*y2) +} + +##Calling primal and dual functions with the arbitrary feasible solutions +PrimalObj(0,0,8/3) +DualObj(6,0) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.3/4.2.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.3/4.2.3.R new file mode 100644 index 00000000..d9840153 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.2.3/4.2.3.R @@ -0,0 +1,20 @@ +##Chapter 4 : Duality and Post-optimality Analysis +##Example 2-3 : Page 166 + +#Optimal Inverse +OptimalInv=matrix(c(2/5,-1/5,1/5,2/5),nrow=2,byrow=T) + +#Original X1 column +OrigX1=c(1,2) + +##Optimal X1 column using formaula 1 +X1Optimal=OptimalInv%*%OrigX1 +X1Optimal + +##Functions to calculate Z coefficients of X1 and R +ZCoefX1<-function(y1,y2) {return(y1+2*y2-5)} +ZCoefR<-function(y1,y2) {return(paste(y2,"+ M"))} + +## Calling the function with optimal dual values +ZCoefX1(29/5,-2/5) +ZCoefR(29/5,-2/5) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.3.1/4.3.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.3.1/4.3.1.R new file mode 100644 index 00000000..73f04d58 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.3.1/4.3.1.R @@ -0,0 +1,29 @@ +##Chapter 4 : Duality and Post-optimality Analysis +##Example 2-1 : Page 171 + +# Objective function :Max 5 * x1 + 4 * x2 +a <- c(5,4) + +# Constraint 1 : 6 * x1 + 4 * x2 <= 24 +C1 <- c(6,4) +bc1<- 24 + +# Constraint 2 : x1 + 2 * x2 <= 6 +C2 <- c(1,2) +bc2<-6 + +# Constraint 3 : -x1 + x2 <= 1 +C3 <- c(-1,1) +bc3<-1 + +# Constraint 4 : x2 <= 2 +C4 <- c(0,1) +bc4<-2 + +library("linprog") + +solveLP(a,c(bc1, bc2, bc3, bc4), rbind(C1, C2, C3, C4), rep("<=",4), maximum = T,lpSolve = T) + +##solve.dual arguement can be passed to solveLP function to solve the dual of the problem +solveLP(a,c(bc1, bc2, bc3, bc4), rbind(C1, C2, C3, C4), rep("<=",4), maximum = T,lpSolve = T, solve.dual = T) + diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.3.2/4.3.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.3.2/4.3.2.R new file mode 100644 index 00000000..c8e173ab --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.3.2/4.3.2.R @@ -0,0 +1,23 @@ +##Chapter 4 : Duality and Post-optimality Analysis +##Example 3-2 : Page 173 + +# Objective function :Max 3 * x1 + 2 * x2 + 5 * x3 +a <- c(3,2,5) + +# Constraint 1 : x1 + 2 * x2 + x3 <= 430 +C1 <- c(1,2,1) +bc1<- 430 + +# Constraint 2 : 3 * x1 + 2 * x3 <= 460 +C2 <- c(3,0,2) +bc2<-460 + +# Constraint 3 : 1 * x1 + 4 * x2 <= 420 +C3 <- c(1,4,0) +bc3<-420 + +library("linprog") +solveLP(a,c(bc1, bc2, bc3), rbind(C1, C2, C3), rep("<=",3), maximum = T,lpSolve = T) + +##solve.dual arguement can be passed to solveLP function to solve the dual of the problem +solveLP(a,c(bc1, bc2, bc3), rbind(C1, C2, C3), rep("<=",3), maximum = T,lpSolve = T,solve.dual = T) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.4.1/4.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.4.1/4.4.1.R new file mode 100644 index 00000000..13fc79d0 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.4.1/4.4.1.R @@ -0,0 +1,101 @@ +##Chapter 4 : Duality and Post-optimal Analysis +##Example 2-1 : Page 175 + +##Please note that the constraints are not given in the example(printing error) and +##it has been deduced from simplex tableau + +##We will be using glpkAPI library. If you are using Debian system, run the following command +##before running the R script :: sudo apt-get install libglpk-dev +##For other linux and windows systems, install GLPK which is available at https://www.gnu.org/software/glpk/ +##or from their respective repositories +library(glpkAPI) + +# Objective function :Min 3 * x1 + 2 * x2 + 1 * x3 +a <- c(3,2,1) + +# Constraint 1 : 3 * x1 + 1 * x2 + x3 >= 3 +# Standardizing constraint by multiplying by -1 +C1 <- c(-3,-1,-1) +bc1<- -3 + +# Constraint 2 : -3 * x1 + 3 * x2 + x3 >= 6 +# Standardizing constraint by multiplying by -1 +C2 <- c(3,-3,-1) +bc2<--6 + +# Constraint 3 : x1 + x2 + x3 <= 3 +C3 <- c(1,1,1) +bc3<-3 + +#upper bound vector +bc <- c(bc1,bc2,bc3) + +#Constraint matrix +ConstraintMatrix <- rbind(a,C1,C2,C3) + +#Initiating row and coloumn index variable as well as constraint coefficient value variable +rowindex <- numeric() +colindex <- numeric() +value <- numeric() + +#initiate GLPK object and name +dualSimplex <- initProbGLPK() +setProbNameGLPK(dualSimplex, "Example 4-1") +setObjNameGLPK(dualSimplex, "Minimize using Dual Simplex") + +#Setting objective direction and number of coloumns +setObjDirGLPK(dualSimplex, GLP_MIN) +addColsGLPK(dualSimplex, 3) + +#setting decision variable names,bounds and coefficients +for (i in 1:3) { + setColsNamesGLPK(dualSimplex,i,toString(c("x",i))) + setColBndGLPK(dualSimplex, i, GLP_LO, 0.0, 0.0) + setObjCoefsGLPK(dualSimplex, i, a[i]) +} + +#add 4 rows (including the objective) +addRowsGLPK(dualSimplex, 4) + +#set row name as objective name itself +setRowsNamesGLPK(dualSimplex, 1, getObjNameGLPK(dualSimplex)) + +#set row names and bounds for constraint +for (i in 1:3){ + setRowsNamesGLPK(dualSimplex, i+1, toString(c("Constraint", i))) + setRowBndGLPK(dualSimplex, i+1, GLP_UP, 0, bc[i]) +} + +#initiating row and coloumn index and the values +counter=1 +for (i in 1:4) { + for (j in 1:3) { + rowindex[counter] <- i + colindex[counter] <- j + value[counter] <- ConstraintMatrix[i,j] + counter=counter+1 + } +} + +#change the soving algorithm to dual simplex +setSimplexParmGLPK(METH,GLP_DUAL) + +#shows the current solver parameters +getSimplexParmGLPK() + +#load and initiate all the data +loadMatrixGLPK(dualSimplex, 12, rowindex, colindex, value) + +#Solve +solveSimplexGLPK(dualSimplex) + +#Prints the status, optimal objective value and decisision variable value +getSolStatGLPK(dualSimplex) +getObjValGLPK(dualSimplex) +getColsPrimGLPK(dualSimplex) + +#prints the summary of the optimization to your working directory +printSolGLPK(dualSimplex,'textfile.txt') + +#deletes the glpk object +delProbGLPK(dualSimplex) \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.1/4.5.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.1/4.5.1.R new file mode 100644 index 00000000..dfb0100f --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.1/4.5.1.R @@ -0,0 +1,13 @@ +##Chapter 4 : Duality and Post-optimal Analysis +##Example 5-1 : Page 182 + +##Situation 1 +Inverse <- rbind(c(0.5,-0.25,0),c(0,0.5,0),c(-2,1,1)) +ConstraintNNewRightHandSide <-rbind(600,640,590) +TableauNewRightHandSide <- Inverse %*% ConstraintNNewRightHandSide +TableauNewRightHandSide + +##Situation 2 +ConstraintNNewRightHandSide <-rbind(450,460,400) +TableauNewRightHandSide <- Inverse %*% ConstraintNNewRightHandSide +TableauNewRightHandSide diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.2/4.5.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.2/4.5.2.R new file mode 100644 index 00000000..2fcc2652 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.2/4.5.2.R @@ -0,0 +1,15 @@ +##Chapter 4 : Duality and Post-optimal Analysis +##Example 5-2 : Page 185 + +##Situation 1 is a theoretical explanation + +##Situation 2 +tableau=matrix(c(-0.25,1,0,0.5,-0.25,0,0,100,1.5,0,1,0,1.5,0,0,230,2,0,0,-2,1,1,0,20,3,3,1,0,0,0,1,500),nrow=4,ncol =8,byrow=T ) + +OldX7Row <- tableau[4,] +CoeffX2 <-OldX7Row[2] +CoeffX3 <-OldX7Row[3] +X2Row <- c(-0.25,1,0,0.5,-0.25,0,0,100) +X3Row <- c(1.5,0,1,0,1.5,0,0,230) +tableau[4,] <- OldX7Row - (CoeffX2 %*% tableau[1,] + CoeffX3 %*% tableau[2,]) +tableau diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.3/4.5.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.3/4.5.3.R new file mode 100644 index 00000000..0af96530 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.3/4.5.3.R @@ -0,0 +1,51 @@ +##Chapter 4 : Duality and Post-optimal Analysis +##Example 5-3 : Page 187 + +##Situation 1 +NewObjCoeffBasic <- c(3,4,0) +Inverse <- rbind(c(0.5,-0.25,0),c(0,0.5,0),c(-2,1,1)) + +NewDualVariables <-NewObjCoeffBasic %*% Inverse +NewDualVariables + +##Element-wise multiplication to get Reduced Costs +ReducedCostX1<-sum(c(1,3,1)*NewDualVariables) -2 +ReducedCostX4<-sum(c(1,0,0)*NewDualVariables) -0 +ReducedCostX5<-sum(c(0,1,0)*NewDualVariables) -0 +ReducedCostX1 +ReducedCostX4 +ReducedCostX5 + + +CurrentOptimal <- c(0,100,230) +NewObjCoeff<-c(2,3,4) + +#Optimal Objective value +NewRevenue <- sum(NewObjCoeff*CurrentOptimal) +NewRevenue + +##Situation 2 +NewObjCoeffBasic <- c(3,4,0) +Inverse <- rbind(c(0.5,-0.25,0),c(0,0.5,0),c(-2,1,1)) + +NewDualVariables <-NewObjCoeffBasic %*% Inverse +NewDualVariables + +##Element-wise multiplication to get Reduced Costs +ReducedCostX1<-sum(c(1,3,1)*NewDualVariables) -6 +ReducedCostX4<-sum(c(1,0,0)*NewDualVariables) -0 +ReducedCostX5<-sum(c(0,1,0)*NewDualVariables) -0 +ReducedCostX1 +ReducedCostX4 +ReducedCostX5 + +NewObjCoeff<-c(-0.75,0,0,1.5,1.25,0) +C1<-c(-0.25,1,0,0.5,-0.25,0) +bc1<-100 +C2<-c(1.5,0,1,0,0.5,0) +bc2<-230 +C3<-c(2,0,0,-2,1,1) +bc3<-20 +library("lpSolve") +solution=lp("max", NewObjCoeff, rbind(C1, C2, C3), rep("=",3), c(bc1, bc2, bc3)) +solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.4/4.5.4.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.4/4.5.4.R new file mode 100644 index 00000000..b6265dc1 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH4/EX4.5.4/4.5.4.R @@ -0,0 +1,11 @@ +##Chapter 4 : Duality and Post-optimal Analysis +##Example 5-4 : Page 189 +OptimalDualValues<-c(1,2,0) + +ReducedCostX7 <-sum(c(1,1,2)*OptimalDualValues)-4 +ReducedCostX7 + +Inverse <- rbind(c(0.5,-0.25,0),c(0,0.5,0),c(-2,1,1)) +OldX7Col<-rbind(1,1,2) +NewX7Col<-Inverse%*%OldX7Col +NewX7Col diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.1.1/5.1.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.1.1/5.1.1.R new file mode 100644 index 00000000..4508f541 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.1.1/5.1.1.R @@ -0,0 +1,18 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 1-1 : Page 195 +##Refer to the transportation tableau in Page 197 +costs <- matrix (c(80,215,100,108,102,68), 3, 2,byrow = T) + +#Constraints 1,2 & 3 are row constraints as they corresponds to rows of transportation tableau +row.signs <-rep("=",3) +row.rhs <-c(1000,1500,1200) + +#Constraints 4 & 5 are coloumn constraints as they corresponds to coloumns of transportation tableau +col.signs <-rep("=",2) +col.rhs <-c(2300,1400) + +library(lpSolve) +##lpSolve library has lp.transport function specially for problems which can be formulated as a transportation tableau +solution <- lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs) +solution$objval +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.1.2/5.1.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.1.2/5.1.2.R new file mode 100644 index 00000000..87c433f5 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.1.2/5.1.2.R @@ -0,0 +1,33 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 1-2 : Page 197 + +##Part1- Adding a dummy origin +costs <- matrix (c(80,215,100,108,102,68,0,0), 4, 2,byrow = T) + +#Constraints 1 to 4 are row constraints as they corresponds to rows of transportation tableau +row.signs <-rep("=",4) +row.rhs <-c(1000,1300,1200,200) + +#Constraints 5 & 6 are coloumn constraints as they corresponds to coloumns of transportation tableau +col.signs <-rep("=",2) +col.rhs <-c(2300,1400) + +library(lpSolve) +solution <- lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs) +solution$solution + + +##Part2 - Adding a dummy destination +costs <- matrix (c(80,215,0,100,108,0,102,68,0), 3, 3,byrow = T) + +#Constraints 1,2 & 3 are row constraints as they corresponds to rows of transportation tableau +row.signs <-rep("=",3) +row.rhs <-c(1000,1500,1200) + +#Constraints 4 & 5 are coloumn constraints as they corresponds to coloumns of transportation tableau +col.signs <-rep("=",3) +col.rhs <-c(1900,1400,400) + +library(lpSolve) +solution <- lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs) +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.2.1/5.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.2.1/5.2.1.R new file mode 100644 index 00000000..84c75a24 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.2.1/5.2.1.R @@ -0,0 +1,17 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 2-1 : Page 202 + +costs <- 40 + matrix (c(0,0.5,1,1.5,2,0,0.5,1,4,2,0,0.5,6,4,2,0), 4, 4,byrow = T) + +#Constraints 1,2,3 & 4 are row constraints as they corresponds to rows of transportation tableau +row.signs <-rep("=",4) +row.rhs <-c(50,180,280,270) + +#Constraints 4 to 8 are coloumn constraints as they corresponds to coloumns of transportation tableau +col.signs <-rep("=",4) +col.rhs <-c(100,200,180,300) + +library(lpSolve) +solution <- lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs) +solution$solution +solution$objval \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.2.2/5.2.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.2.2/5.2.2.R new file mode 100644 index 00000000..93d7ce6d --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.2.2/5.2.2.R @@ -0,0 +1,29 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 2-2 : Page 203 + +#BigM is Big +BigM=1000 + +#Initializing the matrix with all values as M +costs<-matrix(BigM,8,8,byrow = T) +#All values of first row are 12 +costs[1,]=c(rep(12,8)) +#All values of 8th column is 0 +costs[,8]=rbind(rep(0,8)) + +##Adding the rest of the values +for (i in 2:7) { + costs[i,]=c(rep(BigM,i-1),c(6,5,rep(3,4))[1:(8-i)],0) +} + +#Constraints 1 to 8 are row constraints as they corresponds to rows of transportation tableau +row.signs <-rep("=",8) +row.rhs <-c(124,24,12,14,20,18,14,22) + +#Constraints 8 to 16 are coloumn constraints as they corresponds to coloumns of transportation tableau +col.signs <-rep("=",8) +col.rhs <-c(24,12,14,20,18,14,22,124) + +library(lpSolve) +solution <- lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs) +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.1/5.3.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.1/5.3.1.R new file mode 100644 index 00000000..b223424d --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.1/5.3.1.R @@ -0,0 +1,16 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 3-1 : Page 207 +costs <- matrix (c(10,2,20,11,12,7,9,20,4,14,16,18), 3, 4,byrow = T) + +#Constraints 1,2 & 3 are row constraints as they corresponds to rows of transportation tableau +row.signs <-rep("=",3) +row.rhs <-c(15,25,10) + +#Constraints 4 & 5 are coloumn constraints as they corresponds to coloumns of transportation tableau +col.signs <-rep("=",4) +col.rhs <-c(5,15,15,15) + +library(lpSolve) +solution <- lp.transport (costs, "min", row.signs, row.rhs, col.signs, col.rhs) +solution$objval +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.2/5.3.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.2/5.3.2.R new file mode 100644 index 00000000..e879deed --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.2/5.3.2.R @@ -0,0 +1,33 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 3-2 : Page 208 +costs <- matrix (c(10,2,20,11,12,7,9,20,4,14,16,18), 3, 4,byrow = T) +row.rhs <-c(15,25,10) +col.rhs <-c(5,15,15,15) +i=1;j=1 +allotment <- matrix (rep(0,12), 3, 4,byrow = T) + +while (sum(row.rhs) & sum(col.rhs)) { + ##Till we reach the last row and coloumn + while (i<=3 & j<=4) { + ##if demand is >= supply + if (row.rhs[i] >= col.rhs[j]) { + ##assign the demand to that cell + allotment[i,j]=col.rhs[j] + ##deduct supply from demand + row.rhs[i]=row.rhs[i]-col.rhs[j] + ##assign zero to supply + col.rhs[j]=0 + }else { + ##assign the supply to that cell + allotment[i,j]=row.rhs[i] + ##deduct demand from supply + col.rhs[j]=col.rhs[j]-row.rhs[i] + ##assign zero to demand + row.rhs[i]=0 + + } + #if demand=0, go to the next demand,else go to next supply + ifelse(row.rhs[i] == 0,(i=i+1),(j=j+1)) + } +} +allotment \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.3/5.3.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.3/5.3.3.R new file mode 100644 index 00000000..eb2b868a --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.3/5.3.3.R @@ -0,0 +1,41 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 3-3 : Page 209 +costs <- matrix (c(10,2,20,11,12,7,9,20,4,14,16,18), 3, 4,byrow = T) +row.rhs <-c(15,25,10) +col.rhs <-c(5,15,15,15) +costsdup <- costs +allotment <- matrix (rep(0,12), 3, 4,byrow = T) + +#until there are supply and demand +while (sum(row.rhs) & sum(col.rhs)) { + #index of min cost + index=which.min(costsdup) + #get the row index + rowindex=index %% length(row.rhs) + #get the coloumn index + colindex=ceiling(index/length(row.rhs)) + #if row index=0 ,assign 3(since we are takinf modulus) + if (rowindex==0) {rowindex=3} + + #if demand > supply + if(row.rhs[rowindex]>=col.rhs[colindex]){ + #allocate supply to that cell + allotment[index] <- col.rhs[colindex] + ##deduct supply from demand + row.rhs[rowindex] <- row.rhs[rowindex]-col.rhs[colindex] + ##assign zero to supply + col.rhs[colindex]=0 + }else{ + #allocate demand to that cell + allotment[index] <- row.rhs[rowindex] + ##deduct demand from supply + col.rhs[colindex] <- col.rhs[colindex]-row.rhs[rowindex] + ##assign zero to demand + row.rhs[rowindex]=0 + } + costsdup[index]=1000 + +} + + +allotment \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.5/5.3.5.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.5/5.3.5.R new file mode 100644 index 00000000..a4d872b2 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.3.5/5.3.5.R @@ -0,0 +1,15 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 3-5 : Page 212 +#u-v incidence matrix with columns - u1,v1,v2,u2,v3,v4,u3 and rows as uv equations +a=matrix(c(1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,1),6,7,byrow = T) + +#cost matrix +costs <- matrix (c(10,2,20,11,12,7,9,20,4,14,16,18), 3, 4,byrow = T) +#rhs of uv equations +n=c(10,2,7,9,20,18) + +library(limSolve) +##Least Squares with Equality and Inequality Constraints +Sol=lsei(E=a, F=n, A = diag(7), B = rep(0, 7),G=diag(7),H=rep(0, 7), verbose = FALSE)$X + +c(Sol[1]+Sol[5]-20,Sol[1]+Sol[6]-11,Sol[4]+Sol[2]-12,Sol[7]+Sol[2]-4,Sol[7]+Sol[3]-14,Sol[7]+Sol[5]-16) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.4.1/5.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.4.1/5.4.1.R new file mode 100644 index 00000000..c46e7458 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.4.1/5.4.1.R @@ -0,0 +1,32 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 4-1 : Page 221 +costs <- matrix (c(15,10,9,9,15,10,10,12,8), 3, 3,byrow = T) +rowmin<-numeric() +colmin<-numeric() + +##Subtracting minimum cost element of row from all the elements of rows +for(i in 1:nrow(costs)){ + costs[i,]<-costs[i,]-min(costs[i,]) +} + +##Subtracting minimum cost element of column from all the elements of column +for(i in 1:ncol(costs)){ + costs[,i]<-costs[,i]-min(costs[,i]) +} + +##logic1 is a boolean matrix which contains true if cost matrix after the above operations is 0 and 0 otherwise +logic1<-costs==0 +eqnrow<-numeric() + +##We formulate it as a transportation tableau such that only one zero is selected from every row and every column +row.signs <-rep("=",nrow(costs)) +row.rhs <-rep(1,nrow(costs)) + +col.signs <-rep("=",ncol(costs)) +col.rhs <-rep(1,ncol(costs)) + +library(lpSolve) +Solution<-lp.transport (logic1, "max", row.signs, row.rhs, col.signs, col.rhs) +if (Solution$objval==nrow(costs)){ + Solution$solution +} diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.4.2/5.4.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.4.2/5.4.2.R new file mode 100644 index 00000000..2bd4e064 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH5/EX5.4.2/5.4.2.R @@ -0,0 +1,45 @@ +##Chapter 5 : Transportation Model and its Variant +##Example 4-2 : Page 222 +costs <- matrix (c(1,4,6,3,9,7,10,9,4,5,11,7,8,7,8,5), 4, 4,byrow = T) +rowmin<-numeric() +colmin<-numeric() +costsdup<-costs + +##Subtracting minimum cost element of row from all the elements of rows +for(i in 1:nrow(costsdup)){ + costsdup[i,]<-costsdup[i,]-min(costsdup[i,]) +} + +##Subtracting minimum cost element of column from all the elements of column +for(i in 1:ncol(costsdup)){ + costsdup[,i]<-costsdup[,i]-min(costsdup[,i]) +} + + +##We formulate it as a transportation tableau such that only one zero is selected from every row and every column +##maketable function returns the constraint matrix +eqnrow<-numeric() +maketable<-function(costsdup){ + logic1<-costsdup==0 + return(logic1) +} + +matr<-maketable(costsdup) + +row.signs <-rep("=",nrow(costsdup)) +row.rhs <-rep(1,nrow(costsdup)) + +col.signs <-rep("=",ncol(costsdup)) +col.rhs <-rep(1,ncol(costsdup)) +library(lpSolve) + +Solution<-lp.transport (matr, "max", row.signs, row.rhs, col.signs, col.rhs) +while(Solution$objval!=nrow(costsdup)){ + costsdup<-costsdup-min(costsdup[costsdup>0]) + for (i in 1:length(costsdup)){ + ifelse(costsdup[i]<0, (costsdup[i]=0),0) + } + matr<-maketable(costsdup) + Solution<-lp.transport (matr, "max", row.signs, row.rhs, col.signs, col.rhs) +} +Solution$solution \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.2.1/6.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.2.1/6.2.1.R new file mode 100644 index 00000000..5150fccf --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.2.1/6.2.1.R @@ -0,0 +1,31 @@ +##Chapter 6 : Network Model +##Example 2-1 : Page 239 + +#If you have trouble installing the package/library, please reinstall R form the following link:https://cran.r-project.org/bin/ +library(igraph) +#creating the undirected graph with 6 nodes +A=graph(edges=c(1,2,1,5,1,3,1,4,2,5,2,3,2,4,3,4,3,6,4,5,4,6), n=6, directed=F ) +#mst function generates the minimum spanning tree +MST<-mst(A,weights = c(1,9,5,7,3,6,4,5,10,8,3)) + +#The Fruchterman-Reingold Algorithm is a force-directed layout algorithm. The idea of a force directed layout algorithm is to consider +#a force between any two nodes. In this algorithm, the nodes are represented by steel rings and the edges are springs between them. +#The attractive force is analogous to the spring force and the repulsive force is analogous to the electrical force. The basic idea is +#to minimize the energy of the system by moving the nodes and changing the forces between them. +#Here we create the cordinates for our graph using layout.fruchterman.reingold function +lay <- layout.fruchterman.reingold(A) + +#Assigning the coordinates to the nodes of A +V(A)$x <- lay[, 1] +V(A)$y <- lay[, 2] + +#assigning range of x and y +xlim <- range(lay[,1]) +ylim <- range(lay[,2]) + +#plot graph A +plot.igraph(A, layout = lay,vertex.size=20, + xlim = xlim, ylim = ylim, rescale = FALSE) +#plot MST with red edges and nodes over the previous graph +plot.igraph(MST, layout = lay,vertex.color="red", edge.color="red",vertex.size=20, + add = TRUE, rescale = FALSE) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.1/6.3.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.1/6.3.1.R new file mode 100644 index 00000000..802b0487 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.1/6.3.1.R @@ -0,0 +1,34 @@ +##Chapter 6 : Network Model +##Example 3-1 : Page 243 + +#If you have trouble installing the package/library, please reinstall R form the following link:https://cran.r-project.org/bin/ +library(igraph) + +#creating the directed graph with 5 nodes +A=graph(edges=c(1,2,1,3,1,4,2,3,2,4,2,5,3,4,3,5,4,5), n=5, directed=T ) +#creating weights vector for each edges of the graph +weightsg<-c(4000,5400,9800,4300,6200,8700,4800,7100,4900) +#get shortest path from 1 to 5 +sP<-get.shortest.paths(A, 1, to=5,weights =weightsg)$vpath +#get shortest path cost from 1 to 5 +sPCost<-shortest.paths(A, 1, to=5,weights =weightsg) +sP +sPCost + +#creating coordinates for layout +l<-cbind(seq(0,9,2),0) + +#plot the graph with straight edges(edge 1,4,7 & 9 are straight edges.The order of edges is taken from graph initialization in line 6) +plot(delete.edges(A,c(2,3,5,6,8)),layout=l*2,vertex.size=15,edge.arrow.width = 0.2, asp = 0.5,edge.label=weightsg[c(1,4,7,9)]) +#plot the graph with straight edges over the previous graph +plot(delete.edges(A,c(1,4,7,9)),edge.curved=.8,layout=l*2,vertex.size=15,edge.arrow.width = 0.2,asp = 0.5,edge.label=weightsg[c(2,3,5,6,8)],add=T) +A[] <- 0 +#assign color red to each node of the graph in the shortest path +for (ed in 1:(length(sP[[1]])-1)){ + A<-A+edge(c(sP[[1]][ed],sP[[1]][ed+1]),color="red") + V(A)[sP[[1]][ed]]$color<-"red" +} +V(A)[5]$color<-"red" + +#plot the shortest path over the previous graph +plot(A,layout=l*2,vertex.size=15,edge.arrow.width = 0.2,edge.curved=.8,edge.color="orange", asp = 0.5,add=T) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.2/6.3.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.2/6.3.2.R new file mode 100644 index 00000000..222a3789 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.2/6.3.2.R @@ -0,0 +1,28 @@ +##Chapter 6 : Network Model +##Example 3-2 : Page 244 + +#If you have trouble installing the package/library, please reinstall R form the following link:https://cran.r-project.org/bin/ +library(igraph) +#creating the directed graph with 7 nodes +A=make_directed_graph(edges=c(1,2,1,3,2,4,2,3,3,4,3,5,4,5,4,6,5,7,6,7), n=7) +#creating probability vector +prob<-c(.2,.9,.8,.6,.1,.3,.4,.35,.25,.5) +#creating weight vector from probability vector +weightsg<--round(log10(prob),digits = 5) +##calculating shortest path and its cost +sP<-get.shortest.paths(A, 1, to=7,weights =weightsg)$vpath +sPCost<-shortest.paths(A, 1, to=7,weights =weightsg,mode = "out") +sP +10^(-sPCost) +#plotting the graph A +l<-layout.auto(A) +plot(A,vertex.size=15,layout=l,edge.arrow.width = 0.2, asp = 0.5,edge.label=weightsg) + +#plotting the shortest path over graph A +A[] <- 0 +for (ed in 1:(length(sP[[1]])-1)){ + A<-A+edge(c(sP[[1]][ed],sP[[1]][ed+1]),color="red") + V(A)[sP[[1]][ed]]$color<-"red" +} +V(A)[7]$color<-"red" +plot(A,vertex.size=15,layout=l, edge.arrow.width = 0.2,edge.color="orange", asp = 0.5,add=T) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.3/6.3.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.3/6.3.3.R new file mode 100644 index 00000000..b472dc62 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.3/6.3.3.R @@ -0,0 +1,28 @@ +##Chapter 6 : Network Model +##Example 3-3 : Page 245 +library(igraph) + +#creating the directed graph with 15 nodes +A=make_directed_graph(edges=c(1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,1,10,10,11,11,12,12,13,13,14,14,15,15,9,11,2,13,2,15,2,3,10,5,10,7,10), n=15) +#weights vector +weightsg<-rep(1,21) +#shortest path +sP<-get.shortest.paths(A, 1, to=9,weights =weightsg)$vpath +#shortest path cost +sPCost<-shortest.paths(A, 1, to=9,weights =weightsg,mode = "out") +sP +sPCost +#circle layout of graph +l<-layout.circle (A) +#plot graph A +plot(A,vertex.size=15,layout=l,edge.arrow.size = 0.2, asp = 0.5) + +#make an empty graph and add edges of the shortest path to the graph with red color nodes +A[] <- 0 +for (ed in 1:(length(sP[[1]])-1)){ + A<-A+edge(c(sP[[1]][ed],sP[[1]][ed+1]),color="red") + V(A)[sP[[1]][ed]]$color<-"red" +} +V(A)[9]$color<-"red" +#plot the shortest path over the previous graph +plot(A,vertex.size=15,layout=l, edge.arrow.size = 0.2,edge.color="orange", asp = 0.5,add=T) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.4/6.3.4.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.4/6.3.4.R new file mode 100644 index 00000000..91c8ca5a --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.4/6.3.4.R @@ -0,0 +1,57 @@ +##Chapter 6 : Network Model +##Example 3-4 : Page 248 + +# Initializing no of nodes and the distance matrix +n = 5 +d<-matrix(Inf,nrow=n,ncol = n) +d[1,2]=100;d[1,3]=30;d[2,3]=20;d[3,4]=10;d[3,5]=50;d[4,2]=15;d[4,5]=50 + +#initalizing the djiktra's algorithm table as shown in the book +djiktable<-matrix(c(1:n,rep(0,3*n)),nrow=n) + +now=1 +djiktable[1,4]=1 + +#if any of the node doesn't have any outgoing edge,make it permanent. Ex: node 5 +for (i in 1:5){ + if (length(which((d[i,]!=Inf) %in% TRUE))==0){ + djiktable[i,4]=1 + } +} +#while there are nodes with temporary status +while(sum(djiktable[,4])!=n){ + #find all the possibile nodes form current node + possibles<-which((d[now,]!=Inf) %in% TRUE) + #for each node in possible nodes + for (i in possibles){ + #assign current node to temp + temp<-djiktable[i,2] + #if current node is not assigned + if(djiktable[i,2]!=0){ + #the minimum of distance is added + djiktable[i,2]=min(djiktable[i,2],djiktable[now,2]+ d[now,i]) + }else{ + djiktable[i,2]=djiktable[now,2]+ d[now,i] + } + #if there is no change in the next node + if(djiktable[i,2]!=temp){ + #backtrack + djiktable[i,3]=now + } + } + + #assign permanent status to the minimum index + min.indx<-which.min(djiktable[possibles,2]) + djiktable[possibles[min.indx],4]=1 + now<- possibles[min.indx] +} + +#prints out the shortest route +djiktable[now,2] +path<-character() +while (now!=0){ + path<-paste("->",now,path) + now=djiktable[now,3] +} +path + diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.5/6.3.5.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.5/6.3.5.R new file mode 100644 index 00000000..b4c5b2ba --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.5/6.3.5.R @@ -0,0 +1,44 @@ +##Chapter 6 : Network Model +##Example 3-5 : Page 252 +#Initializing the nodes and floyd's D matrix and S matrix +n = 5 +floydD<-array(Inf,dim= c(5,5)) +diag(floydD) <- 0 +floydD[1,2]=3;floydD[1,3]=10;floydD[2,4]=5;floydD[3,4]=6;floydD[4,5]=4; + +#symmetric matrix +for(i in 1:5){ + j=1 + while(j",j,path) + j=floydseq[i,j] +} +path<-paste(i,"->",j,path) +path \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.6/6.3.6.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.6/6.3.6.R new file mode 100644 index 00000000..05bca4bf --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.3.6/6.3.6.R @@ -0,0 +1,31 @@ +##Chapter 6 : Network Model +##Example 3-6 : Page 256 + +# Objective function :Min 100 * x12 + 30 * x13 +20* x23 + 10*x34 + 60 * x35 + 15 * x42 + 50 * x45 +a <- c(100,30,20,10,60,15,50) + +# Constraint 1 : x12 + x13 = 1 +C1 <- c(1,1,0,0,0,0,0) +bc1<- 1 + +# Constraint 2 : x12 + x42 - x23 = 1 +C2 <- c(1,0,-1,0,0,1,0) +bc2<-1 + +# Constraint 3 : x13 + x23 - x34 -x35 = 0 +C3 <- c(0,1,1,-1,-1,0,0) +bc3<-0 + +# Constraint 4 : x34 - x42 - x45 = 0 +C4 <- c(0,0,0,1,0,-1,-1) +bc4<-0 + +# Constraint 5 : x35 + x45 = 0 +C5 <- c(0,0,0,0,1,0,1) +bc5<-0 + +library("lpSolve") + +solution<-lp("min", a, rbind(C1, C2,C3,C4,C5), rep("=",5), c(bc1, bc2,bc3,bc4,bc5)) +solution$objval +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.4.2/6.4.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.4.2/6.4.2.R new file mode 100644 index 00000000..d5eb931b --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.4.2/6.4.2.R @@ -0,0 +1,19 @@ +##Chapter 6 : Network Model +##Example 4-2 : Page 263 + +#If you have trouble installing the package/library, please reinstall R form the following link:https://cran.r-project.org/bin/ +library(optrees) +#edge matrix with weights +arcs<-matrix(c(1,2,20, + 1,3,30, + 1,4,10, + 1,3,30, + 1,4,10, + 2,3,40, + 2,5,30, + 2,5,30, + 3,5,20, + 4,5,20), +byrow=T,ncol=3) +#Finds the min cut for maximal flow +findMinCut(1:5, arcs, algorithm = "Ford-Fulkerson", source.node = 1,sink.node = 5, directed = T)$max.flow \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.4.3/6.4.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.4.3/6.4.3.R new file mode 100644 index 00000000..e1cefa5b --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.4.3/6.4.3.R @@ -0,0 +1,66 @@ +##Chapter 6 : Network Model +##Example 4-3 : Page 271 + +# Objective function 1 :Max x12 + x13 + x14 +a <- c(1,1,1,0,0,0,0,0,0) + +# Objective function 2 :Max x25 + x35 + x45 +b <- c(0,0,0,0,1,0,1,0,1) + +# Constraint 1 : x12 - x23 - x25 = 0 +C1 <- c(1,0,0,-1,-1,0,0,0,0) +bc1<- 0 + +# Constraint 2 : x13 + x23 - x34 -x35 + x43 = 0 +C2 <- c(0,1,0,1,0,-1,-1,1,0) +bc2<-0 + +# Constraint 3 : x14 + x34 - x43 -x45 = 0 +C3 <- c(0,0,1,0,0,1,0,-1,-1) +bc3<-0 + +# Constraint 4 : x12 <= 20 +C4 <- c(1,0,0,0,0,0,0,0,0) +bc4<-20 + +# Constraint 5 : x13 <= 30 +C5 <- c(0,1,0,0,0,0,0,0,0) +bc5<-30 + +# Constraint 6 : x14 <= 10 +C6 <- c(0,0,1,0,0,0,0,0,0) +bc6<-10 + +# Constraint 7 : x23 <= 40 +C7 <- c(0,0,0,1,0,0,0,0,0) +bc7<-40 + +# Constraint 8 : x25 <= 30 +C8 <- c(0,0,0,0,1,0,0,0,0) +bc8<-30 + +# Constraint 9 : x34 <= 10 +C9 <- c(0,0,0,0,0,1,0,0,0) +bc9<-10 + +# Constraint 10 : x35 <= 20 +C10 <- c(0,0,0,0,0,0,1,0,0) +bc10<-20 + +# Constraint 11 : x43 <= 5 +C11 <- c(0,0,0,0,0,0,0,1,0) +bc11<-5 + +# Constraint 12 : x45 <= 20 +C12 <- c(0,0,0,0,0,0,0,0,1) +bc12<-20 + +library("lpSolve") + +solution<-lp("max", a, rbind(C1, C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12), c(rep("=",3),rep("<=",9)), c(bc1, bc2,bc3,bc4,bc5,bc6,bc7,bc8,bc9,bc10,bc11,bc12)) +solution$objval +solution$solution + +solution<-lp("max", b, rbind(C1, C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12), c(rep("=",3),rep("<=",9)), c(bc1, bc2,bc3,bc4,bc5,bc6,bc7,bc8,bc9,bc10,bc11,bc12)) +solution$objval +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.1/6.5.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.1/6.5.1.R new file mode 100644 index 00000000..9bf13367 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.1/6.5.1.R @@ -0,0 +1,12 @@ +##Chapter 6 : Network Model +##Example 4-3 : Page 275 +library(igraph) +#create a directed graph +A=make_directed_graph(edges=c(1,2,3,4,4,6,6,7,7,8,8,9,1,3,1,5,5,7,1,8), n=9) + +#creating layout for plot +l<-cbind(c(1,1.5,3,5,4.5,7,9,11,13),c(1,3,3,3,2,3,2,1,1)) + +#creating plot +plot(A,vertex.size=15,layout=l,edge.arrow.size = 0.5, asp = 0.2,edge.label=c("A -3","E - 2","F - 2","G - 2","I - 2","J - 4","B - 2","D - 3","H - 1","C - 4") ) +plot(graph(c(2,3),n=9),layout=l,edge.arrow.size = 0.5,asp = 0.2,edge.lty=2,add=T) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.2/6.5.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.2/6.5.2.R new file mode 100644 index 00000000..b551d143 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.2/6.5.2.R @@ -0,0 +1,43 @@ +##Chapter 6 : Network Model +##Example 5-2 : Page 280 + +#create distance matrix with -1 meaning no edge and 0 meaning no cost edge +D<-matrix(c(-1,5,6,-1,-1,-1,-1,-1,3,8,-1,-1,-1,-1,-1,-1,2,11,-1,-1,-1,-1,0,1,-1,-1,-1,-1,-1,12,-1,-1,-1,-1,-1,-1),nrow=6,ncol = 6,byrow = T) + +##Forward pass +ECT<-numeric() +ECT[1]<-0 +for(i in 2:6){ + index<-which((D[,i]>=0) %in% TRUE) + ECT[i]<-max(ECT[index]+D[index,i]) +} + +##Backward pass +BP<-numeric() +BP[6]<-ECT[6] +for(i in 5:1){ + index<-which((D[i,]>=0) %in% TRUE) + BP[i]<-min(BP[index]-D[i,index]) +} + +##Finding critical nodes +critical<-character() +criti<-numeric() +critj<-numeric() +for(i in 1:6){ + for(j in 1:6){ + if(BP[i]==ECT[i] & BP[j]==ECT[j] & BP[j]-ECT[i]==D[i,j]){ + critical<-cbind(critical,paste(i,"-",j)) + criti=cbind(criti,i) + critj=cbind(critj,j) + } + } +} +critical + +##Duration of the project +TotalDays<-0 +for (i in 1:length(criti)){ + TotalDays<-TotalDays+D[criti[i],critj[i]] +} +TotalDays \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.3/6.5.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.3/6.5.3.R new file mode 100644 index 00000000..9c9fcaea --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.3/6.5.3.R @@ -0,0 +1,18 @@ +##Chapter 6 : Network Model +##Example 5-3 : Page 282 +#Add an empty plot +plot(1, type="n", axes=T, xlab="Days", ylab="", yaxt='n',xlim=c(0,25),ylim=c(0,10), yaxs= "i", xaxs = "i") + +#Add line segment for each segment +segments(0, 9, x1 = 5, y1 = 9) +segments(5, 8, x1 = 13, y1 = 8) +segments(13, 7, x1 = 25, y1 = 7) +segments(0, 6, x1 = 11, y1 = 6,lty = 2) +segments(5, 5, x1 = 11, y1 = 5,lty = 2) +segments(8, 4, x1 = 13, y1 = 4,lty = 2) +segments(8, 3, x1 = 25, y1 = 3,lty = 2) +segments(13, 2, x1 = 25, y1 = 2,lty = 2) +#Add text at specific coordinates +text(c(2.5,5,7.5,8,10.5,16,19,19),c(9,6,5,8,4,3,2,7)+0.3,labels = c("A - 5","B -6","C - 3","D -8","E - 2","F - 11","G - 1","H - 12"),cex = 0.6) +#Add legend +legend('topright', c("Critical","Non-Critical") ,lty=c(1,2), bty='n', cex=.75) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.4/6.5.4.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.4/6.5.4.R new file mode 100644 index 00000000..60310d02 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.4/6.5.4.R @@ -0,0 +1,63 @@ +##Chapter 6 : Network Model +##Example 5-4 : Page 284 + +#create distance matrix with -1 meaning no edge and 0 meaning no cost edge +D<-matrix(c(-1,5,6,-1,-1,-1,-1,-1,3,8,-1,-1,-1,-1,-1,-1,2,11,-1,-1,-1,-1,0,1,-1,-1,-1,-1,-1,12,-1,-1,-1,-1,-1,-1),nrow=6,ncol = 6,byrow = T) + +##Forward pass +ECT<-numeric() +ECT[1]<-0 +for(i in 2:6){ + index<-which((D[,i]>=0) %in% TRUE) + ECT[i]<-max(ECT[index]+D[index,i]) +} + +##Backward pass +BP<-numeric() +BP[6]<-ECT[6] +for(i in 5:1){ + index<-which((D[i,]>=0) %in% TRUE) + BP[i]<-min(BP[index]-D[i,index]) +} + +##Finding critical nodes +critical<-character() +criti<-numeric() +critj<-numeric() +for(i in 1:6){ + for(j in 1:6){ + if(BP[i]==ECT[i] & BP[j]==ECT[j] & BP[j]-ECT[i]==D[i,j]){ + critical<-cbind(critical,paste(i,"-",j)) + criti=cbind(criti,i) + critj=cbind(critj,j) + } + } +} +critical + +##Duration of the project +TotalDays<-0 +for (i in 1:length(criti)){ + TotalDays<-TotalDays+D[criti[i],critj[i]] +} +TotalDays + +#Calculating total float and free float for non-critical activities +NonCritical<-matrix(c(1,3,2,3,3,5,3,6,4,6),ncol=2,byrow = T) +NCA<-character() +duration<-numeric() +TotalF<-numeric() +FreeF<-numeric() +for(i in 1:length(NonCritical[,1])){ + j<-NonCritical[i,1] + k<-NonCritical[i,2] + NCA[i]<-paste(j,"-->",k) + duration[i]<- D[j,k] + TotalF[i]<- BP[k]-ECT[j]-D[j,k] + FreeF[i]<-ECT[k]-BP[j]-D[j,k] +} + +#Displaying df +df<-data.frame(NCA,duration,TotalF,FreeF) +names(df)<-c("Non-Critical Activity","Duration","Total Float","Free float") +df \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.5/6.5.5.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.5/6.5.5.R new file mode 100644 index 00000000..ccae40f1 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH6/EX6.5.5/6.5.5.R @@ -0,0 +1,33 @@ +##Chapter 6 : Network Model +##Example 5-5 : Page 288 + +# Objective function :Max 6*x12 + 6*x13 + 3*x23 + 8*x24 + 2*x35 + 11*x36 +1 *x46 + 12*x56 +a <- c(6,6,3,8,2,11,0,1,12) + +# Constraint 1 : -x12 - x13 = -1 +C1 <- c(-1,-1,0,0,0,0,0,0,0) +bc1<- -1 + +# Constraint 2 : x12 - x23 - x24 = 0 +C2 <- c(1,0,-1,-1,0,0,0,0,0) +bc2<-0 + +# Constraint 3 : x13 + x23 - x35 - x36 = 0 +C3 <- c(0,1,1,0,-1,-1,0,0,0) +bc3<-0 + +# Constraint 4 : x24 -x45 -x46 = 0 +C4 <- c(0,0,0,1,0,0,-1,-1,0) +bc4<-0 + +# Constraint 5 : x35 + x45 - x56 = 0 +C5 <- c(0,0,0,0,1,0,1,0,-1) +bc5<-0 + +# Constraint 6 : x35 + x46 + x56 = 1 +C6 <- c(0,0,0,0,0,1,0,1,1) +bc6<-1 +library("lpSolve") +solution<-lp("max", a, rbind(C1, C2,C3,C4,C5,C6), rep("=",6), c(bc1, bc2,bc3,bc4,bc5,bc6)) +solution$objval +solution$solution \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.1.2/7.1.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.1.2/7.1.2.R new file mode 100644 index 00000000..211c7f0a --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.1.2/7.1.2.R @@ -0,0 +1,27 @@ +##Chapter 7 : Advanced Linear Programming +##Example 1-2 : Page 300 + +#Creating the A and b matrix +A=matrix(c(1,3,-1,2,-2,-2),nrow=2,byrow=T) +b=matrix(c(4,2),nrow=2) + + +s<-character() +basic<-character() +Type<-character() + +for(i in 3:1){ + for(j in i:3){ + ##if i!=j and ith and jth column are not linearly dependent + if(i!=j & !all(abs(A[,i]/A[,j])==c(1,1))){ + ##Solve for X with the ith and jth column + a<-solve(A[,c(i,j)])%*%b + s<-rbind(s,toString(a)) + basic<-rbind(basic,c(paste(i,"&",j))) + #if all values in a>=0,then feasible ,infeasible otherwise + Type<-rbind(Type,ifelse(all(a >= 0),"Feasible","Infeasible")) + } + } +} + +cbind(basic,s,Type) diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.1.3/7.1.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.1.3/7.1.3.R new file mode 100644 index 00000000..8d976124 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.1.3/7.1.3.R @@ -0,0 +1,22 @@ +##Chapter 7 : Advanced Linear Programming +##Example 1-3 : Page 303 + +# Objective function :Max x1 + 4*x2 + 2*x3 + 5*x4 +a <- c(1,4,7,5) + +# Constraint 1 : 2*x1 + x2 + 2*x3 + 4*x4 = 10 +C1 <- c(2,1,2,4) +bc1<- 10 + +# Constraint 2 : 3*x1 - x2 - 2*x3 + 6*x4 = 5 +C2 <- c(3,-1,-2,6) +bc2<-5 + +A<-rbind(C1,C2) +b<-rbind(bc1,bc2) + +Binv<-solve(A[,c(1,2)]) +X<-Binv%*%b + +Binv +X \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.2.1/7.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.2.1/7.2.1.R new file mode 100644 index 00000000..b428661d --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.2.1/7.2.1.R @@ -0,0 +1,16 @@ +##Chapter 7 : Advanced Linear Programming +##Example 2-1 : Page 309 + +# Objective function +a <- c(5,4,0,0,0,0) + +#Constraints +C<-rbind(c(6,4,1,0,0,0),c(1,2,0,1,0,0),c(-1,1,0,0,1,0),c(0,1,0,0,0,1)) +b<-rbind(24,6,1,2) +library("lpSolve") + +solution<-lp("max", a, C, rep("=",4), b) +solution$objval +solution$solution + +##This solver is based on the revised simplex method \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.3.1/7.3.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.3.1/7.3.1.R new file mode 100644 index 00000000..c9424c2f --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.3.1/7.3.1.R @@ -0,0 +1,13 @@ +##Chapter 7 : Advanced Linear Programming +##Example 3-1 : Page 315 +# Objective function +a <- c(3,5,2) + +#Constraints +C<-rbind(c(1,1,2),c(2,4,3),c(1,0,0),c(0,1,0),c(0,-1,0),c(0,0,1)) +b<-rbind(14,43,4,10,-7,3) +library("lpSolve") + +solution<-lp("max", a, C, rep("<=",6), b) +solution$objval +solution$solution \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.4.1/7.4.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.4.1/7.4.1.R new file mode 100644 index 00000000..69d3fc21 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH7/EX7.4.1/7.4.1.R @@ -0,0 +1,22 @@ +##Chapter 7 : Advanced Linear Programming +##Example 4-1 : Page 322 +# Objective function +w <- c(3,5,0,0) + +#Constraints +C<-rbind(c(1,2,1,0),c(-1,3,0,1)) +b<-rbind(5,2) + +B<-C[,c(1,4)] +Binv<-solve(B) + +#Associated primal and dual variables are assocprimal and assocdual +assocprimal<-Binv%*%b +assocdual<-w[c(1,4)]%*%Binv + +##the objective values are +primalobj<-c(3,0)%*%assocprimal +dualobj<-assocdual%*%c(5,0) + +primalobj +dualobj \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.1/8.1.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.1/8.1.1.R new file mode 100644 index 00000000..05bf4438 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.1/8.1.1.R @@ -0,0 +1,22 @@ +##Chapter 8 : Integer Linear Programming +##Example 1-1 : Page 336 + +# Objective function +a <- c(20,40,20,15,30) + +# Constraint 1 : +C1 <- c(5,4,3,7,8) +bc1<- 25 + +# Constraint 2 +C2 <- c(1,7,9,4,6) +bc2<-25 + +# Constraint 3 +C3 <- c(8,10,2,1,10) +bc3<-25 + +library("lpSolve") +solution<-lp("max", a, rbind(C1, C2,C3), rep("<=",3), c(bc1, bc2,bc3),all.bin=T) +solution$objval +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.2/8.1.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.2/8.1.2.R new file mode 100644 index 00000000..3b2ac1c6 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.2/8.1.2.R @@ -0,0 +1,54 @@ +##Chapter 8 : Integer Linear Programming +##Example 1-2 : Page 340 + +# Objective function +a <- rep(1,8) + +# Constraint 1 : +C1 <- c(1,1,rep(0,6)) +bc1<- 1 + +# Constraint 2 +C2 <- c(0,1,1,rep(0,5)) +bc2<-1 + +# Constraint 3 +C3 <- c(0,0,0,1,1,0,0,0) +bc3<-1 + +# Constraint 4 +C4 <- c(rep(0,6),1,1) +bc4<-1 + +# Constraint 5 +C5 <- c(rep(0,5),1,1,0) +bc5<-1 + +# Constraint 6 +C6 <- c(0,1,0,0,0,1,0,0) +bc6<-1 + +# Constraint 7 +C7 <- c(1,0,0,0,0,1,0,0) +bc7<-1 + +# Constraint 8 +C8 <- c(0,0,0,1,0,0,1,0) +bc8<-1 + +# Constraint 9 +C9 <- c(0,1,0,1,0,0,0,0) +bc9<-1 + +# Constraint 10 +C10 <- c(0,0,0,0,1,0,0,1) +bc10<-1 + +# Constraint 11 +C11 <- c(0,0,1,0,1,0,0,0) +bc11<-1 + +library("lpSolve") +solution<-lp("min", a, rbind(C1, C2,C3,C4,C5,C6,C7,C8,C9,C10,C11), rep(">=",11), c(bc1, bc2,bc3,bc4,bc5,bc6,bc7,bc8,bc9,bc10,bc11),all.bin=T) +solution$objval +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.3/8.1.3.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.3/8.1.3.R new file mode 100644 index 00000000..1d9c95ed --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.3/8.1.3.R @@ -0,0 +1,26 @@ +##Chapter 8 : Integer Linear Programming +##Example 1-3 : Page 346 + +# Objective function +a <- c(0.25,0.21,0.22,16,25,18) + +# Constraint 1 : +C1 <- c(1,1,1,0,0,0) +bc1<- 200 + +# Constraint 2 +C2 <- c(1,0,0,-200,0,0) +bc2<-0 + +# Constraint 3 +C3 <- c(0,1,0,0,-200,0) +bc3<-0 + +# Constraint 4 +C4 <- c(0,0,1,0,0,-200) +bc4<-0 + +library("lpSolve") +solution<-lp("min", a, rbind(C1, C2,C3,C4), c("=","<=","<=","<="), c(bc1, bc2,bc3,bc4),int.vec=c(4,5,6)) +solution$objval +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.4/8.1.4.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.4/8.1.4.R new file mode 100644 index 00000000..c1093445 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.1.4/8.1.4.R @@ -0,0 +1,48 @@ +##Chapter 8 : Integer Linear Programming +##Example 1-4 : Page 350 + +M<-1000 +# Objective function +a <- c(0,0,0,0,0,0,19,0,12,0,34,0) + +# Constraint 1 : +C1 <- c(1,-1,0,M,0,0,0,0,0,0,0,0) +bc1<- 20 + +# Constraint 2 +C2 <-c(-1,1,0,-M,0,0,0,0,0,0,0,0) +bc2<-5-M + +# Constraint 3 +C3 <- c(1,0,-1,0,M,0,0,0,0,0,0,0) +bc3<-15 + +# Constraint 4 +C4 <- c(-1,0,1,0,-M,0,0,0,0,0,0,0) +bc4<-5-M + +# Constraint 5 +C5 <- c(0,1,-1,0,M,0,0,0,0,0,0,0) +bc5<-15 + +# Constraint 6 +C6 <- c(0,-1,1,0,-M,0,0,0,0,0,0,0) +bc6<-20-M + + +# Constraint 7 +C7 <- c(1,0,0,0,0,0,-1,1,0,0,0,0) +bc7<-20 + +# Constraint 8 +C8 <- c(0,1,0,0,0,0,0,0,-1,1,0,0) +bc8<-2 + +# Constraint 9 +C9 <- c(0,0,1,0,0,0,0,0,0,0,-1,1) +bc9<-20 + +library("lpSolve") +solution<-lp("min", a, rbind(C1, C2,C3,C4,C5,C6,C7,C8,C9), c(rep(">=",6),rep("=",3)), c(bc1, bc2,bc3,bc4,bc5,bc6,bc7,bc8,bc9),int.vec=c(4,5,6)) +solution$objval +solution$solution diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.2.1/8.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.2.1/8.2.1.R new file mode 100644 index 00000000..a283f8e4 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.2.1/8.2.1.R @@ -0,0 +1,20 @@ +##Chapter 8 : Integer Linear Programming +##Example 2-1 : Page 356 + +# Objective function +a <- c(5,4) + +# Constraint 1 : +C1 <- c(1,1) +bc1<- 5 + +# Constraint 2 +C2 <-c(10,6) +bc2<-45 + +library("lpSolve") +solution<-lp("max", a, rbind(C1, C2), rep("<=",2), c(bc1, bc2),int.vec=c(1,2)) +solution$objval +solution$solution + +## lpSolve solver is based on the revised simplex method and a branch-and-bound (B&B) approach. \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.2.2/8.2.2.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.2.2/8.2.2.R new file mode 100644 index 00000000..dc931021 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH8/EX8.2.2/8.2.2.R @@ -0,0 +1,20 @@ +##Chapter 8 : Integer Linear Programming +##Example 2-2 : Page 364 + +# Objective function +a <- c(7,10) + +# Constraint 1 : +C1 <- c(-1,3) +bc1<- 6 + +# Constraint 2 +C2 <-c(7,1) +bc2<-35 + +library("lpSolve") +solution<-lp("max", a, rbind(C1, C2), rep("<=",2), c(bc1, bc2),int.vec=c(1,2)) +solution$objval +solution$solution + +## lpSolve solver is based on the revised simplex method and a branch-and-bound (B&B) approach. \ No newline at end of file diff --git a/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH9/EX9.2.1/9.2.1.R b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH9/EX9.2.1/9.2.1.R new file mode 100644 index 00000000..1b88ae13 --- /dev/null +++ b/Operations_Research:_An_Introduction_by_Hamdy_A_Taha/CH9/EX9.2.1/9.2.1.R @@ -0,0 +1,20 @@ +##Chapter 8 : Heuristic Programming +##Example 2-1 : Page 382 + +##Initializing function F, Random number R and index +F=c(90,60,50,80,100,40,20,70) +R=0.1002 +index=ceiling(R*8) +#while any of neighbouring values are lower,keep looping +while (F[index]>=F[index+1] | F[index]>=F[ifelse(index==1,1,index-1)]){ + #if the next index is less than the current index + if(F[index+1]4 | newx<0){newx<-x+(runif(1)-0.5)*(4-0)} + #if the new value is better than the old + if (F(newx)=60 + +p_M=3/6 +p_XM=p_M/p_M +print(p_XM) + +#if 40 <= x < 60 + +p_X=2/6 +p_XM=p_X/p_M +print(p_XM) + +#if 20 <= x < 40 + +p_X=1/6 +p_XM=p_X/p_M +print(p_XM) + +#if x<20 + +p_XM=0 +print(p_XM) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.19/Ex4_19.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.19/Ex4_19.R new file mode 100644 index 00000000..c9a74b1d --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.19/Ex4_19.R @@ -0,0 +1,14 @@ +#page no. 103-105 +#example 4-19 + +k=6 #number of heads +n=10 #number of specific tosses +p_B=(k+1)/(n+2) +print(p_B) + +#this example shows that if the probability density function of a random variable x is unknown, one should make +#noncommittal judgement about its a priori probability density function f(x). Usually, the uniform distribution +#is a reasonable assumption in the absence of any other information. then experimental results (A) are obtained +#and the knowledge about x is updated reflecting this new information. Bayes' rule helps to obtain the a posteriori +#probability density function of x given A. From that point on, this a posteriori probability density functin f(x|A) +#should be used to make further predictions and calculations \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.20/Ex4_20.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.20/Ex4_20.R new file mode 100644 index 00000000..2ea97cc5 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.20/Ex4_20.R @@ -0,0 +1,16 @@ +#page no. 107 +#example 4-20 + +p=q=0.5 #probability of head/tail when a coin is tossed +n=1000 #number of times the coin is tossed + +#part (a) +p_A=1/sqrt(2*3.14*n*p*q) +print(p_A) + +#part (b) + +p_B=(exp(-0.2))/(10*sqrt(5*3.14)) +print(p_B) + +#in book the solution of part (b) is rounded to 0.0207 \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.21/Ex4_21.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.21/Ex4_21.R new file mode 100644 index 00000000..c16a3163 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.21/Ex4_21.R @@ -0,0 +1,17 @@ +#page no. 107 +#example 4-21 + +p=0.5 +n=10 +k=5 +q=1-p + +#part (a) + +p_n_k=choose(n,k)*(p^k)*(q^(n-k)) #usig the "FUNDAMENTAL THEOREM" of Success or Failure of an Event A in n Independent Trials +print(p_n_k) + +#part (b) + +pnk=(exp((-(k-n*p)^2)/(2*n*p*q)))/sqrt(2*3.14*n*p*q) #using "The normal Approximation (DeMoivre-Laplace Theorem) +print(pnk) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.22/Ex4_22.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.22/Ex4_22.R new file mode 100644 index 00000000..bafb8e85 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.22/Ex4_22.R @@ -0,0 +1,19 @@ +#page no. 109 +#example 4-22 + +n=10000 #number of times the coin is tossed (given) +p=q=0.5 #probability of getting head(or tail) in one toss +k1=4900 +k2=5100 +x2=(k2-n*p)/sqrt(n*p*q) +print(x2) +x1=(k1-n*p)/sqrt(n*p*q) +print(x1) + +inte<-function(y){exp(-(y^2)/2)} #these two lines (13 and 14) gives the defination of function G(x) +Gx<-function(x){((1/(sqrt(2*3.14)))*integrate(inte,lower = 0,upper = x)[[1]])+0.5} #which is given on page number 106 + +probability=(2*Gx(2))-1 +cat("probability equals ",probability) + +#answer in the book is 0.9545 with is by apprimation of different values \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.23/Ex4_23.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.23/Ex4_23.R new file mode 100644 index 00000000..a78fd67a --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.23/Ex4_23.R @@ -0,0 +1,16 @@ +#page no. 109 +#example 4-23 + +K=50:70 #number of calls is 50 to 70 + + +probabilitySumation=sum((exp(-((K-60)^2)/80)/(4*sqrt(5*22/7)))) +cat("probability using sumation formula ",probabilitySumation) + +inte<-function(y){exp(-(y^2)/2)} #these two lines (10 and 11) gives the defination of function G(x) +Gx<-function(x){((1/(sqrt(2*3.14)))*integrate(inte,lower = 0,upper = x)[[1]])+0.5} #which is given on page number 106 + +probability=(2*Gx(sqrt(2.5)))-1 +cat("probability using G(x) function (The Normal Approximation) is ",probability) + +print("probability by both the methods are similar as lot of approximation comes into play in sumation formula") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.24/Ex4_24.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.24/Ex4_24.R new file mode 100644 index 00000000..a250d5b4 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.24/Ex4_24.R @@ -0,0 +1,46 @@ +#page no. 109 +#example 4-23 + +p=q=0.5 #(given) +e=0.05 + + + #taking n=100 +n1=100 +x1=e*sqrt(n1/(p*q)) + +inte<-function(y){exp(-(y^2)/2)} #these two lines gives the defination of function G(x) +Gx<-function(x){((1/(sqrt(2*3.14)))*integrate(inte,lower = 0,upper = x)[[1]])+0.5} #which is given on page number 106 + +probability1=(2*Gx(x1))-1 + + +#taking n=400 +n2=400 +x2=e*sqrt(n2/(p*q)) + +inte<-function(y){exp(-(y^2)/2)} #these two lines gives the defination of function G(x) +Gx<-function(x){((1/(sqrt(2*3.14)))*integrate(inte,lower = 0,upper = x)[[1]])+0.5} #which is given on page number 106 + +probability2=(2*Gx(x2))-1 + +#taking n=900 +n3=900 +x3=e*sqrt(n3/(p*q)) + +inte<-function(y){exp(-(y^2)/2)} #these two lines gives the defination of function G(x) +Gx<-function(x){((1/(sqrt(2*3.14)))*integrate(inte,lower = 0,upper = x)[[1]])+0.5} #which is given on page number 106 + +probability3=(2*Gx(x3))-1 + + + + +table <- matrix(c(n1,n2,n3,x1,x2,x3,probability1,probability2,probability3),ncol=3,byrow=TRUE) +#colnames(table) <- c("n") +rownames(table) <- c("n","0.1sqrt(n)","2G(0.1sqrt(n))-1") +table<-as.table(table) + +print("table shows the probability 2G(0.1sqrt(n))-1 that k is between 0.45n and 0.55n for various values of n ") + +table diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.26/Ex4_26.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.26/Ex4_26.R new file mode 100644 index 00000000..efc40516 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.26/Ex4_26.R @@ -0,0 +1,17 @@ +#page no. 111 +#example 4-26 + + + +p1=1/6 #A1={f1} +p2=3/6 #A2={f2,f4,f6} +p3=2/6 #A3={f3,f5} + +print(p1) +print(p2) +print(p3) + +p_10=(factorial(10)/(factorial(3)*factorial(6)*factorial(1)))*((1/6)^3)*((1/2)^6)*(1/3) #p10(3,6,1) +print(p_10) + +#answer in the book is given 0.002 which is wrong \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.27/Ex4_27.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.27/Ex4_27.R new file mode 100644 index 00000000..a43b7cfd --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.27/Ex4_27.R @@ -0,0 +1,13 @@ +#page no. 113 +#example 4-27 + +p=10^-3 #probability of faliure (given) +q=1-p +n=10^3 #number of components (given) + +p_K=q^n + + + +p_k=exp(-n*p) #after applying approximation techniques +print(p_k) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.28/Ex4_28.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.28/Ex4_28.R new file mode 100644 index 00000000..592a66b6 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.28/Ex4_28.R @@ -0,0 +1,11 @@ +#page no. 113-114 +#example 4-28 + +k=0:5 +p_K_lessthanequal_5=exp(-3)*sum(3^k/factorial(k)) +print(p_K_lessthanequal_5) + +p_K_greaterthan_5=1- p_K_lessthanequal_5 +print(p_K_greaterthan_5) + +#in book the answer is given 0.084 which is just round off \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.29/Ex4_29.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.29/Ex4_29.R new file mode 100644 index 00000000..944e3838 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.29/Ex4_29.R @@ -0,0 +1,33 @@ +#page no. 114-115 +#example 4-29 + +n=10^5 #number of people (given) +p=0.001 #porobability of causality (given) +lambda=n*p + + + #part (a) + +n0=(50*10^6)/200000 + + +del=(lambda*exp((1-lambda/n0)))/n0 + +cat("del equals",del,"so that del^250 = 0 and the desired probability is essentially 0") + + + + #part (b) + +n1=((50*10^6)-(25*10^6))/200000 +print(n1) + +del=0.9771 +deln1=del^n1 +print(deln1) + +p_x=1-((deln1*1)/(sqrt(2*3.14*n1))*((1-lambda)/(n1+1))) +print(p_x) + +#the answer in the book is 0.9904 which is approximation which signifies that the company is assured a profit of $25 +#million with almost certainty \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.30/Ex4_30.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.30/Ex4_30.R new file mode 100644 index 00000000..6ea153f2 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.30/Ex4_30.R @@ -0,0 +1,21 @@ +#page no. 115 +#example 4-30 + + + +#when lambda=4 +lambda=4 + +p_not_hit=(1+lambda)*exp(-lambda) +print(p_not_hit) +#this is given as 0.0916 which is just round off + + +#when lambda=5 +lambda=5 +p_not_hit=(1+lambda)*exp(-lambda) +print(p_not_hit) + +#if 5000 shots are fired at the aircraft then the probability of miss +p_miss=exp(-5) +print(p_miss) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.31/Ex4_31.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.31/Ex4_31.R new file mode 100644 index 00000000..0fca6ff2 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.31/Ex4_31.R @@ -0,0 +1,24 @@ +#page no. 115-116 +#example 4-31 + +#the probability of buying a winning ticket +no_of_winning_tickets=100 +total_no_of_tickets=10^6 +p=no_of_winning_tickets/total_no_of_tickets #the probability of buying a winning ticket +print(p) + +n=100 #number of ticket purchased +lambda=n*p + + #part (a) + +p_win=1- exp(-lambda) +print(p_win) + + #part (b) + +#in this part we have to find lambda such that the probability of winning is >=0.95 +#for that lambda should be >=3 +#for which n>=30000 +p_win=1- exp(-3) +print(p_win) #probability of winning comes out to be >=0.95 diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.32/Ex4_32.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.32/Ex4_32.R new file mode 100644 index 00000000..671ee97e --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.32/Ex4_32.R @@ -0,0 +1,10 @@ +#page no. 116 +#example 4-32 + +k=0:4 +n=20000 #number of components in spacecraft (given) +p=10^-4 #probability of any one component defective (given) +lambda=n*p + +p_danger_mission=1-(exp(-2)*sum((lambda^k)/factorial(k))) +print(p_danger_mission) diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.4/Ex4_4.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..345d8ecf --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,23 @@ +#page no. 76 +#example 4-4 + + +xfi=10i + +f100=1 #since it contain of the fi's therefore it is a certain event +f35=3/6 #since x<=35 will only include {f1,f2,f3} +f30.1=3/6 #since x<=35 will only include {f1,f2,f3} +f30=3/6 #since x<=35 will only include {f1,f2,f3} +f29.99=2/6 #since x<=35 will only include {f1,f2} +cat("F(100)=",f100) +cat("F(35)=",f35) +cat("F(30.1)=",f30.1) +cat("F(30)=",f30) +cat("F(29.99)=",f29.99) + +#distribution function of x is a staircase function as ploted below + +x <- c(0,10,20,30,40,50,60) +y=c(0,1/6,2/6,3/6,4/6,5/6,6/6) +plot(x, y, type = "S", ylab = "F(x)") + \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.9/Ex4_9.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.9/Ex4_9.R new file mode 100644 index 00000000..a6cf2f59 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH4/EX4.9/Ex4_9.R @@ -0,0 +1,15 @@ +#page no. 81 +#example 4-9 + +#for x<0 +fx=1/4 + +#for 1<=x<=2 + +fx=3/4 + + +print("the function f(x) comes out to be a staircase like function which is ploted below") +x <- c(0,1,2,3) +y<-c(0,1/4,3/4,1) +plot(x, y, type = "S", ylab = "F(x)") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.1/Ex5_1.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.1/Ex5_1.R new file mode 100644 index 00000000..0b5fd5b4 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.1/Ex5_1.R @@ -0,0 +1,13 @@ +#page no. 124-125 +#example 5-1 + + + #part (a) + +#a and b are constant in the function therefore assuming b=4 and a=2 for the purpose of ploting graphs + +curve((x-4)/2,from = -50, to= 50,main="part (a)",ylab ="y") + + #part(b) + +curve(1-((x-4)/2),from = -50, to= 50,main="part (b)",ylab ="y") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.10/Ex5_10.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.10/Ex5_10.R new file mode 100644 index 00000000..07b2860d --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.10/Ex5_10.R @@ -0,0 +1,15 @@ +#page no. 131 +#example 5-10 + +i=0.01 #(given) +ro=1000 #(given) + +#if r is between 900 and 1100 +r1=900 +v1=i*(r1+ro) + +r2=1100 +v2=i*(r2+ro) + + +cat("If the resistence r is a random varibale uniform between",r1,"and",r2,"ohm ,then v is uniform between ",v1,"and ",v2,"V") diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.17/Ex5_17.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.17/Ex5_17.R new file mode 100644 index 00000000..2071c717 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.17/Ex5_17.R @@ -0,0 +1,6 @@ +#page no. 140 +#example 5-17 + +ex=1/6*(1+2+3+4+5+6) + +cat("If x takes the values 1,2,..,6 with probability 1/6, then E{x}=",ex) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.2/Ex5_2.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.2/Ex5_2.R new file mode 100644 index 00000000..18a1195a --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.2/Ex5_2.R @@ -0,0 +1,6 @@ +#page no. 125-126 +#example 5-2 + + +# this is the cure of y=x^2 +curve(x^2,from = -20,to=20,ylab = "y",main="figure 5-3a") diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.27/Ex5_27.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.27/Ex5_27.R new file mode 100644 index 00000000..84875483 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.27/Ex5_27.R @@ -0,0 +1,19 @@ +#page no. 150-121 +#example 5-27 + + +E=120 #voltage +n=10^3 +sigma_square=(100^2)/3 +gn=E/n + +gnd=-1*E/(n^2) + +gndd=2*E/(n^3) + +cat("g(n)=",gn) +cat("g'(n)=",gnd) +cat("g''(n)=",gndd) + +cat("E{i}=",gn,"+",gndd*sigma_square/2) #using (5-85) +cat("sigma_i_square=",gnd^2*sigma_square) #using (5-87) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.5/Ex5_5.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.5/Ex5_5.R new file mode 100644 index 00000000..6db449f0 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.5/Ex5_5.R @@ -0,0 +1,8 @@ +#page no. 127-128 +#example 5-5 + +#the function Fy(y) is a staircase function and is ploted below + +x<-c(-2,-1,0,1,2) +y<-c(0,0.5,0.5,1,1) +plot(x, y, type = "s", ylab = "Fy(y)",xlab = "y" ,axes = TRUE) diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.9/Ex5_9.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.9/Ex5_9.R new file mode 100644 index 00000000..b30971ac --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH5/EX5.9/Ex5_9.R @@ -0,0 +1,53 @@ +#page no. 129 +#example 5-9 + +y=x^2 #given function + +#part(a) + +#for differenct values of x with probability 1/6 the respective values of y with probability 1/6 +x=1 +y=x^2 +print(y) + +x=2 +y=x^2 +print(y) + +x=3 +y=x^2 +print(y) + +x=6 +y=x^2 +print(y) + +#part (b) + +#y for different values of x with probability 1/6 + +x=-2 +y=x^2 +print(y) + +x=-1 +y=x^2 +print(y) + +x=0 +y=x^2 +print(y) + +x=1 +y=x^2 +print(y) + +x=2 +y=x^2 +print(y) + +x=3 +y=x^2 +print(y) + +print("on different values of x , y takes the values 0,1,4,9 with probabilities 1/6,2/6,2/6,1/6, respectively") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH7/EX7.16/Ex7_16.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH7/EX7.16/Ex7_16.R new file mode 100644 index 00000000..a4fa7554 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH7/EX7.16/Ex7_16.R @@ -0,0 +1,15 @@ +#page no. 280 +#example 7-16 + + +pk=function(k){choose(6,k)*(1/2^6)} +nk=function(k){exp(-((k-3)^2)/3)/(sqrt(3*22/7))} + + +table <- matrix(c(0,1,2,3,4,5,6,pk(0),pk(1),pk(2),pk(3),pk(4),pk(5),pk(6),nk(0),nk(1),nk(2),nk(3),nk(4),nk(5),nk(6)),ncol=7,byrow=TRUE) +#colnames(table) <- c("n") +rownames(table) <- c("k","Pk","N(n,sig)") +table<-as.table(table) +table + +#the values of Pk varies a little bit from the book because of approximation \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH7/EX7.4/Ex7_4.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH7/EX7.4/Ex7_4.R new file mode 100644 index 00000000..e4142487 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH7/EX7.4/Ex7_4.R @@ -0,0 +1,13 @@ +#page no. 247-248 +#example 7-4 + +x1=98.6 +x2=98.8 +x3=98.9 +sigma1=0.20 +sigma2=0.25 +sigma3=0.28 + +E=(x1/sigma1^2 + x2/sigma2^2 + x3/sigma3^2)/(1/sigma1^2 + 1/sigma2^2 + 1/sigma3^2) + +cat("estimate E obtained from (7-17) comes out to be ",E) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.1/Ex8_1.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.1/Ex8_1.R new file mode 100644 index 00000000..b6adb13e --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.1/Ex8_1.R @@ -0,0 +1,14 @@ +#page no. 305 +#example 8-1 + +#functions used +#qnorm():quantile function of the normal distribution:the quantile function maps from probabilities to values in normal distribution +#ceiling():ceiling(x) rounds to the nearest integer that's larger than x. + + +rho=0.05 + +z0.975=ceiling(qnorm(1-rho/2)) + +cat("we can expect with confidence coefficient 0.95 that the life expectancy of our battery will be between ",4-(z0.975*0.5),"and ",4+(z0.975*0.5),"years") + diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.2/Ex8_2.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.2/Ex8_2.R new file mode 100644 index 00000000..389c66e0 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.2/Ex8_2.R @@ -0,0 +1,11 @@ +#page no. 306 +#example 8-2 + +n=100 #number of times the coin is tossed (given) +p=0.5 #probability of getting head in one coin toss (given) +q=1-p +k1=n*p - 3*sqrt(n*p*q) +k2=n*p + 3*sqrt(n*p*q) + + +cat(" We predict,therefore, with confidence coefficient 0.997 that the number of heads will be between ",k1,"and ",k2) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.21/Ex8_21.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.21/Ex8_21.R new file mode 100644 index 00000000..044eab76 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.21/Ex8_21.R @@ -0,0 +1,23 @@ +#page no. 321 +#example 8-21 + +x_bar=110.12 +v0=110 +n=25 #number of times V is measured + + #part (a) + +sigma=0.4 +z=2 +q=(x_bar-v0)/(sigma/sqrt(n)) +print(q) + +cat("since", q, "is in the interval(-2,2), we accept H0") + + + #part (b) + +s=0.6 +q=(x_bar-v0)/(s/sqrt(n)) +print(q) +cat("since", q, "is in the interval(-2.06,2.06), we accept H0") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.22/Ex8_22.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.22/Ex8_22.R new file mode 100644 index 00000000..91a7bbb1 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.22/Ex8_22.R @@ -0,0 +1,14 @@ +#page no. 360 +#example 8-22 + +#functions used +#qnorm():quantile function of the normal distribution:the quantile function maps from probabilities to values in normal distribution + + +alpha=0.05 +z=qnorm(1-alpha) + +q=(62-50)/sqrt(25) + + +cat("since q=",q,">",z,"the fair coin hypothesis is rejected") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.24/Ex8_24.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.24/Ex8_24.R new file mode 100644 index 00000000..9190073a --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.24/Ex8_24.R @@ -0,0 +1,10 @@ +#page no. 362 +#example 8-24 + +k=c(55,43,44,61,40,57) #(given) +np0=50 #(given) +q=sum(((k-np0)^2)/np0) + +x=qchisq(0.95,5) #qchisq() is the function used to calculate Chi-square percentile value in R + +cat("Since (X0.95(5))^2 =",x,">",q," We accept the fair-die hypothesis") diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.25/Ex8_25.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.25/Ex8_25.R new file mode 100644 index 00000000..134bf214 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.25/Ex8_25.R @@ -0,0 +1,11 @@ +#page no. 363 +#example 8-25 + +ki=c(168,68,131,33) +poi=c(0.45,0.15,0.3,0.1) + +q=sum(((ki-400*poi)^2)/(400*poi)) + +x=qchisq(0.95,3) #qchisq() is the function used to calculate Chi-square percentile value in R + +cat("Since (X0.95(3))^2 =",x,">",q," We accept the indepndence hypothesis") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.26/Ex8_26.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.26/Ex8_26.R new file mode 100644 index 00000000..0867f5fc --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.26/Ex8_26.R @@ -0,0 +1,12 @@ +#page no. 364 +#example 8-26 + +ki=c(43,56,42,38,59,61,41,57,46,57) #(given) +m=500 +poi=0.1 + +q=sum(((ki-m*poi)^2)/(m*poi)) + +x=qchisq(0.95,9) #qchisq() is the function used to calculate Chi-square percentile value in R + +cat("Since (X0.95(9))^2 =",x,">",q," We accept the uniformaity hypothesis") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.3/Ex8_3.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.3/Ex8_3.R new file mode 100644 index 00000000..23d5ea8b --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.3/Ex8_3.R @@ -0,0 +1,26 @@ +#page no. 309 +#example 8-3 + +#functions used +#qnorm():quantile function of the normal distribution:the quantile function maps from probabilities to values in normal distribution +#ceiling():ceiling(x) rounds to the nearest integer that's larger than x. + +rho=0.05 +z0.975=ceiling(qnorm(1-rho/2)) + + #part (a) + +x_bar=112 #(given) +sigma=0.4 #(given) +n=25 #number of times the voltage is measured +i=z0.975*sigma/sqrt(n) + +cat("Insetting values into (8-11),we obtain the interval ",x_bar,"+-",i,"V") + + #part (b) + +s=0.6 +i2=z0.975*s/sqrt(n) +cat("Insetting values into (8-14),we obtain the approximate estimate ",x_bar,"+-",i2,"V") + +print("Since t0.975(25)=2.06 (from the table) the exact estimate (8-17) yields 112+-0.247 V") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.4/Ex8_4.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.4/Ex8_4.R new file mode 100644 index 00000000..d65f7520 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.4/Ex8_4.R @@ -0,0 +1,11 @@ +#page no. 311 +#example 8-4 + +x_bar=210 # (given) + +z=2 +n=64 #number of bulbs +h1=x_bar/(1+(z/sqrt(n))) #using the EXPONENTIAL DISTRIBUTION. given by equation (8-18) in the book +h2=x_bar/(1-(z/sqrt(n))) + +cat("We thus expect with confidence coefficient 0.95 that the mean time to failure of the bulb is between ",h1,"and ",h2,"hours.") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.5/Ex8_5.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.5/Ex8_5.R new file mode 100644 index 00000000..4974eda2 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.5/Ex8_5.R @@ -0,0 +1,19 @@ +#page no. 312 +#example 8-5 + +x_bar=6 + +cat("(z^2)/n=0.0625 then the equation (8-19) yields the quadratic ") +cat("(lambda-6)^2=0.0625lambda") + +#from the equation and comparing coefficient with ax^2+bx+c=0 +a=1 +b=-12.0625 +c=36 + +#finding solution of the quadratic equation + +l1=(-b-sqrt(b^2 - 4*a*c))/(2*a) +l2=(-b+sqrt(b^2 - 4*a*c))/(2*a) + +cat("We can thus clain with confidence coefficient 0.95 that ",l1,"< lambda <",l2) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.6/Ex8_6.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.6/Ex8_6.R new file mode 100644 index 00000000..d3c18995 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.6/Ex8_6.R @@ -0,0 +1,15 @@ +#page no. 313 +#example 8-6 + +z=2 #(given) +n=500 # total number of persons (given) +r=240 #person who reported Republican + +x_bar=r/n + +p=z*sqrt((x_bar*(1-x_bar))/n) #using the equation (8-21) + +cat("equation (8-21) yields the interval",x_bar,"+-",p) + +#ansers givent in the book are approximate answers + diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.7/Ex8_7.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.7/Ex8_7.R new file mode 100644 index 00000000..2c9ffcab --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.7/Ex8_7.R @@ -0,0 +1,27 @@ +#page no. 314-315 +#example 8-7 + + #part (a) + +n=6 +v_cap=0.25 +x1=qchisq(0.975,6) #qchisq() is the function used to calculate Chi-square percentile value in R +x2=qchisq(0.025,6) #qchisq() is the function used to calculate Chi-square percentile value in R +c1=n*v_cap/x1 +c2=n*v_cap/x2 + +cat("(8-23) yields ",c1,"< sigma^2 <",c2,". The corresponding interval for sigma is ",sqrt(c1),"< sigma <",sqrt(c2),"V") +#there is slight difference in the values in the book and that is due to approximation + + #part (b) + + +n=5 +s=0.6 +x1=qchisq(0.975,5) #qchisq() is the function used to calculate Chi-square percentile value in R +x2=qchisq(0.025,5) #qchisq() is the function used to calculate Chi-square percentile value in R +c1=(n-1)*s^2/x1 +c2=(n-1)*s^2/x2 + +cat("(8-24) yields ",c1,"< sigma^2 <",c2,". The corresponding interval for sigma is ",sqrt(c1),"< sigma <",sqrt(c2),"V") +#there is slight difference in the values in the book and that is due to approximation \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.8/Ex8_8.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.8/Ex8_8.R new file mode 100644 index 00000000..56b93fe8 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH8/EX8.8/Ex8_8.R @@ -0,0 +1,20 @@ +#page no. 315 +#example 8-8 + +#functions used +#qnorm():quantile function of the normal distribution:the quantile function maps from probabilities to values in normal distribution +#ceiling():ceiling(x) rounds to the nearest integer that's larger than x. + +rho=0.05 +u=0.5 +n=100 #samples of x (given) +z=ceiling(qnorm(1-rho/2)) + +k=n*u - z*sqrt(n*u*(1-u)) #using the equation (8-26) + +k_plus_r=n*u + z*sqrt(n*u*(1-u)) #using the equation (8-26) + +print(k) +print(k_plus_r) + +cat("thus we can claim with condidence coefficient 0.95 that the median of x is between y40 and y60") \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH9/EX9.10/Ex9_10.R b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH9/EX9.10/Ex9_10.R new file mode 100644 index 00000000..0efbb1c2 --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/CH9/EX9.10/Ex9_10.R @@ -0,0 +1,18 @@ +#page no. 386 +#example 9-10 + +#part (a) + +inte<-function(y){exp(-(y^2)/2)} #these two lines (6 and 7) gives the defination of function G(x) +Gx<-function(x){((1/(sqrt(2*3.14)))*integrate(inte,lower = 0,upper = x)[[1]])+0.5} #which is given on page number 106 + +p=Gx(-1/2) +print(p) + +#part (b) + +c=8*(1-exp(-0.6)) #variance +print(c) + +p=2*Gx(1/1.9) - 1 +print(p) \ No newline at end of file diff --git a/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/README.txt b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/README.txt new file mode 100644 index 00000000..c085e73b --- /dev/null +++ b/Probability,_Random_Variables,_And_Stochastic_Processes_by_Athanasios_Papoulis_And_S._Unnikrishna_Pillai/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Neeraj Kumar +Course: Btech +Branch: Computer Science And Engineering +College/Institute/Organization: Amity University Rajasthan + +About The Book + +Book: Probability, Random Variables, And Stochastic Processes +Author: Athanasios Papoulis And S. Unnikrishna Pillai +Publisher: Mcgraw Hill Education (india) Private Limited +Year Of Publication: 2002 +ISBN: 9780070486584 +Edition: 4 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.10.1/Ex1_10_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.10.1/Ex1_10_1.R new file mode 100644 index 00000000..e8375b64 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.10.1/Ex1_10_1.R @@ -0,0 +1,46 @@ +# Chapter 1 - Introduction to Probability, Section - 1.10 (The Probability of a Union of Events), Page No. - 47 + +# 'Total' represents total students. + +Total<-c(200); +A1<-c(137); +A2<-c(50); +A3<-c(124); + +# Students enrolled in both Mathematics and History, History and Music, Music and Mathematics & all three are represented by 'A1_A2', 'A2_A3', 'A3_A1' and 'A1_A2_A3' respectively. + +A1_A2<-c(33); +A2_A3<-c(29); +A3_A1<-c(92); +A1_A2_A3<-c(18); + +# Probability of A1 event is represented by Pr_A1. +# Probability of A2 event is represented by Pr_A2. +# Probability of A3 event is represented by Pr_A3. +# Probability of A1_A2 event is represented by Pr_A1_A2. +# Probability of A2_A3 event is represented by Pr_A2_A3. +# Probability of A3_A1 event is represented by Pr_A3_A1. +# Probability of A1_A2_A3 event is represented by Pr_A1_A2_A3. + +Pr_A1=A1/Total; +Pr_A2=A2/Total; +Pr_A3=A3/Total; +Pr_A1_A2=A1_A2/Total; +Pr_A2_A3=A2_A3/Total; +Pr_A3_A1=A3_A1/Total; +Pr_A1_A2_A3=A1_A2_A3/Total; + +print(Pr_A1) +print(Pr_A2) +print(Pr_A3) +print(Pr_A1_A2) +print(Pr_A2_A3) +print(Pr_A3_A1) +print(Pr_A1_A2_A3) + +# Probability of A1 union A2 union A3 is represented by 'Pr'. + +Pr=Pr_A1 + Pr_A2 + Pr_A3 - Pr_A1_A2 - Pr_A2_A3 - Pr_A3_A1 + Pr_A1_A2_A3; +print(Pr) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.1/Ex1_4_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.1/Ex1_4_1.R new file mode 100644 index 00000000..ed636149 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.1/Ex1_4_1.R @@ -0,0 +1,11 @@ +# Chapter 1 - Introduction to Probability, Section - 1.4 (Set Theory), Page No. - 6 + +S<-c(1:6) + +# "%%" operator is used to find remainder. + +A<-S[S%%2==0] +B<-S[S>2] + +print(A) +print(B) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.2/Ex1_4_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.2/Ex1_4_2.R new file mode 100644 index 00000000..8cc0c527 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.2/Ex1_4_2.R @@ -0,0 +1,13 @@ +# Chapter 1 - Introduction to Probability, Section - 1.4 (Set Theory), Page No. - 7 + +S<-c(1:6) + +A<-S[S%%2==0] +C<-S[S>1] + +# To compare values in vector 'A' and 'C', "%in%" is used. It compares each value +# of 'A' with 'C' and returns true if they exist in 'C' which indicates that 'A' is +# contained in 'C'. + +ans<-A%in%C +print(ans) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.3/Ex1_4_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.3/Ex1_4_3.R new file mode 100644 index 00000000..a839a95e --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.3/Ex1_4_3.R @@ -0,0 +1,10 @@ +# Chapter 1 - Introduction to Probability, Section - 1.4 (Set Theory), Page No. - 8 + +S<-c(1:6) +A<-S[S%%2==0] + +# "!S%in%A" returns all elements as true which are not present in 'A'. +# Complement of 'A' is represented by 'A_Comp'. + +A_Comp<-S[!S%in%A] +print(A_Comp) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.4/Ex1_4_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.4/Ex1_4_4.R new file mode 100644 index 00000000..f837371f --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.4/Ex1_4_4.R @@ -0,0 +1,46 @@ +# Chapter 1 - Introduction to Probability, Section - 1.4 (Set Theory), Page No. - 12 + +#s1<-c('H','H','H') +#s2<-c('H','H','T') +#s3<-c('H','T','H') +#s4<-c('H','T','T') +#s5<-c('T','H','H') +#s6<-c('T','H','T') +#s7<-c('T','T','H') +#s8<-c('T','T','T') + +# Values of each object of sample 'S' are discrete. +# Hence, these objects can be declared as seperate characters to perfrom computational operations. + +S<-c('s1','s2','s3','s4','s5','s6','s7','s8') +A<-c('s1','s2','s3','s4','s5','s6','s7') +B<-c('s1','s2','s4','s6') +C<-c('s4','s5','s6','s8') +D<-c('s8') + +# Value for whether 'A' is contained in 'B' or not is stored in 'A_Contain_B'. +# Complement of 'A' is represented by 'A_Comp'. +# 'B' intersection 'D' is represented by 'B_inter_D'. +# 'A' union 'C' is represented by 'A_union_C'. +# 'B' intersection 'C' is represented by 'B_inter_C'. +# Complement of 'B' union 'C' is represented by 'B_union_C_comp'. +# Intersection of 'A' and 'B' union 'C' is represented by 'A_inter_B_union_C'. + +# "union" and "intersect" functions are being used for operating on sets. +# For description of these functions, type ?union and ?intersect in the console. + +A_Contain_B<-B%in%A +A_Comp<-S[!S%in%A] +B_inter_D<-intersect(B,D) +A_union_C<-union(A,C) +B_inter_C<-intersect(B,C) +B_union_C_comp<-S[!S%in%(union(B,C))] +A_inter_B_union_C<-intersect(A,union(B,C)) + +print(A_Contain_B) +print(A_Comp) +print(B_inter_D) +print(A_union_C) +print(B_inter_C) +print(B_union_C_comp) +print(A_inter_B_union_C) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.5/Ex1_4_5.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.5/Ex1_4_5.R new file mode 100644 index 00000000..bea349a4 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.4.5/Ex1_4_5.R @@ -0,0 +1,18 @@ +# Chapter 1 - Introduction to Probability, Section - 1.4 (Set Theory), Page No. - 12 + +x<-c(4,200); +y<-c(1,150); + +# For description of "plot" and/or "rect" functions, type ?plot and/or ?rect in the console. + +plot(x, y, xlab = "Water", ylab = "Electric", panel.first = rect(x[1],y[1],x[2],y[2])) + +# Water demand is atleast 100 and is represented by xmin. Marked as "Blue". + +xmin=100; +rect(xmin,y[1],x[2],y[2],col='blue') + +# Electric demand is no more than 35 and is represented by ymax. Marked as "Yellow". + +ymax=35; +rect(x[1],y[1],x[2],ymax,col='yellow') \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.2/Ex1_5_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.2/Ex1_5_2.R new file mode 100644 index 00000000..10efc6a8 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.2/Ex1_5_2.R @@ -0,0 +1,30 @@ +# Chapter 1 - Introduction to Probability, Section - 1.5 (The Definition of Probability), Page No. - 17 + +# 'p' is declared as a vector of length 6. For description of a "vector", type ?vector in the console. +# A "length" function returns the length of the input vector. + +p<-(vector(length=6)) +for(i in 1:length(p)) +{ + if(i!=6) + {p[i]=1/7;} + else + {p[i]=2/7;} +} +A<-c(1,3,5) + +# A function with the name 'Pr' is defined to calculate the sum of probabilities at indices mentioned in 'A'. +# A variable named 'output' is declared inside the function 'Pr' which stores the desired sum. + +Pr<-function(A) +{ + output<-c(0); + for(j in 1:length(A)) + { + output=output+p[A[j]] + } + return(output) +} +print(Pr(A)) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.3/Ex1_5_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.3/Ex1_5_3.R new file mode 100644 index 00000000..6234d48f --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.3/Ex1_5_3.R @@ -0,0 +1,15 @@ +# Chapter 1 - Introduction to Probability, Section - 1.5 (The Definition of Probability), Page No. - 19 + +# Probabilities of 'B' and 'V' are represented by 'Pr_B' and 'Pr_V' respectively. + +Pr_B=0.7 +Pr_V=0.4 + +# As sample space is 'B' Union 'V'. Therefore, probability of 'B' union 'V' or 'Pr_B_union_V' must be 1. + +Pr_B_union_V=1 + +# Probability of both infections is represented by 'Pr_B_inter_V'. + +Pr_B_inter_V=Pr_B + Pr_V - Pr_B_union_V; +print(Pr_B_inter_V) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.4/Ex1_5_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.4/Ex1_5_4.R new file mode 100644 index 00000000..ab90dc93 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.5.4/Ex1_5_4.R @@ -0,0 +1,59 @@ +# Chapter 1 - Introduction to Probability, Section - 1.5 (The Definition of Probability), Page No. - 19 + +x<-c(4,200); +y<-c(1,150); + +# "plot" and "rect" functions are used to plot and highlight areas in a graph plot. +# For description of these functions, type ?plot and ?rect in the console. + +plot(x, y, xlab = "Water", ylab = "Electric", panel.first = rect(x[1],y[1],x[2],y[2])) + +# Area of sample space 'S' is represented by 'Area_S'. + +Area_S=(y[2]-y[1])*(x[2]-x[1]) +A<-c(100,200); +B<-c(115,150); + +# Area of 'A' is represented by 'Area_A'. + +Area_A=(y[2]-y[1])*(A[2]-A[1]); + +# Plotting area of 'A' in red color. + +rect(A[1],y[1],A[2],y[2],col='red') + +# Area of 'B' is represented by 'Area_B'. + +Area_B=(B[2]-B[1])*(x[2]-x[1]); + +# Plotting area of 'B' in blue color. + +rect(x[1],B[1],x[2],B[2],col='blue') + +# Probabilities of area 'A' and 'B' are represented by 'Pr_A' and 'Pr_B' respectively. + +Pr_A=Area_A/Area_S; +print(Pr_A) +Pr_B=Area_B/Area_S; +print(Pr_B) + +# Area of intersection of 'A' and 'B' is represented by 'Area_A_inter_B'. + +Area_A_inter_B=(B[2]-B[1])*(A[2]-A[1]); + +# Plotting area of intersection in yellow color. + +rect(A[1],B[1],A[2],B[2],col='yellow') + +# Probability of area of intersection of 'A' and 'B' is represented by 'Pr_A_inter_B'. + +Pr_A_inter_B=Area_A_inter_B/Area_S; +print(Pr_A_inter_B) + +# Probability of either one of the two demands to be high. +# Here, probability of union of area A and B is represented by 'Pr_A_union_B'. + +Pr_A_union_B=Pr_A + Pr_B - Pr_A_inter_B +print(Pr_A_union_B) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.2/Ex1_6_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.2/Ex1_6_2.R new file mode 100644 index 00000000..c2499e7b --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.2/Ex1_6_2.R @@ -0,0 +1,21 @@ +# Chapter 1 - Introduction to Probability, Section - 1.6 (Finite Sample Spaces), Page No. - 22 + +s1<-1; +s2<-2; +s3<-3; +s4<-4; +s5<-5; +S<-c(s1,s2,s3,s4,s5) +A<-c(s1,s2,s3) + +# As sum of all probabilities is 1. Therefore, for the given sample space 'alpha' is '1/15'. + +alpha<-1/15; +Pr<-0; +for (i in 1:length(A)) + { + Pr=Pr+alpha*A[i]; + } +print(Pr) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.3/Ex1_6_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.3/Ex1_6_3.R new file mode 100644 index 00000000..370bea75 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.3/Ex1_6_3.R @@ -0,0 +1,53 @@ +# Chapter 1 - Introduction to Probability, Section - 1.6 (Finite Sample Spaces), Page No. - 23 + +# Possible outcomes for flipping 3 fair coins or sample space 'S' is 8 (2^3) containing objects from 's1' to 's8'. + +s1<-c('H','H','H'); +s2<-c('H','H','T'); +s3<-c('H','T','H'); +s4<-c('H','T','T'); +s5<-c('T','H','H'); +s6<-c('T','H','T'); +s7<-c('T','T','H'); +s8<-c('T','T','T'); +S<-c(s1,s2,s3,s4,s5,s6,s7,s8); + +# For converting a vector into matrix, "matrix" function in used. Final values are saved in a matrix named 'Sample'. +# For description of this function, type ?matrix in the console. + +Sample<-matrix(S,nrow=8,ncol=3) + +# Probability, 'p', assigned to each outcome is 1/8. + +p<-1/8; + +# "nrow" and "ncol" give the number of rows and columns in a matrix. +# A "for loop" is used below to examine all the possible cases where outcome is exactly 2 heads. +# For calculation purpose 2 variables namely, 'Heads' and 'outcome' are declared with initial value as 0. +# The "for loop" will check for all outcomes consisting of 2 heads in the sample space. + +Heads<-c(0); +outcome<-c(0); +for(i in 1:nrow(Sample)) +{ + for(j in 1:ncol(Sample)) + { + if(isTRUE(Sample[i,j]=='H')) + { + Heads=Heads+1; + } + } + if(Heads==2) + { + outcome=outcome+1; + } + Heads<-c(0); +} + +# Number of all possible outcomes in the sample space where there are exactly 2 heads is stored in 'outcome'. +# Required probability is stored in 'Pr'. + +Pr=outcome*p; +print(Pr) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.4/Ex1_6_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.4/Ex1_6_4.R new file mode 100644 index 00000000..67f8cf86 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.4/Ex1_6_4.R @@ -0,0 +1,66 @@ +# Chapter 1 - Introduction to Probability, Section - 1.6 (Finite Sample Spaces), Page No. - 23 + +# Let alleles be represented by the vector 'allele'. + +allele<-c('A','a') +print(allele) + +# "data.farme" function is used in order to create a data frame. +# For more description, type ?data.frame in the console. +# "nrow" and "ncol" functions are used to either assign or find the number of rows and columns in a matrix respectively. +# For more description type, ?nrow and ?ncol in the console. +# Finding all possible genotypes. They are stored in the matrix 'genotype'. +# 'count' variable is defined for assigning values to 'genotype' matrix. + +count<-c(1) +genotype<-matrix(0L,nrow=length(allele),ncol=(2^length(allele))) +for(i in 1:length(allele)) +{ + for(j in 1:length(allele)) + { + genotype[,count]<-c(allele[i],allele[j]) + count=count+1; + } +} + +# Printing table representing possible combinations from the parents. +# Let the table values be stored in the data frame named as 'combinations'. +# "rownames" and "colnames" arguments are used to add names to each row and column of the data frame seperately. +# For more description, type ?rownames and ?colnames in the console. +# "paste0" function is used to combine strings and numbers for printing them together. +# For more description type, ?paste0 in the console. + +combinations<-data.frame(nrow=length(allele),ncol=length(allele)) +colnames(combinations)<-c('A','a'); +for(k in 1:length(allele)) +{ + for(l in 1:length(allele)) + { + combinations[k,l]=paste0(allele[k],allele[l]) + } +} +rownames(combinations)<-c('A','a'); +print(combinations) + +# "intersect" function is used to find common elements in the input vectors. +# For more description type, ?intersect in the console. +# "length" function is used to find the number of elements in a vector. +# For more description type, ?length in the console. +# "!=" represents 'not equal to' and "&&" is used to find the 'logical AND' of given inputs. +# A variable 'count' is defined for computation operations. + +for(m in 1:ncol(genotype)) +{ + count<-c(1); + for(n in 1:ncol(genotype)) + { + if((m!=n)&&(length(intersect(genotype[1:(nrow(genotype)),m],genotype[1:(nrow(genotype)),n]))==2)) + { + count=count+1; + } + } + print(genotype[,m]) + print(paste0(" has the probability ", count/ncol(genotype))) +} + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.5/Ex1_6_5.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.5/Ex1_6_5.R new file mode 100644 index 00000000..b441ac25 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.6.5/Ex1_6_5.R @@ -0,0 +1,55 @@ +# Chapter 1 - Introduction to Probability, Section - 1.6 (Finite Sample Spaces), Page No. - 24 + +# Number of dice is represented by 'A' and total possible outcomes by 'O'. For 2 dice there will be a total of 36 possible outcomes. + +A<-c(2); +O<-c(1); +for(l in 1:A) +{ + O=O*6; +} + +# Following code will find the frequency of sum of digits in each possible outcome pair and store them in vector 'sum'. +# "rep" function is used to initialize a vector by a value which is replicated over a number of times. +# For description of rep function, type ?rep in console. + +sum<-rep(0,11) +for(k in 1:6) +{ + for(j in 1:6) + { + if((k+j)==2) + {sum[1]=sum[1]+1;} + if((k+j)==3) + {sum[2]=sum[2]+1;} + if((k+j)==4) + {sum[3]=sum[3]+1;} + if((k+j)==5) + {sum[4]=sum[4]+1;} + if((k+j)==6) + {sum[5]=sum[5]+1;} + if((k+j)==7) + {sum[6]=sum[6]+1;} + if((k+j)==8) + {sum[7]=sum[7]+1;} + if((k+j)==9) + {sum[8]=sum[8]+1;} + if((k+j)==10) + {sum[9]=sum[9]+1;} + if((k+j)==11) + {sum[10]=sum[10]+1;} + if((k+j)==12) + {sum[11]=sum[11]+1;} + } +} + +# Following code will find the probability of each sum (from 2 to 12) and store the value in a vector 'P'. + +P<-rep(0,11) +for(i in 1:length(P)) +{ + P[i]=sum[i]/O; +} +print(P) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.1/Ex1_7_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.1/Ex1_7_1.R new file mode 100644 index 00000000..3f7234aa --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.1/Ex1_7_1.R @@ -0,0 +1,33 @@ +# Chapter 1 - Introduction to Probability, Section - 1.7 (Counting Methods), Page No. - 26 + +# Let the routes from A to B be stored in 'route_I'. +# Let the routes from B to C be stored in 'route_II'. + +route_I<-c(1,2,3); +route_II<-c(4,5,6,7,8); + +# Let the combinations of possible routes be stored in a data frame named as 'routes'. +# "data.farme" function is used in order to create a data frame. +# For more description, type ?data.frame in the console. +# "nrow" and "ncol" functions are used to either assign or find the number of rows and columns in a matrix respectively. +# For more description type, ?nrow and ?ncol in the console. +# "paste0" function is used to combine strings and numbers for printing them together. +# For more description type, ?paste0 in the console. +# "colnames" argument is used to add names to each column of the data frame seperately. +# For more description, type ?colnames in the console. + +routes<-data.frame(nrow=length(route_I),ncol=length(route_II)) +for(i in 1:length(route_I)) +{ + for(j in 1:length(route_II)) + { + routes[i,j]=paste0(route_I[i],route_II[j]) + } +} +colnames(routes)<-route_II[1:length(route_II)] +print(routes) + +# Let the total number of possible routes be given by the 'total'. + +total=nrow(routes)*ncol(routes) +print(total) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.12/Ex1_7_12.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.12/Ex1_7_12.R new file mode 100644 index 00000000..fa2b1d99 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.12/Ex1_7_12.R @@ -0,0 +1,21 @@ +# Chapter 1 - Introduction to Probability, Section - 1.7 (Counting Methods), Page No. - 31 + +# Stirling's Formula can be used by defining a function named 'Stirling' in the following manner. +# In the function definition, 'n' represents a numeric value. + +Stirling<-function (n) + { + output<-((2*pi*n)^.5)*(n/exp(1))^n + return(output) + } + +# Another function 'P' is defined in order to find permutations using Stirling's Formula in the following manner. +# In the function definition, 'n' represents total number of available items and 'k' represents the number of items to be selected at a time. +P<-function(n,k) + { + output<-(Stirling(n)/Stirling(k)) + return(output) + } +P(70,50) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.3/Ex1_7_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.3/Ex1_7_3.R new file mode 100644 index 00000000..4b2408e7 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.3/Ex1_7_3.R @@ -0,0 +1,11 @@ +# Chapter 1 - Introduction to Probability, Section - 1.7 (Counting Methods), Page No. - 26 + +# Number of dice is represented by 'A' and total possible outcomes by 'O'. For 2 dice (From Multiplication Rule) there will be a total of 6*6=36 possible outcomes. + +A<-c(2); +O<-c(1); +for(l in 1:A) +{ + O=O*6; +} +print(O) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.4/Ex1_7_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.4/Ex1_7_4.R new file mode 100644 index 00000000..566ef340 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.4/Ex1_7_4.R @@ -0,0 +1,74 @@ +# Chapter 1 - Introduction to Probability, Section - 1.7 (Counting Methods), Page No. - 27 + +# Number of coins is represented by 'A' and total possible outcomes by 'O'. For 6 coins (From Multiplication Rule) there will be a total of 2^6=64 possible outcomes. + +A<-c(6); +O<-c(1); +for(l in 1:A) +{ + O=O*2; +} +print(O) + +# Creating sample space 'S' containing all possible outcomes. Here, 'S' is a matrix with 'A' rows and 'O' columns. +# "ceiling" function is used to apply the mathematical ceiling operation. For description of this function, type ?ceiling in the console. + +S<-matrix(nrow=A,ncol=O) +for(i in 1:A) +{ + for(j in 1:O) + { + if((ceiling(j/2^(A-i))%%2)!=0) + {S[i,j]<-c('H')} + else + {S[i,j]<-c('T')} + } +} + +# Finding probabilities of certain outcomes. +# For the purpose of checking for desired outcomes following variables are used. + +count<-c(0); +Heads<-c(0); +Tails<-c(0); + +# For 6 Heads and 0 Tails, let the probability be represented by 'Pr_6H'. + +for(k in 1:O) +{ + for(l in 1:A) + { + if(S[l,k]=='H') + {Heads=Heads+1;} + } + if(Heads==6) + {count=count+1; + Heads<-c(0);} + else + {Heads<-c(0);} +} +Pr_6H=count/O +print(Pr_6H) + +# For 1 Heads and 5 Tails, let the probability be represented by 'Pr_5T' + +count<-c(0); +Heads<-c(0); +Tails<-c(0); +for(m in 1:O) +{ + for(n in 1:A) + { + if(S[n,m]=='H') + {Heads=Heads+1;} + } + if(Heads==1) + {count=count+1; + Heads<-c(0);} + else + {Heads<-c(0);} +} +Pr_5T=count/O +print(Pr_5T) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.5/Ex1_7_5.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.5/Ex1_7_5.R new file mode 100644 index 00000000..069f9c3c --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.5/Ex1_7_5.R @@ -0,0 +1,14 @@ +# Chapter 1 - Introduction to Probability, Section - 1.7 (Counting Methods), Page No. - 27 + +# All possible numbers are represented by 'A', possible positions are represented by 'B' and total possible outcomes by 'O'. +# "seq" function is used to create a sequence having default seperation value as 1. +# For description, type ?seq in the console. + +A<-seq(0,39); +B<-c(3); +O<-c(1); +for(l in 1:B) +{ + O=O*length(A); +} +print(O) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.7/Ex1_7_7.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.7/Ex1_7_7.R new file mode 100644 index 00000000..4f71136c --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.7/Ex1_7_7.R @@ -0,0 +1,13 @@ +# Chapter 1 - Introduction to Probability, Section - 1.7 (Counting Methods), Page No. - 28 + +S<-c(1); +n<-c(50000); +k<-c(3); +for(i in 1:k) +{ + S=S*n; + n=n-1; +} +print(S) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.8/Ex1_7_8.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.8/Ex1_7_8.R new file mode 100644 index 00000000..8f08ec76 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.8/Ex1_7_8.R @@ -0,0 +1,18 @@ +# Chapter 1 - Introduction to Probability, Section - 1.7 (Counting Methods), Page No. - 29 + +# Another method for applying permutations is by using function. +# Hence, a function "P" is defined that takes in values 'n' and 'k' and returns the desired permutation. +# Here 'n' represents number of members in the club and 'k' represents the number of members to be chosen. +# For description, type ?function in the console. + +P<-function(n,k) +{ + S<-c(1); + for(i in 1:k) + { + S=S*n; + n=n-1; + } + return(S); +} +P(25,2) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.9/Ex1_7_9.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.9/Ex1_7_9.R new file mode 100644 index 00000000..d0429b4d --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.7.9/Ex1_7_9.R @@ -0,0 +1,16 @@ +# Chapter 1 - Introduction to Probability, Section - 1.7 (Counting Methods), Page No. - 29 + +# 'S' represents the total permutations or sample space, 'n' represents the number of books available and 'k' represents the number of books to be chosen at a time. +# For the given problem both 'n' and 'k' are same i.e. 6, because 6 books are arranged by taking all 6 at a time. + +P<-function(n,k) +{ + S<-c(1); + for(i in 1:k) + { + S=S*n; + n=n-1; + } + return(S); +} +P(6,6) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.1/Ex1_8_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.1/Ex1_8_1.R new file mode 100644 index 00000000..90b03f45 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.1/Ex1_8_1.R @@ -0,0 +1,105 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 32 + +# Let the input set be 'A'. +# In order to find only distinct subsets we need to find combinations of set 'A' taking 'k' elements at a time. +# "combn" function is used to find combinations of a set. For description, type ?combn in the console. + +A<-c('a','b','c','d'); +k<-c(2); +S<-combn(A,k) + +# 'S' is a matrix with the number of columns as the desired number of distinct subsets. +# "ncol" function is used to calculate the number of columns present in the input data structure. +# For description, type ?ncol in the console. + +print(ncol(S)) + +# "nrow" function is used to calculate the number of rows present in the input data structure. +# For description, type ?nrow in the console. +# Finding all possible subsets of two. +# "matrix" and "vector" functions are used to define a matrix and a vector respectively. +# For description, type ?matrix and ?vector in the console. +# "length" function is used to find the number of elements in a vector. +# For description, type ?length in the console. +# "intersect" function is used to find the intersection of elements in a vector. +# For description, type ?intersect in the console. +# 'count' variable is defined for computation operations. +# 'read' vector is defined for finding the location of subsets having same elements. +# 'break' is used for breaking a loop. +# For description, type ?break in the console. +# Finding all possible subsets of two. + +count<-c(1) +sets<-matrix(0L,nrow=k,ncol=(length(A)*length(A))) +for(i in 1:length(A)) +{ + for(j in 1:length(A)) + { + sets[,count]<-c(A[i],A[j]) + count=count+1; + } +} + +# Removing subsets having same elements + +read<-vector(mode='numeric',length=ncol(sets)); +for(k in 1:ncol(sets)) +{ + if(length(intersect((sets[,k])[1],(sets[,k])[length((sets[,k]))])==1)) + { + read[k]<-c(k); + } +} +read<-read[read>0] +count<-c(0) +for(l in 1:length(read)) +{ + sets<-sets[,-read[l]] + if(l==length(read)) + { + break + } + else + { + count=count+1 + read[l+1]=read[l+1]-count + } +} + +# Removing one among the pair of subsets having same elements. +# "unique" function is used to find and retain only the unique elements in a vector. +# For description, type ?unique in the console. +# "sort.list" function is used sort vector in either ascending or descending order. +# For description, type ?sort.list in the console. + +read<-vector(mode='numeric',length=ncol(sets)); +for(m in 1:ncol(sets)) +{ + for(n in 1:ncol(sets)) + { + if(length(intersect((sets[,m]),(sets[,n])))==2) + { + read[m]<-c(n); + } + } +} +read<-unique(read) +read<-read[sort.list(read,decreasing=FALSE)] +count<-c(0) +for(o in 1:length(read)) +{ + sets<-sets[,-read[o]] + if(o==length(read)) + { + break + } + else + { + count=count+1 + read[o+1]=read[o+1]-count + } +} + +# Final list of unique subsets. + +print(sets) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.10/Ex1_8_10.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.10/Ex1_8_10.R new file mode 100644 index 00000000..2e8fc3dc --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.10/Ex1_8_10.R @@ -0,0 +1,40 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 38 + +# Total number of cards, number of aces and cards occupied by each player be represented by 'Cards', 'Aces' and 'O' respectively. + +Cards<-c(52); +Aces<-c(4); +O<-c(13); + +# Let ways to arrange 4 aces in 4 positions, remaining cards in remaining positions and +# possible arrangements for complete ordering of 52 cards be represented by be represented by 'A_P', 'R_P' and 'C_P' respectively. +# A function 'Fact' is defined in order to find number of possible arrangements. + +Fact<-function(n) +{ + output<-c(1); + for(i in 1:n) + { + output<-output*i; + } + return(output) +} +A_P=Fact(Aces); +R_P=Fact(Cards-Aces); +C_P=Fact(Cards); + +# Following loop will determine the number of possible combinations leading to the desired result. +# Result will be represented by 'R'. + +R<-c(1); +for(j in 1:Aces) +{ + R=R*O; +} + +# Required probability be represented by 'p'. + +p=(R*A_P*R_P)/C_P +print(p) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.11/Ex1_8_11.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.11/Ex1_8_11.R new file mode 100644 index 00000000..9a7a689e --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.11/Ex1_8_11.R @@ -0,0 +1,74 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 38 + +# Let the total numbers be represented by 'n' and numbers drawn by 'k'. + +n<-c(30); +k<-c(6); + +# Following function 'P' will find the number of permutations of 'n' numbers taken 'k' at a time. +# Variable 'output' is declared for computational operations. + +P<-function(n,k) +{ + output<-c(1); + for(i in 1:k) + { + output=output*(n-i+1) + } + return(output) +} + +# The sample space by permutation is represented by 'S'. + +S=P(n,k); +print(S) + +# A function 'C' is defined to determine the number of possible combinations as per given input where variables 'final','N' and 'D' are declared for computation operations. + +C<-function(n,k) +{ + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(n-i+1); + D=D*(i); + } + final<-N/D; + return(final) +} + +# The sample space by combination is represented by 'S_'. + +S_=C(n,k); +print(S_) + +# Required event is represented by 'A'. + +A<-c(1,14,15,20,23,27); + +# In order to find the possible outcomes of getting the required event 'A' in sample space 'S'. +# A function 'Fact' is defined. It finds the factorial of input value. +# A variable 'result' is declared in the function for computation operation. + +Fact<-function(n) +{ + result<-c(1); + for(i in 1:n) + { + result<-result*i; + } + return(result) +} + +# Number of possible outcomes of getting the required event 'A' is represented by 'A_P'. + +A_P=Fact(k); +print(A_P) + +# Required probability is represented by 'Pr_A'. + +Pr_A=A_P/S; +print(Pr_A) + +# The answer may vary as exact numeric values are not calculated in the textbook. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.12/Ex1_8_12.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.12/Ex1_8_12.R new file mode 100644 index 00000000..1a463eb7 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.12/Ex1_8_12.R @@ -0,0 +1,52 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 39 + +# Let possible value of tosses be represented by the vector 'toss'. + +toss<-c('H','T') +print(toss) + +# "data.farme" function is used in order to create a data frame. +# For more description, type ?data.frame in the console. +# "nrow" and "ncol" functions are used to either assign or find the number of rows and columns in a matrix respectively. +# For more description type, ?nrow and ?ncol in the console. +# Finding all possible toss cominations. They are stored in the matrix 'tosses'. +# 'count' variable is defined for assigning values to 'genotype' matrix. +# Possible sample space. + +count<-c(1) +tosses<-matrix(0L,nrow=length(toss),ncol=(2^length(toss))) +for(i in 1:length(toss)) +{ + for(j in 1:length(toss)) + { + tosses[,count]<-c(toss[i],toss[j]) + count=count+1; + } +} +print(tosses) + +# "paste0" function is used to combine strings and numbers for printing them together. +# For more description type, ?paste0 in the console. +# "intersect" function is used to find common elements in the input vectors. +# For more description type, ?intersect in the console. +# "length" function is used to find the number of elements in a vector. +# For more description type, ?length in the console. +# "!=" represents 'not equal to' and "&&" is used to find the 'logical AND' of given inputs. +# A variable 'count' is defined for computation operations. +# Finding probability of each outcome. + +for(k in 1:ncol(tosses)) +{ + count<-c(1); + for(l in 1:ncol(tosses)) + { + if((k!=l)&&(length(intersect(tosses[1:(nrow(tosses)),k],tosses[1:(nrow(tosses)),l]))==2)) + { + count=count+1; + } + } + print(tosses[,k]) + print(paste0(" has the probability ", count/ncol(tosses))) +} + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.2/Ex1_8_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.2/Ex1_8_2.R new file mode 100644 index 00000000..7cd2c347 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.2/Ex1_8_2.R @@ -0,0 +1,21 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 33 + +# The number of people in the group are represented by 'A' and the number of people in committee by 'k'. +# 'C' be the function defined to find the combinations for choosing 'k' people out of 'A' at a time. +# 'N' and 'D' are variables declared in the function definition for the purpose of calculation operations. + +A<-c(20); +k<-c(8); +C<-function(A,k) + { + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(A-i+1); + D=D*(i); + } + output<-N/D + return(output) + } +print(C(A,k)) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.3/Ex1_8_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.3/Ex1_8_3.R new file mode 100644 index 00000000..22329173 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.3/Ex1_8_3.R @@ -0,0 +1,33 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 33 + +# The number of people in the group are represented by 'A' and the number of people in committee by 'k'. +# 'C' be the function defined to find the combinations for choosing 'k' people out of 'A'. +# 'P' be the function to find the number of jobs each selected individual can be assigned to after being selected in the committee. +# 'final' is the output from function 'C' which is used in function 'P'. + +A<-c(20); +k<-c(8); +C<-function(A,k) +{ + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(A-i+1); + D=D*(i); + } + output<-N/D + return(output) +} +final<-C(A,k) +P<-function(k) +{ + for(j in 1:k) + { + final<-j*final + } + return(final) +} +print(P(8)) + +# The answer provided in the textbook is wrong. The correct answer is '5079110400' instead of '5078110400' for 'A=20' and 'k=8'. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.4/Ex1_8_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.4/Ex1_8_4.R new file mode 100644 index 00000000..306c3b76 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.4/Ex1_8_4.R @@ -0,0 +1,24 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 34 + +# Number of pairs are represented by 'n', number of Genotypes by 'G'. +# A function 'C' is defined in order to calculate combination of 'n' items taken 'k' at a time. +# Variables 'N' and 'D' are declared in the function definition of 'C' for calculation operations. +# 'A' is the combination of 'n' pairs taken 2 at a time. + +n<-c(3); +G<-c(0); +C<-function(n,k) +{ + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(n-i+1); + D=D*(i); + } + output<-N/D + return(output) +} +A<-C(n,2) +G=n+A; +print(G) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.5/Ex1_8_5.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.5/Ex1_8_5.R new file mode 100644 index 00000000..8fd88cc0 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.5/Ex1_8_5.R @@ -0,0 +1,18 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 35 + +# This is an example of combinations with repetitions. +# The number of distinct objects is represented by 'n' and the number of objects to be choosen by 'k'. +# In the case of combinations with repetitions, the total number of objects to choose from is "k+(n-1)". For more info. refer to - "https://www.mathsisfun.com/combinatorics/combinations-permutations.html" +# The result of combination is represented by 'C'. For computation purpose two more variables namely 'N' and 'D' are declared. + +n<-c(7); +k<-c(12); +N<-c(1); +D<-c(1); +for(i in 1:(n-1)) +{ + N=N*(k+n-i); + D=D*i; +} +C<-N/D; +print(C) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.6/Ex1_8_6.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.6/Ex1_8_6.R new file mode 100644 index 00000000..2a2648cb --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.6/Ex1_8_6.R @@ -0,0 +1,37 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 35 + +# Method 1 + +# Sample space is represented by 'S1', number of distinct items be represented by 'n' and number of items to be choosen be represented by 'k'. + +n<-c(7); +k<-c(12); +S1=n^k; +print(S1) + +# It is obvious that only 'n' such events are possible where all the items are of same type as there are only 'n' distint objects to choose from. +# Probability of getting all same items is represented by 'P1'. + +P1=n/S1 +print(P1) + +# Method 2 + +# Sample space is represented by 'S2'. +# Variables 'N' and 'D' are declared for computational operations. + +N<-c(1); +D<-c(1); +for(i in 1:(n-1)) +{ + N=N*(k+n-i); + D=D*i; +} +S2<-N/D; + +# Probability of getting all same items is represented by 'P2'. + +P2=n/S2 +print(P2) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.7/Ex1_8_7.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.7/Ex1_8_7.R new file mode 100644 index 00000000..948cdabe --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.7/Ex1_8_7.R @@ -0,0 +1,61 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 36 + +# Sample space be represented by 'S', possible outcomes be represented by 'O' and number of times the coin is tossed by 'Toss'. + +O<-c(2); +Toss<-c(10); +S=O^Toss; + +# (A) Probability for obtaining exactly 3 Heads be 'p'. + +# Number of required heads be represented by 'Heads'. Number of desired outcomes be given by function 'C'. +# Variables 'N' and 'D' are declared for computational operations. + +Heads<-c(3) +C<-function(Toss,Heads) +{ + N<-c(1); + D<-c(1); + for(i in 1:Heads) + { + N=N*(Toss-i+1); + D=D*(i); + } + output<-N/D + return(output) +} +p<-C(Toss,Heads)/S +print(p) + +# (B) Probability for obtaining 3 or fewer Heads be 'p_'. + +# The sum of combinations for all value of Heads be represented by 'final'. +# Variables 'N' and 'D' are declared for computational operations. + +final<-c(0); +Heads<-c(0,1,2,3) +C<-function(Toss,Heads) +{ + N<-c(1); + D<-c(1); + if(Heads==0) + { + output<-N/D + return(output) + } + for(j in 1:Heads) + { + N=N*(Toss-j+1); + D=D*(j); + } + output<-N/D; + return(output) +} +for(k in 1:length(Heads)) +{ + final<-final+C(Toss,Heads[k]) +} +p_<-final/S +print(p_) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.8/Ex1_8_8.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.8/Ex1_8_8.R new file mode 100644 index 00000000..97616cdf --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.8/Ex1_8_8.R @@ -0,0 +1,35 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 37 + +# The number of boys, girls, total students and students to be selected are represented by 'B', 'G', 'Total' and 'S' respectively. + +B<-c(15); +G<-c(30); +Total=B+G; +S<-c(10); + +# The number of boys and girls required are represented by 'B_r' and 'G_r' respectively. + +B_r<-c(3); +G_r<-c(7); + +# A function 'C' is defined to determine the number of possible combinations as per given input where variables 'output','N' and 'D' are declared for computation operations. + +C<-function(n,k) +{ + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(n-i+1); + D=D*(i); + } + output<-N/D; + return(output) +} + +# Probability of getting exactly 3 boys is represented by 'p'. + +p=(C(B,B_r)*C(G,G_r))/C(Total,S); +print(p) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.9/Ex1_8_9.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.9/Ex1_8_9.R new file mode 100644 index 00000000..ac50089c --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.8.9/Ex1_8_9.R @@ -0,0 +1,42 @@ +# Chapter 1 - Introduction to Probability, Section - 1.8 (Combinatorial Methods), Page No. - 37 + +# Total number of cards, number of aces and cards occupied by each player be represented by 'Cards', 'Aces' and 'O' respectively. + +Cards<-c(52); +Aces<-c(4); +O<-c(13); + +# A function 'C' is defined to determine the number of possible combinations as per given input where variables 'output','N' and 'D' are declared for computation operations. + +C<-function(n,k) +{ + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(n-i+1); + D=D*(i); + } + output<-N/D; + return(output) +} + +# Possible combinations of 4 aces be represented by 'A_C'. + +A_C=C(52,4); + +# Following loop will determine the number of possible combinations leading to the desired result. +# Result will be represented by 'R'. + +R<-c(1); +for(j in 1:Aces) +{ + R=R*O; +} + +# Required probability be represented by 'p'. + +p=R/A_C; +print(p) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.1/Ex1_9_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.1/Ex1_9_1.R new file mode 100644 index 00000000..094e59c9 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.1/Ex1_9_1.R @@ -0,0 +1,34 @@ +# Chapter 1 - Introduction to Probability, Section - 1.9 (Multinomial Coefficients), Page No. - 42 + +# Total members present and the members required in the 3 committees be represented by 'Total', 'A', 'B' and 'C' respectively. + +A<-c(8); +B<-c(8); +C<-c(4); +Total=A+B+C; + +# In order to find the possible combinations of selecting members into each committee. +# A function 'C' is defined in which variables 'output','N' and 'D' are declared for computation operations. + +C<-function(n,k) +{ + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(n-i+1); + D=D*(i); + } + output<-N/D; + return(output) +} + +# Numbers of possible combinations for choosing members for 'A' and 'B' are represented by 'C_A' and 'C_B' respectively. + +C_A=C(Total,A); +C_B=C((Total-A),B); + +# Number of total possible combinations is represented by 'R'. + +R=C_A*C_B; +print(R) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.2/Ex1_9_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.2/Ex1_9_2.R new file mode 100644 index 00000000..57ebbb46 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.2/Ex1_9_2.R @@ -0,0 +1,42 @@ +# Chapter 1 - Introduction to Probability, Section - 1.9 (Multinomial Coefficients), Page No. - 43 + +# For calculation purpose 'k' is defined as a vector containing 'n1', 'n2' and 'n3' rather than a count of the numbers being used. + +n<-c(20); +n1<-c(8); +n2<-c(8); +n3<-c(4); +k<-c(n1,n2,n3); + +# A function 'Fact' is defined. It finds the factorial of input value. +# A variable 'result' is declared in the function for computation operation. + +Fact<-function(n) +{ + result<-c(1); + for(i in 1:n) + { + result<-result*i; + } + return(result) +} + +# In order to apply Multinomial Theorem a function named 'Multi' is defined as follows. +# Variables 'output' and 'final' are declared in the function for computation operation. + + +Multi<-function(n,k) +{ + output<-c(1); + for(j in 1:length(k)) + { + output<-output*Fact(k[j]) + } + final=Fact(n)/output; + return(final) +} + +# Required result after the application of Multinomial Theorem is represented by 'R'. + +R=Multi(n,k); +print(R) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.3/Ex1_9_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.3/Ex1_9_3.R new file mode 100644 index 00000000..c9382705 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.3/Ex1_9_3.R @@ -0,0 +1,61 @@ +# Chapter 1 - Introduction to Probability, Section - 1.9 (Multinomial Coefficients), Page No. - 44 + +# For calculation purpose 'k' is defined as a vector containing 'n1', 'n2', 'n3' and so on, rather than a count of the numbers being used. +# Number of dice be represented by 'n'. + +n<-c(12); +n1<-c(2); +n2<-c(2); +n3<-c(2); +n4<-c(2); +n5<-c(2); +n6<-c(2); +k<-c(n1,n2,n3,n4,n5,n6); + +# Sample space is represented by 'S'. + +S<-c(1); +for(l in 1:n) +{ + S=S*6; +} + +# A function 'Fact' is defined. It finds the factorial of input value. +# A variable 'result' is declared in the function for computation operation. + +Fact<-function(n) +{ + result<-c(1); + for(i in 1:n) + { + result<-result*i; + } + return(result) +} + +# In order to apply Multinomial Theorem a function named 'Multi' is defined as follows. +# Variables 'output' and 'final' are declared in the function for computation operation. + + +Multi<-function(n,k) +{ + output<-c(1); + for(j in 1:length(k)) + { + output<-output*Fact(k[j]) + } + final=Fact(n)/output; + return(final) +} + +# Required result after the application of Multinomial Theorem is represented by 'R'. + +R=Multi(n,k); +print(R) + +# Required probability is represented by 'p'. + +p=R/S; +print(p) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.4/Ex1_9_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.4/Ex1_9_4.R new file mode 100644 index 00000000..93a39570 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH1/EX1.9.4/Ex1_9_4.R @@ -0,0 +1,69 @@ +# Chapter 1 - Introduction to Probability, Section - 1.9 (Multinomial Coefficients), Page No. - 44 + +# Number of players, number of total cards, number of hearts and the number of hearts that are needed to be given to players are represented by 'Players','Total', 'H','A','B','C' and 'D' respectively. + +Players<-c(4); +Total<-c(52); +H<-c(13); +A<-c(6); +B<-c(4); +C<-c(2); +D<-c(1); + +# For the purpose of calculation 'A','B','C' and 'D' are enclosed in a vector 'P'. + +P<-c(A,B,C,D); + +# For the purpose of solving this problem following two functions are needed to be defined. +# A function 'Fact' is defined. It finds the factorial of input value. +# A variable 'result' is declared in the function for computation operation. + +Fact<-function(n) +{ + result<-c(1); + for(i in 1:n) + { + result<-result*i; + } + return(result) +} + +# In order to apply Multinomial Theorem a function named 'Multi' is defined as follows. +# Variables 'output' and 'final' are declared in the function for computation operation. + + +Multi<-function(n,k) +{ + output<-c(1); + for(j in 1:length(k)) + { + output<-output*Fact(k[j]) + } + final=Fact(n)/output; + return(final) +} + +# The number of ways in which 13 cards are distributed to 4 players is represented by 'N'. +# For the purpose of finding 'N' a vector 'K' is difined such that it contains the number of cards belomging to each player, i.e. 13. +# Function "rep" creates a vector by replicating values and function "length" is used to find the length of a vector. +# For their description, type ?rep and ?length in the console. + +K=rep(13, Players) +N=Multi(Total,K); +print(N) + +# The number of ways to distribute cards to each player such that they get the desired number of hearts is represented by 'M1'. +# The number of ways such that the remaining cards are distributed to each player for them to have a total of 13 cards each is represented by 'M2'. +# The number of ways to distribute cards to each player such that they get 13 cards is represented by 'M'. + +M1=Multi(H,P); +M2=Multi((Total-H),((P-13)*-1)); +M=M1*M2; +print(M) + +# Required probability is represented by 'p'. + +p=M/N; +print(p) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.10/Ex2_1_10.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.10/Ex2_1_10.R new file mode 100644 index 00000000..1c51a893 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.10/Ex2_1_10.R @@ -0,0 +1,15 @@ +# Chapter 2 - Conditional Probability, Section - 2.1 (The Definition of Conditional Probability), Page No. - 61 + +# Total numbers and probabililty of event 'A' be represented by 'total' and 'Pr_A'. +# For calculation of 'Pr_A', "for" loop is used in order to simulate summation. + +total<-c(50) +Pr_A<-c(0); +for(i in 1:total) +{ + Pr_A=Pr_A+(1/total)*(1/i); +} + +print(Pr_A) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.11/Ex2_1_11.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.11/Ex2_1_11.R new file mode 100644 index 00000000..09c29c9a --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.11/Ex2_1_11.R @@ -0,0 +1,17 @@ +# Chapter 2 - Conditional Probability, Section - 2.1 (The Definition of Conditional Probability), Page No. - 62 + +# The two events be represented by 'B1' and 'B2'. +# Total events be represented by the vector named 'Total'. + +Total<-c('B1','B2') + +# Probability of each event. +# "paste0" function is used to combine numerical values and character strings for the purpose of printing them together. +# "length" function is used to find the number of elements present in a vector. + +for(i in 1:length(Total)) +{ + print(paste0("The probability of event ",Total[i]," happening is ", (length(Total[i])/length(Total)))) +} + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.12/Ex2_1_12.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.12/Ex2_1_12.R new file mode 100644 index 00000000..0e7c0d7b --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.12/Ex2_1_12.R @@ -0,0 +1,16 @@ +# Chapter 2 - Conditional Probability, Section - 2.1 (The Definition of Conditional Probability), Page No. - 62 + +# Total number of compositions which include one for failure and ten for success and probabililty of event 'E1' be represented by 'total' and 'Pr_E1'. +# For calculation of 'Pr_E1', "for" loop is used in order to simulate summation. +# Number of compositions of success be represented by 'success'. + +total<-c(11); +success=total-1; +Pr_E1<-c(0); +for(j in 1:total) +{ + Pr_E1=Pr_E1+((1/total)*((j-1)/success)); +} +print(Pr_E1) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.2/Ex2_1_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.2/Ex2_1_2.R new file mode 100644 index 00000000..7b432081 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.2/Ex2_1_2.R @@ -0,0 +1,47 @@ +# Chapter 2 - Conditional Probability, Section - 2.1 (The Definition of Conditional Probability), Page No. - 56 + +# Total numbers and count of numbers to be drawn be represented by 'Total' and 'N'. + +Total<-c(30); +N<-c(6); + +# In order to find the possible combinations of drawing certain numbers out of a total of 30 numbers. +# A function 'C' is defined in which variables 'output','N' and 'D' are declared for computation operations. + +C<-function(n,k) +{ + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(n-i+1); + D=D*(i); + } + output<-N/D; + return(output) +} + +# Sample space be represented by 'S'. + +S=C(Total,N) + +# Total numbers, count of numbers to be drawn and possible combinations in case of event 'B' be represented by 'Total_B', 'N_B' and 'B'. + +Total_B<-c(29); +N_B<-c(5); +B=C(Total_B,N_B) + +# Possible combinations in the case of event 'A' be represented by 'A'. + +A<-c(1); + +# Probability of event 'B', 'A' and conditional probability of event 'A' given 'B' be represented by 'Pr_B', 'Pr_A' and 'Pr_A_B'. + +Pr_B=B/S; +print(Pr_B) +Pr_A=A/S; +print(Pr_A); +Pr_A_B=Pr_A/Pr_B; +print(Pr_A_B) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.3/Ex2_1_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.3/Ex2_1_3.R new file mode 100644 index 00000000..eae58fe9 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.3/Ex2_1_3.R @@ -0,0 +1,72 @@ +# Chapter 2 - Conditional Probability, Section - 2.1 (The Definition of Conditional Probability), Page No. - 57 + +# Number of dice is represented by 'A' and total possible outcomes by 'O'. For 2 dice there will be a total of 36 possible outcomes. + +A<-c(2); +O<-c(1); +for(l in 1:A) +{ + O=O*6; +} + +# Following code will find the frequency of sum of digits in each possible outcome pair and store them in vector 'sum'. +# "rep" function is used to initialize a vector by a value which is replicated over a number of times. +# For description of rep function, type ?rep in console. + +sum<-rep(0,11) +for(k in 1:6) +{ + for(j in 1:6) + { + if((k+j)==2) + {sum[1]=sum[1]+1;} + if((k+j)==3) + {sum[2]=sum[2]+1;} + if((k+j)==4) + {sum[3]=sum[3]+1;} + if((k+j)==5) + {sum[4]=sum[4]+1;} + if((k+j)==6) + {sum[5]=sum[5]+1;} + if((k+j)==7) + {sum[6]=sum[6]+1;} + if((k+j)==8) + {sum[7]=sum[7]+1;} + if((k+j)==9) + {sum[8]=sum[8]+1;} + if((k+j)==10) + {sum[9]=sum[9]+1;} + if((k+j)==11) + {sum[10]=sum[10]+1;} + if((k+j)==12) + {sum[11]=sum[11]+1;} + } +} + +# Finding probability of event 'A' intersection 'B', represented as 'Pr_A_inter_B'. +# "&&" is logical AND operator. + +Pr_A_inter_B<-c(0); +for(i in 1:length(sum)) +{ + if(((i%%2)==0)&&(i<8)) + {Pr_A_inter_B=Pr_A_inter_B+((sum[i])/O)} +} +print(Pr_A_inter_B) + +# Finding probability of event 'B', represented as 'Pr_B'. + +Pr_B<-c(0); +for(m in 1:length(sum)) +{ + if((m%%2)==0) + {Pr_B=Pr_B+((sum[m])/O)} +} +print(Pr_B) + +# Probability of event 'A' given 'B' be represented as 'Pr_A_B'. + +Pr_A_B=Pr_A_inter_B/Pr_B; +print(Pr_A_B) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.4/Ex2_1_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.4/Ex2_1_4.R new file mode 100644 index 00000000..133bceb5 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.4/Ex2_1_4.R @@ -0,0 +1,30 @@ +# Chapter 2 - Conditional Probability, Section - 2.1 (The Definition of Conditional Probability), Page No. - 57 + +# Total number of patients and number of placebo receiving patients having relapse be represented by 'total','A_P'. + +A_P<-c(24); +B<-c(34); +total<-c(150); + +# Probability of 'B', 'A' intersection 'B' and conditional probability of 'A' given that 'B' has already occured are represented by 'Pr_B', 'Pr_A_inter_B' and 'Pr_A_B' respectively. + +Pr_B=B/total; +Pr_A_inter_B=A_P/total; +Pr_A_B=Pr_A_inter_B/Pr_B; +print(Pr_B) +print(Pr_A_inter_B) +print(Pr_A_B) + +# Event of patients receiving Lithium is given as 'C', let the probability of 'C', 'A' intersection 'C' and conditional probability of 'A' given that 'C' has already occured are represented by 'Pr_C', 'Pr_A_inter_C' and 'Pr_A_C' respectively. +# Number of Lithium receiving patients having relapse be represented by 'A_L'. + +C<-c(38); +A_L<-c(13); +Pr_C=C/total; +Pr_A_inter_C=A_L/total; +Pr_A_C=Pr_A_inter_C/Pr_C; +print(Pr_C) +print(Pr_A_inter_C) +print(Pr_A_C) + +# The answer may slightly vary due to being represented as a real number rather than a fraction and also due to rounding off. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.5/Ex2_1_5.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.5/Ex2_1_5.R new file mode 100644 index 00000000..ca72cc5f --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.5/Ex2_1_5.R @@ -0,0 +1,19 @@ +# Chapter 2 - Conditional Probability, Section - 2.1 (The Definition of Conditional Probability), Page No. - 58 + +# Six events contribute to a sum of '7' and five events contribute to a sum of '8'. +# Total outcomes be represented by 'O'. + +A<-c(6); +B=A+5; +O<-c(36); + +# The probability of event 'A' and event 'B' be represented by 'Pr_A' and 'Pr_B' respectively. + +Pr_A=A/O; +print(Pr_A) +Pr_B=B/O; +print(Pr_B) +p=Pr_A/Pr_B; +print(p) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.9/Ex2_1_9.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.9/Ex2_1_9.R new file mode 100644 index 00000000..0fff79ac --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.1.9/Ex2_1_9.R @@ -0,0 +1,25 @@ +# Chapter 2 - Conditional Probability, Section - 2.1 (The Definition of Conditional Probability), Page No. - 61 + +# Number of long and short bolts from first and second box be represented by 'B1_L', 'B1_S', 'B2_L' and 'B2_S'. + +B1_L<-c(60); +B1_S<-c(40); +B2_L<-c(10); +B2_S<-c(20); + +# Probability of event 'B1' and 'B2' be represented by 'Pr_B1' and 'Pr_B2'. + +Pr_B1<-c(0.5); +Pr_B2<-c(0.5); + +# Probability of selecting long bolts from first box and second box be represnted by 'Pr_A_inter_B1' and 'Pr_A_inter_B2'. + +Pr_A_inter_B1=(Pr_B1)*(B1_L/(B1_L+B1_S)); +Pr_A_inter_B2=(Pr_B2)*(B2_L/(B2_L+B2_S)); + +# Probability of event 'A' be represented by 'Pr_A'. + +Pr_A=Pr_A_inter_B1+Pr_A_inter_B2; +print(Pr_A) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.1/Ex2_2_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.1/Ex2_2_1.R new file mode 100644 index 00000000..17d73710 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.1/Ex2_2_1.R @@ -0,0 +1,49 @@ +# Chapter 2 - Conditional Probability, Section - 2.2 (Independent Events), Page No. - 66 + +# The number of coins, total outcomes and sample space be represented by 'I', 'O' and 'S' respectively. + +I<-c(2); +O<-c(1); +for(l in 1:I) +{ + O=O*2; +} + +# Functions "nrow" and "ncol" are used to find the number of rows and columns in a matrix. +# for description, type ?nrow and/or ?ncol in the console. + +S<-matrix(nrow=I,ncol=O) +for(i in 1:I) +{ + for(j in 1:O) + { + if((ceiling(j/2^(I-i))%%2)!=0) + {S[i,j]<-c('H')} + else + {S[i,j]<-c('T')} + } +} + +# Probability of events 'B', 'A' intersection 'B' and conditional probability of 'A' given that 'B' has already occured be represented by 'Pr_B', 'Pr_A_inter_B' and 'Pr_A_B'. + +Pr_B<-c(0); +Pr_A_inter_B<-c(0); +Pr_A_B<-c(0); +for(k in 1:ncol(S)) +{ + if(S[1,k]=='T') + { + Pr_B=Pr_B+1; + } +} +for(l in 1:ncol(S)) +{ + if(S[1,l]=='T'&&S[2,l]=='H') + { + Pr_A_inter_B=Pr_A_inter_B+1; + } +} +Pr_A_B=Pr_A_inter_B/Pr_B; +print(Pr_A_B) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.10/Ex2_2_10.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.10/Ex2_2_10.R new file mode 100644 index 00000000..6b532266 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.10/Ex2_2_10.R @@ -0,0 +1,34 @@ +# Chapter 2 - Conditional Probability, Section - 2.2 (Independent Events), Page No. - 72 + +# Number of items in sample and number of defectives be represented by 'S' and 'De'. + +S<-c(6); +De<-c(2); + +# A function 'C' is defined in order to calculate combination of 'n' items taken 'k' at a time. +# Variables 'N' and 'D' are declared in the function definition of 'C' for calculation operations. + +C<-function(n,k) +{ + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(n-i+1); + D=D*(i); + } + output<-N/D; + return(output) +} + +# Conditional probability of 'A' given that 'B1' and 'B2' have already occured seperately be represented by 'Pr_A_B1' and 'Pr_A_B2'. +# In case of event 'B1', 'p' is '0.01' and in case of event 'B2', 'p' is '0.4'. + +p=0.01; +Pr_A_B1=(C(S,De))*((p)^De)*((1-p)^(S-De)) +print(Pr_A_B1) +p=0.4; +Pr_A_B2=(C(S,De))*((p)^De)*((1-p)^(S-De)) +print(Pr_A_B2) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.2/Ex2_2_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.2/Ex2_2_2.R new file mode 100644 index 00000000..83b4b77a --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.2/Ex2_2_2.R @@ -0,0 +1,12 @@ +# Chapter 2 - Conditional Probability, Section - 2.2 (Independent Events), Page No. - 67 + +# The probability of events 'A', 'B', both occuring and at least one occuring be represented by 'Pr_A','Pr_B','Pr_A_inter_B' and 'Pr_A_B'. + +Pr_A<-c(1/3); +Pr_B<-c(1/4); +Pr_A_inter_B=Pr_A*Pr_B; +print(Pr_A_inter_B) +Pr_A_B=Pr_A+Pr_B-Pr_A_inter_B; +print(Pr_A_B) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.3/Ex2_2_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.3/Ex2_2_3.R new file mode 100644 index 00000000..51b00d78 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.3/Ex2_2_3.R @@ -0,0 +1,27 @@ +# Chapter 2 - Conditional Probability, Section - 2.2 (Independent Events), Page No. - 67 + +# Let all the outcome of a dice roll be stored in a vector named 'Total'. + +Total<-c(1:6) +A<-Total[Total%%2==0] +B<-c(1:4) + +# Let the probability of event 'A' and 'B' be represented by 'Pr_A' and 'Pr_B' respectively. + +Pr_A<-length(A)/length(Total) +Pr_B<-length(B)/length(Total) +print(Pr_A) +print(Pr_B) + +# Let the intersection of event 'A' and 'B' be stored in 'A_inter_B'. +# Probability of intersection of event 'A' and 'B' be represented by 'Pr_A_inter_B'. + +A_inter_B<-intersect(A,B) +Pr_A_inter_B<-length(A_inter_B)/length(Total) +print(Pr_A_inter_B) + +# Product of probabilities of event 'A' and 'B'. + +print(Pr_A*Pr_B) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.4/Ex2_2_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.4/Ex2_2_4.R new file mode 100644 index 00000000..d79813cc --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.4/Ex2_2_4.R @@ -0,0 +1,73 @@ +# Chapter 2 - Conditional Probability, Section - 2.2 (Independent Events), Page No. - 69 + +# The number of coins, total outcomes and sample space be represented by 'I', 'O' and 'S' respectively. + +I<-c(2); +O<-c(1); +for(l in 1:I) +{ + O=O*2; +} + +# Functions "nrow" and "ncol" are used to find the number of rows and columns in a matrix. +# for description, type ?nrow and/or ?ncol in the console. + +S<-matrix(nrow=I,ncol=O) +for(i in 1:I) +{ + for(j in 1:O) + { + if((ceiling(j/2^(I-i))%%2)!=0) + {S[i,j]<-c('H')} + else + {S[i,j]<-c('T')} + } +} + +# Probability of events 'A', 'B' and 'C' be represented by 'Pr_A', 'Pr_B' and 'Pr_C' respectively. + +Pr_A<-c(0); +Pr_B<-c(0); +Pr_C<-c(0); +for(k in 1:ncol(S)) +{ + if(S[1,k]=='H') + { + Pr_A=Pr_A+1; + } + if(S[2,k]=='H') + { + Pr_B=Pr_B+1; + } + if(S[1,k]==S[2,k]) + { + Pr_C=Pr_C+1; + } +} +Pr_A=Pr_A/O; +print(Pr_A); +Pr_B=Pr_B/O; +print(Pr_B); +Pr_C=Pr_C/O; +print(Pr_C); + +# Probability of intersection of events 'A' & 'B', 'A' & 'C', 'B' & 'C' and 'A', 'B' & 'C' be represented by 'Pr_A_inter_B', 'Pr_A_inter_C', 'Pr_B_inter_C' and 'Pr_A_inter_B_inter_C' respectively. + +Pr_A_inter_B=Pr_A*Pr_B; +print(Pr_A_inter_B) +Pr_A_inter_C=Pr_A*Pr_C; +print(Pr_A_inter_C) +Pr_B_inter_C=Pr_B*Pr_C; +print(Pr_B_inter_C) +Pr_A_inter_B_inter_C<-c(0); +for(l in 1:ncol(S)) +{ + if(S[1,l]=='H'&&S[2,l]=='H') + { + Pr_A_inter_B_inter_C=Pr_A_inter_B_inter_C+1; + } +} +Pr_A_inter_B_inter_C=Pr_A_inter_B_inter_C/O; +print(Pr_A_inter_B_inter_C) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.7/Ex2_2_7.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.7/Ex2_2_7.R new file mode 100644 index 00000000..c2747800 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.7/Ex2_2_7.R @@ -0,0 +1,19 @@ +# Chapter 2 - Conditional Probability, Section - 2.2 (Independent Events), Page No. - 70 + +# The example illustrates an infinite sum of a Geometric Progression. +# Let the first term be represented by 'a' and the common ratio by 'r'. + +a<-c(1/2) +r<-c(1/2) + +# Infinite summation is given by a function named 'Final'. + +Final<-function(a,r) +{ + return(a/(1-r)) +} +print(Final(a,r)) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. + + diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.9/Ex2_2_9.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.9/Ex2_2_9.R new file mode 100644 index 00000000..7ebef7a3 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.2.9/Ex2_2_9.R @@ -0,0 +1,29 @@ +# Chapter 2 - Conditional Probability, Section - 2.2 (Independent Events), Page No. - 70 + +# Let the probability of event 'A','B' and 'C' be represented by the functions 'Pr_A','Pr_B' and 'Pr_C' respectively. +# Let 'p' represents the probability of finding couple with specific characteristics and 'n' represents the total population. + +Pr_A<-function(p,n) +{ + (1-(1-p)^n) +} +Pr_C<-function(p,n) +{ + n*p*((1-p)^(n-1)) +} +Pr_B<-function(p,n) +{ + return(Pr_A(p,n)-Pr_C(p,n)) +} + +# Let the probability of event 'B' given 'A' be represented by 'Pr_B_given_A'. + +Pr_B_given_A<-function(p,n) +{ + return(Pr_B(p,n)/Pr_A(p,n)) +} +p<-c(8.3e-8) +n<-c(8000000) +print(Pr_B_given_A(p,n)) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.2/Ex2_3_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.2/Ex2_3_2.R new file mode 100644 index 00000000..961f734c --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.2/Ex2_3_2.R @@ -0,0 +1,31 @@ +# Chapter 2 - Conditional Probability, Section - 2.3 (Bayes' Theorem), Page No. - 77 + +# Number of long and short bolts from first and second box be represented by 'B1_L', 'B1_S', 'B2_L' and 'B2_S'. + +B1_L<-c(60); +B1_S<-c(40); +B2_L<-c(10); +B2_S<-c(20); + +# Probability of event 'B1' and 'B2' be represented by 'Pr_B1' and 'Pr_B2'. + +Pr_B1<-c(0.5); +Pr_B2<-c(0.5); + +# Probability of selecting long bolts from first box and second box be represnted by 'Pr_A_inter_B1' and 'Pr_A_inter_B2'. + +Pr_A_inter_B1=(Pr_B1)*(B1_L/(B1_L+B1_S)); +Pr_A_inter_B2=(Pr_B2)*(B2_L/(B2_L+B2_S)); + +# Probability of event 'A' be represented by 'Pr_A'. + +Pr_A=Pr_A_inter_B1+Pr_A_inter_B2; + +# Conditional probability of 'B1' and 'B2' seperately given that 'A' has already occured are represented by 'Pr_B1_A' and 'Pr_B2_A'. + +Pr_B1_A=Pr_A_inter_B1/Pr_A; +print(Pr_B1_A) +Pr_B2_A=Pr_A_inter_B2/Pr_A; +print(Pr_B2_A) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.3/Ex2_3_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.3/Ex2_3_3.R new file mode 100644 index 00000000..703ea2ec --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.3/Ex2_3_3.R @@ -0,0 +1,15 @@ +# Chapter 2 - Conditional Probability, Section - 2.3 (Bayes' Theorem), Page No. - 78 + +# Probability of events 'B1', 'B2' and Conditional probability of 'A' given that 'B1' and 'B2' has already occured are represented by 'Pr_B1','Pr_B2','Pr_A_B1' and 'Pr_A_B2'. + +Pr_B1<-c(0.0001); +Pr_B2=1-Pr_B1; +Pr_A_B1<-c(0.9); +Pr_A_B2=1-Pr_A_B1; + +# Probability of event 'B1' such that event 'A' has already occured be represented by 'Pr_B1_A'. + +Pr_B1_A=((Pr_A_B1*Pr_B1)/((Pr_A_B1*Pr_B1)+(Pr_A_B2*Pr_B2))); +print(Pr_B1_A) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.4/Ex2_3_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.4/Ex2_3_4.R new file mode 100644 index 00000000..dc5313e3 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.4/Ex2_3_4.R @@ -0,0 +1,22 @@ +# Chapter 2 - Conditional Probability, Section - 2.3 (Bayes' Theorem), Page No. - 78 + +# Probability of events 'B1','B2' and 'B3' be represented by vector 'Pr_B'. +# Conditional probability of event 'A' given that events 'B1','B2' and 'B3' have already occured be represented by vector 'Pr_A_B'. + +Pr_B<-c(0.2,0.3,0.5); +Pr_A_B<-c(0.01,0.02,0.03); + +# Conditional probability of event 'B2' such that event 'A' has already occured is represented by 'Pr_B2_A'. +# "for" loop is used to simulate summation and "length" function is used to find the length of a vector. +# For description type ?length in the console. +# 'sum' variable is declared for calculation operations. + +sum<-c(0); +for(i in 1:length(Pr_B)) +{ + sum=sum+Pr_B[i]*Pr_A_B[i]; +} +Pr_B2_A=((Pr_B[2]*Pr_A_B[2])/sum); +print(Pr_B2_A) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.5/Ex2_3_5.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.5/Ex2_3_5.R new file mode 100644 index 00000000..0cf2ac9b --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.5/Ex2_3_5.R @@ -0,0 +1,24 @@ +# Chapter 2 - Conditional Probability, Section - 2.3 (Bayes' Theorem), Page No. - 79 + +# Probability of events 'B1','B2','B3','B4','B5' and 'B6' be represented by vector 'Pr_B'. +# Conditional probability of event 'E' given that events 'B1','B2','B3','B4','B5' and 'B6' have already occured be represented by vector 'Pr_E_B'. + +Pr_B<-c(1/16,1/4,1/8,1/4,1/4,1/16); +Pr_E_B<-c(1,1,1,3/4,1/2,0); + +# Conditional probability of events 'B1' and 'B5' seperately such that event 'E' has already occured is represented by 'Pr_B1_E' and 'Pr_B5_E'. +# "for" loop is used to simulate summation and "length" function is used to find the length of a vector. +# For description type ?length in the console. +# 'sum' variable is declared for calculation operations. + +sum<-c(0); +for(i in 1:length(Pr_B)) +{ + sum=sum+Pr_B[i]*Pr_E_B[i]; +} +Pr_B1_E=((Pr_B[1]*Pr_E_B[1])/sum); +print(Pr_B1_E) +Pr_B5_E=((Pr_B[5]*Pr_E_B[5])/sum); +print(Pr_B5_E) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.6/Ex2_3_6.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.6/Ex2_3_6.R new file mode 100644 index 00000000..a5271111 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.6/Ex2_3_6.R @@ -0,0 +1,14 @@ +# Chapter 2 - Conditional Probability, Section - 2.3 (Bayes' Theorem), Page No. - 82 + +# The prior probability of 'B1' and 'B2' be represented by 'Pr_p_B1' and 'Pr_p_B2' respectively. +# Conditional probability of 'A' given that 'B1'and 'B2' have already occured seperately are represented by 'Pr_A_B1' and 'Pr_A_B2' respectively. +# Conditional probability of 'B1' given that 'A' has already occured be represented by 'Pr_B1_A'. + +Pr_p_B1<-c(0.9) +Pr_p_B2<-c(0.1) +Pr_A_B1<-c(0.00144) +Pr_A_B2<-c(0.311) +Pr_B1_A=(Pr_p_B1*Pr_A_B1)/((Pr_p_B1*Pr_A_B1)+(Pr_p_B2*Pr_A_B2)) +print(Pr_B1_A) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.7/Ex2_3_7.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.7/Ex2_3_7.R new file mode 100644 index 00000000..136e20b3 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.7/Ex2_3_7.R @@ -0,0 +1,88 @@ +# Chapter 2 - Conditional Probability, Section - 2.3 (Bayes' Theorem), Page No. - 82 + +# A function named 'Bayes' is defined in order to find the conditional probability of event 'Bj', where 'j' varies from '1' to '11', such that event 'E1' has already occured. + +Bayes<-function(j) +{ + return((j-1)/55) +} + +# Conditional probability of 'B1','B2' and 'B11' given that 'E1' has already occured be represented by 'Pr_B1_E1','Pr_B2_E1' and 'Pr_B11_E1' respectively. + +Pr_B1_E1=Bayes(1) +print(Pr_B1_E1) +Pr_B2_E1=Bayes(2) +print(Pr_B2_E1) +Pr_B11_E1=Bayes(11) +print(Pr_B11_E1) + +# Let the number of patients be represented by the variable named 'patient'. +# Let the number of successes be represented by the variable named 'success'. +# Let the number of failures be represented by the variable named 'failure'. + +patient<-c(40) +success<-c(22) +failure<-c(18) + +# Let a function 'sequenc' for finding the possible number of sequences for the given number patients and successes. +# 'N','D' and 'output' are variables declared in the function definition for the purpose of calculation operations. + +sequenc<-function(patient,success) +{ + N<-c(1); + D<-c(1); + for(i in 1:success) + { + N=N*(patient-i+1); + D=D*(i); + } + output<-N/D + return(output) +} + +# Let the number of possible compositions be stored in the variable 'composition'. + +composition<-c(11) + +# Let the posterior probabilities be given by the function named 'post' and stored in a vector named 'Final'. +# 'sum' and 'Numerator' are variables declared in the function definition for the purpose of calculation operations. +# "vector" function is used for defining a vector. +# For more description, type ?vector in the console. + +Final<-vector(mode='numeric',length=composition) +post<-function(comp) +{ + sum<-c(0) + Numerator<-((1/composition)*(sequenc(patient,success))*(((comp-1)/10)^success)*((1-((comp-1)/10))^failure)); + for(j in 1:composition) + { + sum=sum+((1/composition)*(sequenc(patient,success))*(((j-1)/10)^success)*((1-((j-1)/10))^failure)) + } + return(Numerator/sum) +} + +for(k in 1:composition) +{ + Final[k]<-post(k) +} + +# "barplot" function is used to draw a barplot on the input vector's data. +# For more description, type ?barplot in the console. + +barplot(Final,xlab="Events from B1 to B11",main="Posterior Probabilities") + +# Let the probability of one more patient's success given that the observed event of given successes and failures has occured be given by the function named 'last'. +# A variable named 'outcome' is defined in the function for computational operations. + +last<-function(comp) +{ + outcome<-c(0) + for(l in 1:comp) + { + outcome=outcome+(((l-1)/10)*post(l)) + } + return(outcome) +} +last(composition) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.8/Ex2_3_8.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.8/Ex2_3_8.R new file mode 100644 index 00000000..21ef0bb1 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.3.8/Ex2_3_8.R @@ -0,0 +1,89 @@ +# Chapter 2 - Conditional Probability, Section - 2.3 (Bayes' Theorem), Page No. - 84 + +# Let the number of patients be represented by the variable named 'patient'. +# Let the number of successes be represented by the variable named 'success'. +# Let the number of failures be represented by the variable named 'failure'. + +patient<-c(40) +success<-c(22) +failure<-c(18) + +# Let a function 'sequenc' for finding the possible number of sequences for the given number patients and successes. +# 'N','D' and 'output' are variables declared in the function definition for the purpose of calculation operations. + +sequenc<-function(patient,success) +{ + N<-c(1); + D<-c(1); + for(i in 1:success) + { + N=N*(patient-i+1); + D=D*(i); + } + output<-N/D + return(output) +} + +# Let the prior probabilities be stored in a vector named "Prior". + +Prior<-c(0.00, 0.19, 0.19, 0.17, 0.14, 0.11, 0.09, 0.06, 0.04, 0.01, 0.00) + +# Let the posterior probabilities be given by the function named 'post' and stored in a vector named 'Final'. +# 'sum' and 'Numerator' are variables declared in the function definition for the purpose of calculation operations. +# "vector" function is used for defining a vector. +# For more description, type ?vector in the console. + +Final<-vector(mode='numeric',length=length(Prior)) +post<-function(comp) +{ + sum<-c(0) + Numerator<-((Prior[comp])*(sequenc(patient,success))*(((comp-1)/10)^success)*((1-((comp-1)/10))^failure)); + for(j in 1:length(Prior)) + { + sum=sum+((Prior[j])*(sequenc(patient,success))*(((j-1)/10)^success)*((1-((j-1)/10))^failure)) + } + return(Numerator/sum) +} + +for(k in 1:length(Prior)) +{ + Final[k]<-post(k) +} + +# "barplot" function is used to draw a barplot on the input vector's data. +# For more description, type ?barplot in the console. + +barplot(Final,xlab="Events from B1 to B11",main="Posterior Probabilities",space=0.07) + +# Adding posterior probabilities from previous example as points in the same plot. + +# Let the number of possible compositions be stored in the variable 'composition'. + +composition<-c(11) + +# Let the posterior probabilities be given by the function named 'post' and stored in a vector named 'Final'. +# 'sum' and 'Numerator' are variables declared in the function definition for the purpose of calculation operations. +# "vector" function is used for defining a vector. +# For more description, type ?vector in the console. + +Final<-vector(mode='numeric',length=composition) +post<-function(comp) +{ + sum<-c(0) + Numerator<-((1/composition)*(sequenc(patient,success))*(((comp-1)/10)^success)*((1-((comp-1)/10))^failure)); + for(j in 1:composition) + { + sum=sum+((1/composition)*(sequenc(patient,success))*(((j-1)/10)^success)*((1-((j-1)/10))^failure)) + } + return(Numerator/sum) +} + +for(k in 1:composition) +{ + Final[k]<-post(k) +} + +# "points" function is used to add points in existing plot. +# For more description, type ?points in the console. + +points(Final, pch=4) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.4.1/Ex2_4_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.4.1/Ex2_4_1.R new file mode 100644 index 00000000..bf6500e1 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.4.1/Ex2_4_1.R @@ -0,0 +1,9 @@ +# Chapter 2 - Conditional Probability, Section - 2.4 (The Gambler's Ruin Problem), Page No. - 88 + +i<-c(98); +k<-c(100); + +# Let the probability of gambler 'A' winning before gambler 'B' be represented by 'a'. + +a=i/k; +print(a) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.4.2/Ex2_4_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.4.2/Ex2_4_2.R new file mode 100644 index 00000000..21225c5c --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH2/EX2.4.2/Ex2_4_2.R @@ -0,0 +1,12 @@ +# Chapter 2 - Conditional Probability, Section - 2.4 (The Gambler's Ruin Problem), Page No. - 89 + +i<-c(99); +k<-c(100); +p<-c(0.4); + +# Let the probability of gambler 'A' winning before gambler 'B' be represented by 'a'. + +a=(((((1-p)/p)^i)-1)/((((1-p)/p)^k)-1)) +print(a) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.1/Ex3_1_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.1/Ex3_1_1.R new file mode 100644 index 00000000..5a8f8d60 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.1/Ex3_1_1.R @@ -0,0 +1,66 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.1 (Random Variables and Discrete Distributions), Page No. - 93 + +# Possible outcomes of a coin toss is represented by 'toss'. + +toss<-c('H','T') + +# Let 'T' represents the number of times a fair coin is tossed. + +T<-c(10) + +# Let the possible number of Heads and Tails sequence be represented by 'Sequence'. + +Sequence=2^T; +print(Sequence) + +# In order to find all possible permutations of coin toss, "gtools" package is installed by executing the following command. + +install.packages("gtools") + +# "gtools" library is added by executing the following command. + +library(gtools) + +# All permutations are represented by 'tosses'. +# "permutations" function is used in order to find all the possible permutations for the coin toss. +# For more description, type ?permutations in the console. + +tosses<-permutations(n=2,r=10,v=toss,repeats.allowed=TRUE) + +# Let a function named 'X' for counting the number of Heads in a sequence. +# Let variable 'sum' be defined in the function for computational operations. + +X<-function(x) +{ + sum<-c(0); + for(i in 1:length(x)) + { + if(x[i]=='H') + { + sum=sum+1; + } + } + return(sum) +} + +# Let the number of Heads for each sequence be stored in the vector named 'Heads'. +# "vector" function is used to define a vector. +# For more description, type ?vector in the console. + +Heads<-vector(mode='numeric',length=(nrow(tosses))) +for(j in 1:nrow(tosses)) +{ + Heads[j]=X(tosses[j,]) +} + +# "unique" function can be used to find unique values in a vector. + +Heads<-unique(Heads) + +# "sort" function is used to sort values in a vector. + +Heads<-sort(Heads,decreasing=FALSE) + +# Possible values given out by the function 'X' be as follows. + +print(Heads) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.3/Ex3_1_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.3/Ex3_1_3.R new file mode 100644 index 00000000..7a399f33 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.3/Ex3_1_3.R @@ -0,0 +1,38 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.1 (Random Variables and Discrete Distributions), Page No. - 94 + +X<-c(4,200); +Y<-c(1,150); + +# "plot" and "rect" functions are used to plot and highlight areas in a graph plot. +# For description of these functions, type ?plot and ?rect in the console. + +plot(X, Y, Xlab = "Water", Ylab = "Electric", panel.first = rect(X[1],Y[1],X[2],Y[2])) + +# Area of sample space 'S' is represented bY 'Area_S'. + +Area_S=(Y[2]-Y[1])*(X[2]-X[1]) +A<-c(100,200); +B<-c(115,150); + +# Area of 'A' is represented bY 'Area_A'. + +Area_A=(Y[2]-Y[1])*(A[2]-A[1]); + +# Plotting area of 'A' in red color. + +rect(A[1],Y[1],A[2],Y[2],col='red') + +# Area of 'B' is represented bY 'Area_B'. + +Area_B=(B[2]-B[1])*(X[2]-X[1]); + +# Plotting area of 'B' in blue color. + +rect(X[1],B[1],X[2],B[2],col='blue') + +# Plotting area of 'A' union 'B' in green color. +# "legend" function is used to add a legend on the plot. For description, type ?legend in the console. + +rect(A[1],Y[1],A[2],Y[2],col='green',density=15) +rect(X[1],B[1],X[2],B[2],col='green',density=15) +legend("topright", legend=c("A union B"),fill='green', density=60) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.5/Ex3_1_5.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.5/Ex3_1_5.R new file mode 100644 index 00000000..5639b88b --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.5/Ex3_1_5.R @@ -0,0 +1,31 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.1 (Random Variables and Discrete Distributions), Page No. - 95 + +X<-c(4,200); +Y<-c(1,150); + +# Area of sample space 'S' is represented bY 'Area_S'. + +Area_S=(Y[2]-Y[1])*(X[2]-X[1]) +A<-c(100,200); + +# Area of 'A' is represented bY 'Area_A'. + +Area_A=(Y[2]-Y[1])*(A[2]-A[1]); + +# Probability of area 'A' is represented by 'Pr_A'. + +Pr_A=Area_A/Area_S; +print(Pr_A) + +C<-c(50,175); + +# Area of 'C' is represented bY 'Area_C'. + +Area_C=(Y[2]-Y[1])*(C[2]-C[1]); + +# Probability of area 'C'is represented by 'Pr_C'. + +Pr_C=Area_C/Area_S; +print(Pr_C) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.6/Ex3_1_6.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.6/Ex3_1_6.R new file mode 100644 index 00000000..44216b90 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.6/Ex3_1_6.R @@ -0,0 +1,54 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.1 (Random Variables and Discrete Distributions), Page No. - 96 + +X<-c(4,200); +Y<-c(1,150); + +# Area of sample space 'S' is represented bY 'Area_S'. + +Area_S=(Y[2]-Y[1])*(X[2]-X[1]) +A<-c(100,200); +B<-c(115,150); + +# Area of 'A' is represented by 'Area_A'. + +Area_A=(Y[2]-Y[1])*(A[2]-A[1]); + +# Area of 'B' is represented by 'Area_B'. + +Area_B=(B[2]-B[1])*(X[2]-X[1]); + +# Area of intersection of 'A' and 'B' is represented by 'Area_A_inter_B'. + +Area_A_inter_B=(B[2]-B[1])*(A[2]-A[1]); + +# Let the probability function of 'Z' be represented by 'f'. + +f<-function(z) +{ + if(z==1) + { + return((Area_A/Area_S) + (Area_B/Area_S) - (Area_A_inter_B/Area_S)); + } + else if(z==0) + { + return(1-((Area_A/Area_S) + (Area_B/Area_S) - (Area_A_inter_B/Area_S))); + } + else + { + return(0); + } +} + +# For Z=1 + +print(f(1)) + +# For Z=0 + +print(f(0)) + +# Otherwise + +print(f(2)) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.8/Ex3_1_8.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.8/Ex3_1_8.R new file mode 100644 index 00000000..fcb13754 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.1.8/Ex3_1_8.R @@ -0,0 +1,23 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.1 (Random Variables and Discrete Distributions), Page No. - 97 + +# Let the number of possible values be represented by 'V'. + +V<-c(1000); +X<-function(s) +{ + return(((100*s[1]))+(10*s[2])+(s[3])) +} +s<-c(0,1,5) + +# Let the probability of winning the lottery game for the given sample space 's' be represented by the function 'Pr'. + +Pr<-function(X) +{ + return(X/V); +} + +# Probabilty of winning for the sample space (0,1,5). + +print(Pr(length(X(s)))) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.11/Ex3_10_11.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.11/Ex3_10_11.R new file mode 100644 index 00000000..efd15f13 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.11/Ex3_10_11.R @@ -0,0 +1,26 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.10 (Markov Chains), Page No. - 197 + +# "vector" function is used in order to create a vector. +# For more description, type ?vector in the console. +# Let all probabilities be stored initailly in a vactor 'p'. + +p<-c(0.1,0.4,0.2,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.4,0.2) + +# "matrix" function is used in order to create a vector. +# For more description, type ?matrix in the console. +# Let the Transition Matrix be represented by 'P'. + +P<-matrix(p,nrow=6,ncol=6,byrow=TRUE) +print(P) + +# Let the initial probability vector be represented by 'v'. + +v<-c(0.5,0.3,0.2,0,0,0) + +# Second probability vector + +print(v%*%P) + +# Third probability vector + +print(v%*%P%*%P) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.12/Ex3_10_12.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.12/Ex3_10_12.R new file mode 100644 index 00000000..5d8f9a25 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.12/Ex3_10_12.R @@ -0,0 +1,40 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.10 (Markov Chains), Page No. - 197 + +# "vector" function is used in order to create a vector. +# For more description, type ?vector in the console. +# Let all probabilities be stored initailly in a vactor 'p'. + +p<-c(0.1,0.4,0.2,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.4,0.2) + +# "matrix" function is used in order to create a vector. +# For more description, type ?matrix in the console. +# Let the Transition Matrix be represented by 'P'. + +P<-matrix(p,nrow=6,ncol=6,byrow=TRUE) +print(P) + +# Let the initial probability vector be represented by 'v'. + +v<-c(0.119,0.193,0.186,0.173,0.196,0.133) + +# Let vP be stored in the vector 'v_P'. +# "round" function is used for rounding off digits in the resultant vector. +# For more description, type ?round in the console. + +v_P=round(v%*%P,digits=3) + +# Checking if vP=v. +# Let a variable 'count' be used for comparing the similarity of both vectors. + +count<-c(0); +for(i in 1:length(v)) +{ + if(v_P[i]==v[i]) + { + count=count+1; + } +} +if(count==length(v)) +{ + print("'v' is a stationary distribution.") +} \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.14/Ex3_10_14.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.14/Ex3_10_14.R new file mode 100644 index 00000000..65bafb3e --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.14/Ex3_10_14.R @@ -0,0 +1,69 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.10 (Markov Chains), Page No. - 199 + +# Let the possible values for state at time "n+1" be stored in the vector 'X_n_1' and for state at time "n" be stored in the vector 'X_n'. + +X_n<-c(1,2) +X_n_1<-c(1,2) + +# Let the probability for all possible combination of states be given by the function 'Pr'. + +Pr<-function(a,b) +{ + if(a!=b) + return(2/3) + else + return(1/3) +} + +# "vector" function is used in order to create a vector. +# For more description, type ?vector in the console. +# Let the vector storing probabilities be represented by 'p'. + +p<-vector(mode='numeric',length=4) +p[1]=Pr(1,1); +p[2]=Pr(2,1); +p[3]=Pr(1,2); +p[4]=Pr(2,2); + +# "matrix" function is used in order to create a vector. +# For more description, type ?matrix in the console. +# Let the Transition Matrix be represented by 'P'. + +P<-matrix(p,nrow=2,ncol=2) + +# "diag" function can be used to create an identity matrix. +# For more description, type ?diag in the console. +# Let the identity matrix be represented by 'I'. + +I<-diag(2) + +# "P-I" matrix. + +print(P-I) +G<-P-I; +for(i in 1:nrow(G)) +{ + G[i,ncol(G)]=1 +} + +# "G" matrix. + +print(G) + +# "solve" function can be used to find the inverse of a matrix. +# For more description, type ?solve in the console. +# Let the inverse matrix be represented by 'G_inverse'. + +G_inverse=solve(G) + +# "G inverse" matrix. + +print(G_inverse) + +# Let the stationary distribution be represented by 'v'. + +v<-G_inverse[2,] + +# "v" vector. + +print(v) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.15/Ex3_10_15.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.15/Ex3_10_15.R new file mode 100644 index 00000000..7d86802b --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.15/Ex3_10_15.R @@ -0,0 +1,54 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.10 (Markov Chains), Page No. - 199 + +# "diag" function can be used to create an identity matrix. +# For more description, type ?diag in the console. +# In order to flip matrix "Thermimage" package is needed. +# To install the package following command must be executed - + +install.packages("Thermimage") + +# In order to initialize the package the following command is executed - + +library(Thermimage) + +# For more description of the package, type ?Thermimage in the console. +# "flip.matrix" function can be used to flip a matrix left-right. +# For more description, type ?flip.matrix in the console. +# Let the Transition Matrix be represented by 'P'. + +P<-flip.matrix(diag(2)) + +# Let the identity matrix be represented by 'I'. + +I<-diag(2) + +# "P-I" matrix. + +print(P-I) +G<-P-I; +for(i in 1:nrow(G)) +{ + G[i,ncol(G)]=1 +} + +# "G" matrix. + +print(G) + +# "solve" function can be used to find the inverse of a matrix. +# For more description, type ?solve in the console. +# Let the inverse matrix be represented by 'G_inverse'. + +G_inverse=solve(G) + +# "G inverse" matrix. + +print(G_inverse) + +# Let the stationary distribution be represented by 'v'. + +v<-G_inverse[2,] + +# "v" vector. + +print(v) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.2/Ex3_10_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.2/Ex3_10_2.R new file mode 100644 index 00000000..00e11083 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.2/Ex3_10_2.R @@ -0,0 +1,35 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.10 (Markov Chains), Page No. - 189 + +# Let the possible values for state at time "n+1" be stored in the vector 'X_n_1' and for state at time "n" be stored in the vector 'X_n'. + +X_n<-c(1,2) +X_n_1<-c(1,2) + +# Let the probability for all possible combination of states be given by the function 'Pr'. + +Pr<-function(a,b) +{ + if(a!=b) + return(2/3) + else + return(1/3) +} + +# Probability for value of state at time - +# 1) "n+1"=1 given "n"=1 + +print(Pr(1,1)) + +# 2) "n+1"=2 given "n"=1 + +print(Pr(2,1)) + +# 3) "n+1"=1 given "n"=2 + +print(Pr(1,2)) + +# 4) "n+1"=2 given "n"=2 + +print(Pr(2,2)) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.4/Ex3_10_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.4/Ex3_10_4.R new file mode 100644 index 00000000..f3585b0d --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.4/Ex3_10_4.R @@ -0,0 +1,35 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.10 (Markov Chains), Page No. - 190 + +# Let the possible values for state at time "n+1" be stored in the vector 'X_n_1' and for state at time "n" be stored in the vector 'X_n'. + +X_n<-c(1,2) +X_n_1<-c(1,2) + +# Let the probability for all possible combination of states be given by the function 'Pr'. + +Pr<-function(a,b) +{ + if(a!=b) + return(2/3) + else + return(1/3) +} + +# "vector" function is used in order to create a vector. +# For more description, type ?vector in the console. +# Let the vector storing probabilities be represented by 'p'. + +p<-vector(mode='numeric',length=4) +p[1]=Pr(1,1); +p[2]=Pr(2,1); +p[3]=Pr(1,2); +p[4]=Pr(2,2); + +# "matrix" function is used in order to create a vector. +# For more description, type ?matrix in the console. +# Let the Transition Matrix be represented by 'P'. + +P<-matrix(p,nrow=2,ncol=2) +print(P) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.5/Ex3_10_5.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.5/Ex3_10_5.R new file mode 100644 index 00000000..867ea16a --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.5/Ex3_10_5.R @@ -0,0 +1,22 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.10 (Markov Chains), Page No. - 191 + +# "vector" function is used in order to create a vector. +# For more description, type ?vector in the console. +# Let all probabilities be stored initailly in a vactor 'p'. + +p<-c(0.1,0.4,0.2,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.4,0.2) + +# "matrix" function is used in order to create a vector. +# For more description, type ?matrix in the console. +# Let the Transition Matrix be represented by 'P'. + +P<-matrix(p,nrow=6,ncol=6,byrow=TRUE) +print(P) + +# (a) Required probability is given as follows - + +print(P[6,5]) + +# (b) Required probability is given as follows - + +print(1-P[1,1]) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.7/Ex3_10_7.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.7/Ex3_10_7.R new file mode 100644 index 00000000..b541f83c --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.7/Ex3_10_7.R @@ -0,0 +1,28 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.10 (Markov Chains), Page No. - 193 + +# Let the values of transition matrix be stored in the vector 'p' and the transition matrix be represented by 'P'. +# For converting a vector into matrix, "matrix" function in used. Final values are saved in the matrix 'f'. +# For description of this function, type ?matrix in the console. + +p<-c(0.9,0.1,0.6,0.4) +P<-matrix(p,nrow=2,ncol=2,byrow=TRUE) + +# Let 'Pr' represents the probability of state at "n+2" time given the state at "n" time. +# State at "n+2" time be represented by 'n_2' and at "n" time by 'n'. + +Pr<-function(n_2,n) +{ + return(P[n,1]*P[1,n_2]+P[n,2]*P[2,n_2]) +} + +# Probability for '1' as "n+2" time and "n" time state. + +print(Pr(1,1)) + +# Probability for '1' as "n+2" time and '2' as "n" time state. + +print(Pr(1,2)) + +# Probability for '1' as "n+2" time and "n" time state. + +print(Pr(2,2)) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.8/Ex3_10_8.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.8/Ex3_10_8.R new file mode 100644 index 00000000..6709dc6c --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.10.8/Ex3_10_8.R @@ -0,0 +1,41 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.10 (Markov Chains), Page No. - 194 + +# "vector" function is used in order to create a vector. +# For more description, type ?vector in the console. +# Let all probabilities be stored initailly in a vactor 'p'. + +p<-c(0.1,0.4,0.2,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.2,0.3,0.2,0.1,0.1,0.1,0.1,0.4,0.2) + +# "matrix" function is used in order to create a vector. +# For more description, type ?matrix in the console. +# Let the Transition Matrix be represented by 'P'. + +P<-matrix(p,nrow=6,ncol=6,byrow=TRUE) +print(P) + +# Let two step transition matrix be represented by 'P_2'. +# Operator used for matrix multiplication is "%*%". + +P_2=P%*%P; +print(P_2) + +# (a) Required probability is given as follows - + +print(P_2[4,2]) + +# (b) Required probability is given as follows - + +print(P_2[3,2]) + +# Let three step transition matrix be represented by 'P_3'. + +P_3=P_2%*%P; +print(P_3) + +# (a) Required probability is given as follows - + +print(P_3[5,1]) + +# (b) Required probability is given as follows - + +print(P_3[2,2]) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.3/Ex3_2_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.3/Ex3_2_3.R new file mode 100644 index 00000000..67f708a4 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.3/Ex3_2_3.R @@ -0,0 +1,16 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.2 (Continuous Distributions), Page No. - 104 + +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# Let a linear function 'x' be defined such that it returns its input. + +x<-function(x) x + +# Let the integration of 'x' from limits "0 to 4" be stored in a list named 'Integrate'. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. + +Integrate=integrate(x,0,4); +c=1/(Integrate$value); +print(c) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.4/Ex3_2_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.4/Ex3_2_4.R new file mode 100644 index 00000000..0ba7101d --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.4/Ex3_2_4.R @@ -0,0 +1,17 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.2 (Continuous Distributions), Page No. - 105 + +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# Let a linear function 'x' be defined such that it returns 1/8th of its input. + +x<-function(x) (x/8) + +# Let the probability for range between "1 and 2" be represented by 'Pr_I' and for range above "2" by 'Pr_II'. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. + +Pr_I=integrate(x,1,2)$value; +Pr_II=integrate(x,2,4)$value; +print(Pr_I) +print(Pr_II) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.7/Ex3_2_7.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.7/Ex3_2_7.R new file mode 100644 index 00000000..2f28d4dd --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.2.7/Ex3_2_7.R @@ -0,0 +1,36 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.2 (Continuous Distributions), Page No. - 106 + +# Let 'Pr' be the function which determines probability. Let upper limit of voltage record be represented by 'value'. + +value<-c(3); +Pr<-function(x,value) +{ + if(x>0) + { + if(x0) + { + return(1-(1/(1+X))) + } +} + +print(F(3)) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.3.3/Ex3_3_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.3.3/Ex3_3_3.R new file mode 100644 index 00000000..a5001fe6 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.3.3/Ex3_3_3.R @@ -0,0 +1,20 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.3 (The Cumulative Distribution Function), Page No. - 110 + +F<-function(X) +{ + if(X<=0) + { + return(0) + } + else if(X>0) + { + return(1-(1/(1+X))) + } +} + +# Let the probability of event 'A' be represented as 'Pr_A'. + +Pr_A=F(4)-F(2); +print(Pr_A) + +# The answer provided in the textbook is wrong. F(2)=2/3, hence correct answer is 2/15 or 1.3333. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.3.9/Ex3_3_9.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.3.9/Ex3_3_9.R new file mode 100644 index 00000000..3003fa0c --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.3.9/Ex3_3_9.R @@ -0,0 +1,57 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.3 (The Cumulative Distribution Function), Page No. - 115 + +# A function 'C' is defined in order to calculate combination of 'n' items taken 'k' at a time. +# Variables 'N' and 'D' are declared in the function definition of 'C' for calculation operations. + +C<-function(n,k) +{ + N<-c(1); + D<-c(1); + if(k>0) + { + for(i in 1:k) + { + N=N*(n-i+1); + D=D*(i); + } + output<-N/D; + return(output) + } + else if (k==0) + { + return(1) + } +} + +# Binomial distribution with parameters 'n' and 'p'. + +n<-c(5); +p<-c(0.3); +f<-function(x) +{ + return(C(n,x)*(p^(x))*((1-p)^(n-x))) +} + +# "pbinom" function is used in order to find the c. d. f. of a binomial distribution. For description type ?pbinom in the console. + +F<-function(x) +{ + return(pbinom(x,n,p)) +} + +# Displaying values of p.f. 'f'. + +x<-c(0:5) +for(k in 1:length(x)) +{ + print(f(x[k])) +} + +# Displaying values of c.d.f. 'F'. + +for(l in 1:length(x)) +{ + print(F(x[l])) +} + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.11/Ex3_4_11.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.11/Ex3_4_11.R new file mode 100644 index 00000000..67b7772f --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.11/Ex3_4_11.R @@ -0,0 +1,40 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.4 (Bivariate Distributions), Page No. - 124 + +x<-c(1,2,3) +f<-function(x,y) +{ + ((x*(y^(x-1)))/3) +} + +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. +# Let the final result after integration and summation be stored in 'Result'. + +# (I) + +Result<-c(0) +for(i in 1:length(x)) +{ + F<-function(y) + { + f(i,y) + } + Result=Result+integrate(F,0,1)$value +} +print(Result) + +# (II) + +Result<-c(0) +for(j in 2:length(x)) +{ + F<-function(y) + { + f(j,y) + } + Result=Result+integrate(F,1/2,1)$value +} +print(Result) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.12/Ex3_4_12.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.12/Ex3_4_12.R new file mode 100644 index 00000000..35bbef75 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.12/Ex3_4_12.R @@ -0,0 +1,28 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.4 (Bivariate Distributions), Page No. - 125 + +x<-c(0,1) +f<-function(x,p) +{ + ((p^x)*((1-p)^(1-x))) +} +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. +# Let the final result after integration and summation be stored in 'Result'. +# For (x=0) + +F<-function(y) +{ + f(x[1],y) +} + print((integrate(F,0,1/2))$value) + +# For (x=1) + +F<-function(y) +{ + f(x[2],y) +} +print((integrate(F,0,1))$value) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.3/Ex3_4_3.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.3/Ex3_4_3.R new file mode 100644 index 00000000..32258569 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.3/Ex3_4_3.R @@ -0,0 +1,38 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.4 (Bivariate Distributions), Page No. - 119 + +# Let the values of joint probability function of 'X' and 'Y' be represented by a matrix named 'f'. +# Let 'y1' to 'y4' represent the values in each column of the joint probability table 3.2 as mentioned in the textbook. + +y1<-c(0.1,0.3,0); +y2<-c(0,0,0.2); +y3<-c(0.1,0.1,0); +y4<-c(0,0.2,0); +x<-c(y1,y2,y3,y4); + +# For converting a vector into matrix, "matrix" function in used. Final values are saved in the matrix 'f'. +# For description of this function, type ?matrix in the console. + +f<-matrix(x,nrow=3,ncol=4) + +# A function 'F' is defined. It finds the required probability. In function definition, variables 'a','b','c' and 'd' represents the limits of rows and columns of matrix 'f'. +# A variable 'outcome' is declared in the function for computation operation. + +F<-function(a,b,c,d) +{ + outcome=0; + for(i in a:c) + { + for(j in b:d) + ( + outcome=outcome+f[i,j] + ) + } + return(outcome) +} + +# Let the required probability for the case of "x >= 2" and "y >= 2", be represented by 'Pr_1' and for the case of "X = 1" by 'Pr_2'. + +Pr_1=F(2,2,nrow(f),ncol(f)); +print(Pr_1) +Pr_2=F(1,1,1,ncol(f)); +print(Pr_2) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.7/Ex3_4_7.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.7/Ex3_4_7.R new file mode 100644 index 00000000..ee58eecd --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.7/Ex3_4_7.R @@ -0,0 +1,26 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.4 (Bivariate Distributions), Page No. - 122 + +# For the purpose of double integration it is required to install a package known as "pracma". +# It can be installed by executing the following command. + +install.packages("pracma") + +# After installing the package, it is required to be loaded by using the following command. +# For description of this package, type ?pracma in the console. + +library(pracma) + +# "integral2" function is used for the double integration of any function with 2 variables. +# For description of this function, type ?integral2 in the console. +# Required value of the constant in the function as shown in textbook is determined by a variable 'c'. +# For the purpose of calculating 'c', it is not included in the function definition below, in order to support calculation operations in R. + +f<-function(x,y) x^2*y +xmin<-c(-1); +xmax<-c(1); +ymin<-function(x) x^2; +ymax<-c(1); +c<-1/(integral2(f, xmin, xmax, ymin, ymax)$Q) +print(c) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.8/Ex3_4_8.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.8/Ex3_4_8.R new file mode 100644 index 00000000..a6ed984f --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.8/Ex3_4_8.R @@ -0,0 +1,25 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.4 (Bivariate Distributions), Page No. - 122 + +# For the purpose of double integration it is required to install a package known as "pracma". +# It can be installed by executing the following command. + +install.packages("pracma") + +# After installing the package, it is required to be loaded by using the following command. +# For description of this package, type ?pracma in the console. + +library(pracma) + +# "integral2" function is used for the double integration of any function with 2 variables. +# For description of this function, type ?integral2 in the console. +# Required probability is represented by 'Pr' + +f<-function(x,y) (21/4)*x^2*y +xmin<-c(0); +xmax<-c(1); +ymin<-function(x) x^2; +ymax<-function(x) x; +Pr<-(integral2(f, xmin, xmax, ymin, ymax)$Q) +print(Pr) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.9/Ex3_4_9.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.9/Ex3_4_9.R new file mode 100644 index 00000000..902df35c --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.4.9/Ex3_4_9.R @@ -0,0 +1,11 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.4 (Bivariate Distributions), Page No. - 123 + +# Radius of the circle from the equation "x^2 + y^2 =< 9", be represented by 'r'. +# "sqrt" function is used to find the square root of input value. "pi" is a constant. +# For more information, type ?sqrt and ?pi in the console. + +r<-c(sqrt(9)); +c<-1/(pi*r^2); +print(c) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.2/Ex3_5_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.2/Ex3_5_2.R new file mode 100644 index 00000000..9ca07ada --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.2/Ex3_5_2.R @@ -0,0 +1,55 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.5 (Marginal Distributions), Page No. - 131 + +# Let the values of joint probability function of 'X' and 'Y' be represented by a matrix named 'f'. +# Let 'y1' to 'y4' represent the values in each column of the table 3.4 as mentioned in the textbook. + +y1<-c(0.1,0.3,0); +y2<-c(0,0,0.2); +y3<-c(0.1,0.1,0); +y4<-c(0,0.2,0); +x<-c(y1,y2,y3,y4); + +# For converting vectors into a matrix, "matrix" function in used. Final values are saved in the matrix 'f'. +# For description of this function, type ?matrix in the console. + +f<-matrix(x,nrow=3,ncol=4) + +# Let the marginal probability function of 'X' be represented by 'f1'. +# A variable 'outcome' is declared in the function for computation operation. + +f1<-function(x) +{ + outcome=0; + for(i in 1:ncol(f)) + { + outcome=outcome+f[x,i]; + } + return(outcome) +} + +# Let the marginal probability function of 'Y' be represented by 'f2'. +# A variable 'outcome' is declared in the function for computation operation. + +f2<-function(y) +{ + outcome=0; + for(j in 1:nrow(f)) + { + outcome=outcome+f[j,y]; + } + return(outcome) +} + +# Marginal probabilities of 'X'. + +for(k in 1:nrow(f)) +{ + print(f1(k)) +} + +# Marginal probabilities of 'Y'. + +for(l in 1:ncol(f)) +{ + print(f2(l)) +} \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.4/Ex3_5_4.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.4/Ex3_5_4.R new file mode 100644 index 00000000..4b1dd7fe --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.4/Ex3_5_4.R @@ -0,0 +1,26 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.5 (Marginal Distributions), Page No. - 134 + +x<-c(1,2,3) +f<-function(x,y) +{ + ((x*(y^(x-1)))/3) +} + +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. +# Let the final result after integration and summation be stored in 'Result'. + +# Marginal p.f. for each value of 'x' is given by the following - + +Result<-c(0) +for(i in 1:length(x)) +{ + F<-function(y) + { + f(i,y) + } + print(paste0("Marginal p.f. for x = ",i," is ",integrate(F,0,1)$value)) +} + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.7/Ex3_5_7.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.7/Ex3_5_7.R new file mode 100644 index 00000000..c4be1355 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.7/Ex3_5_7.R @@ -0,0 +1,88 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.5 (Marginal Distributions), Page No. - 137 + +# Let the total possible numbers which can appear on the face of a die after rolling be represented by 'outcome_dice'. +# Let the probability of a number to occur on a die be represented by 'dice'. + +outcome_dice<-c(6); +dice=1/outcome_dice; + +# Total events of getting a head in case of tossing 2 coins are '4' i.e. getting no heads, getting a heads on first toss, getting a heads on second toss and getting heads on both tosses. +# Let the probability of getting no heads on tossing two coins be represented by 'no_heads'. +# Let the probability of getting atleast 1 heads on tossing two coins be represented by 'one_heads'. +# Let the probability of getting 2 heads on tossing two coins be represented by 'two_heads'. + +no_heads=1/4; +one_heads=2/4; +two_heads=1/4; + +# Joint probability of getting no heads for all cases of dice throw be represented by 'x1'. +# Joint probability of getting atleast 1 heads for all cases of dice throw be represented by 'x2'. +# Joint probability of getting two heads for all cases of dice throw be represented by 'x3'. +# In order to define a vector, "vector" function is used. +# For description of this function, type ?vector in the console. + +x1<-vector(mode='numeric',length=outcome_dice); +x2<-vector(mode='numeric',length=outcome_dice); +x3<-vector(mode='numeric',length=outcome_dice); +for(i in 1:outcome_dice) +{ + x1[i]=dice*no_heads; +} +for(i in 1:outcome_dice) +{ + x2[i]=dice*one_heads; +} +for(i in 1:outcome_dice) +{ + x3[i]=dice*two_heads; +} +x<-c(x1,x2,x3); + +# Joint probabilities of both events X and Y be represented by a matrix 'f'. +# For converting vectors into a matrix by adjusting each vector in each row, "matrix" function in used with "byrow" argument set to TRUE. +# Final values are saved in the matrix 'f'. +# For description of this function, type ?matrix in the console. + +f<-matrix(x,nrow=3,ncol=outcome_dice,byrow=TRUE); + +# Let the marginal probability function of 'X' be represented by 'f1'. +# A variable 'outcome' is declared in the function for computation operation. + +f1<-function(x) +{ + outcome=0; + for(i in 1:ncol(f)) + { + outcome=outcome+f[x,i]; + } + return(outcome) +} + +# Let the marginal probability function of 'Y' be represented by 'f2'. +# A variable 'outcome' is declared in the function for computation operation. + +f2<-function(y) +{ + outcome=0; + for(j in 1:nrow(f)) + { + outcome=outcome+f[j,y]; + } + return(outcome) +} + +# Marginal probabilities of 'X'. + +for(k in 1:nrow(f)) +{ + print(f1(k)) +} + +# Marginal probabilities of 'Y'. + +for(l in 1:ncol(f)) +{ + print(f2(l)) +} + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.8/Ex3_5_8.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.8/Ex3_5_8.R new file mode 100644 index 00000000..2e06a20b --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.8/Ex3_5_8.R @@ -0,0 +1,57 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.5 (Marginal Distributions), Page No. - 137 + +# Joint probability of getting relapse for different treatments is represented by 'x1'. +# Joint probability of not getting relapse for different treatments is represented by 'x2'. +# In order to define a vector, "vector" function is used. +# For description of this function, type ?vector in the console. + +x1<-c(0.120,0.087,0.146,0.160); +x2<-c(0.147,0.166,0.107,0.067); +x<-c(x1,x2); + +# Joint probabilities of both events X and Y be represented by a matrix 'f'. +# For converting vectors into a matrix by adjusting each vector in each row, "matrix" function in used with "byrow" argument set to TRUE. +# Final values are saved in the matrix 'f'. +# For description of this function, type ?matrix in the console. + +f<-matrix(x,nrow=2,ncol=4,byrow=TRUE); + +# Let the marginal probability function of 'X' be represented by 'f1'. +# A variable 'outcome' is declared in the function for computation operation. + +f1<-function(x) +{ + outcome=0; + for(i in 1:ncol(f)) + { + outcome=outcome+f[x,i]; + } + return(outcome) +} + +# Let the marginal probability function of 'Y' be represented by 'f2'. +# A variable 'outcome' is declared in the function for computation operation. + +f2<-function(y) +{ + outcome=0; + for(j in 1:nrow(f)) + { + outcome=outcome+f[j,y]; + } + return(outcome) +} + +# Marginal probabilities of 'X'. + +for(k in 1:nrow(f)) +{ + print(f1(k)) +} + +# Marginal probabilities of 'Y'. + +for(l in 1:ncol(f)) +{ + print(f2(l)) +} \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.9/Ex3_5_9.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.9/Ex3_5_9.R new file mode 100644 index 00000000..6012b1ec --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.5.9/Ex3_5_9.R @@ -0,0 +1,25 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.5 (Marginal Distributions), Page No. - 138 + +# For the purpose of double integration it is required to install a package known as "pracma". +# It can be installed by executing the following command. + +install.packages("pracma") + +# After installing the package, it is required to be loaded by using the following command. +# For description of this package, type ?pracma in the console. + +library(pracma) + +# "integral2" function is used for the double integration of any function with 2 variables. +# For description of this function, type ?integral2 in the console. +# Let the required probability be represented by 'Pr'. + +f<-function(x,y) 4*x*y +xmin<-c(0); +xmax<-c(1); +ymin<-c(0); +ymax<-function(x) 1-x; +Pr<-integral2(f, xmin, xmax, ymin, ymax)$Q +print(Pr) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.1/Ex3_6_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.1/Ex3_6_1.R new file mode 100644 index 00000000..46ebec73 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.1/Ex3_6_1.R @@ -0,0 +1,57 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.6 (Conditional Distributions), Page No. - 142 + +# Joint probability of a car not getting stolen is represented by 'x1'. +# Joint probability of a car getting stolen is represented by 'x2'. +# In order to define a vector, "vector" function is used. +# For description of this function, type ?vector in the console. + +x1<-c(0.129,0.298,0.161,0.280,0.108); +x2<-c(0.010,0.010,0.001,0.002,0.001); +x<-c(x1,x2); + +# Joint probabilities of both events X and Y be represented by a matrix 'f'. +# For converting vectors into a matrix by adjusting each vector in each row, "matrix" function in used with "byrow" argument set to TRUE. +# Final values are saved in the matrix 'f'. +# For description of this function, type ?matrix in the console. + +f<-matrix(x,nrow=2,ncol=5,byrow=TRUE); + +# Let the marginal probability function of 'X' be represented by 'f1'. +# A variable 'outcome' is declared in the function for computation operation. + +f1<-function(x) +{ + outcome=0; + for(i in 1:ncol(f)) + { + outcome=outcome+f[x,i]; + } + return(outcome) +} + +# Let the marginal probability function of 'Y' be represented by 'f2'. +# A variable 'outcome' is declared in the function for computation operation. + +f2<-function(y) +{ + outcome=0; + for(j in 1:nrow(f)) + { + outcome=outcome+f[j,y]; + } + return(outcome) +} + +# Marginal probabilities of 'X'. + +for(k in 1:nrow(f)) +{ + print(f1(k)) +} + +# Marginal probabilities of 'Y'. + +for(l in 1:ncol(f)) +{ + print(f2(l)) +} \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.2/Ex3_6_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.2/Ex3_6_2.R new file mode 100644 index 00000000..58f7a0bc --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.2/Ex3_6_2.R @@ -0,0 +1,44 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.6 (Conditional Distributions), Page No. - 143 + +# Let the values of joint probability function of 'X' and 'Y' be represented by a matrix named 'f'. +# Let 'y1' to 'y4' represent the values in each column of the table 3.4 as mentioned in the textbook. + +y1<-c(0.1,0.3,0); +y2<-c(0,0,0.2); +y3<-c(0.1,0.1,0); +y4<-c(0,0.2,0); +x<-c(y1,y2,y3,y4); + +# For converting vectors into a matrix, "matrix" function in used. Final values are saved in the matrix 'f'. +# For description of this function, type ?matrix in the console. + +f<-matrix(x,nrow=3,ncol=4) + +# Let the marginal probability function of 'X' be represented by 'f1'. +# A variable 'outcome' is declared in the function for computation operation. + +f1<-function(x) +{ + outcome=0; + for(i in 1:ncol(f)) + { + outcome=outcome+f[x,i]; + } + return(outcome) +} + +# Let the function for finding required conditional probabilities be represented by 'g2'. + +g2<-function(y) +{ + return(f[2,y]/f1(2)) +} + +# Required conditional probabilities. + +for(i in 1:ncol(f)) +{ + print(g2(i)) +} + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.5/Ex3_6_5.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.5/Ex3_6_5.R new file mode 100644 index 00000000..faed1c28 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.5/Ex3_6_5.R @@ -0,0 +1,21 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.6 (Conditional Distributions), Page No. - 144 + +Y<-c(4) +X<-c(9) + +# Marginal p.d.f. of 'Y' be represented by 'f'. + +f<-function(x) +{ + exp(Y-x) +} + +# Let the conditional probability that "X>=9" for "Y=4" be represented by 'Pr'. +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. + +Pr<-integrate(f,9,Inf)$value +print(Pr) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.9/Ex3_6_9.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.9/Ex3_6_9.R new file mode 100644 index 00000000..d4a1dd43 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.6.9/Ex3_6_9.R @@ -0,0 +1,17 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.6 (Conditional Distributions), Page No. - 148 + +# Result of the integration of denominator for "n=2" and "x=1". +# Let 'g' represents the denominator of the conditional probability distribution function of 'P' given 'X' as mentioned in the textbook. + +g<-function(q,n=2,x=1) +{ + q^x*(1-q)^(n-x) +} + +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. + +print((integrate(g,0,1))$value) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.15/Ex3_7_15.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.15/Ex3_7_15.R new file mode 100644 index 00000000..2967b530 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.15/Ex3_7_15.R @@ -0,0 +1,31 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.7 (Multivariate Distributions), Page No. - 161 + +# Let the conditional probability distribution function be represented by 'g'. + +g<-function(x1,x2) +{ + (4/((2+x1+x2)^3)) +} + +# For the purpose of double integration it is required to install a package known as "pracma". +# It can be installed by executing the following command. + +install.packages("pracma") + +# After installing the package, it is required to be loaded by using the following command. +# For description of this package, type ?pracma in the console. + +library(pracma) + +# "integral2" function is used for the double integration of any function with 2 variables. +# For description of this function, type ?integral2 in the console. +# Let the required probability be represented by 'Pr'. + +xmin<-c(0); +xmax<-c(4); +ymin<-c(0); +ymax<-function(x2) 4-x2; +Pr<-integral2(g, xmin, xmax, ymin, ymax)$Q +print(Pr) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.16/Ex3_7_16.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.16/Ex3_7_16.R new file mode 100644 index 00000000..840da198 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.16/Ex3_7_16.R @@ -0,0 +1,16 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.7 (Multivariate Distributions), Page No. - 162 + +# Let the conditional probability distribution function of "Z<=1" given "X1=1" and "X2=4" be represented by 'g'. + +g<-function(z) +{ + 171.5*(z^2)*exp(-7*z) +} + +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. + +print((integrate(g,0,1))$value) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.7/Ex3_7_7.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.7/Ex3_7_7.R new file mode 100644 index 00000000..9450377a --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.7/Ex3_7_7.R @@ -0,0 +1,12 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.7 (Multivariate Distributions), Page No. - 155 + +# Let 'f' be the function representing the final expression in the example. + +f<-function(y) {2*exp(-2*y)} + +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. +# Finding probability for "y>0" - + +print((integrate(f,0,Inf))$value) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.8/Ex3_7_8.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.8/Ex3_7_8.R new file mode 100644 index 00000000..7ef71bdb --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.7.8/Ex3_7_8.R @@ -0,0 +1,18 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.7 (Multivariate Distributions), Page No. - 156 + +# Let 'f' be the function representing the final expression in the example. + +f<-function(p) {p*(1-p)} + +# "integrate" function is used for the purpose of integrating one dimensional functions. It returns a 'list" with desired values. For description, type ?integrate in the console. +# "$" sign is used to access particular values in a data structure. +# Here, 'value' variable in the list returned by "integrate" function consists of the integral result of an integration. +# Finding probability for "03" - + +print((integrate(f,3,Inf))$value) \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.1/Ex3_8_1.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.1/Ex3_8_1.R new file mode 100644 index 00000000..338ef2a2 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.1/Ex3_8_1.R @@ -0,0 +1,35 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.8 (Functions of a Random Variable), Page No. - 168 + +# Let all possible values of X and Y be stored in variables 'X' and 'Y'. +# "vector" function is used in order to create a vector. +# For more description, type ?vector in the console. + +X<-c(1,2,3,4,5,6,7,8,9); +y<-vector(mode='numeric',length=length(X)) + +# In order to find the absolute value, "abs" function is used. +# For more description, type ?abs in the console. + +for(i in 1:length(y)) +{ + y[i]=abs(X[i]-5) +} + +# Let the required probability of occuring of certain value of Y be given by the function named 'Pr'. +# For the purpose of performing computation operations, 'count' variable is defined in the function 'g'. + +Pr<-function(Y) +{ + count=0; + for(j in 1:length(y)) + { + if(Y==y[j]) + { + count=count+1; + } + } + return(count/length(y)) +} +print(Pr(1)) + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.2/Ex3_8_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.2/Ex3_8_2.R new file mode 100644 index 00000000..e18145d4 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.2/Ex3_8_2.R @@ -0,0 +1,51 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.8 (Functions of a Random Variable), Page No. - 168 + +# Let all possible values of X and Y be stored in variables 'X' and 'Y'. +# "vector" function is used in order to create a vector. +# For more description, type ?vector in the console. + +X<-c(1,2,3,4,5,6,7,8,9); +y<-vector(mode='numeric',length=length(X)) + +# In order to find the absolute value, "abs" function is used. +# For more description, type ?abs in the console. + +for(i in 1:length(y)) +{ + y[i]=abs(X[i]-5) +} + +# Let the required probability of occuring of certain value of Y be given by the function named 'g'. +# All probabilities for "Y=0" to "Y=4" are saved in a variable named 'Pr'. +# For the purpose of performing computation operations, 'count' variable is defined in the function 'g'. + +Pr<-vector(mode='numeric',length=5) +g<-function(Y) + { + count=0; + for(k in 1:length(y)) + { + if(Y==y[k]) + { + count=count+1; + } + } + return(count/length(y)) + } +for(j in 1:5) +{ + Pr[j]=g(j-1) +} + +# Printing 'g(0)'. + +print(Pr[1]) + +# Printing 'g(1)' to 'g(4)'. + +for(k in 2:5) +{ + print(Pr[k]) +} + +# The answer may slightly vary due to being represented as a real number rather than a fraction. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.6/Ex3_8_6.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.6/Ex3_8_6.R new file mode 100644 index 00000000..b3636306 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.8.6/Ex3_8_6.R @@ -0,0 +1,16 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.8 (Functions of a Random Variable), Page No. - 171 + +y<-function(x) +{ + 2*(1-((1-x)^0.5)) +} + +# Let the three generated values be stored in the variable 'x'. + +x<-c(0.4125,0.0894,0.8302) +for(i in 1:length(x)) +{ + print(y(x[i])) +} + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.9.2/Ex3_9_2.R b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.9.2/Ex3_9_2.R new file mode 100644 index 00000000..3453f714 --- /dev/null +++ b/Probability_And_Statistics,_4th_Edition_by_Morris_H._Degroot,_Carnegie-Mellon_University_&_Mark_J._Schervish,_Carnegie-Mellon_University/CH3/EX3.9.2/Ex3_9_2.R @@ -0,0 +1,46 @@ +# Chapter 3 - Random Variables and Distributions, Section - 3.9 (Functions of Two or More Random Variables), Page No. - 176 + +# Let 'Y' be the vector storing that point where joint probability is to be determined. + +Y1<-c(3); +Y2<-c(5); +Y3<-c(8); +Y<-c(Y1,Y2,Y3); + +# A function 'C' is defined to determine the number of possible combinations as per given input where variables 'final','N' and 'D' are declared for computation operations. + +C<-function(n,k) +{ + N<-c(1); + D<-c(1); + for(i in 1:k) + { + N=N*(n-i+1); + D=D*(i); + } + final<-N/D; + return(final) +} + +# A function named 'point' is used to determine the number of points in a set. +# Variable named 'product' is defined for internal computations in the function. + +point<-function(a) +{ + product<-c(1); + for(j in 1:length(a)) + { + product=product*C(10,a[j]) + } + return(product) +} + +# Let the joint probability function be represented by 'g'. + +g<-function(Y) +{ + return(point(Y)/2^(10*length(Y))) +} +print(g(Y)) + +# The answer may slightly vary due to rounding off values. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.1/Ex1_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.1/Ex1_1.R new file mode 100644 index 00000000..65844fdb --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.1/Ex1_1.R @@ -0,0 +1,9 @@ +#Ex1.1, Page 4 + +library(lattice) + +data<-c(6.1,12.6,34.7,1.6,18.8,2.2,3.0,2.2,5.6,3.8,2.2,3.1,1.3,1.1,14.1,4.0,21.0,6.1,1.3,20.4,7.5,3.9,10.1,8.1,19.5,5.2,12.0,15.8,10.4,5.2,6.4,10.8,83.1,3.6,6.2,6.3,16.3,12.7,1.3,0.8,8.8,5.1,3.7,26.3,6.0,48.0,8.2,11.7,7.2,3.9,15.3,16.6,8.8,12.0,4.7,14.7,6.4,17.0,2.5,16.2) + +stem(data,scale=2) + +hist(data,main="Histogram for charity fundraising percentage data",xlab="FundRaising",col="grey",xlim=c(0,100),ylim=c(0,40)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.10/Ex1_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.10/Ex1_10.R new file mode 100644 index 00000000..3154ea30 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.10/Ex1_10.R @@ -0,0 +1,21 @@ +#Ex1.10, Page 18 +#Answers may vary since different class intervals have been taken + +#Please install and load the following packages: 1)HistogramTools 2)ash +library(HistogramTools) +library(ash) + +data<-c(2.97,4.00,5.20,5.56,5.94,5.98,6.35,6.62,6.72,6.78,6.80,6.85,6.94,7.15,7.16,7.23,7.29,7.62,7.62,7.69,7.73,7.87,7.93,8.00,8.26,8.29,8.37,8.47,8.54,8.58,8.61,8.67,8.69,8.81,9.07,9.27,9.37,9.43,9.52,9.58,9.60,9.76,9.82,9.83,9.83,9.84,9.96,10.04,10.21,10.28,10.28,10.30,10.35,10.36,10.40,10.49,10.50,10.64,10.95,11.09,11.12,11.21,11.29,11.43,11.62,11.70,11.70,12.16,12.19,12.28,12.31,12.62,12.69,12.71,12.91,12.92,13.11,13.38,13.42,13.43,13.47,13.60,13.96,14.24,14.35,15.12,15.24,16.06,16.90,18.26) + +#Class intervals can also be created using classIntervals() from ClassInt library: +#classIntervals(data,style="pretty",intervalClosure="left") which creates different intervals as compared to those of textbook + +#To create class intervals +ci<-seq(1,19,2) + +freq<-table(cut(data,ci,right=FALSE)) +rel_freq<-freq/length(data) +print(cbind(freq,rel_freq)) + +#To display histogram +PlotRelativeFrequency(hist(data,breaks = ci,right=FALSE,plot=FALSE),xlab="BTUIN",main="Histogram of energy consumption data",ylim=c(0,0.30)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.11/Ex1_11.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.11/Ex1_11.R new file mode 100644 index 00000000..d25b9bf7 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.11/Ex1_11.R @@ -0,0 +1,16 @@ +#Ex1.11, Page 20 + +data<-c(11.5,12.1,9.9,9.3,7.8,6.2,6.6,7.0,13.4,17.1,9.3,5.6,5.7,5.4,5.2,5.1,4.9,10.7,15.2,8.5,4.2,4.0,3.9,3.8,3.6,3.4,20.6,25.5,13.8,12.6,13.1,8.9,8.2,10.7,14.2,7.6,5.2,5.5,5.1,5.0,5.2,4.8,4.1,3.8,3.7,3.6,3.6,3.6) +#Unequal class widths +ci<-c(2,4,6,8,12,20,30) + +#To find frequency, relative frequency and density of data manually +freq<-table(cut(data,ci,right=FALSE)) +rel_freq<-freq/length(data) +density<-rel_freq/diff(ci) + +print(cbind(freq,rel_freq,density)) + +#To create histogram of the bond strength data +hist(data,breaks=ci,freq=FALSE,right=FALSE,main="Histogram for bond strength data",xlab="Bond Strength") + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.13/Ex1_13.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.13/Ex1_13.R new file mode 100644 index 00000000..862f7a39 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.13/Ex1_13.R @@ -0,0 +1,13 @@ +#Ex1.13, Page 23 +#Answers may vary slightly due to rounding off of values + +Rating<-c("A","B","C","D","F","Don't know") +Frequency<-c(478,893,680,178,100,172) +Relative_frequency<-Frequency/sum(Frequency) +df1<-data.frame(Rating,Frequency,Relative_frequency) +print(df1) + +print(paste("Total frequency:",sum(Frequency))) +print(paste("Total relative frequency:",sum(Relative_frequency))) + +barplot(df1$Relative_frequency,space=1,names.arg=df1$Rating,ylim=c(0,0.4),xlab="Rating",ylab="Relative Frequency",main="Chart of relative frequency vs. rating") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.14/Ex1_14.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.14/Ex1_14.R new file mode 100644 index 00000000..486d1eec --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.14/Ex1_14.R @@ -0,0 +1,14 @@ +#Ex1.14, Page 29 +#Steam and leaf plot differs since number of stem parts=1 + +library(aplpack) + +x<-c(16.1,9.6,24.9,20.4,12.7,21.2,30.2,25.8,18.5,10.3,25.3,14.0,27.1,45.0,23.3,24.2,14.6,8.9,32.4,11.8,28.5) + +sl<-stem.leaf(x,unit=0.1,m=1,style="bare") + +s<-sum(x) +mean<-s/length(x) +print(paste("Mean value:",mean)) +print(paste("The value",sl$upper,"is an outlier")) +print(paste("Mean value when",sl$upper,"is excluded=",(s-45)/(length(x)-1))) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.15/Ex1_15.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.15/Ex1_15.R new file mode 100644 index 00000000..adaa55da --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.15/Ex1_15.R @@ -0,0 +1,18 @@ +#Ex1.15, Page 30 +#Answers may vary slightly due to rounding off of values + +data<-c(62.3,62.8,63.6,65.2,65.7,66.4,67.4,68.4,68.8,70.8,75.7,79.0) + +dotplot(data,xlab="Duration") + +n<-length(data) +n1<-data[n/2] +n2<-data[(n/2)+1] +med<-(n1+n2)/2 +print(paste("Median:",med)) + +max<-max(data) +#If maximum value is omitted +data1<-data[1:length(data)-1] +mean1<-mean(data1) +print(paste("Mean when maximum value,",max,"is omitted:",mean1)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.17/Ex1_17.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.17/Ex1_17.R new file mode 100644 index 00000000..4c1c6a12 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.17/Ex1_17.R @@ -0,0 +1,9 @@ +#Ex1.17, Page 36 + +Car<-1:11 +xi<-c(27.3,27.9,32.9,35.2,44.9,39.9,30.0,29.7,28.5,32.0,37.6) + +xibar<-mean(xi) +s<-sd(xi) + +print(paste("The size of the representative deviation from the mean,",round(xibar,digits=2),"is roughly",round(s,digits=2),"mpg")) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.18/Ex1_18.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.18/Ex1_18.R new file mode 100644 index 00000000..4b265d12 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.18/Ex1_18.R @@ -0,0 +1,7 @@ +#Ex1.18, Page 38 +#Answers may vary slightly due to rounding off of values + +data<-c(154,142,137,133,122,126,135,135,108,120,127,134,122) + +print(paste("s:",sd(data))) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.19/Ex1_19.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.19/Ex1_19.R new file mode 100644 index 00000000..0d1136a2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.19/Ex1_19.R @@ -0,0 +1,8 @@ +#Ex1.19, Page 40 + +obs<-c(40,52,55,60,70,75,85,85,90,90,92,94,94,95,98,100,115,125,125) + +#To find five-number summary +print(summary(fivenum(obs))) + +boxplot(obs,horizontal=TRUE,xlab="Depth",main="Boxplot of the corrosion data") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.20/Ex1_20.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.20/Ex1_20.R new file mode 100644 index 00000000..486332b7 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.20/Ex1_20.R @@ -0,0 +1,10 @@ +#Ex1.20, Page 41 + +data<-c(9.69,13.16,17.09,18.12,23.70,24.07,24.29,26.43,30.75,31.54,35.07,36.99,40.32,42.51,45.64,48.22,49.98,50.06,55.02,57.00,58.41,61.31,64.25,65.24,66.14,67.68,81.40,90.80,92.17,92.42,100.82,101.94,103.61,106.28,106.80,108.69,114.61,120.86,124.54,143.27,143.75,149.64,167.79,182.50,192.55,193.53,271.57,292.61,312.45,352.09,371.47,444.68,460.86,563.92,690.11,826.54,1529.35) + +#To find relevant summary quantities +print(summary(fivenum(data))) + +c<-seq(0,1600,by=200) + +boxplot(data,horizontal=TRUE,xlab="Daily nitrogen load",main="Boxplot of daily nitrogen load data showing mild and extreme outliers") diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.5/Ex1_5.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.5/Ex1_5.R new file mode 100644 index 00000000..9ac1793b --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.5/Ex1_5.R @@ -0,0 +1,15 @@ +#Ex1.5, Page 11 + +Adhesive_Type<-c(1,1,2,2) +Conductor_material<-c(1,2,1,2) +Observed_bond_strength<-c(82,75,84,78,77,87,80,90) +mat1<-matrix(Observed_bond_strength,nrow=4,ncol=2) +Average<-c(sum(mat1[1,])/2,sum(mat1[2,])/2,sum(mat1[3,])/2,sum(mat1[4,])/2) +mat1<-cbind(Adhesive_Type,Conductor_material,mat1,Average) +colnames(mat1)[3]<-"Observed bond strength" +print(mat1) + +n<-length(Adhesive_Type)/2 +plot(Conductor_material,Average,main="Average bond strengths",xlab="Conducting material",ylab="Average strength") +segments(Conductor_material[1],Average[1],Conductor_material[2],Average[2]) +segments(Conductor_material[3],Average[3],Conductor_material[4],Average[4]) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.8/Ex1_8.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.8/Ex1_8.R new file mode 100644 index 00000000..d245bd61 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.8/Ex1_8.R @@ -0,0 +1,8 @@ +#Ex1.8, Page 15 + +library(graphics) + +data<-c(10.8,6.9,8.0,8.8,7.3,3.6,4.1,6.0,4.4,8.3,8.1,8.0,5.9,5.9,7.6,8.9,8.5,8.1,4.2,5.7,4.0,6.7,5.8,9.9,5.6,5.8,9.3,6.2,2.5,4.5,12.8,3.5,10.0,9.1,5.0,8.1,5.3,3.9,4.0,8.0,7.4,7.5,8.4,8.3,2.6,5.1,6.0,7.0,6.5,10.3) + +#To create a stacked dotplot +stripchart(data,method="stack",offset=0.5,pch=20,at=0,main="Dotplot of given data") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.9/Ex1_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.9/Ex1_9.R new file mode 100644 index 00000000..f49f105d --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH1/EX1.9/Ex1_9.R @@ -0,0 +1,31 @@ +#Ex1.9, Page 17 + +Hits_per_game<-0:27 +No_of_games<-c(20,72,209,527,1048,1457,1988,2256,2403,2256,1967,1509,1230,834,569,393,253,171,97,53,31,19,13,5,1,0,1,1) +sum1<-sum(No_of_games) +Relative_frequency<-round(No_of_games/sum1,digits=4) +df1<-data.frame(Hits_per_game,No_of_games,Relative_frequency) +print(df1) + +#Proportion of games with atmost 2 hits +f1<-0 +for(i in Hits_per_game){ + if(i<=2){ + f1<-f1+df1[i+1,3] + } +} +print(paste("Proportion of games with atmost two hits:",f1)) + +#Proportion of games with between 5 and 10 hits +f2<-0 +for(j in Hits_per_game){ + if(j>=5 && j<=10){ + f2<-f2+df1[j+1,3] + } +} +print(paste("Proportion of games with between 5 and 10 hits:",f2)) + +par(mfrow=c(1,2)) +plot(Hits_per_game,Relative_frequency,type="h",xlim=c(0,20),main="Histogram of hits/game") +barplot(Relative_frequency,width=1,space=0,xlim=c(0,25),main="Histogram of hits/game",xlab="Hits/game",ylab="Relative frequency") + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.1/Ex10_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.1/Ex10_1.R new file mode 100644 index 00000000..f8b7cacd --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.1/Ex10_1.R @@ -0,0 +1,55 @@ +#Ex10.1, Page 392 +#Answers may vary slightly due to rounding off of values + +Type_of_box<-c(1,2,3,4) +CS1<-c(655.5,789.2,737.1,535.1) +CS2<-c(788.3,772.5,639.0,628.7) +CS3<-c(734.3,786.9,696.3,542.4) +CS4<-c(721.4,686.1,671.7,559.0) +CS5<-c(679.1,732.1,717.2,586.9) +CS6<-c(699.4,774.8,727.1,520.0) +Mean<-c(NULL) +SD<-c(NULL) + +#To find mean of observations +for(i in 1:4){ + sum<-CS1[i]+CS2[i]+CS3[i]+CS4[i]+CS5[i]+CS6[i] + mean<-sum/6 + Mean[i]<-mean +} +#To find standard deviation of values +for(i in 1:4){ + s<-(CS1[i]-Mean[i])^2+(CS2[i]-Mean[i])^2+(CS3[i]-Mean[i])^2+(CS4[i]-Mean[i])^2+(CS5[i]-Mean[i])^2+(CS6[i]-Mean[i])^2 + sd<-sqrt(s/5) + SD[i]<-sd +} + +data<-data.frame(Type_of_box,CS1,CS2,CS3,CS4,CS5,CS6,Mean,SD) +print(data) + +#To find grand mean of mean values +tot_mean<-0 +for(i in 1:4){ + tot_mean<-tot_mean+Mean[i] +} +tot_mean<-tot_mean/4 +print(paste("Grand mean:",tot_mean)) + +par(mfrow=c(1,2)) +#To create boxplots of the data +#First element of each CS column gives us the compression strength of one box +a<-c(CS1[1],CS2[1],CS3[1],CS4[1],CS5[1],CS6[1]) +b<-c(CS1[2],CS2[2],CS3[2],CS4[2],CS5[2],CS6[2]) +c<-c(CS1[3],CS2[3],CS3[3],CS4[3],CS5[3],CS6[3]) +d<-c(CS1[4],CS2[4],CS3[4],CS4[4],CS5[4],CS6[4]) +boxplot(a,b,c,d) +title(main="Boxplots for original data") + +#Altering data in sample 2 by adding 120 to every value in Sample 4 +e<-c(NULL) +for(i in 1:6){ + e[i]<-d[i]+120 +} +boxplot(a,b,c,e) +title(main="Boxplots for altered data") + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.10/Ex10_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.10/Ex10_10.R new file mode 100644 index 00000000..c69c756a --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.10/Ex10_10.R @@ -0,0 +1,30 @@ +#Ex10.10, Page 413 + +alpha<-0.95 +n<-22 +J1<-8 +J2<-8 +J3<-6 +I<-3 +J<-n-I +MSE<-0.316 +Q<-qtukey(alpha,I,J) +xibar<-c(44.71,44.06,45.58) + +#To find w12 +w12<-Q*sqrt((MSE/2)*(1/J1+1/J2)) +print(paste("w12:",w12)) +w23<-Q*sqrt((MSE/2)*(1/J2+1/J3)) +print(paste("w23:",w23)) +w31<-Q*sqrt((MSE/2)*(1/J3+1/J1)) +print(paste("w31:",w31)) + +if(xibar[1]-xibar[2]< w12){ + print(paste("mu1 and mu2 are not significantly different")) +} +if(xibar[2]-xibar[3]< w23){ + print(paste("mu2 and mu3 are not significantly different")) +} +if(xibar[3]-xibar[1]< w31){ + print(paste("mu3 and mu1 are not significantly different")) +} \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.11/Ex10_11.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.11/Ex10_11.R new file mode 100644 index 00000000..4155e8c0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.11/Ex10_11.R @@ -0,0 +1,20 @@ +#Ex.10.11, Page 415 + +#H0: sigmaA^2=0 + +C1<-c(55,53,54) +C2<-c(26,37,32) +C3<-c(78,91,85) +C4<-c(92,100,96) +C5<-c(49,51,50) +C6<-c(80,85,83) +data1<-data.frame(C1,C2,C3,C4,C5,C6) +print(paste("x..=",sum(data1))) + + +#To create ANOVA table +col<-stack(data1) +names(col)<-c("Type","Treatments") +a<-aov(Type~Treatments,data=col) +print(paste("ANOVA table:")) +print(summary(a)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.2/Ex10_2.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.2/Ex10_2.R new file mode 100644 index 00000000..142b9d07 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.2/Ex10_2.R @@ -0,0 +1,41 @@ +#Ex10.2, Page 397 +#Answers may vary slightly due to rounding off of values + +#From Ex10.1 +Mean<-c(713.00,756.93,698.07,562.02) +SD<-c(46.55,40.34,37.20,39.87) +tot_mean<-682.50 + +I<-4 +J<-6 + +#Numerator +v1<-I-1 + +#Denominator +v2<-I*(J-1) + +alpha<-0.05 + +#H0:mu1=mu2=mu3=mu4 +#Ha:at least two mean values will be different + +#To find F critical value +F<-qf(p=1-alpha,df1=v1,df2=v2) +print(paste("Critical value F:",F)) + +#To find mean square for treatment +MSTr<-(J/(I-1))*sum((Mean-tot_mean)^2) +print(paste("MSTr:",MSTr)) + +#To find mean square for error +MSE<-(1/I)*sum(SD^2) +print(paste("MSE:",MSE)) + +#To find f value +f<-MSTr/MSE +print(paste("f:",f)) + +if(f>=F) print(paste("H0 is rejected at significance level",alpha,"since f>=F")) else print(paste("H0 not rejected")) + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.3/Ex10_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.3/Ex10_3.R new file mode 100644 index 00000000..3968859b --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.3/Ex10_3.R @@ -0,0 +1,45 @@ +#Ex10.3, Page 397 +#Answers may vary slightly due to rounding off of values + +Treatment<-c(1,2,3,4,5) +Sample_mean<-c(10.5,14.8,15.7,16.0,21.6) +Sample_sd<-c(4.5,6.8,6.5,6.7,6.0) + +#To find total mean of mean values +tot_mean<-mean(Sample_mean) +print(paste("Grand mean:",tot_mean)) + +#H0: mu1=mu2=mu3=mu4=mu5 +#Ha: at least two of the mean values are different + +I<-5 +J<-10 +alpha<-0.01 + +#Numerator +v1<-I-1 + +#Denominator +v2<-I*(J-1) + +#To find F value +F<-qf(1-alpha,v1,v2) +print(paste("Critical value F:",F)) + +#To find mean square for treatment +s<-Sample_mean-tot_mean +MSTr<-(J/(I-1))*sum(s^2) +print(paste("MSTr:",MSTr)) + +#To find mean square for error +MSE<-mean(Sample_sd^2) +print(paste("MSE:",MSE)) + +#To find f value +f<-MSTr/MSE +print(paste("f:",f)) + +if(f>=F) print(paste("H0 is rejected at significance level",alpha,"since f>=F")) else print(paste("H0 not rejected")) + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.4/Ex10_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.4/Ex10_4.R new file mode 100644 index 00000000..8a079cf2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.4/Ex10_4.R @@ -0,0 +1,33 @@ +#Ex10.4, Page 400 +#Answers may vary slightly due to rounding off of values + +Mixture1<-c(0.56,1.12,0.90,1.07,0.94) +Mixture2<-c(0.72,0.69,0.87,0.78,0.91) +Mixture3<-c(0.62,1.08,1.07,0.99,0.93) + +data1<-data.frame(Mixture1,Mixture2,Mixture3) + +I<-3 +J<-5 + +#Numerator +v1<-I-1 + +#Denominator +v2<-I*(J-1) + +alpha<-0.01 +#To find F value +F<-qf(1-alpha,v1,v2) +print(paste("Critical value, F:",F)) + + +#To create ANOVA table +mix<-stack(data1) +names(mix)<-c("Degree","Treatment") + +a<-aov(Degree~Treatment,data=mix) +print(paste("ANOVA table:")) +a1<-summary(a) +print(a1) +print(paste("f value:",a1[[1]]$F[1])) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.6/Ex10_6.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.6/Ex10_6.R new file mode 100644 index 00000000..59e74434 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.6/Ex10_6.R @@ -0,0 +1,15 @@ +#Ex10.6, Page 404 + +Treatment1<-c(88.6,73.2,91.4,68.0,75.2) +Treatment2<-c(63.0,53.9,69.2,50.1,71.5) +Treatment3<-c(44.9,59.5,40.2,56.3,38.7) +Treatment4<-c(31.0,39.6,45.3,25.2,22.7) +data1<-data.frame(Treatment1,Treatment2,Treatment3,Treatment4) + +Treatment<-stack(data1) +names(Treatment)<-c("Time","Model") + +#To display ANOVA table +a<-aov(Time~Model,data=Treatment) +print(summary(a)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.9/Ex10_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.9/Ex10_9.R new file mode 100644 index 00000000..7d25f6f8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH10/EX10.9/Ex10_9.R @@ -0,0 +1,12 @@ +#Ex10.9, Page 412 + +Permanent_molding<-c(45.5,45.3,45.4,44.4,44.6,43.9,44.6,44.0) +Die_casting<-c(44.2,43.9,44.7,44.2,44.0,43.8,44.6,43.1) +Plaster_molding<-c(46.0,45.9,44.8,46.2,45.1,45.5) + +#To display ANOVA table +data1<-data.frame(Mold=c(Permanent_molding,Die_casting,Plaster_molding),Treatment=factor(rep(c("Mold1","Mold2","Mold3"),times=c(length(Permanent_molding),length(Die_casting),length(Plaster_molding))))) + +cat("ANOVA table\n") +a<-aov(Mold~Treatment,data=data1) +print(summary(a)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.1/Ex11_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.1/Ex11_1.R new file mode 100644 index 00000000..278521af --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.1/Ex11_1.R @@ -0,0 +1,11 @@ +#Ex11.1, Page 420 + +dat<-c(0.97,0.48,0.48,0.46,0.77,0.14,0.22,0.25,0.67,0.39,0.57,0.19) +mat1<-matrix(dat,nrow=3,ncol=4,byrow=TRUE) +rownames(mat1)<-c("Brand1","Brand2","Brand3") +colnames(mat1)<-c("WT1","WT2","WT3","WT4") +print(mat1) + +print(paste("Number of levels of factor A(Brand of pen), I:",nrow(mat1))) +print(paste("Number of levels of factor B(Washing treatment), J:",ncol(mat1))) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.10/Ex11_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.10/Ex11_10.R new file mode 100644 index 00000000..9257298c --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.10/Ex11_10.R @@ -0,0 +1,22 @@ +#Ex11.10, Page 444 +#Answers may vary slightly due to rounding off of values + +#To create data frame +A<-rep(c(rep(c("A1","A2","A3","A4"),each=3)),8) +B<-rep(c("B1","B2"),each=48) +C<-rep(c("C1","C2","C3","C4","C1","C2","C3","C4"),each=12) +data<-c(3.6,3.8,3.9,3.8,3.6,4.0,3.7,3.9,4.2,3.6,3.5,3.8,3.4,3.7,3.9,3.8,3.9,3.9,3.8,4.0,3.9,3.6,3.7,3.9,2.9,2.8,2.7,2.9,2.9,2.8,2.9,2.7,2.8,2.6,2.9,2.9,2.5,2.4,2.2,2.4,2.2,2.2,2.1,2.0,1.8,2.0,2.0,1.9,4.2,4.0,3.9,4.4,4.4,4.6,4.2,4.4,4.5,4.0,4.1,4.2,4.4,3.9,4.2,4.2,4.3,4.7,4.0,4.6,4.5,4.0,4.4,4.2,3.6,3.7,3.4,3.8,3.7,3.4,4.0,3.8,3.3,3.8,3.7,3.5,3.0,2.8,2.9,2.0,2.9,2.8,2.0,2.4,2.0,2.0,2.2,2.3) + +df1<-data.frame(A,B,C,data) +print(df1) + +#To find cell totals for all combinations of the three factors +cat("\nCell totals:\n") +m1<-tapply(df1$data,list(A,B,C),sum) +print(m1) + +#To create ANOVA table +a<-aov(data~A+B+C+A:B+A:C+B:C+A:B:C,data=df1) +print(a) +cat("\nSummarized table:\n") +print(summary(a)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.11/Ex11_11.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.11/Ex11_11.R new file mode 100644 index 00000000..9df394c9 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.11/Ex11_11.R @@ -0,0 +1,34 @@ +#Ex11.11, Page 447 +#Answers may vary from textbook values + +library(nlme) +library(multcomp) + +#Dependent variable +data<-c(7.38,7.15,6.75,8.05,5.65,6.00,5.39,8.16,5.64,6.45,5.44,6.55,5.03,4.96,6.34,6.31,7.27,5.93,5.50,5.78,5.31,5.46,6.54,8.02,5.01,6.24,7.81,6.05,7.03,5.80,6.79,5.06,8.05,5.51,5.96,6.61) + +#Repeated measures +##B(Columns) +B<-factor(rep(c("1","2","3","4","5","6"),each=6)) + +##A(Rows) +A<-factor(rep(c("I","II","III","IV","V","VI"),6)) + +df1<-data.frame(A,B,data) +print(df1) + +#To create ANOVA table +#using aov() function +cat("\nUsing aov():\n") +a1<-aov(data~A+Error(B/A),data=df1) +print(summary(a1)) + +#using lme() +cat("\nUsing lme():\n") +model<-lme(data~A,random=~1|B/A,data=df1) +a2<-anova(model) +print(a2) + +#Tukey test +print(summary(glht(model,linfct=mcp(A="Tukey")))) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.12/Ex11_12.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.12/Ex11_12.R new file mode 100644 index 00000000..7903e7ba --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.12/Ex11_12.R @@ -0,0 +1,61 @@ +#Ex11.12, Page 452 + +Age<-rep(c("1","2"),each=2,4) +Temp<-rep(c("1","2"),8) +Soil<-rep(c("1","2"),each=8) +Comp_Stre<-c(471,485,712,712,413,552,637,789,385,530,770,741,434,593,705,806) +df1<-data.frame(Age,Temp,Soil,Comp_Stre) + +#To compute cell totals +s1<-s2<-s3<-s4<-s5<-s6<-s7<-s8<-c(NULL) +for(i in 1:length(Comp_Stre)){ + if(df1$Age[i]=="1" && df1$Temp[i]=="1" && df1$Soil[i]=="1"){ + s1[i]<-df1$Comp_Stre[i] + x111<-sum(s1,na.rm=TRUE) + } + else if(df1$Age[i]=="1" && df1$Temp[i]=="2" && df1$Soil[i]=="1"){ + s2[i]<-df1$Comp_Stre[i] + x121<-sum(s2,na.rm=TRUE) + } + else if(df1$Age[i]=="1" && df1$Temp[i]=="1" && df1$Soil[i]=="2"){ + s3[i]<-df1$Comp_Stre[i] + x112<-sum(s3,na.rm=TRUE) + } + else if(df1$Age[i]=="2" && df1$Temp[i]=="1" && df1$Soil[i]=="1"){ + s4[i]<-df1$Comp_Stre[i] + x211<-sum(s4,na.rm=TRUE) + } + else if(df1$Age[i]=="2" && df1$Temp[i]=="1" && df1$Soil[i]=="2"){ + s5[i]<-df1$Comp_Stre[i] + x212<-sum(s5,na.rm=TRUE) + } + else if(df1$Age[i]=="1" && df1$Temp[i]=="2" && df1$Soil[i]=="2"){ + s6[i]<-df1$Comp_Stre[i] + x122<-sum(s6,na.rm=TRUE) + } + else if(df1$Age[i]=="2" && df1$Temp[i]=="2" && df1$Soil[i]=="1"){ + s7[i]<-df1$Comp_Stre[i] + x221<-sum(s7,na.rm=TRUE) + } + else if(df1$Age[i]=="2" && df1$Temp[i]=="2" && df1$Soil[i]=="2"){ + s8[i]<-df1$Comp_Stre[i] + x222<-sum(s8,na.rm=TRUE) + } + +} +#Parameters of the model +n<-2 +alpha1_cap<-(x111+x121+x112+x122-x211-x212-x221-x222)/(8*n) +alpha2_cap<-(-1)*alpha1_cap + +gamma11_cap<-(x111-x121-x211+x221+x112-x122-x212+x222)/(8*n) +gamma12_cap<-(-1)*gamma11_cap +gamma21_cap<-(-1)*gamma11_cap +gamma22_cap<-gamma11_cap + +print(paste("alpha1_cap:",alpha1_cap)) +print(paste("alpha2_cap:",alpha2_cap)) +print(paste("gamma11_cap:",gamma11_cap)) +print(paste("gamma12_cap:",gamma12_cap)) +print(paste("gamma21_cap:",gamma21_cap)) +print(paste("gamma22_cap:",gamma22_cap)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.13/Ex11_13.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.13/Ex11_13.R new file mode 100644 index 00000000..eeba3652 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.13/Ex11_13.R @@ -0,0 +1,104 @@ +#Ex11.13, Page 453 +#Answers may vary slightly due to rounding off of values + +Age<-factor(rep(c("1","2"),each=2,4)) +Temp<-factor(rep(c("1","2"),8)) +Soil<-factor(rep(c("1","2"),each=8)) +Comp_Stre<-c(471,485,712,712,413,552,637,789,385,530,770,741,434,593,705,806) +df1<-data.frame(Age,Temp,Soil,Comp_Stre) + +#To compute cell totals +s1<-s2<-s3<-s4<-s5<-s6<-s7<-s8<-c(NULL) +for(i in 1:length(Comp_Stre)){ + if(df1$Age[i]=="1" && df1$Temp[i]=="1" && df1$Soil[i]=="1"){ + s1[i]<-df1$Comp_Stre[i] + x111<-sum(s1,na.rm=TRUE) + } + else if(df1$Age[i]=="1" && df1$Temp[i]=="2" && df1$Soil[i]=="1"){ + s2[i]<-df1$Comp_Stre[i] + x121<-sum(s2,na.rm=TRUE) + } + else if(df1$Age[i]=="1" && df1$Temp[i]=="1" && df1$Soil[i]=="2"){ + s3[i]<-df1$Comp_Stre[i] + x112<-sum(s3,na.rm=TRUE) + } + else if(df1$Age[i]=="2" && df1$Temp[i]=="1" && df1$Soil[i]=="1"){ + s4[i]<-df1$Comp_Stre[i] + x211<-sum(s4,na.rm=TRUE) + } + else if(df1$Age[i]=="2" && df1$Temp[i]=="1" && df1$Soil[i]=="2"){ + s5[i]<-df1$Comp_Stre[i] + x212<-sum(s5,na.rm=TRUE) + } + else if(df1$Age[i]=="1" && df1$Temp[i]=="2" && df1$Soil[i]=="2"){ + s6[i]<-df1$Comp_Stre[i] + x122<-sum(s6,na.rm=TRUE) + } + else if(df1$Age[i]=="2" && df1$Temp[i]=="2" && df1$Soil[i]=="1"){ + s7[i]<-df1$Comp_Stre[i] + x221<-sum(s7,na.rm=TRUE) + } + else if(df1$Age[i]=="2" && df1$Temp[i]=="2" && df1$Soil[i]=="2"){ + s8[i]<-df1$Comp_Stre[i] + x222<-sum(s8,na.rm=TRUE) + } + +} + +Effect_contrasts<-c(NULL) +#To compute effect contrasts +for(j in 1:7){ + if(j==1){ + Effect_contrasts[j]=-x111+x211-x121+x221-x112+x212-x122+x222 + } + else if(j==2){ + Effect_contrasts[j]=-x111-x211+x121+x221-x112-x212+x122+x222 + } + else if(j==3){ + Effect_contrasts[j]=x111-x211-x121+x221+x112-x212-x122+x222 + } + else if(j==4){ + Effect_contrasts[j]=-x111-x211-x121-x221+x112+x212+x122+x222 + } + else if(j==5){ + Effect_contrasts[j]=x111-x211+x121-x221-x112+x212-x122+x222 + } + else if(j==6){ + Effect_contrasts[j]=x111+x211-x121-x221-x112-x212+x122+x222 + } + else if(j==7){ + Effect_contrasts[j]=-x111+x211+x121-x221+x112-x212-x122+x222 + } +} + +SS<-(Effect_contrasts^2)/(8*n) +df2<-data.frame(Effect_contrasts,SS) +cat("\nEffect contrast and SS values:\n") +print(df2) +SSsum<-sum(SS) + +#To find sum of squares value +x2_ijkl<-0 +X2<-0 +for(k in 1:length(Comp_Stre)){ + x2_ijkl<-x2_ijkl+(Comp_Stre[k]^2) +} +x2<-(x111+x112+x211+x121+x212+x221+x122+x222)^2/16 +print(paste("Sum of square of data:",x2_ijkl)) +print(paste("x...^2/16:",x2)) + +#To find SST value +SST<-x2_ijkl-x2 +print(paste("SST:",SST)) + +#To find SSE value +SSE<-SST-SSsum +print(paste("SSE:",SSE)) + +#To display corresponding ANOVA tables +model1<-lm(Comp_Stre~Age:Temp:Soil) +model2<-lm(Comp_Stre~Age*Temp*Soil) +a<-aov(model1,data=df1) +b<-aov(model2,data=df1) +print(summary(a)) +print(summary(b)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.3/Ex11_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.3/Ex11_3.R new file mode 100644 index 00000000..8a1d16a2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.3/Ex11_3.R @@ -0,0 +1,25 @@ +#Ex11.3, Page 424 +#Answers may vary slightly due to rounding off of values + +#To create data frame +brand<-rep(c("I","II","III"),4) +WT<-rep(c("1","2","3","4"),each=3) #WT<-Washing treatment +col_change<-c(0.97,0.77,0.67,0.48,0.14,0.39,0.48,0.22,0.57,0.46,0.25,0.19) + +df1<-data.frame(brand,WT,col_change) +print(df1) + +#To display ANOVA table +a<-aov(col_change~brand+WT,data=df1) +print(a) +cat("\nSummarized table:\n") +print(summary(a)) + +#Diagnostic plots +model<-lm(col_change~brand+WT,data=df1) +par(mfrow=c(1,2)) +qqnorm(model$residuals,datax=TRUE,main="Normal probability plot",ylab="Residual",xlab="Percent") +qqline(model$residuals,datax=TRUE) + +plot(df1$col_change,resid(model),main="Residual plot",xlab="Fitted value",ylab="Residual") +abline(0,0) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.5/Ex11_5.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.5/Ex11_5.R new file mode 100644 index 00000000..aa3753af --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.5/Ex11_5.R @@ -0,0 +1,16 @@ +#Ex11.5, Page 427 +#Answers may vary slightly due to rounding off of values + +#To create data frame +Treatment<-rep(c("I","II","III","IV","V"),4) +Block<-rep(c("1","2","3","4"),each=5) +Power<-c(685,722,733,811,828,792,806,802,888,920,838,893,880,952,978,875,953,941,1005,1023) + +df1<-data.frame(Treatment,Block,Power) +print(df1) + +#To display ANOVA table +a<-aov(Power~Treatment+Block,data=df1) +print(a) +cat("\nSummarized table:\n") +print(summary(a)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.6/Ex11_6.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.6/Ex11_6.R new file mode 100644 index 00000000..0da45bc9 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.6/Ex11_6.R @@ -0,0 +1,25 @@ +#Ex11.6, Page 428 +#Answers may vary slightly due to rounding off of values + +#To create data frame +Tension<-rep(c("210","235","260","285"),6) +Player<-rep(c("1","2","3","4","5","6"),each=4) +Speed<-c(105.7,113.3,117.2,110.0,116.6,119.9,124.4,106.8,106.6,120.5,122.3,110.0,113.9,119.3,120.0,115.3,119.4,122.5,115.1,122.6,123.5,124.0,127.9,128.3) + +df1<-data.frame(Tension,Player,Speed) +print(df1) + +#To find mean for corresponding tension data +cat("\nTension mean values:\n") +m1<-tapply(df1$Speed,list(Tension),mean) +print(m1) + +#To find mean of corresponding player data +cat("\nPlayer mean values:\n") +m2<-tapply(df1$Speed,list(Player),mean) +print(m2) + +#To display ANOVA table +a<-aov(Speed~Tension+Player,data=df1) +print(a) +print(summary(a)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.7/Ex11_7.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.7/Ex11_7.R new file mode 100644 index 00000000..51b36ac3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.7/Ex11_7.R @@ -0,0 +1,35 @@ +#Ex11.7, Page 435 + +AggCont<-rep(c("38","41","44"),each=6) +AsphGr<-rep(c("PG58","PG64","PG70"),6) +data<-c(0.835,0.855,0.815,0.845,0.865,0.825,0.822,0.832,0.800,0.826,0.836,0.820,0.785,0.790,0.770,0.795,0.800,0.790) +df1<-data.frame(AggCont,AsphGr,data) +print(df1) + +#To find mean for corresponding content data +cat("\nCoarse aggregate content(%) mean values:\n") +m1<-tapply(df1$data,list(AggCont),mean) +print(m1) + +#To find mean of corresponding Asphalt binder grade data +cat("\nAsphalt binder grade mean values:\n") +m2<-tapply(df1$data,list(AsphGr),mean) +print(m2) + + +#To display ANOVA table +model<-lm(data~AsphGr+AggCont+AsphGr:AggCont) +a<-aov(data~AsphGr+AggCont+AsphGr:AggCont) +print(a) +print(summary(a)) + +#To display interaction plots(Thermal diffusivity data is not given) +interaction.plot(AggCont,AsphGr,response=data) + +#Plots for checking normality and constant variance assumptions +par(mfrow=c(1,2)) +qqnorm(model$residuals,datax=TRUE,main="Normal probability plot",ylab="Residual",xlab="Percent") +qqline(model$residuals,datax=TRUE) + +plot(df1$data,resid(model),main="Residual plot",xlab="Fitted value",ylab="Residual") +abline(0,0) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.9/Ex11_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.9/Ex11_9.R new file mode 100644 index 00000000..cf16a1fc --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH11/EX11.9/Ex11_9.R @@ -0,0 +1,16 @@ +#Ex11.9, Page 439 +#Answers may vary slightly from textbook values + +#To create data frame +Casmater<-rep(c("Steel","Aluminium","Plastic"),10) +Source<-rep(c("1","2","3","4","5"),each=6) +Power<-c(13.1,15.0,14.0,13.2,14.8,14.3,16.3,15.7,17.2,15.8,16.4,16.7,13.7,13.9,12.4,14.3,14.3,12.3,15.7,13.7,14.4,15.8,14.2,13.9,13.5,13.4,13.2,12.5,13.8,13.1) + +df1<-data.frame(Casmater,Source,Power) +print(df1) + +#To create ANOVA table +a<-aov(Power~Casmater+Source+Casmater:Source,data=df1) +print(a) +cat("\nSummarized table:\n") +print(summary(a)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.1/Ex12_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.1/Ex12_1.R new file mode 100644 index 00000000..08c8cad8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.1/Ex12_1.R @@ -0,0 +1,12 @@ +#Ex12.1, Page 470 + +i<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30) +xi<-c(0.40,0.42,0.48,0.51,0.57,0.60,0.70,0.75,0.75,0.78,0.84,0.95,0.99,1.03,1.12,1.15,1.20,1.25,1.25,1.28,1.30,1.34,1.37,1.40,1.43,1.46,1.49,1.55,1.58,1.60) +yi<-c(1.02,1.21,0.88,0.98,1.52,1.83,1.50,1.80,1.74,1.63,2.00,2.80,2.48,2.47,3.05,3.18,3.76,3.68,3.82,3.21,4.27,3.12,3.99,3.75,4.10,4.18,3.77,4.34,4.21,4.92) +data<-data.frame(xi,yi,row.names=i) +print(data) + +par(mfrow=c(1,3)) +plot(xi,yi,main="Scatterplot",xlab="Width of palprebal fissure",ylab="OSA") +dotchart(xi,labels=row.names(xi),main="Dot plot of x values") +dotchart(yi,labels=row.names(yi),main="Dot plot of y values") diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.11/Ex12_11.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.11/Ex12_11.R new file mode 100644 index 00000000..c0bda967 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.11/Ex12_11.R @@ -0,0 +1,74 @@ +#Ex12.11, Page 494 +#Answers may vary slightly due to rounding off of values + +x<-c(5.7,6.8,9.6,10.0,10.7,12.6,14.4,15.0,15.3,16.2,17.8,18.7,19.7,20.6,25.0) +y<-c(119.0,121.3,118.2,124.0,112.3,114.1,112.2,115.1,111.3,107.2,108.9,107.8,111.0,106.2,105.0) + +plot(x,y,main="Scatterplot",xlab="Air content",ylab="Density") + +n<-length(x) +xi<-sum(x) +yi<-sum(y) +#To find sum of xi^2, yi^2 and xi*yi +xi2<-sum(x^2) +yi2<-sum(y^2) +xiyi<-sum(x*y) + +#To find Sxx and Sxy +Sxx<-xi2-(xi^2)/length(x) +Sxy<-xiyi-(yi*xi)/length(y) +print(paste("Sxx:",Sxx)) +print(paste("Sxy:",Sxy)) + +#To find beta1 and beta0 +xbar<-mean(x) +ybar<-mean(y) +beta1<-Sxy/Sxx +beta0<-ybar-beta1*xbar +print(paste("Beta1:",beta1)) +print(paste("Beta0:",beta0)) + +#To find SSE +SSE<-yi2-beta0*yi-beta1*xiyi +print(paste("SSE:",SSE)) + +#To find SST +SST<-yi2-yi^2/n +print(paste("SST:",SST)) + +#To find r^2 +r2<-1-(SSE/SST) +print(paste("r^2:",r2)) + +I<-15 +J<-2 +df<-I-J + +#s^2 +s2<-SSE/df +s<-sqrt(s2) + +#Estimated standard deviation of beta1 +sb<-s/sqrt(Sxx) +print(paste("Estimated standard deviation of beta1:",sb)) + +alpha<-0.05 +t<-qt(1-alpha/2,df) + +#To find confidence intervals +l<-beta1-t*sb +r<-beta1+t*sb +print(paste("Left endpoint of confidence interval:",l)) +print(paste("Right endpoint of confidence interval:",r)) + +#To display analysis of variance and parameter estimates +model<-lm(y~x) +cat("\nParameter estimates\n") +print(summary(model)) +cat("\nANOVA table:\n") +print(summary(aov(model))) +a<-predict(model) +print(paste("Predict values:")) +print(a) +print(paste("Residuals:")) +print(resid(model)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.12/Ex12_12.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.12/Ex12_12.R new file mode 100644 index 00000000..892ff45e --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.12/Ex12_12.R @@ -0,0 +1,15 @@ +#Ex12.12, Page 496 +#Answers may vary slightly due to rounding off of values + +x<-c(42.2,42.6,43.3,43.5,43.7,44.1,44.9,45.3,45.7,45.7,45.9,46.0,46.2,46.2,46.8,46.8,47.1,47.2) +y<-c(44,44,44,45,45,46,46,46,47,48,48,48,47,48,48,49,49,49) +data1<-data.frame(x,y) + +model<-lm(y~x,data=data1) +cat("Regression model:\n") +print(summary(model)) + +#To display ANOVA table +a<-aov(model) +cat("ANOVA table:\n") +print(summary(a)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.13/Ex12_13.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.13/Ex12_13.R new file mode 100644 index 00000000..459c6f59 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.13/Ex12_13.R @@ -0,0 +1,27 @@ +#Ex12.13, Page 501 +#Answers may vary slightly due to rounding off of values + +library(ggplot2) + +x<-c(8.0,15.0,16.5,20.0,20.0,27.5,30.0,30.0,35.0,38.0,40.0,45.0,50.0,50.0,55.0,55.0,59.0,65.0) +y<-c(22.8,27.2,23.7,17.1,21.5,18.6,16.1,23.4,13.4,19.5,12.4,13.2,11.4,10.3,14.1,9.7,12.0,6.8) +data1<-data.frame(x,y) + +#To plot data using ggplot +ggplot(data=data1,mapping=aes(x,y))+geom_point(size=2)+geom_smooth(method=lm) + +#To display linear regression model +model<-lm(y~x) +print(summary(model)) + +#To display analysis of variance +cat("ANOVA table:\n") +a<-aov(model,data=data1) +print(summary(a)) + +#To display confidence and prediction intervals +d<-data.frame(x=c(35,45)) +cat("Confidence intervals:\n") +print(predict(model,newdata=d,interval="confidence",level=0.95)) +cat("Prediction intervals:\n") +print(predict(model,newdata=d,interval="predict",level=0.95)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.14/Ex12_14.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.14/Ex12_14.R new file mode 100644 index 00000000..07e65753 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.14/Ex12_14.R @@ -0,0 +1,15 @@ +#Ex12.14, Page 505 +#Answers may vary slightly due to rounding off of values + +ycap<-13.79 +sy<-0.7582 +s<-2.8640 +n<-18 +df<-n-2 +t<-2.120 + +#To find confidence intervals +l<-ycap-t*sqrt(s^2+sy^2) +r<-ycap+t*sqrt(s^2+sy^2) +print(paste("Left endpoint of confidence interval:",l)) +print(paste("Right endpoint of confidence interval:",r)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.15/Ex12_15.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.15/Ex12_15.R new file mode 100644 index 00000000..1eb3a161 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.15/Ex12_15.R @@ -0,0 +1,9 @@ +#Ex12.15, Page 509 +#Answers may vary slightly due to rounding off of values + +x<-c(2.4,3.4,4.6,3.7,2.2,3.3,4.0,2.1) +y<-c(1.33,2.12,1.80,1.65,2.00,1.76,2.11,1.63) + +#To find sample correlation coefficient +r<-cor(x,y) +print(paste("Sample correlation coefficient,r:",r)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.16/Ex12_16.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.16/Ex12_16.R new file mode 100644 index 00000000..907142a0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.16/Ex12_16.R @@ -0,0 +1,9 @@ +#Ex12.16, Page 511 +#Answers may vary slightly due to rounding off of values + +x<-c(0.066,0.088,0.120,0.050,0.162,0.186,0.057,0.100,0.112,0.055,0.154,0.074,0.111,0.140,0.071,0.110) +y<-c(4.6,11.6,9.5,6.3,13.8,15.4,2.5,11.8,8.0,7.0,20.6,16.6,9.2,17.9,2.8,13.0) + +#To find r(point estimate of population correlation coefficient) +r<-cor(x,y) +print(paste("r:",r)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.17/Ex12_17.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.17/Ex12_17.R new file mode 100644 index 00000000..06b9d5f6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.17/Ex12_17.R @@ -0,0 +1,13 @@ +#Ex12.17, Page 513 +#Answers may vary slightly due to rounding off of values + +r<-0.29 +n<-45 +#To find the test statistic +t<-r*sqrt(n-2)/sqrt(1-r^2) +print(paste("t:",round(t,digits=0))) + +#P value for two tailed test +p<-2*pt(-abs(t),df=n-1) +print(p) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.18/Ex12_18.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.18/Ex12_18.R new file mode 100644 index 00000000..bb2ff8f7 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.18/Ex12_18.R @@ -0,0 +1,29 @@ +#Ex12.18, Page 515 +#Answers may vary slightly due to rounding off of values + +x<-c(55.10,44.83,46.32,51.10,49.89,45.20,48.18,46.70,54.31,41.50,47.50,52.00,52.25,50.86,51.66,54.77,57.06,57.84,55.22) +y<-c(49.10,31.20,32.80,42.60,42.50,32.70,36.21,40.40,37.42,30.80,35.34,44.80,41.75,39.35,44.07,43.40,45.30,39.08,41.89) + +#To find r +r<-cor(x,y) +print(paste("Correlation coefficient, r:",r)) + +#H0: rho=0.5 +#Ha: rho>0.5 +rho<-0.5 + +#To find v +v<-0.5*log((1+r)/(1-r)) +print(paste("v:",v)) + +muv<-0.5*log((1+rho)/(1-rho)) +print(paste("muv:",muv)) + +z<-(v-muv)*sqrt(length(x)-3) +print(paste("z:",z)) + +#To find P value +p<-pnorm(z,lower.tail=FALSE) +print(paste("p value:",p)) + +print(paste("H0 is rejected...")) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.19/Ex12_19.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.19/Ex12_19.R new file mode 100644 index 00000000..d448e9ad --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.19/Ex12_19.R @@ -0,0 +1,27 @@ +#Ex12.19, Page 516 +#Answers may vary slightly due to rounding off of values + +xi<-285.90 +xi2<-4409.55 +yi<-690.30 +yi2<-29040.29 +xiyi<-10818.56 +r<-0.733 +v<-0.935 +n<-20 +alpha<-0.05 + +#To find z +zalpha2<-qnorm(1-alpha/2) + +#95% interval for muv +c1<-v-zalpha2/sqrt(n-3) +c2<-v+zalpha2/sqrt(n-3) +print(paste("Left endpoint of CI for muv:",c1)) +print(paste("Right endpoint of CI for muv:",c2)) + +#95% interval for rho +l<-(exp(1)^(2*c1)-1)/(exp(1)^(2*c1)+1) +r<-(exp(1)^(2*c2)-1)/(exp(1)^(2*c2)+1) +print(paste("Left endpoint of CI for rho:",l)) +print(paste("Right enpoint of CI for rho:",r)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.2/Ex12_2.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.2/Ex12_2.R new file mode 100644 index 00000000..ccbc6463 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.2/Ex12_2.R @@ -0,0 +1,9 @@ +#Ex12.2, Page 471 + +x<-c(7.01,7.11,7.12,7.24,7.94,7.94,8.04,8.05,8.07,8.90,8.94,8.95,8.97,8.98,9.85,9.86,9.86,9.87) +y<-c(60,67,66,52,50,45,52,48,40,23,20,40,31,26,9,22,13,7) +data1<-data.frame(x,y) +print(data) + +plot(x,y,main="Scatterplot",xlab="pH",ylab="Arsenic removed(%)") + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.3/Ex12_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.3/Ex12_3.R new file mode 100644 index 00000000..f2bb2513 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.3/Ex12_3.R @@ -0,0 +1,31 @@ +#Ex12.3, Page 474 +#Answers may slightly vary due to rounding off of probabilities + +y<- function(x) (65-1.2*x) +sd<-8 + +#P(time-to-failure exceeds 50 when applied stress is 20) +x1<-20 +mu1<-y(x1) +q<-50 +P1<-1-pnorm(q,mu1,sd) +print(paste("Probability that the time-to-failure>50 when applied stress=20):",P1)) + +#P(time-to-failure exceeds 50 when applied stress is 25) +x2<-25 +mu2<-y(x2) +q<-50 +P2<-1-pnorm(q,mu2,sd) +print(paste("Probability that the time-to-failure>50 when applied stress=25):",P2)) + +#Let Y1<-observation made with x=25 and Y2<-observation made with x=24 +#Mean value +X1<-25 +X2<-24 +E<-y(X1)-y(X2) +#Variance +V<-sd^2+sd^2 +SD<-sqrt(V) +#Probability that Y1 exceeds Y2 +P3<-1-pnorm(0,E,V) +print(paste("P(Y1>Y2):",P3)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.4/Ex12_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.4/Ex12_4.R new file mode 100644 index 00000000..d254743c --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.4/Ex12_4.R @@ -0,0 +1,16 @@ +#Ex12.4, Page 479 +#Answers may slightly vary due to rounding off of values + +x<-c(132.0,129.0,120.0,113.2,105.0,92.0,84.0,83.2,88.4,59.0,80.0,81.5,71.0,69.2) +y<-c(46.0,48.0,51.0,52.1,54.0,52.0,59.0,58.7,61.6,64.0,61.4,54.6,58.8,58.0) +data1<-data.frame(x,y) + +#To display regression model +model<-lm(y~x,data=data1) +cat("Regression model of data:\n") +a<-summary(model) +print(a) + +#To display the scatterplot +plot(x,y,main="Scatterplot with least square line superimposed",xlab="iod val",ylab="cet num") +abline(a$coefficients[1],a$coefficients[2]) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.5/Ex12_5.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.5/Ex12_5.R new file mode 100644 index 00000000..02c2e2bc --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.5/Ex12_5.R @@ -0,0 +1,6 @@ +#Ex12.5, Page 480 + +y<- function(x) {75.212-0.2094*x} +#If iodine value 100 is selected... +x<-100 +print(paste("Point prediction for the resulting cetane number:",round(y(x),digits=2))) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.6/Ex12_6.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.6/Ex12_6.R new file mode 100644 index 00000000..29d83e79 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.6/Ex12_6.R @@ -0,0 +1,20 @@ +#Ex12.6, Page 482 +#Answers may slightly vary due to rounding off of values + +x<-c(125.3,98.2,201.4,147.3,145.9,124.7,112.2,120.2,161.2,178.9,159.5,145.8,75.1,151.4,144.2,125.0,198.8,132.5,159.6,110.7) +y<-c(77.9,76.8,81.5,79.8,78.2,78.3,77.5,77.0,80.1,80.2,79.9,79.0,76.7,78.2,79.5,78.1,81.5,77.0,79.0,78.6) +data1<-data.frame(x,y) + +model<-lm(y~x) + +#To display final table of predicted values and residuals +yb<-predict(model,data1) +Residual<-resid(model) +data1<-data.frame(x,y,yb,Residual) +colnames(data1)[colnames(data1)=="x"]<-"Filtrate" +colnames(data1)[colnames(data1)=="y"]<-"Moistcon" +colnames(data1)[colnames(data1)=="yb"]<-"Fit" +print(data1) + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.7/Ex12_7.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.7/Ex12_7.R new file mode 100644 index 00000000..7aad2f06 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.7/Ex12_7.R @@ -0,0 +1,27 @@ +#Ex12.7, Page 483 +#Answers may vary slightly due to rounding off of values + +#From Ex12.6 +x<-c(125.3,98.2,201.4,147.3,145.9,124.7,112.2,120.2,161.2,178.9,159.5,145.8,75.1,151.4,144.2,125.0,198.8,132.5,159.6,110.7) +y<-c(77.9,76.8,81.5,79.8,78.2,78.3,77.5,77.0,80.1,80.2,79.9,79.0,76.7,78.2,79.5,78.1,81.5,77.0,79.0,78.6) +data1<-data.frame(x,y) + +model<-lm(y~x) +Residual<-resid(model) +n<-length(Residual) + +SSE<-sum(Residual^2) +print(paste("SSE:",SSE)) + +#To find variance(sigma^2) +s2<-SSE/(n-2) +print(paste("Estimate of variance:",s2)) + +#To find standard deviation(sigma) +sd<-sqrt(s2) +print(paste("Estimate of standard deviation:",sd)) + +#To display ANOVA table +a<-aov(model,data=data1) +cat("ANOVA table:\n") +print(summary(a)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.8/Ex12_8.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.8/Ex12_8.R new file mode 100644 index 00000000..13c65130 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.8/Ex12_8.R @@ -0,0 +1,13 @@ +#Ex12.8, Page 484 +#Answers may vary slightly due to rounding off of values + +x<-c(12,30,36,40,45,57,62,67,71,78,93,94,100,105) +y<-c(3.3,3.2,3.4,3.0,2.8,2.9,2.7,2.6,2.5,2.6,2.2,2.0,2.3,2.1) +data1<-data.frame(x,y) + +#To display ANOVA table +model<-lm(y~x) +print(summary(model)) +a<-aov(model,data=data1) +cat("ANOVA table:\n") +print(summary(a)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.9/Ex12_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.9/Ex12_9.R new file mode 100644 index 00000000..146f3b2e --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH12/EX12.9/Ex12_9.R @@ -0,0 +1,31 @@ +#Ex12.9, Page 486 +#Answers may vary slightly due to rounding off of values + +#From Ex12.4 +x<-c(132.0,129.0,120.0,113.2,105.0,92.0,84.0,83.2,88.4,59.0,80.0,81.5,71.0,69.2) +y<-c(46.0,48.0,51.0,52.1,54.0,52.0,59.0,58.7,61.6,64.0,61.4,54.6,58.8,58.0) +data1<-data.frame(x,y) + +n<-14 +beta0<-75.212432 +beta1<-(-0.20938742) +yi<-779.2 +xiyi<-71347.30 +yi2<-43745.22 + +#To find SST and SSE +SST<-yi2-(yi^2)/n +print(paste("SST:",SST)) +SSE<-yi2-beta0*yi-beta1*xiyi +print(paste("SSE:",SSE)) + +#Coefficient of determination +r2<-1-(SSE/SST) +print(paste("Coefficient of determination:",r2)) + +#To create regression model using ANOVA table +a<-lm(y~x) +print(summary(a)) +a1<-aov(a,data=data1) +print(summary(a1)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.10/Ex13_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.10/Ex13_10.R new file mode 100644 index 00000000..325ae379 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.10/Ex13_10.R @@ -0,0 +1,35 @@ +#Ex13.10, Page 549 +#Answers may vary slightly due to rounding off of values + +x<-c(280,284,292,295,298,305,308,315) +x_dash<-c(-17.13,-13.13,-5.13,-2.13,0.87,7.87,10.87,17.87) +y<-c(770,800,840,810,735,640,590,560) +df<-data.frame(x,x_dash,y) + +#To find estimated coefficients and standard deviations using original model +m1<-lm(y~x+I(x^2)) +print(summary(m1)) +Estimate1<-c(NULL) +Estimated_SD1<-c(NULL) +for(i in 1:3){ + Estimate1[i]<-m1$coefficients[i] + Estimated_SD1[i]<-coef(summary(m1))[,"Std. Error"][i] +} +cat("Estimated coefficients and standard deviations using original model\n") +Parameter1<-c("beta0","beta1","beta2") +df1<-data.frame(Parameter1,Estimate1,Estimated_SD1) +print(df1) + +#To find estimated coefficients and standard deviations using centered model +Estimate2<-c(NULL) +Estimated_SD2<-c(NULL) +m2<-lm(y~x_dash+I(x_dash^2)) +print(summary(m2)) +for(i in 1:3){ + Estimate2[i]<-m2$coefficients[i] + Estimated_SD2[i]<-coef(summary(m2))[,"Std. Error"][i] +} +cat("Estimated coefficients and standard deviations using centered model\n") +Parameter2<-c("beta0*","beta1*","beta2*") +df2<-data.frame(Parameter2,Estimate2,Estimated_SD2) +print(df2) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.12/Ex13_12.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.12/Ex13_12.R new file mode 100644 index 00000000..46b9d4a4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.12/Ex13_12.R @@ -0,0 +1,21 @@ +#Ex13.12, Page 558 +#Answers may vary slightly due to rounding off of values + +Observation<-1:30 +Force<-c(30,40,30,40,30,40,30,40,30,40,30,40,30,40,30,40,25,45,35,35,35,35,35,35,35,35,35,35,35,35) +Power<-c(60,60,90,90,60,60,90,90,60,60,90,90,60,60,90,90,75,75,45,105,75,75,75,75,75,75,75,75,75,75) +Temperature<-c(175,175,175,175,225,225,225,225,175,175,175,175,225,225,225,225,200,200,200,200,150,250,200,200,200,200,200,200,200,200) +Time<-c(15,15,15,15,15,15,15,15,25,25,25,25,25,25,25,25,20,20,20,20,20,20,10,30,20,20,20,20,20,20) +Strength<-c(26.2,26.3,39.8,39.7,38.6,35.5,48.8,37.8,26.6,23.4,38.6,52.1,39.5,32.3,43.0,56.0,35.2,46.9,22.7,58.7,34.5,44.0,35.7,41.8,36.5,37.6,40.3,46.0,27.8,40.3) + +m1<-lm(Strength~(Force+Power+Temperature+Time)) + +#To form estimated regression equation +Force<-35 #Force +Power<-75 #Power +Temperature<-200 #Temperature +Time<-20 #Time + +new<-data.frame(Force,Power,Temperature,Time) +y_cap<-predict(m1,new) +print(paste("Point prediction of strength at (35,75,200,20):",y_cap,"gm")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.13/Ex13_13.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.13/Ex13_13.R new file mode 100644 index 00000000..aec33f84 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.13/Ex13_13.R @@ -0,0 +1,49 @@ +#Ex13.13, Page 560 +#Answers may vary slightly due to rounding off of values + +temp1<-x1<-c(21,21,7,7,28,0,14,14,14) +temp2<-x2<-c(0.65,0.55,0.65,0.55,0.60,0.60,0.70,0.50,0.60) +x1x2<-x1*x2 +Comp_str<-c(33.55,47.55,35.00,35.90,40.90,39.10,31.55,48.00,42.30) +Adsorbability<-c(8.42,6.26,6.74,6.59,7.28,6.90,10.80,5.63,7.43) +df1<-data.frame(x1,x2,x1x2,Comp_str,Adsorbability) + +#To find mean and SST values +ybar_compstr<-mean(Comp_str) +ybar_Adsorb<-mean(Adsorbability) +SST_CompStr<-sum((Comp_str-ybar_compstr)^2) +SST_Adsorb<-sum((Adsorbability-ybar_Adsorb)^2) +cat("Mean of compression strength values:",ybar_compstr,"\n") +cat("Mean of adsorbability values:",ybar_Adsorb,"\n") +cat("SST of compression strength:",SST_CompStr,"\n") +cat("SST of adsorbability:",SST_Adsorb,"\n\n") + +#First-order regression model +m1<-lm(Comp_str~(x1+x2)) +SSE1<-sum(resid(m1)^2) +cat("SSE for first-order model:",SSE1,"\n") +cat("R squared value:",summary(m1)$r.squared,"\n\n") + +#Model including interaction predictor +m2<-lm(Comp_str~(x1*x2)) +SSE2<-sum(resid(m2)^2) +cat("SSE for first-order model including interaction predictor:",SSE2,"\n") +cat("R squared value:",summary(m2)$r.squared,"\n\n") + +#To create estimated regression function +x1<-14 #% limestone +x2<-0.6 #Water-cement ratio +new<-data.frame(x1,x2) +y_cap<-predict(m2,new) +cat("Prediction of compression strength at (14,0.6):",y_cap,"\n") + +#When adsorbability is taken as the dependent variable +#First-order regression model +m3<-lm(Adsorbability~(temp1+temp2)) +cat("R squared value for first-order model:",summary(m3)$r.squared,"\n") + +#Model including interaction predictor +m4<-lm(Adsorbability~(temp1*temp2)) +cat("R squared value when using interaction predictor:",summary(m4)$r.squared,"\n\n") + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.14/Ex13_14.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.14/Ex13_14.R new file mode 100644 index 00000000..5029d59f --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.14/Ex13_14.R @@ -0,0 +1,22 @@ +#Ex13.14, Page 562 + +#H0: beta1=beta2=beta3=beta4=0 +#Ha: at least one of these four betas!=0 + +Observation<-1:30 +Force<-c(30,40,30,40,30,40,30,40,30,40,30,40,30,40,30,40,25,45,35,35,35,35,35,35,35,35,35,35,35,35) +Power<-c(60,60,90,90,60,60,90,90,60,60,90,90,60,60,90,90,75,75,45,105,75,75,75,75,75,75,75,75,75,75) +Temperature<-c(175,175,175,175,225,225,225,225,175,175,175,175,225,225,225,225,200,200,200,200,150,250,200,200,200,200,200,200,200,200) +Time<-c(15,15,15,15,15,15,15,15,25,25,25,25,25,25,25,25,20,20,20,20,20,20,10,30,20,20,20,20,20,20) +Strength<-c(26.2,26.3,39.8,39.7,38.6,35.5,48.8,37.8,26.6,23.4,38.6,52.1,39.5,32.3,43.0,56.0,35.2,46.9,22.7,58.7,34.5,44.0,35.7,41.8,36.5,37.6,40.3,46.0,27.8,40.3) + +Model<-cbind(Force,Power,Temperature,Time) + +m1<-lm(Strength~Model) +print(summary(m1)) + +#To display analysis of variance table +a<-summary(aov(Strength~Model)) +print(a) + +print(paste("F value:",a[[1]]$F[1])) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.15/Ex13_15.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.15/Ex13_15.R new file mode 100644 index 00000000..b3a17349 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.15/Ex13_15.R @@ -0,0 +1,26 @@ +#Ex13.15, Page 564 +#Answers may vary slightly due to rounding off of values + +x1<-c(61,175,111,124,130,173,169,169,160,244,257,333,199) +x2<-c(13,21,24,23,64,38,33,61,39,71,112,88,54) +y<-c(4,18,14,18,26,26,21,30,28,36,65,62,40) +data1<-data.frame(x1,x2,y) + +model<-lm(y~(x1+x2)) +print(summary(model)) + +new<-data.frame(x1=160,x2=39) +y_cap<-predict(model,new) +print(paste("y_cap:",y_cap)) + +cat("\n99% CI:\n") +print(confint(model,level=0.99)) + +#To find confidence and prediction intervals +cat("95% CI:\n") +print(predict(model,new,interval="confidence")) +cat("95% PI:\n") +print(predict(model,new,interval="prediction")) + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.16/Ex13_16.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.16/Ex13_16.R new file mode 100644 index 00000000..412e78b0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.16/Ex13_16.R @@ -0,0 +1,53 @@ +#Ex13.16, Page 566 +#Answers may slightly vary due to rounding off of values + +Observation<-1:30 +x1<-c(8,2,7,10,7,7,7,5,4,5,8,2,4,6,10,4,4,10,5,8,10,2,6,7,5,8,4,6,4,7) +x2<-c(4,4,4,7,4,7,13,4,7,1,10,4,10,7,13,10,13,10,4,13,1,13,13,1,13,1,1,1,1,10) +x3<-c(100,180,180,120,180,180,140,160,140,100,140,100,180,120,180,160,100,120,100,140,180,140,180,120,140,160,180,160,100,100) +x4<-c(1,7,1,5,5,1,1,7,3,7,3,3,3,7,3,5,7,7,1,1,1,1,7,7,1,7,7,1,1,7) +y<-c(1.4,2.2,4.6,4.9,4.6,4.7,4.6,4.5,4.8,1.4,4.7,1.6,4.5,4.7,4.8,4.6,4.3,4.9,1.7,4.6,2.6,3.1,4.7,2.5,4.5,2.1,1.8,1.5,1.3,4.6) +x12<-x1^2 +x22<-x2^2 +x32<-x3^2 +x42<-x4^2 +x1x2<-x1*x2 +x1x3<-x1*x3 +x1x4<-x1*x4 +x2x3<-x2*x3 +x2x4<-x2*x4 +x3x4<-x3*x4 +df1<-data.frame(Observation,x1,x2,x3,x4,y) +print(df1) + +#To find estimate for reduced model +cat("\nReduced model:\n") +m1<-lm(y~x1+x2+x3+x4) +print(summary(m1)) + +#To find estimate for full model +cat("Full model:\n") +m2<-lm(y~(x1+x2+x3+x4+x12+x22+x32+x42+x1x2+x1x3+x1x4+x2x3+x2x4+x3x4)) +print(summary(m2)) + +#H0: beta5=beta6=.....=beta14=0 +#Ha: at least one among beta5,....beta14 is not 0 +n<-30 +k<-14 +l<-4 +alpha<-0.01 +#To find F value +Fval<-qf(1-alpha,df1=k-l,df2=n-(k+1)) +cat("F value:",Fval,"\n") + +#Unexplained variation for the full model +SSEk<-sum(resid(m2)^2) + +#Unexplained variation for the reduced model +SSEl<-sum(resid(m1)^2) + +#f value +f<-((SSEl-SSEk)/(k-l))/(SSEk/(n-(k+1))) +cat("f value:",f,"\n") + +if(f>=Fval) cat("H0 is rejected since",f,">=",Fval) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.18/Ex13_18.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.18/Ex13_18.R new file mode 100644 index 00000000..23b145f9 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.18/Ex13_18.R @@ -0,0 +1,14 @@ +#Ex13.18, Page 575 + +s<-c(20,20,20,20,20,20,20,20,20,60,60,60,60,60,60,60,60,60,100,100,100,100,100,100,100,100,100) +l_1000s<-c(3,3,3,6,6,6,10,10,10,3,3,3,6,6,6,10,10,10,3,3,3,6,6,6,10,10,10) +w<-c(300.2,310.8,333.0,99.6,136.2,142.4,20.2,28.2,102.7,67.3,77.9,93.9,43.0,44.5,65.9,10.7,34.1,39.1,26.5,22.3,34.8,32.8,25.6,32.7,2.3,4.4,5.8) + +si<-log(s,base=exp(1)) +li<-log(l_1000s,base=exp(1)) +wi<-log(w,base=exp(1)) + +#To display estimated coefficients and t ratios +df1<-data.frame(si,li,wi) +model<-lm(wi~(si+li),data=df1) +print(summary(model)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.2/Ex13_2.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.2/Ex13_2.R new file mode 100644 index 00000000..afed8028 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.2/Ex13_2.R @@ -0,0 +1,21 @@ +#Ex13.2, Page 526 + +x<-c(100,125,125,150,150,200,200,250,250,300,300,350,400,400) +y<-c(150,140,180,210,190,320,280,400,430,440,390,600,610,670) +y_cap<-(-45.55)+(1.71*x) +m1<-lm(y~x) +ei<-round(resid(m1),digits=1) +ei_std<-round(rstandard(m1),digits=2) +df<-data.frame(x,y,y_cap,ei,ei_std) +print(df) + +par(mfrow=c(3,2)) +plot(x,y,main="y vs. x") +abline(m1) +plot(y_cap,ei_std,main="Standardized residuals vs. y_cap") +abline(0,0) +plot(y,y_cap,main="y_cap vs. y") +abline(lm(y_cap~y)) +plot(x,ei_std,main="Standardized residuals vs. x") +abline(0,0) +qqnorm(ei_std,xlab="z percentile",ylab="e*",main="Normal probability plot") diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.4/Ex13_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.4/Ex13_4.R new file mode 100644 index 00000000..73e0d020 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.4/Ex13_4.R @@ -0,0 +1,32 @@ +#Ex13.4, Page 534 +#Answers may vary slightly due to rounding off of values + +x<-c(2,10,20,30,40,50,60,70,80,90,100) +y<-c(408,274,196,137,90,78,51,40,30,22,15) +y_dash<-log(y,base=exp(1)) +m1<-lm(y~x) +m2<-lm(y_dash~x) +ei_std1<-rstandard(m1) +ei_std2<-rstandard(m2) + +par(mfrow=c(2,2)) +plot(x,y,main="Scatterplot") +abline(m1) +plot(x,ei_std1,xlab="x",ylab="e*",main="Residual plot from linear regression for the data") +abline(0,0) + +#To find the coefficients +beta0<-m2$coefficients[1] +beta1<-round(m2$coefficients[2],digits=4) + +y_cap<-(exp(1)^(beta0))*(exp(1)^(beta1*x)) + +df<-data.frame(x,y,y_dash,y_cap) +print(df) + +plot(x,ei_std2,ylab="e*",main="Standardized residuals(after transforming) vs. x") +abline(0,0) +plot(y,y_cap,main="ycap vs. y") +abline(lm(y_cap~y)) + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.7/Ex13_7.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.7/Ex13_7.R new file mode 100644 index 00000000..b1c8bba5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.7/Ex13_7.R @@ -0,0 +1,29 @@ +#Ex13.7, Page 544 + +Thickness<-c(220,220,220,220,370,370,370,370,440,440,440,440,680,680,680,680,860,860,860,860) +Strength<-c(24.0,22.0,19.1,15.5,26.3,24.6,23.1,21.2,25.2,24.0,21.7,19.2,17.0,14.9,13.0,11.8,12.2,11.2,6.6,2.8) + +df<-data.frame(Thickness,Strength) +cat("Regression model:\n") +relation<-lm(Strength~Thickness+I(Thickness^2)) +print(summary(relation)) + +cat("Analysis of variance:\n") +model<-lm(Strength~poly(Thickness,2)) +a<-aov(model,data=df) +print(summary(a)) + +#To find confidence and prediction intervals +cat("\nWhen thickness=500\n") +cat("95% CI:\n") +print(predict(relation,newdata=data.frame(Thickness=500),interval="confidence")) +cat("95% PI:\n") +print(predict(relation,newdata=data.frame(Thickness=500),interval="prediction")) + +cat("\nWhen thickness=800\n") +cat("95% CI:\n") +print(predict(relation,newdata=data.frame(Thickness=800),interval="confidence")) +cat("95% PI:\n") +print(predict(relation,newdata=data.frame(Thickness=800),interval="prediction")) + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.8/Ex13_8.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.8/Ex13_8.R new file mode 100644 index 00000000..b2ced406 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.8/Ex13_8.R @@ -0,0 +1,22 @@ +#Ex13.8, Page 546 +#Answers may vary slightly due to rounding off of values + +#From Ex13.7 +Thickness<-c(220,220,220,220,370,370,370,370,440,440,440,440,680,680,680,680,860,860,860,860) +Strength<-c(24.0,22.0,19.1,15.5,26.3,24.6,23.1,21.2,25.2,24.0,21.7,19.2,17.0,14.9,13.0,11.8,12.2,11.2,6.6,2.8) +df<-data.frame(Thickness,Strength) +relation<-lm(df$Strength~poly(df$Thickness,2),data=df) +a<-summary(aov(relation,data=df)) +print(a) + +n<-20 +k<-2 +SSE<-a[[1]][, 'Sum Sq'][2] +SST<-a[[1]][, 'Sum Sq'][1]+a[[1]][, 'Sum Sq'][2] +R2<-1-(SSE/SST) +print(paste("R-squared value:",R2)) + +#To find variance +sigma2<-SSE/(n-(k+1)) +print(paste("sigma^2:",sigma2)) +print(paste("sigma:",sqrt(sigma2))) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.9/Ex13_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.9/Ex13_9.R new file mode 100644 index 00000000..6c149a7f --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH13/EX13.9/Ex13_9.R @@ -0,0 +1,17 @@ +#Ex13.9, Page 548 +#Answers may vary slightly due to rounding off of values + +Thickness<-c(220,220,220,220,370,370,370,370,440,440,440,440,680,680,680,680,860,860,860,860) +Strength<-c(24.0,22.0,19.1,15.5,26.3,24.6,23.1,21.2,25.2,24.0,21.7,19.2,17.0,14.9,13.0,11.8,12.2,11.2,6.6,2.8) + +model<-lm(Strength~Thickness+I(Thickness^2)) + +new<-data.frame(Thickness=500) +y_cap<-predict(model,new) +print(paste("ycap when x=500:",y_cap)) + +#To find confidence and prediction intervals +cat("95% CI:\n") +print(predict(model,newdata=data.frame(Thickness=500),interval="confidence")) +cat("95% PI:\n") +print(predict(model,newdata=data.frame(Thickness=500),interval="prediction")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.1/Ex14_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.1/Ex14_1.R new file mode 100644 index 00000000..7aed2b17 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.1/Ex14_1.R @@ -0,0 +1,30 @@ +#Ex14.1, Page 597 +#Answers may vary slightly due to rounding off of value + +p<-c(9/16,3/16,3/16,1/16) +ni<-c(926,288,293,104) +n<-1611 +k<-4 +df<-k-1 + +npi<-round(n*p,digits=1) +df1<-data.frame(ni,npi) + +#To find contribution to chi square from each cell +chi<-c(NULL) +for(i in 1:length(ni)){ + s<-((ni[i]-npi[i])^2)/npi[i] + chi[i]<-s +} +print(paste("Chi-square values:")) +print(chi) + +sum<-sum(chi) +print(paste("Chi square value:",sum)) + +alpha<-0.1 +#To find chi square value +chival<-qchisq(1-alpha,df) +print(paste("Critical value:",chival)) + +if(sum < chival) print(paste("H0 cannot be rejected")) else print(paste("H0 can be rejected")) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.10/Ex14_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.10/Ex14_10.R new file mode 100644 index 00000000..c0c4b904 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.10/Ex14_10.R @@ -0,0 +1,40 @@ +#Ex14.10, Page 608 +#Answers may vary slightly from textbook values + +data<-c(204,108,140,152,158,129,175,146,157,174,192,194,144,152,135,223,145,231,115,131,129,142,114,173,226,155,166,220,180,172,143,148,171,143,124,158,144,108,189,136,136,197,131,95,139,181,165,142,162) + +n<-length(data) +mu_cap<-round(mean(data),digits=2) +sigma_cap<-round(sqrt((n-1)*(sd(data)^2)/n),digits=2) +print(paste("mu_cap:",mu_cap)) +print(paste("sigma_cap:",sigma_cap)) + +#To find estimated expected counts +interval<-c(-Inf,117.9,132.9,144.6,155.4,167.1,182.1,Inf) +p<-c(NULL) +npi<-c(NULL) +for(i in 1:length(interval)-1){ + p[i]<-pnorm(interval[i+1],mean=mu_cap,sd=sigma_cap)-pnorm(interval[i],mean=mu_cap,sd=sigma_cap) + npi[i]<-n*p[i] +} + +Cell<-c("(-Inf,117.9)","(117.9,132.9)","(132.9,144.6)","(144.6,155.4)","(155.4,167.1)","(167.1,182.1)","(182.1,Inf)") +Observed<-c(5,5,11,6,6,7,9) +Estimated_expected<-npi +data1<-data.frame(Cell,Observed,Estimated_expected) +print(data1) + +#To find chi-squared values +alpha<-0.95 +df1<-length(npi)-1 +m<-2 +q1<-qchisq(alpha,df=df1) +print(paste("X^2(0.05,k-1):",q1)) + +df2<-df1-m +q2<-qchisq(alpha,df=df2) +print(paste("X^2(0.05,k-1-m):",q2)) + + + + \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.12/Ex14_12.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.12/Ex14_12.R new file mode 100644 index 00000000..ebc718ba --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.12/Ex14_12.R @@ -0,0 +1,21 @@ +#Ex14.12, Page 611 + +#Package to be installed: DescTools +library(DescTools) + +yi<-c(-1.871,-1.404,-1.127,-0.917,-.742,-0.587,-0.446,-0.313,-0.186,-0.062,0.062,0.186,0.313,0.446,0.587,0.742,0.917,1.127,1.404,1.871) +xi<-c(24.46,25.61,26.25,26.42,26.66,27.15,27.31,27.54,27.74,27.94,27.98,28.04,28.28,28.49,28.50,28.87,29.11,29.13,29.50,30.88) + +z<-c(NULL) +#To find z percentiles +for(i in 1:length(xi)){ + z[i]<-round(qnorm(1-((i-0.5)/length(xi)),lower.tail=FALSE),digits=2) +} + +#Shapiro test is similar to Ryan-Joiner test which is not available in R +t<-shapiro.test(xi) +print(t) + +#To create normal probability plot +qqnorm(xi,datax=TRUE,ylab="Voltage",xlab="Probability",main="Normal probability plot") +qqline(xi,datax=TRUE) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.13/Ex14_13.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.13/Ex14_13.R new file mode 100644 index 00000000..ac96ebc5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.13/Ex14_13.R @@ -0,0 +1,31 @@ +#Ex14.13, Page 615 + +print(paste("Reason for nonconformity:")) +Blemish<-c(34,23,32) +Crack<-c(65,52,28) +Location<-c(17,25,16) +Missing<-c(21,19,14) +Other<-c(13,6,10) +Sample_size<-c(150,125,100) +df1<-data.frame(Blemish,Crack,Location,Missing,Other,Sample_size) +print(df1) + + +#Total values +Blemish_tot<-sum(Blemish) +Crack_tot<-sum(Crack) +Location_tot<-sum(Location) +Missing_tot<-sum(Missing) +Other_tot<-sum(Other) +Sample_tot<-sum(Sample_size) + +#H0: production lines are homogeneous +#Ha: production lines are not not homogeneous + +tbl<-cbind.data.frame(df1$Blemish,df1$Crack,df1$Location,df1$Missing,df1$Other) +c<-chisq.test(tbl,df1$Sample_size) +print(c) + +print(paste("P value:",c$p.value)) + +print(paste("H0 should not be rejected at levels 0.05 or 0.01")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.14/Ex14_14.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.14/Ex14_14.R new file mode 100644 index 00000000..3a1f30be --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.14/Ex14_14.R @@ -0,0 +1,30 @@ +#Ex14.14, Page 617 +#Answers may vary slightly due to rounding off of values + +O<-c(24,15,17,52,73,80,58,86,36) +E<-c(17.02,22.10,16.89,62.29,80.88,61.83,54.69,71.02,54.29) + +print(paste("Observed pricing policy")) +Observed<-matrix(data=O,nrow=3,ncol=3,byrow=TRUE) +rownames(Observed)<-c("Substandard","Standard","Modern") +colnames(Observed)<-c("Aggressive","Neutral","Nonaggressive") +print(Observed) + +print(paste("Expected pricing policy")) +Expected<-matrix(data=E,nrow=3,ncol=3,byrow=TRUE) +rownames(Expected)<-c("Substandard","Standard","Modern") +colnames(Expected)<-c("Aggressive","Neutral","Nonaggressive") +print(Expected) + +chi<-c(NULL) +for(i in 1:length(Observed)){ + chi[i]<-(Observed[i]-Expected[i])^2/(Expected[i]) +} +sum<-sum(chi) +print(paste("Chi square value:",sum)) + +alpha<-0.01 +#To find chi square value +chival<-qchisq(1-alpha,df=4) +print(paste("Critical value (Chi square):",chival)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.2/Ex14_2.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.2/Ex14_2.R new file mode 100644 index 00000000..684b684f --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.2/Ex14_2.R @@ -0,0 +1,38 @@ +#Ex14.2, Page 599 +#Answers may vary slightly due to rounding off of values + +p<-9/16 +n<-4 +k<-5 +df<-k-1 +b<-c(NULL) +prob<-dbinom(0:4,n,p) +print(prob) + +npi<-269*prob +print(npi) + +Observed<-c(16,45,100,82,26) +Expected<-npi + +df1<-data.frame(Observed,Expected) + +#To find contribution to chi square from each cell +chi<-c(NULL) +for(i in 1:length(prob)){ + s<-((Observed[i]-Expected[i])^2)/Expected[i] + chi[i]<-round(s,digits=3) +} +print(paste("Chi-square values:")) +print(chi) + +sum<-sum(chi) +print(paste("Chi square value:",sum)) + +alpha<-0.01 +#To find chi square value +chival<-qchisq(1-alpha,df) +print(paste("Critical value:",chival)) + +if(sum < chival) print(paste("H0 cannot be rejected")) else print(paste("H0 can be rejected")) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.3/Ex14_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.3/Ex14_3.R new file mode 100644 index 00000000..086440aa --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.3/Ex14_3.R @@ -0,0 +1,30 @@ +#Ex14.3, Page 600 +#Answers may vary slightly due to rounding off of values + +k<-24 +df<-k-1 +p<-1/24 + +#Cell counts +Observed<-c(52,73,89,88,68,47,58,47,48,53,47,34,21,31,40,24,37,31,47,34,36,44,78,59) +npi<-1186*p +Expected<-c(NULL) +for(i in 1:length(Observed)){ + Expected[i]<-npi +} +chi<-c(NULL) +for(i in 1:length(Observed)){ + s<-((Observed[i]-Expected[i])^2)/Expected[i] + chi[i]<-round(s,digits=3) +} +sum<-sum(chi) +print(paste("Chi square value:",sum)) + +alpha<-0.01 +#To find chi square value +chival<-qchisq(1-alpha,df) +print(paste("Critical value:",chival)) + +if(sum < chival) print(paste("H0 cannot be rejected")) else print(paste("H0 can be rejected")) + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.4/Ex14_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.4/Ex14_4.R new file mode 100644 index 00000000..5e8dcdf9 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.4/Ex14_4.R @@ -0,0 +1,31 @@ +#Ex14.4, Page 600 +#Answers may vary slightly due to rounding off fo values + +#Cell counts +Observed<-c(21,17,12,16,10,15,19,10) +p<-1/8 +n<-120 +k<-8 +df<-k-1 +npi<-n*p + +Expected<-c(NULL) +for(i in 1:length(Observed)){ + Expected[i]<-npi +} +chi<-c(NULL) +for(i in 1:length(Observed)){ + s<-((Observed[i]-Expected[i])^2)/Expected[i] + chi[i]<-round(s,digits=3) +} +sum<-sum(chi) +print(paste("Chi square value:",sum)) + +alpha<-0.1 +#To find chi square value +chival<-qchisq(1-alpha,df) +print(paste("Critical value:",chival)) + +if(sum < chival) print(paste("H0 cannot be rejected")) else print(paste("H0 can be rejected")) + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.5/Ex14_5.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.5/Ex14_5.R new file mode 100644 index 00000000..74406708 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.5/Ex14_5.R @@ -0,0 +1,16 @@ +#Ex14.5, Page 603 + +Type<-c("Observed") +M<-c(125) +MN<-c(225) +N<-c(150) +print(paste("Observed counts:")) +df<-data.frame(Type,M,MN,N) +print(df) + +n<-500 + +n1<-M +n2<-MN +theta<-(2*n1+n2)/(2*n) +print(paste("Resulting estimator:",theta)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.6/Ex14_6.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.6/Ex14_6.R new file mode 100644 index 00000000..102d1625 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.6/Ex14_6.R @@ -0,0 +1,29 @@ +#Ex14.6, Page 604 +#Answers may slightly due to rounding off of values + +k<-3 +m<-1 +theta<-0.475 +n<-500 +npi1<-500*theta^2 +npi2<-n*2*theta*(1-theta) +npi3<-n-npi1-npi2 + +Observed<-c(125,225,150) +Estimated_expected<-c(npi1,npi2,npi3) + +chi<-c(NULL) +for(i in 1:length(Observed)){ + s<-((Observed[i]-Estimated_expected[i])^2)/Estimated_expected[i] + chi[i]<-round(s,digits=3) +} +sum<-sum(chi) +print(paste("Chi square value:",sum)) + +alpha<-0.05 +df<-k-m-1 +#To find chi square value +chival<-qchisq(1-alpha,df) +print(paste("Critical value:",chival)) + +if(sum < chival) print(paste("H0 is rejected")) else print(paste("H0 can be rejected")) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.9/Ex14_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.9/Ex14_9.R new file mode 100644 index 00000000..26751b18 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH14/EX14.9/Ex14_9.R @@ -0,0 +1,36 @@ +#Ex14.9, Page 608 +#Answers may vary slightly due to rounding off of values + +k<-5 +m<-1 +mu<-2.10 +n<-48 +df<-k-m-1 + +Frequency<-c(9,9,10,14,6) + +npi<-c(NULL) +for(i in 1:(k-1)){ + num<-(exp(1)^((-1)*mu))*(mu^(i-1)) + npi[i]<-n*(num/factorial(i-1)) + +} +npi[5]<-n-npi[1]-npi[2]-npi[3]-npi[4] +print(npi) + +chi<-c(NULL) +for(i in 1:length(Frequency)){ + s<-((Frequency[i]-npi[i])^2)/npi[i] + chi[i]<-round(s,digits=3) +} +sum<-sum(chi) +print(paste("Chi square value:",sum)) + +alpha<-0.05 +#To find chi square value +chival<-qchisq(1-alpha,df) +print(paste("Critical value:",chival)) + +if(sum < chival) print(paste("H0 is not rejected since",sum,"<",chival)) else print(paste("H0 can be rejected")) + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.1/Ex15_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.1/Ex15_1.R new file mode 100644 index 00000000..7beb4e1d --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.1/Ex15_1.R @@ -0,0 +1,9 @@ +#Ex15.1, Page 629 + +library(stats) + +x<-c(494.6,510.8,487.5,493.2,502.6,485.0,495.9,498.2,501.6,497.3,492.0,504.3,499.2,493.5,505.8) +y<-x-500 + +#Performing Wilcoxon signed rank test using wilcox.test function +print(wilcox.test(y)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.10/Ex15_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.10/Ex15_10.R new file mode 100644 index 00000000..68913398 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.10/Ex15_10.R @@ -0,0 +1,44 @@ +#Ex15.10, Page 647 +#Answers may vary slightly due to rounding off of values + +data<-c(23.1,57.6,10.5,23.6,11.9,54.6,21.0,20.3,22.7,53.2,9.7,19.6,13.8,47.1,13.6,23.6,22.5,53.7,10.8,21.1,13.7,39.2,13.7,16.3,22.6,53.1,8.3,21.6,13.3,37.0,14.8,14.8) +m1<-matrix(data,nrow=4,dimnames=list(c("Fear","Happiness","Depression","Calmness"),c("1","2","3","4","5","6","7","8")),byrow=TRUE) +print(m1) + +#To find ranks of respective data +r1<-rank(m1[,1]) +r2<-rank(m1[,2]) +r3<-rank(m1[,3]) +r4<-rank(m1[,4]) +r5<-rank(m1[,5]) +r6<-rank(m1[,6]) +r7<-rank(m1[,7]) +r8<-rank(m1[,8]) +data1<-data.frame(r1,r2,r3,r4,r5,r6,r7,r8) +cat("\nRanks of data:\n") +print(data1) + +I<-nrow(data1) +J<-ncol(data1) + +#To find rank sum and mean with respect to each plate length type +ri<-c(NULL) +ri2<-c(NULL) +for(i in 1:nrow(data1)){ + ri[i]<-sum(data1[i,]) + ri2[i]<-(ri[i])^2 +} +df1<-data.frame(ri,ri2) +print(df1) + +#To find test statistic +Fr<-(12/(I*J*(I+1)))*sum(ri2)-3*J*(I+1) +print(paste("Test statistic value:",Fr)) + +#To find chi-square value +alpha<-0.95 +chival<-qchisq(alpha,df=I-1) +print(paste("Chi-squared value:",chival)) + +if(Fr=z1 || z<=z1) print(paste("H0 is rejected")) else print(paste("H0 is not rejected")) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.6/Ex15_6.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.6/Ex15_6.R new file mode 100644 index 00000000..1933128c --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.6/Ex15_6.R @@ -0,0 +1,10 @@ +#Ex15.6, Page 642 +#Interval values may vary slightly..... + +#Given data +averages<-c(4.51,4.55,4.59,4.705,4.72,4.745,4.76,4.795,4.835,4.90,4.915,4.93,4.99,5.005,5.08,5.09,5.13,5.285,5.30,5.375,5.655,5.67,5.695,5.85,5.865,5.94,6.235,6.80) + +print(summary(averages)) + +#To display confidence intervals of the data +print(wilcox.test(averages,conf.int=TRUE,conf.level=0.95)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.8/Ex15_8.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.8/Ex15_8.R new file mode 100644 index 00000000..e38ff038 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.8/Ex15_8.R @@ -0,0 +1,18 @@ +#Ex15.8, Page 643 +#Answers vary from that of text book(CI in text=>(4830,8220)) + +Epoxy<-c(10860,11120,11340,12130,14380,13070) +Other<-c(4590,4850,6510,5640,6390,0) + +dat<-data.frame(Crush_Strength=c(Epoxy,Other),Bark_board=rep(c("Epoxy","Other"),each=6)) +print(dat) + +#To display differences between crushing strengths of both bark boards +o<-outer(Epoxy,Other,"-") +print(o) + +#To find corresponding CI intervals +print(wilcox.test(Crush_Strength~Bark_board,data=dat,conf.int=TRUE,conf.level=0.95)) + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.9/Ex15_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.9/Ex15_9.R new file mode 100644 index 00000000..27f8856e --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH15/EX15.9/Ex15_9.R @@ -0,0 +1,42 @@ +#Ex15.9, Page 646 +#Answers may vary slightly due to rounding off of values + +data<-c(309.2,309.7,311.0,316.8,326.5,349.8,409.5,331.0,347.2,348.9,361.0,381.7,402.1,404.5,351.0,357.1,366.2,367.3,382.0,392.4,409.9,346.7,362.6,384.2,410.6,433.1,452.9,461.4,407.4,410.7,419.9,441.2,441.8,465.8,473.4) +m1<-matrix(data,nrow=5,dimnames=list(c("4''","6''","8''","10''","12''")),byrow=TRUE) +print(m1) + +N<-length(data) + +#To find ranks of respective data +r1<-matrix(rank(m1),nrow=5) +cat("Ranks of data\n") +print(r1) + +I<-nrow(r1) +J<-ncol(r1) + +#To find rank sum and mean with respect to each plate length type +ri<-c(NULL) +ribar<-c(NULL) +for(i in 1:nrow(r1)){ + ri[i]<-sum(r1[i,]) + ribar[i]<-round(mean(r1[i,]),digits=2) +} +df1<-data.frame(ri,ribar) +cat("Rank sum and mean\n") +print(df1) + +#To find k value +sum<-0 +for(j in 1:nrow(r1)){ + sum<-sum+(ri[j])^2/J +} +k<-(12/(N*(N+1)))*sum-3*(N+1) +print(paste("k value:",k)) + +#To find chi-square value +alpha<-0.99 +chival<-qchisq(alpha,df=I-1) +print(paste("Chi-squared value:",chival)) + +if(k>=chival) print(paste("H0 is not rejected since",k,">=",chival)) else print(paste("H0 is rejected")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.1/Ex16_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.1/Ex16_1.R new file mode 100644 index 00000000..c1e55086 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.1/Ex16_1.R @@ -0,0 +1,15 @@ +#Ex16.1, Page 655 +#Answers may vary slightly due to rounding off of values + +#Package to be installed: qcc(Quality control charts) +library(qcc) + +Vis_obs<-c(10.37,10.48,10.77,10.47,10.84,10.48,10.41,10.40,10.33,10.73,10.41,10.00,10.37,10.47,10.46,10.44,10.65,10.73,10.39,10.59,10.47,10.40,10.24,10.37,10.46,10.19,10.24,10.22,10.26,10.75,10.53,10.52,10.38,10.35,10.45,10.68,10.60,10.50,10.60,10.46,10.68,10.42,10.72,10.75,10.23,10.67,10.55,10.71,10.69,10.35,10.36,10.58,10.54,10.31,10.53,10.50,10.46,10.69,10.49,10.30,10.25,10.71,10.34,10.75,10.56,10.32,10.26,10.83,10.27,10.35,10.64,10.38,10.27,10.40,10.37) +s<-c(rep(1:25,3)) + +q<-qcc.groups(Vis_obs,s) + +#To plot X-bar chart +q1<-qcc(q,type="xbar",center=10.5,std.dev=0.18) +plot(q1) +print(summary(q1)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.10/Ex16_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.10/Ex16_10.R new file mode 100644 index 00000000..80f56c14 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.10/Ex16_10.R @@ -0,0 +1,14 @@ +#Ex16.10, Page 680 + +sigma<-0.004 +kbar<-0.74 +delta<-0.003 + +n<-round((2*kbar*sigma/delta)^2,digits=0) +print(paste("Sample size:",n)) + +hbar<-3.2 +h<-(sigma/sqrt(n))*hbar +print(paste("h value:",h)) + +print(paste("Out of control signal if d>",h,"or e>",h)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.11/Ex16_11.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.11/Ex16_11.R new file mode 100644 index 00000000..00c4ceb5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.11/Ex16_11.R @@ -0,0 +1,17 @@ +#Ex16.11, Page 681 + +P<- function(p) {(1-p)^50+50*p*(1-p)^49+1225*p^2*(1-p)^48} + +p<-c(0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,0.12,0.15) + +#Finding P(A) values +PA<-c(NULL) +for(i in 1:length(p)){ + PA[i]<-round(P(p[i]),digits=3) +} + +df<-data.frame(p,PA) +print(df) + +#To plot data +plot(p,PA,ylab="P(A)",main="Curve plotting P(A) and p values") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.12/Ex16_12.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.12/Ex16_12.R new file mode 100644 index 00000000..65747bf3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH16/EX16.12/Ex16_12.R @@ -0,0 +1,61 @@ +#Ex16.12, Page 683 +#Answers may vary slightly due to rounding off of values + +#Package to be installed: AcceptanceSampling +library(AcceptanceSampling) + +c<-0:15 +np1<-c(0.051,0.355,0.818,1.366,1.970,2.613,3.285,3.981,4.695,5.425,6.169,6.924,7.690,8.464,9.246,10.040) +np2<-c(2.30,3.89,5.32,6.68,7.99,9.28,10.53,11.77,12.99,14.21,15.41,16.60,17.78,18.86,20.13,21.29) +p2_p1<-np2/np1 +df1<-data.frame(c,np1,np2,p2_p1) +print(df1) +cat("\n") + +AQL<-p1<-0.01 +LTPD<-p2<-0.045 + +#Ratio of p2 to p1 +r<-LTPD/AQL +print(paste("Ratio of p2 to p1:",r)) + +for(i in 1:length(c)){ + if(r>p2_p1[i+1] && rprobability that a household gets internet service +pa<-60/100 + +#P(B)=>probability that a household gets TV service +pb<-80/100 + +#P(A n B)=>probability that a household gets both services +pab<-50/100 + +#To find probability that a household gets at least one of the services +p1<-pa+pb-pab +cat("P(at least one service)=P(A U B) =",p1,"\n") + +pa_b<-p1-pa +pb_a<-p1-pb +#To find probability that a household gets exactly one service +p2<-pa_b+pb_a +cat("P(exactly one service)=",p2) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.19/Ex2_19.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.19/Ex2_19.R new file mode 100644 index 00000000..1a18aba9 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.19/Ex2_19.R @@ -0,0 +1,12 @@ +#Ex2.19, Page 67 + +#No of appliance dealers +n1<-5 + +#No of plumbing contractors +n2<-12 + +#No of electrical contractors +n3<-9 + +cat("There are",n1*n2*n3,"ways to first choose an appliance dealer, then a plumbing contractor and finally an electrical contractor") diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.21/Ex2_21.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.21/Ex2_21.R new file mode 100644 index 00000000..674ca7b6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.21/Ex2_21.R @@ -0,0 +1,10 @@ +#Ex2.21, Page 68 + +#No of teaching assistants +n<-10 +#No of questions in the first exam +k<-4 + +#To find number of permutations +p<-factorial(n)/factorial(n-k) +cat("The professor could give",p,"different four-question exam papers without using the same graders") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.22/Ex2_22.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.22/Ex2_22.R new file mode 100644 index 00000000..7dae33c0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.22/Ex2_22.R @@ -0,0 +1,20 @@ +#Ex2.22, Page 69 +#Answers may vary slightly due to rounding off of values + +#Total no of songs +n<-100 + +#No of songs by the Beatles +m<-10 + +#Probability that the 1st Beatles song heard is the 5th song played +t<-5 +p1<-(factorial(n-m)/factorial(n-m-(t-1))*m/(factorial(n)/factorial(n-t))) +cat("P(1st B is 5th song played):",p1,"\n") + +#Probability that the 1st Beatles song heard is the 1st,2nd,3rd,4th or 5th song played +p2<-0 +for(i in 1:5){ + p2<-p2+(choose(n-i,m-1))/(choose(n,m)) +} +cat("P(1st B is 1st,2nd,3rd,4th or 5th song played):",p2,"\n") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.23/Ex2_23.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.23/Ex2_23.R new file mode 100644 index 00000000..075cfa03 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.23/Ex2_23.R @@ -0,0 +1,23 @@ +#Ex2.23, Page 70 +#Answers may vary slightly due to rounding off of values + +#Total no of printers +n<-25 +l<-10 +i<-15 + +#Probability that 6 random printers selected will have 3 laser printers +r1<-6 +r<-3 +ND3<-(choose(l,r)*choose(i,r))/choose(n,r1) +cat("P(3 laser printers are selected among the 6 selected):",ND3,"\n") + + +#To find the probability that at least 3 inkjet printers are selected +prob<-0 +for(j in 3:6){ + num<-choose(i,j)*choose(l,r1-j) + denom<-choose(n,r1) + prob<-prob+(num/denom) +} +cat("P(at least 3 inkjet printers are selected):",prob,"\n") diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.25/Ex2_25.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.25/Ex2_25.R new file mode 100644 index 00000000..bc4b98a8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.25/Ex2_25.R @@ -0,0 +1,21 @@ +#Ex2.25, Page 74 + +#Probability that memory card is purchased +pa<-0.6 + +#Probability that battery is purchased +pb<-0.4 + +#Probability that both memory card and battery is purchased +pab<-0.3 + +#Probability that an optional card was purchased given that individuals purchased extra battery +pa_b<-pab/pb +cat("P(A|B)=",pa_b,"\n") +cat("Of all individuals who purchased an extra battery,",pa_b*100,"% purchased an optional memory card\n") + +#Probability that an additional battery was purchased given that individuals purchased an optional memory card +pb_a<-pab/pa +cat("P(B|A)=",pb_a,"\n") + +if(pa_b!=pb_a) print(paste("P(A|B) is not equal to P(B|A)")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.26/Ex2_26.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.26/Ex2_26.R new file mode 100644 index 00000000..06de2416 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.26/Ex2_26.R @@ -0,0 +1,34 @@ +#Ex2.26, Page 75 +#Answers may vary slightly due to rounding off of values + +#Package to be installed: VennDiagram +library(VennDiagram) + +#A=>Arts, B=>Books, C=>Cinema +pa<-0.14 +pb<-0.23 +pc<-0.37 +pab<-0.08 +pbc<-0.13 +pac<-0.09 +pabc<-0.05 + +#To illustrate the Venn diagram using the given probabilities +draw.triple.venn(area1=pa,area2=pb,area3=pc,n12=pab,n23=pbc,n13=pac,n123=pabc,category=c("Arts","Books","Cinema")) + +cat("With the help of Venn diagram:\n") +#P(A|B) +pa_b<-pab/pb +print(paste("P(A|B)=",pa_b)) + +#P(A|B U C) +pa_bUc<-(pab+pac-pabc)/(pb+pc-pbc) +print(paste("P(A|B U C)=",pa_bUc)) + +#P(A|reads at least once)=P(A|A U B U C) +pa_aUbUc<-pa/(pa+pb+pc-pab-pac-pbc+pabc) +print(paste("P(A|reads at least once)=",pa_aUbUc)) + +#P(A U B|C) +paUb_c<-(pac+pbc-pabc)/pc +print(paste("P(A U B|C)=",paUb_c)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.30/Ex2_30.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.30/Ex2_30.R new file mode 100644 index 00000000..e230a97b --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.30/Ex2_30.R @@ -0,0 +1,24 @@ +#Ex2.30, Page 78 + +# % of messages which come into account 1 +pa1<-70/100 + +# % of messages which come into account 2 +pa2<-20/100 + +# % of messages which come into account 3 +pa3<-10/100 + +# % of messages which are spam in account 1 +pb_a1<-1/100 + +# % of messages which are spam in account 2 +pb_a2<-2/100 + +# % of messages which are spam in account 3 +pb_a3<-5/100 + +#To find the probability that a randomly selected message is spam +#Using law of total probability +pb<-pa1*pb_a1+pa2*pb_a2+pa3*pb_a3 +print(paste("P(Randomly selected message is spam):",pb,"and thus,",pb*100,"% messages will be spam")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.36/Ex2_36.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.36/Ex2_36.R new file mode 100644 index 00000000..a648d222 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.36/Ex2_36.R @@ -0,0 +1,12 @@ +#Ex2.36, Page 85 +#Answers may vary slightly due to rounding off of values + +pai<-rep(0.9,times=6) + +#To find probability that system lifetime exceeds t0 +prob1<-pai[1]*pai[2]*pai[3]+pai[4]*pai[5]*pai[6]-(prod(pai)) +print(paste("P(system lifetime exceeds t0):",prob1)) + +#To find probability that system lifetime is at least t0 +prob2<-(1-(1-pai[1])*(1-pai[2]))^3 +print(paste("P(system lifetime is at least t0):",prob2)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.8/Ex2_8.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.8/Ex2_8.R new file mode 100644 index 00000000..6701dc38 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH2/EX2.8/Ex2_8.R @@ -0,0 +1,13 @@ +#Ex2.8, Page 53 + +A<-c(0,1,2,3,4) +B<-c(3,4,5,6) +C<-c(1,3,5) +U<-union(A,B) + +cat("A'=",setdiff(U,A),"\n") +cat("A U B =",union(A,B),"\n") +cat("A U C =",union(A,C),"\n") +cat("A n B =",intersect(A,B),"\n") +cat("A n C =",intersect(A,C),"\n") +cat("(A n C)'=",setdiff(U,intersect(A,C))) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.10/Ex3_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.10/Ex3_10.R new file mode 100644 index 00000000..a029cac1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.10/Ex3_10.R @@ -0,0 +1,55 @@ +#Ex3.10, Page 98 +#Let Y=>O+ blood type and N=>Other blood types +p1<-c('a','Y','b','Y','c','N','d','N','e','N') +row.names<-c("Blood donors","O+ blood donors") +column.names<-c("","","","","") +matrix.names<-c("Blood donation table") +p<-array(c(p1),dim=c(2,5,1),dimnames=list(row.names,column.names,matrix.names)) +print(p) +#p(1)=P(X=1) +c<-0 +for(i in 1:5) { + d<-p[2,i,1] + if(d=="Y"){ + c<-c+1 + } +} +d1<-c/5 +print(paste("p(1)=",d1)) + +#p(2)=P(X=2) +g<-0 +e<-0 +for(i in 1:5) { + h<-p[2,i,1] + if(h=="Y"){ + g<-g+1 + } + else{ + e<-e+1 + } +} +h<-g/5 +f<-e/4 +d2<-h*f +print(paste("p(2)=",d2)) + +#p(3)=P(X=3) +d3<-(e/5)*((e-1)/4)*(c/3) +print(paste("p(3)=",d3)) + +#p(4)=P(X=4) +d4<-(e/5)*((e-1)/4)*((e-2)/3) +print(paste("p(4)=",d4)) + +p2<-c(1,d1,2,d2,3,d3,4,d4) +row.names<-c("y","p(y)") +column.names<-c("","","","") +matrix.names<-c("PMF") +q<-array(c(p2),dim=c(2,4,1),dimnames=list(row.names,column.names,matrix.names)) +print(q) + +py<- 1:4 +y<- c(0.4,0.3,0.2,0.1) +plot(py,y,type="h",main="Line graph for pmf",xlab="y",ylab="p(y)") + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.13/Ex3_13.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.13/Ex3_13.R new file mode 100644 index 00000000..ff1a6088 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.13/Ex3_13.R @@ -0,0 +1,26 @@ +#Ex3.13, Page 101 + +y<-c(1,2,4,8,16) +p<-c(0.05,0.1,0.35,0.4,0.1) + +#F(1)=P(Y<=1)=p(1) +print(paste("F(1)=",cumsum(p[1]))) + +#F(2)=P(Y<=2)=p(2) +print(paste("F(2)=",max(cumsum(p[1:2])))) + +#F(4)=P(Y<=4)=p(4) +print(paste("F(4)=",max(cumsum(p[1:3])))) + +#F(8)=P(Y<=8)=p(8) +print(paste("F(8)=",max(cumsum(p[1:4])))) + +#F(16)=P(X<=16)=p(16) +print(paste("F(16)=",max(cumsum(p[1:5])))) + + + + + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.15/Ex3_15.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.15/Ex3_15.R new file mode 100644 index 00000000..0acf73bb --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.15/Ex3_15.R @@ -0,0 +1,16 @@ +#Ex3.15, Page 104 +a<-c(0,0.58,1,0.72,2,0.76,3,0.81,4,0.88,5,0.94) +row.names<-c("X","F(X)") +column.names<-c("","","","","","") +matrix.names<-c("Number of days of sick leave taken by a randomly selected employee") +b<-array(c(a),dim=c(2,6,1),dimnames=list(row.names,column.names,matrix.names)) +print(b) + +#P(2<=X<=5)=P(X=2,3,4,5) +p<-b[2,6,1]-b[2,2,1] +print(paste("P(2<=X<=5)=",p)) + +#P(X=3) +q<-b[2,4,1]-b[2,3,1] +print(paste("P(X=3)=",q)) + \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.16/Ex3_16.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.16/Ex3_16.R new file mode 100644 index 00000000..9ccb1633 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.16/Ex3_16.R @@ -0,0 +1,8 @@ +#Ex3.16, Page 107 + +x<-1:7 +w<-c(0.01,0.03,0.13,0.25,0.39,0.17,0.02) + +#Mean, m=sum of(xp(x)) +m<-weighted.mean(x,w) +print(paste("Population mean =",m)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.17/Ex3_17.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.17/Ex3_17.R new file mode 100644 index 00000000..a6f64ccc --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.17/Ex3_17.R @@ -0,0 +1,8 @@ +#Ex3.17, Page 107 + +x<-0:10 +w<-c(0.002,0.001,0.002,0.005,0.02,0.04,0.18,0.37,0.25,0.12,0.01) + +#Mean, m= sum of(xp(x)) +m<-weighted.mean(x,w) +print(paste("Population mean, E(X) =",m)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.23/Ex3_23.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.23/Ex3_23.R new file mode 100644 index 00000000..9fd0d92d --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.23/Ex3_23.R @@ -0,0 +1,14 @@ +#Ex3.23, Page 110 + +comp<-c(0,0.1,1,0.2,2,0.3,3,0.4) +row.names<-c("X","p(X)") +column.names<-c("","","","") +matrix.names<-c("X->Number of computers sold") +p<-array(c(comp),dim=c(2,4,1),dimnames=list(row.names,column.names,matrix.names)) +print(p) + +x<-0:3 +w<-c(0.1,0.2,0.3,0.4) +#h(x)<-profit associated with selling x units<-revenue-cost<-800x-900 +print(paste("Expected profit:$",weighted.mean(800*x-900,w))) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.24/Ex3_24.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.24/Ex3_24.R new file mode 100644 index 00000000..69b48c71 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.24/Ex3_24.R @@ -0,0 +1,17 @@ +#Ex3.24, Page 111 +#Answers may slightly vary due to rounding off of values + +w<-c(0.3,0.25,0.15,0.05,0.1,0.15) +x<-c(1,2,3,4,5,6) + +#Mean, m= sum of(xp(x)) +m<-weighted.mean(x,w) +print(paste("Mean =",m)) + +#Variance, v= sum of(x-m)p(x) +v<-weighted.mean((x-m)^2,w) +print(paste("Variance =",v)) + +#Standard deviation, sd= square root(variance) +print(paste("Standard deviation=", sqrt(v))) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.25/Ex3_25.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.25/Ex3_25.R new file mode 100644 index 00000000..b186fab0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.25/Ex3_25.R @@ -0,0 +1,13 @@ +#Ex3.25, Page 112 + +#Alternative formula for variance, v= E(X^2)-(m^2) +x<-1:6 +w<-c(0.3,0.25,0.15,0.05,0.1,0.15) + +#E(X^2)= sum of (X^2)p(X) +e<-weighted.mean(x^2,w) +print(paste("E(X^2)=",e)) + +#Variance +mean<-weighted.mean(x,w) +print(paste("Variance through alternative formula =",e-(mean^2))) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.26/Ex3_26.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.26/Ex3_26.R new file mode 100644 index 00000000..56a82b37 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.26/Ex3_26.R @@ -0,0 +1,23 @@ +#Ex3.26, Page 113 + +x<-0:3 +w<-c(0.1,0.2,0.3,0.4) + +#Mean, m = sum of (xp(x)) +m<-weighted.mean(x,w) +print(paste("Mean, E(X)=",m)) + +#To find E(X^2) +e<-weighted.mean(x^2,w) +print(paste("E(X^2)=",e)) + +#To find V(X) +v<-e-(m^2) +print(paste("V(X)=",v)) + +#Profit function, h(X)=800X-900 +#Variance +print(paste("Variance=",(800^2)*v)) + +#Standard deviation +print(paste("Standard deviation =",sqrt((800^2)*v))) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.29/Ex3_29.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.29/Ex3_29.R new file mode 100644 index 00000000..82a303af --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.29/Ex3_29.R @@ -0,0 +1,25 @@ +#Ex3.29, Page 115 +#Number of licensed restaurants +n<-50 +#Number of restaurants having at least one serious health code violation +f<-15 +#Number of restaurants having no serious health code violations +s<-35 +#P(s on first trial) +p1<-s/n; +print(paste("P(s on first trial)=",p1)) + +#P(s on second trial)=P(ss)+P(fs) +p2<-(s/n)*((s-1)/(n-1))+(f/n)*(s/(n-1)) +print(paste("P(s on second trial)=",p2)) +print(paste("Similarly, P(s on ith trial) = 0.7 for i=3,4,5")) + +#P(s on fifth trial|ssss) +p3<-(s-4)/(n-4) +print(paste("P(s on fifth trial|ssss)=",p3)) + +#P(s on fifth trial|ffff) +p4<-s/(n-4) +print(paste("P(s on fifth trial|ffff)=",p4)) + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.30/Ex3_30.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.30/Ex3_30.R new file mode 100644 index 00000000..20937bf4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.30/Ex3_30.R @@ -0,0 +1,14 @@ +#Ex3.30, Page 116 +#Number of licensed drivers +n<-500000 +#Number of licensed drivers who are insured +s<-400000 +#P(s on second trial after s on first trial) +p1<-(s-1)/(n-1) +print(paste("P(s on 2|s on 1)=",p1)) + +#P(s on tenth trial after s on ninth trial) +p2<-(s-9)/(n-9) +print(paste("P(s on 10|s on 9)=",p2)) + +print(paste("The experiment is binomial with n=10 and p=0.8")) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.31/Ex3_31.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.31/Ex3_31.R new file mode 100644 index 00000000..3c9b24b8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.31/Ex3_31.R @@ -0,0 +1,13 @@ +#Ex3.31, Page 118 +#Answers may slightly vary due to rounding off of values + +#n=6, p=0.5 + +#P(X=3) +print(paste("P(X=3)=",dbinom(3,size=6,prob=0.5))) + +#Probability that at least 3 three prefer S is +print(paste("P(X>=3)=",pbinom(3,size=6,prob=0.5))) + +#Probability that at most one prefers S is +print(paste("P(X<=1)=",pbinom(1,size=6,prob=0.5))) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.1/Ex3_32_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.1/Ex3_32_1.R new file mode 100644 index 00000000..0f3d7860 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.1/Ex3_32_1.R @@ -0,0 +1,13 @@ +#Example 3.32.1, Page 118 +#Binomial distribution: n=15, p=2 +#The answers may slightly vary due to rounding off of values + +#Probability that at most 8 copies fail the test +#P(X<=8) +a=pbinom(8,size=15,prob=0.2) +print(paste("The probability that at most 8 copies fail the test is", a)) + + + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.2/Ex3_32_2.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.2/Ex3_32_2.R new file mode 100644 index 00000000..75743fc6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.2/Ex3_32_2.R @@ -0,0 +1,10 @@ +#Example 3.32.2, Page 118 +#Binomial distribution: n=15, p=0.2 +#The answers may slightly vary due to rounding off of values + +#Probability that exactly 8 copies fail +#P(X=8)=P(X<=8)-P(X<=7) +a<-0.999 +b=pbinom(7,size=15,prob=0.2) +print(paste("The probability that exactly 8 copies fail the test", a-b)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.3/Ex3_32_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.3/Ex3_32_3.R new file mode 100644 index 00000000..bf6299a8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.3/Ex3_32_3.R @@ -0,0 +1,15 @@ +#Example 3.32.3, Page 119 +#Binomial distribution: n=15, p=0.2 +#The answers may slightly vary due to rounding off of values + +#Probability that at least 8 copies fail +#P(X>=8)=1-P(X<=7) +b<-0.996 +c=1-b +print(paste("The probability that at least 8 copies fail", c)) + + + + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.4/Ex3_32_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.4/Ex3_32_4.R new file mode 100644 index 00000000..596daa30 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.32.4/Ex3_32_4.R @@ -0,0 +1,11 @@ +#Example 3.32.4, Page 119 +#Binomial distribution: n=15, p=0.2 +#The answers may slightly vary due to rounding off of values + +#Probability that between 4 to 7 copies fail +#P(4<=X<=7)=P(X=4)+P(X=5)+P(X=6)+P(X=7) +d=pbinom(7,15,0.2)-pbinom(3,15,0.2) +print(paste("The probability that between 4 to 7 copies fail is", d)) + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.33/Ex3_33.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.33/Ex3_33.R new file mode 100644 index 00000000..93b0214c --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.33/Ex3_33.R @@ -0,0 +1,11 @@ +#Ex3.33, Page 119 +#Answers may vary slightly due to rounding off of values + +#n=20 +#P(X>=5) when p=0.10 +p1<-1-pbinom(4,size=20,prob=0.1) +print(paste("P(X>=5 when p=.1)=",p1)) + +#P(X<=4) when p=0.2 +p2<-pbinom(4,size=20,prob=0.2) +print(paste("P(X<=4 when p=.2)=",p2)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.34/Ex3_34.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.34/Ex3_34.R new file mode 100644 index 00000000..df4c4a1f --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.34/Ex3_34.R @@ -0,0 +1,21 @@ +#Ex3.34,Page 120 +n<-10 +p<-0.75 + +#Mean, E(x)=np +e<-n*p +print(paste("Mean=",e)) + +#Variance, V(X)=npq +v<-n*p*(1-p) +print(paste("Variance=",v)) + +#Standard deviation=sqrt(V(X)) +s<-sqrt(v) +print(paste("Standard deviation=",s)) + +#P(X= 7or8)=P(X=7)+P(X=8) +prob1=dbinom(0:7,size=10,prob=0.75) +prob2=dbinom(0:8,size=10,prob=0.75) +c<-max(prob1)+max(prob2) +print(paste("P(X= 7or8)=",c)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.35/Ex3_35.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.35/Ex3_35.R new file mode 100644 index 00000000..7dda1b47 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.35/Ex3_35.R @@ -0,0 +1,11 @@ +#Ex3.35, Page 123 +#Answers may slightly vary due to rounding off of values + +N<-20 +n<-5 +M<-12 + +#P(X=2)=h(2,5,12,20) +x<-2 +h<-(choose(M,x)*choose(N-M,n-x))/choose(N,n) +print(paste("h(2;5,12,20)=",h)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.36/Ex3_36.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.36/Ex3_36.R new file mode 100644 index 00000000..e4e3969e --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.36/Ex3_36.R @@ -0,0 +1,19 @@ +#Ex3.36, Page 124 +#Answers may slightly vary due to rounding off of values + +N<-25 +n<-10 +M<-5 + +#P(X=2)=h(2,10,5,25) +x<-2 +h1<-(choose(M,X)*choose(N-M,n-x))/choose(N,n) +print(paste("P(X=2)=",h1)) + +#P(X<=2)=P(X=0)+P(X=1)+P(X=2) +s<-0 +for(i in 0:2){ + h2<-(choose(M,i)*choose(N-M,n-i))/choose(N,n) + s<-s+h2 +} +print(paste("P(X<=2)=",s)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.37/Ex3_37.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.37/Ex3_37.R new file mode 100644 index 00000000..eca8feae --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.37/Ex3_37.R @@ -0,0 +1,21 @@ +#Ex3.37, Page 125 + +n<-10 +M<-5 +N<-25 +p<-M/N + +#E(X)=np +e<-n*p +print(paste("Mean=",e)) + +#V(X)=npq +v<-n*p*(1-p) +print(paste("Variance without replacement=",v)) + +#Estimate of N when M=5, n=10 and x=16 +M<-100 +n<-40 +x<-16 +ne<-(M*n)/x +print(paste("Estimate is", ne)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.38/Ex3_38.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.38/Ex3_38.R new file mode 100644 index 00000000..270dc6ad --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.38/Ex3_38.R @@ -0,0 +1,10 @@ +#Ex3.38, Page 126 +#Answers may slightly vary due to rounding off of values + +#P(X=10)=nb(10;5,0.2) +prob1=dnbinom(0:10,size=5,prob=0.2) +print(paste("P(X=10)=",max(prob1))) + +#P(X<=10) +s<-pnbinom(0:10,size=5,prob=0.2) +print(paste("P(X<=10)=",max(s))) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.39/Ex3_39.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.39/Ex3_39.R new file mode 100644 index 00000000..a5ee29e7 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.39/Ex3_39.R @@ -0,0 +1,12 @@ +#Ex3.39, Page 129 +#Answers may slightly vary due to rounding off of values + +u<-4.5 +#Poisson distribution +#P(X=5) +p1<-dpois(5,lambda=u) +print(paste("P(X=5)=",p1)) + +#P(X<=5) +p2<-ppois(5,lambda=u) +print(paste("P(X<=5)=",p2)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.40/Ex3_40.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.40/Ex3_40.R new file mode 100644 index 00000000..eee02095 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.40/Ex3_40.R @@ -0,0 +1,14 @@ +#Ex3.40, Page 129 +#Answers may vary slightly due to rounding off of values + +n<-400 +p<-0.005 + +#P(X=1):b(x;n,p)->p(x;u) +u<-n*p +p1<-dpois(1,lambda=u) +print(paste("P(X=1)=",p1)) + +#P(X<=3) +p2<-ppois(3,lambda=u) +print(paste("P(X<=3)=",p2)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.41/Ex3_41.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.41/Ex3_41.R new file mode 100644 index 00000000..5e95e546 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.41/Ex3_41.R @@ -0,0 +1,7 @@ +#Ex3.41, Page 130 +#Answer may slightly vary due to rounding off of value + +u<-4.5 +#Standard deviation +sd<-sqrt(u) +print(paste("Standard deviation=",sd)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.42/Ex3_42.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.42/Ex3_42.R new file mode 100644 index 00000000..d9df143d --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.42/Ex3_42.R @@ -0,0 +1,10 @@ +#Ex3.42, Page 131 +#Answer may slightly vary due to rounding off of value + +alpha<-6 +t<-0.5 +l<-alpha*t + +#P(X>=1)=1-P(X=0) +p<-1-dpois(0,lambda=l) +print(paste("P(X>=1)=",p)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.7/Ex3_7.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.7/Ex3_7.R new file mode 100644 index 00000000..f19546c5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH3/EX3.7/Ex3_7.R @@ -0,0 +1,22 @@ +#Example 3.7, Page 97 +#Storing all probabilities in an array +prob<-c(0.05,0.1,0.15,0.25,0.20,0.15,0.10) +P<-array(c(prob),dim=c(1,7,1)) + +#P(X<=2)=P(X=0)+P(X=1)+P(X=2) +p1<-P[1,1,1]+P[1,2,1]+P[1,3,1] +print(paste("P(X<=2) =",p1)) + +#P(X>=3)=1-P(X<=2) +p2<-1-(P[1,1,1]+P[1,2,1]+P[1,3,1]) +print(paste("P(X>=3) =",p2)) + +#P(2<=X<=5)=P(X=2,3,4 or 5) +p3<-P[1,3,1]+P[1,4,1]+P[1,5,1]+P[1,6,1] +print(paste("P(2<=X<=5) =",p3)) + +#P(21.25) +#Variable to store result(1-P(Z<=1.25)) +a=1-pnorm(1.25,0,1) +print(paste("The standard normal probability is", a)) + + +#To plot the standard normal distribution bell curve +curve(dnorm, xlim = c(-3, 3), ylim = c(0, 0.4), xlab = "z", ylab="f(z)",lwd=2, col="black") +z = 1.25 +pnorm(z) +x = c(z, seq(z, 3, by=.001), 3) +#plot(x) +y = c(0, dnorm(seq(z, 3, by=.001)), 0) +#plot(y) +polygon(x, y, col="red") + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.c/Ex4_13_c.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.c/Ex4_13_c.R new file mode 100644 index 00000000..59e23d66 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.c/Ex4_13_c.R @@ -0,0 +1,25 @@ +#Example 4.13.C, Page 154 +#The answers may slightly vary due to rounding off of values + +#P(Z<=-1.25)=P(Z>=1.25) +#Variable to store result(1-P(Z<=1.25)) +a=1-pnorm(1.25,0,1) +print(paste("The standard normal probability is", a)) + +#To plot the standard normal distribution bell curve +x=seq(-3,3,length=200) +y=dnorm(x) +plot(x,y,type="l", lwd=2, col="black") +x=seq(-3,-1.25,length=200) +y=dnorm(x) +polygon(c(-3,x,-1.25),c(0,y,0),col="red") + +#To plot the standard normal distribution bell curve +curve(dnorm, xlim = c(-3, 3), ylim = c(0, 0.4), xlab = "z", ylab="f(z)",lwd=2, col="black") +z = -1.25 +pnorm(z) +x = c(-3, seq(-3, z, by=.001), z) +#plot(x) +y = c(0, dnorm(seq(-3, z, by=.001)), 0) +#plot(y) +polygon(x, y, col="red") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.d/Ex4_13_d.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.d/Ex4_13_d.R new file mode 100644 index 00000000..629f1241 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.13.d/Ex4_13_d.R @@ -0,0 +1,18 @@ +#Example 4.13.d, Page 154 +#The answers may slightly vary due to rounding off of values + +#P(-0.38<=Z<=1.25) +#Variable to store result(1-P(Z<=1.25)) +a<-pnorm(1.25,0,1)-pnorm(-0.38,0,1) +print(paste("The standard normal probability is", a)) + +#To plot the standard normal distribution bell curve +curve(dnorm, xlim = c(-3, 3), ylim = c(0, 0.4), xlab = "z", ylab="f(z)",lwd=2, col="black") +z1 = 1.25 +z2 = -0.38 +pnorm(z) +x = c(z2, seq(z2, z1, by=.001), z1) +#plot(x) +y = c(0, dnorm(seq(z2, z1, by=.001)), 0) +#plot(y) +polygon(x, y, col="red") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.14/Ex4_14.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.14/Ex4_14.R new file mode 100644 index 00000000..e9a78197 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.14/Ex4_14.R @@ -0,0 +1,25 @@ +#Ex4.14, Page 155 +#Answers may slightly vary due to rounding off of values + +print(paste("99th percentile:",qnorm(0.99))) +print(paste("1st percentile:",qnorm(0.01))) + +#Blue=> 99th percentile +#Red=> 1st percentile +plot.new() +title(main="Blue: 99th percentile +Red: 1st percentile") +curve(dnorm, xlim = c(-3, 3), ylim = c(0, 0.5), xlab = "z", ylab="f(z)") +prob1 = 0.99 +x1= c(-3, seq(-3, qnorm(prob1), by=.001), qnorm(prob1)) +y1= c(0, dnorm(seq(-3, qnorm(prob1), by=.001)), 0) +polygon(x1, y1, col="blue") + +par(new=TRUE) + +prob2 = 0.01 +x2= c(-3, seq(-3, qnorm(prob2), by=.0001), qnorm(prob2)) +y2= c(0, dnorm(seq(-3, qnorm(prob2), by=.0001)), 0) +polygon(x2, y2, col="red") + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.15/Ex4_15.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.15/Ex4_15.R new file mode 100644 index 00000000..508e23ff --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.15/Ex4_15.R @@ -0,0 +1,25 @@ +#Ex4.15, Page 156 +#Answers may slightly vary due to rounding off of values + +#z(.05) +x<-0.05 +z<-100*(1-x) + +plot.new() +title(main="Red: z(0.05) +Blue: -z(0.05)") + +#z(.05) +print(paste(z,"th percentile:",qnorm(z/100))) +curve(dnorm, xlim = c(-3, 3), ylim = c(0, 0.5), xlab = "z", ylab="f(z)") +prob = z/100 +x = c(-3, seq(-3, qnorm(prob), by=.001), qnorm(prob)) +y = c(0, dnorm(seq(-3, qnorm(prob), by=.001)), 0) +polygon(x, y, col="red") + +#-z(.05) +print(paste("-z(.05)",-qnorm(z/100))) +x = c(-3, seq(-3, -qnorm(prob), by=.001), -qnorm(prob)) +y = c(0, dnorm(seq(-3, -qnorm(prob), by=.001)), 0) +polygon(x, y, col="blue") + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.16/Ex4_16.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.16/Ex4_16.R new file mode 100644 index 00000000..3b4ab9a6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.16/Ex4_16.R @@ -0,0 +1,26 @@ +#Ex4.16, Page 158 +#Answers may slightly vary due to rounding off of values + +#P(1.00<=X<=1.75) +#Mean=>1.25, Standard deviation=>0.46 + +title(main="P(1.00<=X<=1.75)") +a<-pnorm(1.00,mean=1.25,sd=0.46) +b<-pnorm(1.75,mean=1.25,sd=0.46) +c<-b-a +print(paste("P(1.00<=X<=1.75)=",c)) + +#To plot the standard normal distribution bell curve +curve(dnorm, xlim = c(-3, 3), ylim = c(0, 0.4), xlab = "z", ylab="f(z)",lwd=2, col="black") +z<-1.75 +# Cumulative density function of the standard normal distribution +pnorm(z) +x<-c(1.00, seq(1.00, z, by=.001), z) +#plot(x) +y<-c(0, dnorm(seq(1.00, z, by=.001)), 0) +#plot(y) +polygon(x, y, col="red") + +#P(X>2) +d<-1-pnorm(2,mean=1.25,sd=0.46) +print(paste("P(X>2)=",d)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.17/Ex4_17.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.17/Ex4_17.R new file mode 100644 index 00000000..55664ddf --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.17/Ex4_17.R @@ -0,0 +1,14 @@ +#Ex4.17, Page 158 +#Answers may slightly vary due to rounding off of values + +#P(-1.00<=Z<=1.00) +a<-pnorm(1.00,0,1)-pnorm(-1.00,0,1) +print(paste("P(X is within 1 standard deviation of its mean):",a)) + +#P(-2.00<=Z<=2.00) +b<-pnorm(2.00,0,1)-pnorm(-2.00,0,1) +print(paste("P(X is within 2 standard deviation of its mean):",b)) + +#P(-3.00<=Z<=3.00) +c<-pnorm(3.00,0,1)-pnorm(-3.00,0,1) +print(paste("P(X is within 3 standard deviation of its mean):",c)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.18/Ex4_18.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.18/Ex4_18.R new file mode 100644 index 00000000..c37e3098 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.18/Ex4_18.R @@ -0,0 +1,25 @@ +#Ex4.18, Page 159 +#Answers may slightly vary due to rounding off of values + +m<-64 +sd<-0.78 +#P(X>c)=0.05 +p<-0.005 +#P(X<=c)=1-P(X>c) +s<-(1-p)*100 +print(paste("c is the",s,"th percentile of the normal distribution with mean=64 and sd=0.78")) +q<-qnorm(s/100) +print(paste("Therefore",s,"th percentile:",q)) + +c<-m+q*sd +print(paste("c=",c,"oz")) + +#Plotting 99.5th percentile +plot.new() +title(main="99.5th percentile",sub="Shaded area=>0.995") +curve(dnorm, xlim = c(-3, 3), ylim = c(0, 0.5), xlab = "z", ylab="f(z)") +prob = 0.995 +x1= c(-3, seq(-3, qnorm(prob), by=.001), qnorm(prob)) +y1= c(0, dnorm(seq(-3, qnorm(prob), by=.001)), 0) +polygon(x1, y1, col="blue") + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.20/Ex4_20.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.20/Ex4_20.R new file mode 100644 index 00000000..dfe29ff2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.20/Ex4_20.R @@ -0,0 +1,20 @@ +#Ex4.20, Page 161 +#Answers may vary slightly due to rounding off of values + +n<-50 +p<-25/100 +q<-1-p +m<-12.5 +sd<-3.06 +x<-n*p +y<-sqrt(n*p*q) +z<-n*q +if(x>=10 && z>=10){ + #P(X<=10) + a<-pnorm(10+0.5,mean=x,sd=y) + print(paste("P(X<=10)=",a)) + + #P(5<=X<=15) + b<-pnorm(15+0.5,mean=x,sd=y)-pnorm(5-0.5,mean=x,sd=y) + print(paste("P(5<=X<=15)=",b)) +} \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.21/Ex4_21.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.21/Ex4_21.R new file mode 100644 index 00000000..f50be4e3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.21/Ex4_21.R @@ -0,0 +1,14 @@ +#Ex4.21, Page 166 +#Answers may slightly vary due to rounding off of values + +#E(X)=6MPa=1/lambda +e<-6 +lambda<-1/e +#Probability that stress range is at most 10MPa +p<-pexp(10,lambda) +print(paste("P(stress range is at most 10MPa)=",p)) + +#Probability that stress range is between 5 and 10MPa +q<-pexp(10,lambda)-pexp(5,lambda) +print(paste("P(stress range is between 5 and 10MPa)=",q)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.22/Ex4_22.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.22/Ex4_22.R new file mode 100644 index 00000000..19e3e5b1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.22/Ex4_22.R @@ -0,0 +1,12 @@ +#Ex4.22, Page 167 +#Answer may slightly vary due to rounding off of value + +alpha<-0.5 + +#P(X>2)=1-P(X<=2) +x<-2 +p<-1-pexp(x,alpha) +print(paste("P(X>2)=",p)) + +t<-1/alpha +print(paste("The expected time between successive calls is",t,"days")) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.23/Ex4_23.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.23/Ex4_23.R new file mode 100644 index 00000000..1ccd9538 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.23/Ex4_23.R @@ -0,0 +1,12 @@ +#Ex4.23, Page 169 +#Answers may slightly vary due to rounding off of values + +alpha<-2 + +#P(3<=X<=5) +a<-pgamma(5,shape=alpha)-pgamma(3,shape=alpha) +print(paste("P(3<=X<=5)=",a)) + +#P(X>4)=1-P(X<=4) +b<-1-pgamma(4,shape=alpha) +print(paste("P(reaction time is more than 4 sec)=",b)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.24/Ex4_24.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.24/Ex4_24.R new file mode 100644 index 00000000..2b144bd4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.24/Ex4_24.R @@ -0,0 +1,30 @@ +#Ex4.24, Page 169 +#Answers may slightly vary due to rounding off of values + +#alpha +a<-8 +#beta +b<-15 + +#E(X) +e<-a*b +print(paste("E(X)=",e)) + +#V(X) +v<-a*(b^2) +print(paste("V(X)=",v)) + +#SD +sd<-sqrt(v) +print(paste("Standard deviation =",sd)) + +#P(60<=X<=120)=P(X<=120)-P(X<=60) +p1<-pgamma(120/b,shape=a)-pgamma(60/b,a) +print(paste("P(mouse survives between 60 and 120 weeks)=",p1)) + +#P(X>=30)=1-P(X<30) +p2<-1-pgamma(30/b,a) +print(paste("P(mouse survives at least 30 weeks)=",p2)) + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.25/Ex4_25.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.25/Ex4_25.R new file mode 100644 index 00000000..464db31d --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.25/Ex4_25.R @@ -0,0 +1,18 @@ +#Ex4.25, Page 173 +#Answers may slightly vary due to rounding off of values + +alpha<-2 +beta<-10 + +#P(X<=10) +p1<-pweibull(10,alpha,beta) +print(paste("P(X<=10)=",p1)) + +#P(X<=25) +p2<-pweibull(25,alpha,beta) +print(paste("P(X<=25)=",p2)) + +#To find c value which separates 5% of all engines having largest NOx emissions from remaining 95% +per<-5/100 +c<-sqrt((-1)*(10^2)*log(per)) +print(paste(c,"is the 95th percentile of the emission distribution")) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.26/Ex4_26.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.26/Ex4_26.R new file mode 100644 index 00000000..5c528023 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.26/Ex4_26.R @@ -0,0 +1,14 @@ +#Ex4.26, Page 173 +#Answers may slightly vary due to rounding off of values + +#alpha +a<-1.3 +#beta +b<-0.8 +#gamma +g<-4 + +#P(5<=X<=6) +p1<-pweibull(6-g,a,b)-pweibull(5-g,a,b) +print(paste("P(air void volume of a specimen is between 5% and 6%)=",p1)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.27/Ex4_27.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.27/Ex4_27.R new file mode 100644 index 00000000..876a7533 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.27/Ex4_27.R @@ -0,0 +1,22 @@ +#Ex4.27, Page 175 +#Answers may slightly vary due to rounding off of values + +m<-0.353 +s<-0.754 + +e<-exp(m+(s^2)/2) +print(paste("E(X)=",e)) + +v<-exp(2*m+(s^2))*(exp(s^2)-1) +print(paste("V(X)=",v)) + +#P(1<=X<=2) +l1<-log(1,base=exp(1)) +l2<-log(2,base=exp(1)) +p<-pnorm(l2,m,s)-pnorm(l1,m,s) +print(paste("P(maximum pit depth is between 1 and 2 mm)=",p)) + +#To find c such that only 1% of all specimens have a maximum pit depth excceding c +per<-1/100 +c<-exp(1)^(qnorm(1-per)*s+m) +print(paste(c,"is the 99th percentile of the maximum pit depth distribution")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.28/Ex4_28.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.28/Ex4_28.R new file mode 100644 index 00000000..cc3787dd --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.28/Ex4_28.R @@ -0,0 +1,21 @@ +#Ex4.28, Page 177 + +#Optimistic time +A<-2 + +#Pessimistic time +B<-5 + +#alpha +a<-2 +#beta +b<-3 + +#E(X) +e<-A+(B-A)*(a/(a+b)) +print(paste("Mean=",e)) + +c<-(1/(B-A))*((gamma(a+b))/(gamma(a)*gamma(b))) +f1<-function(x) {c*(((x-A)/(B-A))^(a-1))*(((B-x)/(B-A))^(b-1))} +p<-integrate(f1,lower=2,upper=3) +print(paste("P(it take atmost 3 days to lay the foundation)=",p$value)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.29/Ex4_29.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.29/Ex4_29.R new file mode 100644 index 00000000..44df107f --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.29/Ex4_29.R @@ -0,0 +1,21 @@ +#Ex4.29, Page 181 + +old.par<-par(mfrow=c(1,2)) + +#To plot first sample +Percentage1<-c(5, 15, 25, 35, 45) +z_percentile1<-c(qnorm(5/100), qnorm(15/100), qnorm(25/100), qnorm(35/100), qnorm(45/100)) +Sample_observation1<-c(-1.91, -1.25, -0.75, -0.53, 0.2) +df1<-data.frame(Percentage1, z_percentile1, Sample_observation1) +print(df1) +plot(z_percentile1,Sample_observation1) + +#To plot second sample +Percentage2<-c(55, 65, 75, 85, 95) +z_percentile2<-c(qnorm(55/100), qnorm(65/100), qnorm(75/100), qnorm(85/100), qnorm(95/100)) +Sample_observation2<-c(0.35, 0.72, 0.87, 1.40, 1.56) +df2<-data.frame(Percentage2, z_percentile2, Sample_observation2) +print(df2) +plot(z_percentile2,Sample_observation2) + +par(old.par) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.30/Ex4_30.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.30/Ex4_30.R new file mode 100644 index 00000000..15b6fa18 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.30/Ex4_30.R @@ -0,0 +1,14 @@ +#Ex4.30, Page 182 + +old.par<-par(mfrow=c(1,1)) +n<-20 +z_percentile<-c(qnorm((1-0.5)/n), qnorm((2-0.5)/n), qnorm((3-0.5)/n), qnorm((4-0.5)/n), qnorm((5-0.5)/n), + qnorm((6-0.5)/n), qnorm((7-0.5)/n), qnorm((8-0.5)/n), qnorm((9-0.5)/n), qnorm((10-0.5)/n), + qnorm((11-0.5)/n), qnorm((12-0.5)/n), qnorm((13-0.5)/n), qnorm((14-0.5)/n), qnorm((15-0.5)/n), + qnorm((16-0.5)/n), qnorm((17-0.5)/n), qnorm((18-0.5)/n), qnorm((19-0.5)/n), qnorm((20-0.5)/n)) +Sample_observation<-c(24.46, 25.61, 26.25, 26.42, 26.66, 27.15, 27.31, 27.54, 27.74, 27.94, 27.98, 28.04, 28.28, 28.49, 28.50, 28.87, 29.11, 29.13, 29.50, 30.88) +df<-data.frame(z_percentile, Sample_observation) +print(df) +plot(z_percentile,Sample_observation) + +par(old.par) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.31/Ex4_31.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.31/Ex4_31.R new file mode 100644 index 00000000..535d1c02 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.31/Ex4_31.R @@ -0,0 +1,13 @@ +#Ex4.31, Page 186 + +old.par<-par(mfrow=c(1,1)) + +Percentile<-c(-2.97, -1.82, -1.25, -0.84, -0.51, -0.23, 0.05, 0.33, 0.64, 1.10) +x<-c(282, 501, 741, 851, 1072, 1122, 1202, 1585, 1905, 2138) +lnx<-c(log(282,base=exp(1)),log(501,base=exp(1)), log(741,base=exp(1)), log(851,base=exp(1)), log(1072,base=exp(1)), + log(1122,base=exp(1)), log(1202,base=exp(1)), log(1585,base=exp(1)), log(1905,base=exp(1)), log(2138,base=exp(1))) +df<-data.frame(Percentile,x,lnx) +print(df) +plot(Percentile,lnx) + +par(old.par) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.4/Ex4_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..507fc636 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,19 @@ +#Example 4.4, Page 139* +#n=10,M=5,N=25 + +#f(x)>=0 +#Area under density curve +a<-(1/360)*360 + +#P(90<=X<=180) +f1<-function(x) {(x^0)/360} +p1<-integrate(f1,lower=90,upper=180) +print(paste("Probability that angle is between 90 and 180 is",p1$value)) + +#P(0<=X<=90)+P(270<=X<360) +f2<-function(x) {(x^0)/360} +p2<-integrate(f2,lower=0,upper=90) +f3<-function(x) {(x^0)/360} +p3<-integrate(f3,lower=270,upper=360) +p4<-p2$value+p3$value +print(paste("P(angle of occurrence is within 90 degrees of reference line)=",p4)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.5/Ex4_5.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..4d22ded7 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,15 @@ +#Example 4.5, Page 141 +#The answers may slightly vary due to rounding off of values + +#Taking upper limit as 1000 instead of infinity +integrand<-function(x) {.15*exp(-.15*(x-.5))} +#f(x)>=0 +#To show that integral from negative infinity to infinity is 1 +c<-integrate(integrand,lower=0.5,upper=Inf) +#To access the list of values of integrate by name +print(paste("Value of integral is",c$value)) + +#To find P(X<5) +d<-integrate(integrand,lower=0.5,upper=5) +print(paste("Thus, probability that headway time is atmost 5 sec:",d$value)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.7/Ex4_7.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.7/Ex4_7.R new file mode 100644 index 00000000..4312c79b --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH4/EX4.7/Ex4_7.R @@ -0,0 +1,18 @@ +#Ex4.7, Page 145* + +#if x<0, F(X)=0 +#if 0<=x<=2, F(X)=(x/8)+(3/16)(x^2) +#if x>2, F(X)=1 + +load<-function(x){ + f<-(x/8)+(3/16)*(x^2) + return(f) +} + +#P(1<=X<=1.5)=P(X=1.5)-P(X=1) +p1<-load(1.5)-load(1) +print(paste("P(1<=X<=1.5)=",p1)) + +#P(X>1)=1-P(X<=1) +p2<-1-load(1) +print(paste("P(load exceeds 1)=",p2)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.1/Ex5_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.1/Ex5_1.R new file mode 100644 index 00000000..bbc95a58 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.1/Ex5_1.R @@ -0,0 +1,10 @@ +#Ex5.1, Page 194 + +m<-matrix(c(0.20,0.05,0.10,0.15,0.20,0.30),nrow=2,ncol=3) +rownames(m)<-c("100","250") +colnames(m)<-c("0","100","200") +print(m) + +#To find P(Y>=100) +prob<-m[1,2]+m[1,3]+m[2,2]+m[2,3] +print(paste("P(Y>=100)=",prob)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.12/Ex5_12.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.12/Ex5_12.R new file mode 100644 index 00000000..f40a83e4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.12/Ex5_12.R @@ -0,0 +1,14 @@ +#Ex5.12, Page 203 +#Answers may slightly vary due to rounding off of values + +#Function when X=0.8: (1/34)(24+30(y^2)) + +#P(Y<=0.5) given X=0.8 +f1<-function(y) {(1/34)*(24+30*(y^2))} +f<-integrate(f1,lower=0,upper=0.5) +print(paste("P(walk-up facility is busy atmost half the time)=",f$value)) + +#E(Y) given that X=0.8 +f2<-function(y) {y*(1/34)*(24+30*(y^2))} +p<-integrate(f2,lower=0,upper=1) +print(paste("Expected proportion of time that walk-up facility is busy:",p$value)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.14/Ex5_14.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.14/Ex5_14.R new file mode 100644 index 00000000..91a6603a --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.14/Ex5_14.R @@ -0,0 +1,16 @@ +#Ex5.14, Page 207 + +#Joint pdf +f<-function(x,y) {24*x*y} + +almonds<-1 +cashews<-1.5 +peanuts<-0.5 + +#Total cost of the contents of a can +h<-function(x,y) {almonds*x+cashews*y+(1-x-y)*peanuts} + +#Expected total cost +integral<-Vectorize(function(x) {sapply(x,function(z) {integrate(function(y) h(x,y)*f(x,y),0,1-z)$value})}) +prob<-integrate(integral,0,1) +print(paste("Expected total cost:$",prob$value)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.15/Ex5_15.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.15/Ex5_15.R new file mode 100644 index 00000000..22232bf4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.15/Ex5_15.R @@ -0,0 +1,59 @@ +#Ex5.15, Page 208 + +x<-c(100,250) +y<-c(0,100,200) + +m1<-matrix(c(0.20,0.05,0.10,0.15,0.20,0.30),nrow=2,ncol=3) +rownames(m1)<-c("100","250") +colnames(m1)<-c("0","100","200") +print(m1) +cat("\n") + +m2<-matrix(c(0.5,0.5),nrow=1,ncol=2) +rownames(m2)<-c("p(x)") +colnames(m2)<-c("100","250") +print(m2) +cat("\n") + +m3<-matrix(c(0.25,0.25,0.5),nrow=1,ncol=3) +rownames(m3)<-c("p(y)") +colnames(m3)<-c("0","100","200") +print(m3) +cat("\n") + +x1<-c(0.5,0.5) +j<-1 +mu_x<-0 + +for(i in x){ + if(j<=length(x1)){ + mu_x<-mu_x+i*x1[j] + j=j+1 + } +} +cat("mu_X=",mu_x,"\n\n") + +y1<-c(0.25,0.25,0.5) +k<-1 +mu_y<-0 + +for(i in y){ + if(k<=length(y1)){ + mu_y<-mu_y+i*y1[k] + k=k+1 + } +} +cat("mu_Y=",mu_y,"\n\n") + +p<-c(0.2,0.1,0.20,0.05,0.15,0.30) +sum<-0 +k<-1 +for(i in x){ + for(j in y){ + if(k<=length(p)){ + sum=sum+(i-175)*(j-125)*p[k] + k=k+1 + } + } +} +print(paste("Cov(X,Y):",sum)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.18/Ex5_18.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.18/Ex5_18.R new file mode 100644 index 00000000..51629156 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.18/Ex5_18.R @@ -0,0 +1,20 @@ +#Ex5.18, Page 210 + +x<-c(-4,4,2,-2) +y<-c(1,-1,2,-2) +xy<-x*y +w<-c(1/4,1/4,1/4,1/4) +m<-weighted.mean(xy,w) +print(paste("E(XY)=",m)) + +#Cov(XY)=E(XY)-ux.uy +ux<-0 +uy<-0 +cov<-m-(ux*uy) +print(paste("Cov(XY)=",cov)) + +print(paste("Complete absence of any linear relationship")) + +#To scatterplot +df<-data.frame(x,y) +plot(x,y) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.19/Ex5_19.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.19/Ex5_19.R new file mode 100644 index 00000000..4d4d5166 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.19/Ex5_19.R @@ -0,0 +1,31 @@ +#Ex5.19, Page 212 +#Answers may vary slightly due to rounding off of values + +#alpha +a<-2 + +#beta +b<-5 + +#Mean +u<-b*gamma(1+(1/a)) +print(paste("Mean, E(X)=",u)) + +#Variance +v<-(b^2)*{gamma(1+(2/a))-(gamma(1+(1/a)))^2} +print(paste("Variance=",v)) + +#Standard deviation +s<-sqrt(v) +print(paste("Standard deviation=",s)) + +#Median +med<-b*(log(2,base=exp(1)))^(1/a) +print(paste("Median=",med)) + +q<-qweibull(0.99,shape=a,scale=b) +curve(dweibull(x,a,b),from=0,to=q,ylab='density') + +if(u>med){ + print(paste("Mean exceeds median because of the distribution's positive skew")) +} \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.2/Ex5_2.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.2/Ex5_2.R new file mode 100644 index 00000000..2b74c67e --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.2/Ex5_2.R @@ -0,0 +1,32 @@ +#Ex5.2, Page 195 + +m<-matrix(c(0.20,0.05,0.10,0.15,0.20,0.30),nrow=2,ncol=3) +rownames(m)<-c("100","250") +colnames(m)<-c("0","100","200") +print(m) +cat("\n") + +px_100<-apply(m,1,sum)[1] +px_250<-apply(m,1,sum)[2] +cat("px(100)=",px_100,"\n") +cat("px(250)=",px_250,"\n\n") + +cat("Marginal pmf of X:\n") +cat("p(x)=",px_100,"when x=100,250\n") +cat("p(x)=0 otherwise\n\n") + +py_0<-apply(m,2,sum)[1] +py_100<-apply(m,2,sum)[2] +py_200<-apply(m,2,sum)[3] +cat("py(0)=",py_0,"\n") +cat("py(100)=",py_100,"\n") +cat("py(200)=",py_200,"\n\n") + +cat("Marginal pmf of Y:\n") +cat("p(y)=",py_0,"when y=0,100\n") +cat("p(y)=",py_200,"when y=200\n") +cat("p(y)=0 otherwise\n\n") + +#To find P(Y>=100) +prob<-py_100+py_200 +cat("P(Y>=100)=",prob) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.24/Ex5_24.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.24/Ex5_24.R new file mode 100644 index 00000000..7757d53d --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.24/Ex5_24.R @@ -0,0 +1,39 @@ +#Ex5.24, Page 223 + +n<-25 +u<-28000 +s<-5000 + +#E(Mean) +print(paste("E(Mean)=",u)) + +#E(T0) +t<-n*u +print(paste("E(T0)=",t)) + +#Standard deviation of mean +sm<-s/sqrt(n) +print(paste("SD of mean:",sm)) + +#Standard deviation of T0 +st<-s*sqrt(n) +print(paste("SD of T0:",st)) + +#When sample size increases to n=100 +print(paste("When n=100:")) +n<-100 +#E(Mean) +print(paste("E(Mean)=",u)) + +#E(T0) +t<-n*u +print(paste("E(T0)=",t)) + +#Standard deviation of mean +sm<-s/sqrt(n) +print(paste("SD of mean:",sm)) + +#Standard deviation of T0 +st<-s*sqrt(n) +print(paste("SD of T0:",st)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.25/Ex5_25.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.25/Ex5_25.R new file mode 100644 index 00000000..f9e767f1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.25/Ex5_25.R @@ -0,0 +1,31 @@ +#Ex5.25, Page 224 +#Answers may slightly vary due to rounding off of values + +n<-5 + +#Mean(min) +m<-1.5 + +#Standard deviation(min) +sd<-0.35 + +ut<-n*m +print(paste("uT0:",ut)) + +vt<-n*(sd^2) +print(paste("vT0:",vt)) + +st<-sqrt(vt) +print(paste("sT0:",st)) + +#P(6<=T0<=8) +p1<-pnorm(8,mean=ut,sd=st)-pnorm(6,mean=ut,sd=st) +print(paste("P(6<=T0<=8)=",p1)) + +#Probability that the sample average time is atmost 2 min +u<-1.5 +s<-sd/sqrt(n) + +#P(Mean<=2.0) +p2<-pnorm(2,mean=u,sd=s) +print(paste("P(Mean<=2)=",p2)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.26/Ex5_26.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.26/Ex5_26.R new file mode 100644 index 00000000..07d33502 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.26/Ex5_26.R @@ -0,0 +1,13 @@ +#Ex5.26, Page 225 +#Answer may slightly vary due to rounding off of value + +n<-50 +m<-4 +sd<-1.5 + +ux<-m +sx<-sd/sqrt(n) + +#P(3.5<=Mean<=3.8) +p<-pnorm(3.8,mean=ux,sd=sx)-pnorm(3.5,mean=ux,sd=sx) +print(paste("P(3.5<=Mean<=3.8)=",p)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.27/Ex5_27.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.27/Ex5_27.R new file mode 100644 index 00000000..11c1141c --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.27/Ex5_27.R @@ -0,0 +1,13 @@ +#Ex5.27, Page 226 +#Answer may slightly vary due to rounding off of value + +n<-100 +m<-3.2 +sd<-2.4 + +ux<-m +sx<-sd/sqrt(n) + +#P(Mean>4)=1-P(Mean<=4) +p<-1-pnorm(4,mean=ux,sd=sx) +print(paste("P(Mean>4)=",p)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.29/Ex5_29.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.29/Ex5_29.R new file mode 100644 index 00000000..62a882c6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.29/Ex5_29.R @@ -0,0 +1,24 @@ +#Ex5.29, Page 231 +#Answers may vary slightly due to rounding off of values + +a1<-3.00 +a2<-3.20 +a3<-3.40 + +#Mean +u1<-1000 +u2<-500 +u3<-300 + +#Standard deviation +s1<-100 +s2<-80 +s3<-50 + +#Y=3.0X1+3.20X2+3.40X3 +EY<-a1*u1+a2*u2+a3*u3 +VY<-(a1^2)*(s1^2)+(a2^2)*(s2^2)+(a3^2)*(s3^2) +sY<-sqrt(VY) +print(paste("E(Y)=$",EY)) +print(paste("V(Y)=$",VY)) +print(paste("sY=$",sY)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.3/Ex5_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.3/Ex5_3.R new file mode 100644 index 00000000..bbabfc4f --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.3/Ex5_3.R @@ -0,0 +1,16 @@ +#Ex5.3, Page 196 +#Answers may ary slightly due to rounding off of values + +f<-function(x,y) {(6/5)*(x+y^2)} + +#To check whether pdf is legitimate +check_val<-integrate(function(y) {sapply(y,function(y) {integrate(function(x) f(x,y),0,1)$value})},0,1) +if(check_val$value==1) cat("PDF is legitimate\n\n") + +#P(0<=X<=1/4,0<=Y<=1/4) +low1<-0 +high1<-1/4 +low2<-0 +high2<-1/4 +integral<-integrate(function(y) {sapply(y,function(y) {integrate(function(x) f(x,y),low1,high1)$value})},low2,high2) +print(paste("P(0<=X<=1/4,0<=Y<=1/4)=",integral$value)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.30/Ex5_30.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.30/Ex5_30.R new file mode 100644 index 00000000..a6a23a09 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.30/Ex5_30.R @@ -0,0 +1,19 @@ +#Ex5.30, Page 232 +#Answers may slightly vary due to rounding off of values + +u1<-22 +u2<-26 +s1<-1.2 +s2<-1.5 + +#Mean +e<-u1-u2 +print(paste("E(X1-X2)=",e)) + +#Variance +v<-(s1^2)+(s2^2) +print(paste("V(X1-X2)=",v)) + +#Standard deviation +sd<-sqrt(v) +print(paste("SD=",sd)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.31/Ex5_31.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.31/Ex5_31.R new file mode 100644 index 00000000..7040b452 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.31/Ex5_31.R @@ -0,0 +1,10 @@ +#Ex5.31, Page 232 + +#Y=3.0X1+3.2X2+3.4X3 +u<-5620 +s<-429.46 + +#P(Y>4500) +p<-1-pnorm(4500,mean=u,sd=s) +print(paste("P(revenue exceeds 4500)=",p)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.4/Ex5_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.4/Ex5_4.R new file mode 100644 index 00000000..2fcec390 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.4/Ex5_4.R @@ -0,0 +1,11 @@ +#Ex5.4, Page 197 + +f<-function(x,y) {(6/5)*(x+y^2)} + +#Finding P(1/4<=Y<=3/4) using marginal pdf of Y +xlow<-0 +xhigh<-1 +ylow<-1/4 +yhigh<-3/4 +prob<-integrate(function(y) {sapply(y,function(y) {integrate(function(x) f(x,y),xlow,xhigh)$value})},ylow,yhigh) +print(paste("P(1/4<=Y<=3/4)=",prob$value)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.5/Ex5_5.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.5/Ex5_5.R new file mode 100644 index 00000000..a8f0221e --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.5/Ex5_5.R @@ -0,0 +1,16 @@ +#Ex5.5, Page 198 + +#Joint pdf +f<-function(x,y) {24*x*y} + +val<-Vectorize(function(x) {sapply(x,function(z) {integrate(function(y) f(x,y),0,1-z)$value})}) +check_val<-integrate(val,0,1)$value +if(check_val==1) print(paste("PDF is legitimate")) + +#Probability that two types of nuts together make up 50% of the can +#Taking A={(x,y):0<=x<=1,0<=y<=1,x+y<=0.5} +xlow<-0 +xhigh<-0.5 +integral<-Vectorize(function(x) {sapply(x,function(z) {integrate(function(y) f(x,y),0,0.5-z)$value})}) +prob<-integrate(integral,xlow,xhigh) +print(paste("P((X,Y)EA) =",prob$value)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.8/Ex5_8.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.8/Ex5_8.R new file mode 100644 index 00000000..db3fa750 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.8/Ex5_8.R @@ -0,0 +1,17 @@ +#Ex5.8, Page 200 +#Answers may vary slightly due to rounding off of values + +#Expected lifetimes are 1000 and 1200 hours +lambda1<-(1/1000) +lambda2<-(1/1200) + +#P(X1>=1500) +p1<-exp(-(lambda1)*1500) + +#P(X2>=1500) +p2<-exp(-(lambda2)*1500) + +#Joint PDF +#P(X1>=1500,X2>=1500) +p<-p1*p2 +print(paste("P(both component lifetimes are at least 1500 hours)=",p)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.9/Ex5_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.9/Ex5_9.R new file mode 100644 index 00000000..570fcec8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH5/EX5.9/Ex5_9.R @@ -0,0 +1,10 @@ +#Ex5.9, Page 201 +#Answer may slightly vary due to rounding off of value + +#Respective number and probabilities +n<-c(2,5,3) +p<-c(0.25,0.5,0.25) + +#Multinomial PMF +m<-dmultinom(n,prob=p) +print(paste("Multinomial PMF:",m)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.1/Ex6_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.1/Ex6_1.R new file mode 100644 index 00000000..17d7157e --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.1/Ex6_1.R @@ -0,0 +1,6 @@ +#Ex6.1, Page 241 + +x<-15 +n<-25 +p<-x/n +print(paste("Most reasonable estimate is",p)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.10/Ex6_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.10/Ex6_10.R new file mode 100644 index 00000000..c4c892f3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.10/Ex6_10.R @@ -0,0 +1,16 @@ +#Ex6.10, Page 251 +#Answers may vary slightly due to rounding off of values + +n<-25 +p<-0.6 +q<-1-p + +#To find estimated standard error +sp1<-sqrt((p*q)/n) +print(paste("Estimated standard error:",sp1)) + +#pq is largest when +p<-q<-0.5 +sp2<-sqrt((p*q)/n) +print(paste("Estimated standard error when pq is largest:",sp2)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.11/Ex6_11.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.11/Ex6_11.R new file mode 100644 index 00000000..a0bed243 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.11/Ex6_11.R @@ -0,0 +1,13 @@ +#Ex6.11, Page 252 +#Answers may slightly vary due to rounding off of values + +t<-c(41.53,18.73,2.99,30.34,12.33,117.52,73.02,223.63,4.00,26.78) + +#Mean +m<-mean(t) +print(paste("Mean:",m)) + +#lambda(l) +l<-1/m +print(paste("Reasonable estimate of lambda:",l)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.13/Ex6_13.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.13/Ex6_13.R new file mode 100644 index 00000000..87adfed7 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.13/Ex6_13.R @@ -0,0 +1,20 @@ +#Ex6.13, Page 257 +#Answers may vary slightly due to rounding off of values + +data<-c(152,115,109,94,88,137,152,77,160,165,125,40,128,123,136,101,62,153,83,69) +n<-length(data) + +#Mean +m<-mean(data) +print(paste("Mean:",m)) + +#Sum of x^2 +s<-sum(data^2)/n + +#alpha +alpha<-(m^2)/(s-(m^2)) +print(paste("Alpha:",alpha)) + +#beta +beta<-(s-(m^2))/m +print(paste("Beta:",beta)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.14/Ex6_14.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.14/Ex6_14.R new file mode 100644 index 00000000..a969f3e6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.14/Ex6_14.R @@ -0,0 +1,22 @@ +#Ex6.14, Page 257 +#Answers may vary slightly due to rounding off of values + +goals<-c(0,1,2,3,4,5,6,7,8,9,10) +freq<-c(29,71,82,89,65,45,24,7,4,1,3) + +#Mean +m<-weighted.mean(goals,freq) +print(paste("Mean=",m)) + +#To find sum of x^2 +ms<-weighted.mean(goals^2,freq) +print(paste("Sum of x^2/frequency=",ms)) + +#To find alpha +p_cap<-m/(ms-(m^2)) +print(paste("Alpha:",p_cap)) + +#To find beta +r_cap<-(m^2)/(ms-(m^2)-m) +print(paste("Beta:",r_cap)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.2/Ex6_2.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.2/Ex6_2.R new file mode 100644 index 00000000..a89d9c50 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.2/Ex6_2.R @@ -0,0 +1,21 @@ +#Ex6.2, Page 241 +#Answers may vary slightly due to rounding off of values + +volt<-c(24.46,25.61,26.25,26.42,26.66,27.15,27.31,27.54,27.74,27.94,27.98,28.04,28.28,28.49,28.50,28.87,29.11,29.13,29.50,30.88) + +#Estimator1 +x1<-mean(volt) +print(paste("Estimator(1):",x1)) + +#Estimator2 +x2<-median(volt) +print(paste("Estimator(2):",x2)) + +#Estimator3 +x3<-(min(volt)+max(volt))/2 +print(paste("Estimator(3):",x3)) + +#Estimator4 +volt<-setdiff(volt,c(volt[1],volt[2],volt[19],volt[20])) +x4<-mean(volt) +print(paste("Estimator(4):",x4)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.21/Ex6_21.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.21/Ex6_21.R new file mode 100644 index 00000000..6a59126c --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.21/Ex6_21.R @@ -0,0 +1,7 @@ +#Ex6.21, Page 262 +#Answers may slightly vary due to rounding off of values + +alpha<-11.9731 +beta<-77.0153 +m<-beta*gamma(1+(1/alpha)) +print(paste("Mean estimate:",m)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.3/Ex6_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.3/Ex6_3.R new file mode 100644 index 00000000..68c02975 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.3/Ex6_3.R @@ -0,0 +1,27 @@ +#Ex6.3, Page 242 +#Answers may vary slightly due to rounding off of values + +obs<-c(74.33,71.07,73.82,77.42,79.35,82.27,77.75,78.65,77.19,74.69, + 77.25,74.84,60.90,60.75,74.09,65.36,67.84,69.97,68.83,75.09, + 62.54,67.47,72.00,66.51,68.21,64.46,64.34,64.93,67.33,66.08, + 67.31,74.87,69.40,70.83,81.73,82.50,79.87,81.96,79.51,84.12, + 80.61,79.89,79.70,78.74,77.28,79.97,75.09,74.38,77.67,83.73, + 80.39,76.90) + +#Mean +print(paste("Mean=",mean(obs))) + +#Variance +print(paste("Point estimate of the population variance:",var(obs))) + +#Alternative formula +#To find numerator of s^2 +s1<-sum(obs) +s2<-sum(obs^2) +Sxx<-s2-(s1^2)/length(obs) + +#Standard deviation +print(paste("Point estimate of the population standard deviation:",sd(obs))) + +#Alterative estimator +print(paste("Alternative estimator of population variance:",Sxx/length(obs))) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.9/Ex6_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.9/Ex6_9.R new file mode 100644 index 00000000..2e0bc32a --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH6/EX6.9/Ex6_9.R @@ -0,0 +1,16 @@ +#Ex6.9, Page 251 +#Answers may slightly vary due to rounding off of values + +n<-20 +sigma<-1.5 + +#Standard error of mean +sigx<-sigma/sqrt(n) +print(paste("Standard error of mean:",sigx)) + +#Estimate of standard deviation +s<-1.462 + +sx<-s/sqrt(n) +print(paste("Estimated standard error:",sx)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.10/Ex7_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.10/Ex7_10.R new file mode 100644 index 00000000..f96f95d9 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.10/Ex7_10.R @@ -0,0 +1,11 @@ +#Ex7.10, Page 283 +#Answer may slightly vary due to rounding off of value + +mean<-17.17 +z<-qnorm(0.95) +n<-48 +sd<-3.28 + +#To find lower bound +c<-mean-(z*sd/sqrt(n)) +print(paste("Lower confidence bound for mean:",c)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.11/Ex7_11.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.11/Ex7_11.R new file mode 100644 index 00000000..f3160985 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.11/Ex7_11.R @@ -0,0 +1,32 @@ +#Ex7.11, Page 288 +#Answers may slightly vary due to rounding off of values +data<-c(6807.99,7637.06,6663.28,6165.03,6991.41,6992.23,6981.46,7569.75, + 7437.88,6872.39,7663.18,6032.28,6906.04,6617.17,6984.12,7093.71, + 7659.50,7378.61,7295.54,6702.76,7440.17,8053.26,8284.75,7347.95, + 7422.69,7886.87,6316.67,7713.65,7503.33,7674.99) + +n<-30 + +#To find mean +mean<-mean(data) +print(paste("Mean:",mean)) + +#To find standard deviation +s<-sd(data) +print(paste("Standard deviation:",s)) + +#To find confidence intervals +t<-qt(1-(0.05/2),df=n-1) +print(paste("Critical value,t:",t)) +error<-t*(s/sqrt(n)) + +#Left endpoint +l<-mean-error +print(paste("Left endpoint of interval:",l)) + +#Right endpoint +r<-mean+error +print(paste("Right endpoint of interval:",r)) + +#To plot the normal probability plot +qqnorm(data,main="Normal Probability of MOR") diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.12/Ex7_12.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.12/Ex7_12.R new file mode 100644 index 00000000..1a68c438 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.12/Ex7_12.R @@ -0,0 +1,29 @@ +#Ex7.12, Page 288 +#Answers may slightly vary due to rounding off of values + +data<-c(25.2,21.3,22.8,17.0,29.8,21.0,25.5,16.0,20.9,19.5) +print(data) + +n<-10 + +#To find mean +mean<-mean(data) +print(paste("Mean:",mean)) + +#To find standard deviation +s<-sd(data) +print(paste("Standard deviation:",s)) + +#To find confidence intervals +t<-qt(1-(0.05/2),df=n-1) +print(paste("Critical value,t:",t)) +error<-t*(s/sqrt(n)) + +#Left endpoint +l<-mean-error +print(paste("Left endpoint of interval:",l)) + +#Right endpoint +r<-mean+error +print(paste("Right endpoint of interval:",r)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.13/Ex7_13.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.13/Ex7_13.R new file mode 100644 index 00000000..06980b69 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.13/Ex7_13.R @@ -0,0 +1,20 @@ +#Ex7.13, Page 290 +#Answers may slightly vary due to rounding off of values + +mean<-21.9 +s<-4.134 +n<-10 + +#To find critical value +t<-qt(1-(0.05/2),df=n-1) +print(paste("Critical value,t:",t)) + +error<-t*s*sqrt(1+(1/n)) + +#Left endpoint +l<-mean-error +print(paste("Left endpoint of prediction interval:",l)) + +#Right endpoint +r<-mean+error +print(paste("Right endpoint of prediction interval:",r)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.14/Ex7_14.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.14/Ex7_14.R new file mode 100644 index 00000000..a0f3a78e --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.14/Ex7_14.R @@ -0,0 +1,46 @@ +#Ex7.14, Page 291 +#Answers may vary slightly due to rounding off of values + +data<-c(10490,16620,17300,15480,12970,17260,13400,13900, + 13630,13260,14370,11700,15470,17840,14070,14760) +print(data) + +n<-16 + +#To find mean +mean<-mean(data) +print(paste("Mean:",mean)) + +#To find standard deviation +s<-sd(data) +print(paste("Standard deviation:",s)) + +#To find tolerance intervals +t1<-2.903 +error1<-t1*s +#Left endpoint +l1<-mean-error1 +print(paste("Left endpoint of tolerance interval:",l1)) +#Right endpoint +r1<-mean+error1 +print(paste("Right endpoint of tolerance interval:",r1)) + +#To find confidence intervals +t2<-qt(1-(0.05/2),df=n-1) +error2<-t2*(s/sqrt(n)) +#Left endpoint +l2<-mean-error2 +print(paste("Left endpoint of confidence interval:",l2)) +#Right endpoint +r2<-mean+error2 +print(paste("Right endpoint of confidence interval:",r2)) + +#To find prediction intervals +t3<-qt(1-(0.05/2),df=n-1) +error3<-t3*s*sqrt(1+(1/n)) +#Left endpoint +l3<-mean-error3 +print(paste("Left endpoint of prediction interval:",l3)) +#Right endpoint +r3<-mean+error3 +print(paste("Right endpoint of prediction interval:",r3)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.15/Ex7_15.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.15/Ex7_15.R new file mode 100644 index 00000000..049318e4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.15/Ex7_15.R @@ -0,0 +1,15 @@ +#Ex7.15, Page 296 +#Answers may slightly vary due to rounding off of values + +data<-c(1470,1510,1690,1740,1900,2000,2030,2100,2190, + 2200,2290,2380,2390,2480,2500,2580,2700) + +interval<- function(data,conf.level=0.95){ + df<-length(data)-1 + l<-qchisq((1 - conf.level)/2, df) + r<-qchisq((1 - conf.level)/2, df, lower.tail = FALSE) + v<-var(data) + c(df* v/r,df*v/l) +} +print(paste("Confidence interval for variance of normal population:")) +print(interval(data)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.2/Ex7_2.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.2/Ex7_2.R new file mode 100644 index 00000000..cb4081cd --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.2/Ex7_2.R @@ -0,0 +1,15 @@ +#Ex7.2, Page 270 +#Answers may slightly vary due to rounding off of values + +mean<-80 +n<-31 +sd<-2 +error<-qt(0.95,df=n-1)*sd/sqrt(n) + +#Left endpoint +l<-mean-error +print(paste("Left endpoint of interval:",l)) + +#Right endpoint +r<-mean+error +print(paste("Right endpoint of interval:",r)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.3/Ex7_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.3/Ex7_3.R new file mode 100644 index 00000000..ae2eaa53 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.3/Ex7_3.R @@ -0,0 +1,19 @@ +#Ex7.3, Page 272 +#Answers may slightly vary due to rounding off of values + +mean<-5.426 +n<-40 +sd<-0.1 + +#To find alpha for (100(1-alpha)=90) +alpha<-solve(100,10) + +error<-qnorm(1-(alpha/2))*(sd/sqrt(n)) + +#Left endpoint +l<-mean-error +print(paste("Left endpoint of interval:",l)) + +#Right endpoint +r<-mean+error +print(paste("Right endpoint of interval:",r)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.4/Ex7_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.4/Ex7_4.R new file mode 100644 index 00000000..4d56d975 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.4/Ex7_4.R @@ -0,0 +1,11 @@ +#Ex7.4, Page 273 +#Answers may slightly vary due to rounding off of values + +#For 95% CI +z<-qnorm(1-(0.05/2)) + +sd<-25 +w<-10 + +n<-(2*z*sd/w)^2 +print(paste("Sample size necessary for CI to have width 10 is ",n,"and thus approx. 97")) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.6/Ex7_6.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.6/Ex7_6.R new file mode 100644 index 00000000..ba58643e --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.6/Ex7_6.R @@ -0,0 +1,36 @@ +#Ex7.6, Page 277-278 +#Answers may slightly vary due to rounding off of values + +data<-c(2948,2996,7197,8338,8500,8759,12710,12925,15767,20000,23247,24863,26000, +26210,30552,30600,35700,36466,40316,40596,41021,41234,43000,44607,45000, +45027,45442,46963,47978,49518,52000,53334,54208,56062,57000,57365,60020, +60265,60803,62851,64404,72140,74594,79308,79500,80000,80000,84000,113000,118634) +boxplot(data) +print(data) + +n<-50 + +#To find mean +mean<-mean(data) +print(paste("Mean:",mean)) + +#To find median +med<-median(data) +print(paste("Median:",med)) + +#To find standard deviation +s<-sd(data) +print(paste("Standard deviation:",s)) + +#To find confidence intervals +z<-qnorm(1-(0.05/2)) +error<-z*(s/sqrt(n)) + +#Left endpoint +l<-mean-error +print(paste("Left endpoint of interval:",l)) + +#Right endpoint +r<-mean+error +print(paste("Right endpoint of interval:",r)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.7/Ex7_7.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.7/Ex7_7.R new file mode 100644 index 00000000..f4a2a2b2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.7/Ex7_7.R @@ -0,0 +1,15 @@ +#Ex7.7, Page 279 + +t1<-320 +t2<-440 + +#To find value of s +s<-(t2-t1)/4 + +w<-5 + +z<-qnorm(1-(0.05/2)) + +n<-(z*s/w)^2 +print(paste("Sample size:",n)) +print(paste("Integer value of sample size:",ceiling(n))) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.8/Ex7_8.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.8/Ex7_8.R new file mode 100644 index 00000000..dab76251 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH7/EX7.8/Ex7_8.R @@ -0,0 +1,10 @@ +#Ex7.8, Page 282 +#Answer may vary slightly compared to textbook value + +n<-48 +n1<-16 +p<-n1/n + +alpha<-0.05 +b<-binom.test(16,48,p,conf.level=0.95) +print(b) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.1/Ex8_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.1/Ex8_1.R new file mode 100644 index 00000000..eab98a92 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.1/Ex8_1.R @@ -0,0 +1,33 @@ +#Ex8.1, Page 304 +#Answers may vary slightly due to rounding off of values + +#X<-number of crashes with no visible damage +#Reject H0 if x>=8 (x<-observed value of test statistic) + +#When H0 is true +n<-20 +p1<-0.25 + +#alpha=P(type I error) +alpha<-1-pbinom(7,n,p1) +print(paste("Alpha value:",alpha)) + +print(paste("When H0 is true, roughly",trunc(100*alpha,digits=2),"% of all experiments consisting of 20 crashes would result into a Type I error")) + +#beta=P(type II error) +#Different beta for each different p that exceeds 0.25, thus taking p=0.3 +p2<-0.3 +beta<-pbinom(7,n,p2) +print(paste("Beta value:",beta)) +print(paste("When H0 is false, roughly",trunc(100*beta,digits=2),"% of all experiments would result into a Type II error")) + +#Table showing variation of beta values with increase in value of p +for(i in 3:8){ + p<-0.1*i + a<-pbinom(7,n,p) + print(paste("p-value:",p)) + print(paste("Beta value:",a)) +} + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.11/Ex8_11.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.11/Ex8_11.R new file mode 100644 index 00000000..14e90c75 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.11/Ex8_11.R @@ -0,0 +1,27 @@ +#Ex8.11, Page 324 +#Answers may vary slightly due to rounding off of values + +#H0:p=0.15 +#Ha:p>0.15 + +p0<-0.15 +q0<-1-p0 +n<-91 +n1<-16 + +#Check validity of test procedures +if(n*p0>10 && n*q0>10) print(paste("Large sample z test can be used")) else print(paste("z test cannot be used")) + +alpha<-0.1 +zalpha<-qnorm(1-alpha) +print(paste("Rejection region: z>=",zalpha)) + +p<-n1/n +print(paste("p-cap:",p)) + +#To find z +z<-(p-p0)/(sqrt(p0*q0/n)) +print(paste("Test statistic value:",z)) + +if(z=z when mu=2.0) +p<-1-pnorm(z) +print(paste("P-value:",p)) + +alpha<-c(0.01,0.001) +for(i in alpha){ + if(p<=i) + print(paste("H0 rejected when significance level is at",i)) + else + print(paste("H0 not rejected when significance level is at",i)) +} \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.15/Ex8_15.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.15/Ex8_15.R new file mode 100644 index 00000000..276c9c95 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.15/Ex8_15.R @@ -0,0 +1,29 @@ +#Ex8.15, Page 330 +#Answers may vary slightly due to rounding off of values + +#H0: mu=15 +#Ha: mu>1.5 + +z<-2.10 + +#To determine p-value +p<-1-pnorm(z) +print(paste("P-value:",p)) + +alpha<-c(0.1,0.05,0.01) +for(i in alpha){ + z1<-qnorm(1-i) + if(z>=z1) + print(paste("Reject H0 at significance level",i)) + else + print(paste("Do not reject H0 at significance level",i)) +} + +#Using p-value approach +print(paste("Using p-value approach:")) +for(j in alpha){ + if(j>=p) + print(paste("Reject H0 at significance level",j,"since",j,">=",p)) + else + print(paste("Do not reject H0 at significance level",j,"since",j,"<",p)) +} \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.17/Ex8_17.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.17/Ex8_17.R new file mode 100644 index 00000000..6a675967 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.17/Ex8_17.R @@ -0,0 +1,21 @@ +#Ex8.17, Page 333 +#Answers may vary slightly due to rounding off of values + +#H0: mu=245 +#Ha: mu!=245 + +xbar<-246.18 +mu0<-245 +n<-50 +sd<-3.6 +alpha<-0.01 + +#To find z value +z<-(xbar-mu0)/(sd/sqrt(n)) +print(paste("Test statistic value:",z)) + +#To find p value in two tailed experiment +p<-2*(1-pnorm(z)) +print(paste("P-value:",p)) + +if(p>alpha) print(paste("H0 not rejected at significance level",alpha)) else print(paste("H0 rejected at significance level",alpha)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.18/Ex8_18.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.18/Ex8_18.R new file mode 100644 index 00000000..94d86d3c --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.18/Ex8_18.R @@ -0,0 +1,28 @@ +#Ex8.18, Page 335 + +#H0: mu=4 +#Ha: mu!=4 + +n<-5 +t<-round(-0.594,digits=1) +df<-n-1 + +alpha<-0.05 + +#To find critical values +a<-qt(1-alpha/2,df=n-1) + +#Since test is two tailed +p<-2*pt(t,df=n-1) +print(paste("P-value:",round(p,digits=2))) + +b<-c(0.01,0.05,0.1) +for(i in b){ + if(p>i) + print(paste("H0 is not rejected at significance level",i)) + else + print(paste("H0 rejected at significance level",i)) +} + + + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.19/Ex8_19.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.19/Ex8_19.R new file mode 100644 index 00000000..ad9034cf --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.19/Ex8_19.R @@ -0,0 +1,27 @@ +#Ex8.19, Page 335 +#Answers may vary slightly due to rounding off of values +#Tests for mean=20 have only been done.... + +#H0: mu=20 +#Ha: mu>20 + +n<-4 +df<-n-1 +mu0<-20 +sd<-2 +x<-c(20.83,22.232,20.276,17.718) + +xbar<-mean(x) +print(paste("Mean:",xbar)) +s<-sd(x) +print(paste("Standard deviation:",s)) + +#To find t +t<-(xbar-mu0)/(s/sqrt(n)) +print(paste("Test statistic value:",t)) + +#To find p value +p<-pt(t,df=n-1,lower.tail = FALSE) + +alpha<-0.05 +if(p>alpha) print(paste("H0 is not rejected at significance level",alpha)) else print(paste("H0 is rejected at significance level",alpha)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.2/Ex8_2.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.2/Ex8_2.R new file mode 100644 index 00000000..0074dfc1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.2/Ex8_2.R @@ -0,0 +1,33 @@ +#Ex8.2, Page 305 +#Answers may vary slightly due to rounding off of values + +m<-75 +sd<-9 +#Hypotheses H0: mean=75, H1: mean<75 + +#Experimental data +n<-25 +sd<-9 +#Standard deviation of normal distribution +sdx<-sd/sqrt(n) +print(paste("SD of normal distribution:",sdx)) + +#When H0 is true +mx<-75 + +#Consider rejection region x<=70.8 +#To find alpha and beta + +#P(type I error) +alpha<-pnorm(70.8,mx,sdx) +print(paste("Alpha value:",alpha)) + +#P(type II error) +mx<-c(72,70,67) #H0 is not rejected when it is false because mean= eg:72 +for(i in mx){ + beta<-1-pnorm(70.8,i,sdx) + print(paste("Beta value:",beta,"when mean is",i)) +} + +print(paste("Only",round(alpha,digits=3)*100,"% of all experiments will result into Type I error")) +print(paste("Possibility of Type II error decreases as mean value increases")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.3/Ex8_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.3/Ex8_3.R new file mode 100644 index 00000000..5b9f16f1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.3/Ex8_3.R @@ -0,0 +1,21 @@ +#Ex8.3, Page 306 +#Answers may vary slightly due to rounding off of values + +#R9={9,10,......,20} +n<-20 + +#To find alpha=P(H0 rejected when p=.25)=P(X>=9 when X follows binomial dist.) +p<-0.25 +alpha<-1-pbinom(8,n,p) +print(paste("Alpha value:",alpha)) +print(paste("Type I error probability has reduced considerably when using R9 rather than R8 rejection region")) + +#To find beta value=P(H0 not rejected)=P(X<=8 when X follows binomial dist.) +p1<-0.3 #1st case +beta1<-pbinom(8,n,p1) +print(paste("Beta(0.3)=",beta1)) + +p2<-0.5 #2nd case +beta2<-pbinom(8,n,p2) +print(paste("Beta(0.5)=",beta2)) +print(paste("P(Type II error in R9)>P(Type II error in R8)")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.4/Ex8_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.4/Ex8_4.R new file mode 100644 index 00000000..67d8c6e6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.4/Ex8_4.R @@ -0,0 +1,19 @@ +#Ex8.4, Page 307 +#Answers may vary slightly due to rounding off of values + +#New rejection region x<=72 +sdx<-1.8 + +#To find alpha=P(H0 rejected when true)=P(X<=72 when X follows normal dist) +mx<-75 +alpha<-pnorm(72,mx,sdx) +print(paste("Alpha value:",alpha)) +print(paste("Type I error probability is greater in the new rejection region")) + +#To find beta=P(H0 not rejected) +mx<-c(72,70,67) #H0 is not rejected when it is false because mean= eg:72 +for(i in mx){ + beta<-1-pnorm(72,i,sdx) + print(paste("Beta(",i,"):",beta)) +} +print(paste("Type II error probability is lower in the new rejection region")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.5/Ex8_5.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.5/Ex8_5.R new file mode 100644 index 00000000..8ad5cad1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.5/Ex8_5.R @@ -0,0 +1,20 @@ +#Ex8.5, Page 308 + +#H0: mu=1.5 +#Ha: mu>1.5 + +mu0<-1.5 +n<-32 +sd<-0.2 +sdx<-sd/sqrt(n) +print(paste("Rejection region: Z>=c")) + +alpha<-0.05 +#where alpha=P(type I error)=P(Z>=c when Z follows N(0,1)) +c<-qnorm(1-alpha) +print(paste("C value:",c)) + +#Z>=c +x<-round(mu0+sdx*c,digits=2) +print(paste("xbar>=",x)) +print(paste("Beta refers to the prob. that xbar<",x,"and can be calculated for any mu>1.5")) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.6/Ex8_6.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.6/Ex8_6.R new file mode 100644 index 00000000..99565983 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.6/Ex8_6.R @@ -0,0 +1,19 @@ +#Ex8.6, Page 312 +#Answers may vary slightly due to rounding off of values + +mu0<-130 +n<-9 +sd<-1.5 +xbar<-131.08 + +z<-(xbar-mu0)/(sd/sqrt(n)) #Test statistic value +print(paste("Test statistic value:",z)) + +#To determine rejection region +alpha<-0.01 +a<-qnorm(1-alpha/2) +l<-(-a) +r<-a +print(paste("Rejection region: z<=",l,",z>=",r)) +if(z<=l || z>=r)print(paste(z,"falls in the rejection region and H0 is rejected"))else print(paste(z,"does not fall in the rejection region so H0 cannot be rejected at significance level",alpha)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.7/Ex8_7.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.7/Ex8_7.R new file mode 100644 index 00000000..85c374a2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.7/Ex8_7.R @@ -0,0 +1,28 @@ +#Ex8.7, Page 314 +#Answers may vary slightly due to rounding off of values + +n<-16 +sd<-1500 +alpha1<-0.01 +xbar<-30000 +mu0<-31000 + +zalpha1<-qnorm(1-alpha1) + +z<-(xbar-mu0)/(sd/sqrt(n)) + +#To find beta(31000) when alpha=0.01 +beta1<-pnorm(zalpha1+z) +print(paste("Beta(31000):",beta1,"when alpha=",alpha1)) + +alpha2<-0.1 +zalpha2<-qnorm(1-alpha2) + +#To find beta(31000) when alpha=0.1 +beta2<-pnorm(zalpha2+z) +print(paste("Beta(31000):",round(beta2,digits=1),"when alpha=",alpha2)) + +#To find n +n<-(sd*(zalpha1+zalpha2)/(xbar-mu0))^2 +print(paste("n value:",n)) +print(paste("Sample size=",ceiling(n))) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.8/Ex8_8.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.8/Ex8_8.R new file mode 100644 index 00000000..9a589337 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.8/Ex8_8.R @@ -0,0 +1,23 @@ +#Ex8.8, Page 315 +#Answers may vary slightly due to rounding off of values + +n<-52 +mu0<-30 +data<-c(14.1,14.5,15.5,16.0,16.0,16.7,16.9,17.1,17.5,17.8,17.8,18.1,18.2,18.3,18.3, + 19.0,19.2,19.4,20.0,20.0,20.8,20.8,21.0,21.5,23.5,27.5,27.5,28.0,28.3,30.0, + 30.0,31.6,31.7,31.7,32.5,33.5,33.9,35.0,35.0,35.0,36.7,40.0,40.0,41.3,41.7, + 47.5,50.0,51.0,51.8,54.4,55.0,57.0) +xbar<-mean(data) +sd<-sd(data) +print(paste("Mean:",xbar)) +print(paste("Standard deviation:",sd)) + +alpha<-0.05 +#To find zalpha +z1<-qnorm(alpha) + +#To find z +z<-(xbar-mu0)/(sd/sqrt(n)) +print(paste("z value:",z)) + +if(z>z1) print(paste("H0 cannot be rejected since",z,">",z1)) else print(paste("H0 is rejected since",z,"<",z1)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.9/Ex8_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.9/Ex8_9.R new file mode 100644 index 00000000..2e6e7422 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH8/EX8.9/Ex8_9.R @@ -0,0 +1,26 @@ +#Ex8.9, Page 317 +#Answers may vary slightly due to rounding off of values + +data<-c(2.67,4.62,4.14,3.81,3.83) +n<-length(data) + +alpha<-0.05 +mu0<-4 + +#To determine rejection region +t1<-qt(1-alpha/2,df=n-1) +l<-(-t1) +r<-t1 +print(paste("Rejection region: t<=",l,",t>=",r)) + +#To find mean +print(paste("Sum of sample:",sum(data))) +print(paste("Mean:",mean(data))) + +#To find standard deviation +print(paste("Standard deviation:",sd(data))) +print(paste("Estimated standard error of the mean:",sd(data)/sqrt(n))) + +#Test statistic value +t1<-t.test(data,alternative="two.sided",mu=mu0) +print(t1) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.1/Ex9_1.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.1/Ex9_1.R new file mode 100644 index 00000000..b03db496 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.1/Ex9_1.R @@ -0,0 +1,22 @@ +#Ex9.1, Page 348 +#Answers may slightly vary due to rounding off of values + +#H0: mu1-mu2=0 +#Ha: mu1-mu2!=0 + +xbar<-29.8 +ybar<-34.7 +s1<-4 +s2<-5 +m<-20 +n<-25 + +#To find percentile +alpha<-0.01 +H0<-qnorm(1-alpha/2) + +#To find test statistic value +z<-(xbar-ybar)/sqrt((s1^2)/m+(s2^2)/n) +print(paste("Test statistic value:",z)) + +if(z>=H0||z<=H0)print(paste("H0 is rejected at level",alpha)) else print(paste("H0 is accepted at level",alpha)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.10/Ex9_10.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.10/Ex9_10.R new file mode 100644 index 00000000..0466852c --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.10/Ex9_10.R @@ -0,0 +1,22 @@ +#Ex9.10, Page 369 +#Answers may vary slightly due to rounding off of values + +Subject<-c(1,2,3,4,5,6,7,8,9,10,11,12,13) +Slide<-c(30,35,40,25,20,30,35,62,40,51,25,42,33) +Digital<-c(25,16,15,15,10,20,7,16,15,13,11,19,19) +Difference<-Slide-Digital +data<-data.frame(Slide,Digital,Difference,row.names=Subject) +print(data) + +#Normal probability plot +qqnorm(data$Difference,main="Normal probability plot of the differences",ylab="diff",xlab="Probability") +qqline(data$Difference) + +#To find t critical value +alpha<-0.05 +t<-qt(1-alpha/2,df=12) +print(paste("t statistic value:",t)) + +#To find confidence intervals +t1<-t.test(Slide,Digital,paired=TRUE) +print(t1) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.11/Ex9_11.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.11/Ex9_11.R new file mode 100644 index 00000000..3d85a1a3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.11/Ex9_11.R @@ -0,0 +1,32 @@ +#Ex9.11, Page 376 +#Answers may slightly vary due to rounding off of values + +alpha<-0.05 + +#H0: p1-p2=0 +#Ha: p1-p2<0 + +a<-81 +tot1<-549 +p1cap<-a/tot1 +q1cap<-1-p1cap + +b<-141 +tot2<-730 +p2cap<-b/tot2 +q2cap<-1-p2cap + +pcap<-(a+b)/(tot1+tot2) +qcap<-1-pcap + +#To find test statistic value +if((tot1*p1cap)>=10 && (tot1*q1cap)>=10 && (tot2*p2cap)>=10 && (tot2*q2cap)>=10) + z<-(p1cap-p2cap)/sqrt(pcap*qcap*(1/tot1+1/tot2)) +print(paste("Test statistic value:",z)) + +#To find P-value +p<-pnorm(z) +print(paste("P-value:",p)) + +if(p<=alpha) print(paste("H0 can be rejected at significance level",alpha)) else print(paste("H0 cannot be rejected")) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.12/Ex9_12.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.12/Ex9_12.R new file mode 100644 index 00000000..76900406 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.12/Ex9_12.R @@ -0,0 +1,27 @@ +#Ex9.12, Page 378 +#Answers may vary slightly due to rounding off of values + +#H0: p1-p2=0 +#Ha: p1-p2>0 + +a<-30 +tot1<-100000 +p1<-a/tot1 +print(paste("p1:",p1)) +q1<-1-p1 + +b<-a/2 +p2<-b/tot1 +print(paste("p2:",p2)) +q2<-1-p2 + +alpha<-0.05 +beta<-0.1 + +zalpha<-qnorm(1-alpha) +zbeta<-qnorm(1-beta) +d<-p1-p2 + +#To find n value +n<-(zalpha*sqrt((p1+p2)*(q1+q2)/2)+zbeta*sqrt(p1*q1+p2*q2))^2/d^2 +print(paste("Value of n:",n)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.13/Ex9_13.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.13/Ex9_13.R new file mode 100644 index 00000000..54cf195f --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.13/Ex9_13.R @@ -0,0 +1,26 @@ +#Ex9.13, Page 380 +#Answers may vary slightly due to rounding off of values + +alpha<-0.01 +a<-76 #number of people who survived through chemotherapy treatment +m<-154 #number of people who received chemotherapy treatment +p1cap<-a/m +q1cap<-1-p1cap +print(paste("p1cap:",p1cap)) + +b<-98 #number of people who survived through hybrid treatment +n<-164 #number of people who received hybrid treatment +p2cap<-b/n +q2cap<-1-p2cap +print(paste("p2cap:",p2cap)) + +#To find z +zalpha<-qnorm(1-alpha/2) + +if(m*p1cap>=10 && m*q1cap>=10 && n*p2cap>=10 && n*q2cap>=10) + l<-p1cap-p2cap-zalpha*sqrt((p1cap*q1cap/m)+(p2cap*q2cap/n)) + r<-p1cap-p2cap+zalpha*sqrt((p1cap*q1cap/m)+(p2cap*q2cap/n)) + +print(paste("Left endpoint of confidence interval:",l)) +print(paste("Right endpoint of confidence interval:",r)) +print(paste("Hence",round(l,digits=3),"0 + +xbar<-48.9 +ybar<-43.2 +s1<-14.6 +s2<-14.4 +m<-125 +n<-90 +alpha<-0.01 + +#To find test statistic value +z<-(xbar-ybar)/sqrt((s1^2)/m+(s2^2)/n) +print(paste("Test statistic value:",z)) + +#To find p-value +p<-pnorm(-abs(z)) +print(paste("p-value:",p)) + +if(alpha>p) print(paste("H0 is rejected at level",alpha)) else print(paste("H0 is accepted at level",alpha)) + diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.3/Ex9_3.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.3/Ex9_3.R new file mode 100644 index 00000000..41fb3303 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.3/Ex9_3.R @@ -0,0 +1,9 @@ +#Ex9.3, Page 350 +#Answers may slightly vary due to rounding off of values + +t<-5 +t1<-0 +s<-1.34 +n<-qnorm(1-0.01/2) +beta<-pnorm(n-((t-t1)/s))-pnorm(-n-((t-t1)/s)) +print(paste("Beta(5):",beta)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.4/Ex9_4.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.4/Ex9_4.R new file mode 100644 index 00000000..fb394fe2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.4/Ex9_4.R @@ -0,0 +1,25 @@ +#Ex9.4, Page 352 +#Answers may vary slightly due to rounding off of values + +mu1<-2258 +mu2<-2637 +s1<-1519 +s2<-1138 +m<-663 +n<-413 +l<-0.05 +H0<-(-200) + +#To find z0.05 +z1<-qnorm(1-l) + +#To find test statistic value +z<-(mu1-mu2-H0)/sqrt(((s1^2)/m+(s2^2)/n)) +print(paste("Test statistic value:",z)) + +if(z<=-z1) print(paste("H0 is rejected since",z,"<=",-z1)) + +#To find p-value +p<-pnorm(-abs(z)) +print(paste("P-value:",p)) +if(p<=l) print(paste("H0 is rejected since",p,"<=",l)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.5/Ex9_5.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.5/Ex9_5.R new file mode 100644 index 00000000..1a121ced --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.5/Ex9_5.R @@ -0,0 +1,22 @@ +#Ex9.5, Page 354 +#Answers may vary slightly due to rounding off values + +c1<-c('Variable_diam', 'N', 'Mean', 'Median', 'TrMean', 'StDev', 'SEMean', 'Min', 'Max', 'Q1','Q3') +c2<-c('3/8',78,4.250,4.230,4.238,1.300,0.147,1.634,7.327,3.389,5.075) +c3<-c('1/2',88,7.140,7.113,7.150,1.680,0.179,2.450,11.343,5.965,8.447) +df<-data.frame(c1,c2,c3) +print(df) + +mu1<-4.25 +mu2<-7.14 +z<-qnorm(1-(0.05/2)) +s1<-1.3 +s2<-1.68 +m<-78 +n<-88 + +#To find confidence intervals +l<-(mu1-mu2)-z*sqrt((s1^2)/m+(s2^2)/n) +r<-(mu1-mu2)+z*sqrt((s1^2)/m+(s2^2)/n) +print(paste("Left endpoint of interval:",l)) +print(paste("Right endpoint of interval:",r)) diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.6/Ex9_6.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.6/Ex9_6.R new file mode 100644 index 00000000..da229897 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.6/Ex9_6.R @@ -0,0 +1,38 @@ +#Ex9.6, Page 358 +#Answers may vary slightly due to rounding off of values + +Fabric_type<-c('Cotton','Triacetate') +Sample_size<-c(10,10) +Sample_mean<-c(51.71,136.14) +Sample_standard_deviation<-c(.79,3.59) +data<-data.frame(Sample_size,Sample_mean,Sample_standard_deviation,row.names=Fabric_type) +print(data) + +#Assigning values to variables +s1<-Sample_standard_deviation[1] +s2<-Sample_standard_deviation[2] + +xbar<-Sample_mean[1] +ybar<-Sample_mean[2] + +m<-Sample_size[1] +n<-Sample_size[2] + +#To find df +num<-((s1^2/m)+(s2^2/n))^2 +denom<-((s1^2/m)^2)/(m-1)+((s2^2/n)^2)/(n-1) +df<-num/denom +print(paste("df:",df)) + +#To find t value +alpha<-0.05 +t<-qt(1-alpha/2,df=m-1) +print(paste("t:",t)) + +#To find intervals +l<-xbar-ybar-t*sqrt((s1^2/m)+(s2^2/n)) +r<-xbar-ybar+t*sqrt((s1^2/m)+(s2^2/n)) +print(paste("Left endpoint of interval:",l)) +print(paste("Right endpoint of interval:",r)) + +print(paste("The true average porosity of the triacetate fabric is greater than that of the cotton fabric by between",round(-r,digits=2),"and",round(-l,digits=2),"cm^3/cm^2/sec")) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.7/Ex9_7.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.7/Ex9_7.R new file mode 100644 index 00000000..9d272bef --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.7/Ex9_7.R @@ -0,0 +1,21 @@ +#Ex9.7, Page 359 +#Answers may vary slightly due to rounding off of values + +No_fusion<-c(2748,2700,2655,2822,2511,3149,3257,3213,3220,2753) +Fused<-c(3027,3356,3359,3297,3125,2910,2889,2902) + +#H0: mu1-mu2=0 +#Ha: mu1-mu2<0 + +#To find test staistic value +t<-t.test(No_fusion,Fused) +print(t) +print(paste("t statistic value:",t$statistic)) +print(paste("df:",t$parameter)) + +#To plot normal probability plots +par(mfrow=c(2,1)) +qqnorm(No_fusion,datax=TRUE,ylab="Not fused",xlab="Probability",main="Normal probability plot for not fused data") +qqline(No_fusion,datax=TRUE) +qqnorm(Fused,datax=TRUE,ylab="Fused",xlab="Probability",main="Normal probability plot for fused data") +qqline(Fused,datax=TRUE) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.9/Ex9_9.R b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.9/Ex9_9.R new file mode 100644 index 00000000..714eec85 --- /dev/null +++ b/Probability_And_Statistics_For_Engineering_And_The_Sciences_by_Jay_L_Devore/CH9/EX9.9/Ex9_9.R @@ -0,0 +1,26 @@ +#Ex9.9, Page 367 +#Answers may vary slightly due to rounding off of values + +Subject<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) +Before<-c(81,87,86,82,90,86,96,73,74,75,72,80,66,72,56,82) +After<-c(78,91,78,78,84,67,92,70,58,62,70,58,66,60,65,73) +Difference<-Before-After +data<-data.frame(Before,After,Difference,row.names=Subject) +print(data) + +#Normal probability plot +par(mfrow=c(1,2)) +qqnorm(data$Difference,main="Normal probability plot of the differences",xlab="diff",ylab="Probability") +qqline(data$Difference) +boxplot(Difference,horizontal=TRUE,xlab="Difference") + +#H0: mu=0 +#Ha: mu!=0 +t1<-t.test(Difference,mu=0) +print(paste("t statistic value:",t1$statistic)) +print(paste("p value:",t1$p.value)) + +alpha<-0.01 +if(t1$p.value 0.6 +# alpha = 0.05. +# critical region - z>1.645 + +# using binomial approximation.. + + +ans <- pnorm(0.7,mean = 0.6,sd=sqrt(0.6*0.4/100),lower.tail = F) + +cat("The p_value is",ans,"we reject null hypothesis and conclude that the new drug is superior") + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.11/Ex10_11.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.11/Ex10_11.R new file mode 100644 index 00000000..4f9467ef --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.11/Ex10_11.R @@ -0,0 +1,33 @@ + +# Chapter 10 +# Example 10.11 page 364 from the pdf.. +# Two Sample Tests On 2 Proportions.. + +# hypothesis testing on 2 proportion..using z test +# Null- H0 p1=p2 +# alternate - H1 = p1>p2 + +# information - +x1 <- 120 + +x2 <- 240 + +n1 <- 200 + +n2 <- 500 + +# to find the estimate.. +p_hat <- c(x1/n1,x2/n2) + +pooled_p <- (x1+x2)/(n1+n2) + +p_value <- 1-pnorm((p_hat[1]-p_hat[2])/(sqrt((pooled_p*0.49)*(1/n1+1/n2)))) + +cat("Since the p_value is",p_value,"we reject the null hypothesis and conclude that town voters favouring the proporsal are higher than county voters") + +# this problem can also be solved directly using prop.test(c(120,240),c(200,500),alternative="greater"), but this test uses chi square test method and the T.B solved it with z-test.. +# If you want to explore it write this code into your console - +# prop.test(c(120,240),c(200,500),alternative = "greater") + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.12/Ex10_12.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.12/Ex10_12.R new file mode 100644 index 00000000..d43222d5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.12/Ex10_12.R @@ -0,0 +1,22 @@ + +# Chapter 10 +# Example 10.12 page no. 366 from the pdf.. +# One and Two Sample Tests Concerning Variance.. + +# null - sig^2 = 0.81 +# alternaitve - sig^2 > 0.81 +# alpha = 0.05 + +n <- 10 + +sig <- 0.9 + +s <- 1.2 + +chi.sq <- (n-1)*s*s/(sig*sig) + +p_value <- pchisq(chi.sq,df=9 ,lower.tail = F) + +cat("The p value is",p_value,"there is evidence that sig>0.9") + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.13/Ex10_13.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.13/Ex10_13.R new file mode 100644 index 00000000..78f5140d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.13/Ex10_13.R @@ -0,0 +1,17 @@ + +# Chapter 10 +# example 10.13 page no. 368 from the pdf.. +# To do Hypothesis Testing for 2 variances.. + +# refer example 10.6 for value of 2 variances +# Null - sig1^2 = sig2^2 +#alternaitive - sig1^2 != sig2^2 + +s1_sq <- 16 + +s2_sq <- 25 + + +# null reject if f <0.34 or f > 3.11.. +ifelse(s1_sq/s2_sq < qf(0.05,11,9) | s1_sq/s2_sq > qf(0.95,11,9),print("The null hypothesis is rejected and conclude there is sufficient evidence that variance differ"),print("Do not reject null hypothesis and conclude that there is insufficient evidence that the variances differ.")) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.14/Ex10_14.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.14/Ex10_14.R new file mode 100644 index 00000000..7bcacac4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.14/Ex10_14.R @@ -0,0 +1,32 @@ + +# Chapter 10 +# Example 10.14 page no. 377 from the pdf.. +# Test For Homogeneity.. + +# given data test the hypothesis + +# H0 - proportion of all political affiliation are same for each opinion + +# H1 - for at least 1 opinion the proportion is not same + +# using chi-sq statistic.. + +for1 <- c(82,70,62) + +against <- c(93,62,67) + + +undecided <- c(25,18,21) + +pol_affi <- as.data.frame(rbind(for1,against,undecided)) + +names(pol_affi) <- c('Democrat','Republican','Independent') + +chisq.test(pol_affi) + +cat("The p-value is",chisq.test(pol_affi)$p.value,"so we cannot reject null hypothesis") + +# the answer to the chi^2 is aprroximated to 1.53 as computed 1.5274 by R.. + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.15/Ex10_15.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.15/Ex10_15.R new file mode 100644 index 00000000..1524cf44 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.15/Ex10_15.R @@ -0,0 +1,18 @@ + +# Chapter 10 +# Example 10.15 page no. 378 from the pdf.. +# testing for several proportion.. + +defectives <- c(45,55,70) + +nondefectives <- c(905,890,870) + +# making a data frame of Variables.. +shifts <- as.data.frame(rbind(defectives,nondefectives)) + +# Giving names to the columns.. +names(shifts) <- c('Day','Evening','Night') + +chisq.test(shifts) + +cat("Since the p-value is",chisq.test(shifts)$p.value," grater than the significant value 0.025 we cannot reject null hypothesis but from the p-value calculated we also cannot say that the proportion of defectives is same ") diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.3/Ex10_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.3/Ex10_3.R new file mode 100644 index 00000000..1530de85 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.3/Ex10_3.R @@ -0,0 +1,27 @@ + +# Chapter 10 +# Example 10.3 page no. 338 from the pdf.. +# Test Concerning a Single Mean for Single Sample.. + +# Note - 10.1 and 10.2 are theoretical with nothing to Compute.. + +# given +m <- 71.8 + +n <- 100 + +sd <- 8.9 + +alpha <- 0.05 + +# Null hypothesis, mean = 70years +# alternative mean > 70 years + +sd1 <- sd/sqrt(n) + +p_value <- 1 - pnorm((m-70)/sd1,0,1) + +cat("The p-value is",p_value,",which is less than 0.05 level of significance hence we conclude the evidence favour alternative hypothesis more than null") + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.4/Ex10_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.4/Ex10_4.R new file mode 100644 index 00000000..329c2216 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.4/Ex10_4.R @@ -0,0 +1,33 @@ + +# Chapter 10 +# Example 10.4 page no. 338 from the pdf.. +# Test Concerning a Single Mean for Single Sample.. + +# given +# H0 = 8kg +# H1 != 8kg + +alpha <- 0.01 + + +n <- 50 + +sd <- 0.5 + +m <- 7.8 + +sd1 <- sd/sqrt(n) + +# two sided hypothesis test.. + +p_value <- 2*pnorm((m-8)/sd1) + +if(p_value < 0.01){ + + print("Since the p_value is less than 0.01 we reject the null hypothesis that mu= 8kg") + +}else{ + + print("Since the p_value is more than 0.01 there is not enough evidence to claim the alternative hypothesis, so evidence supports mu can be 8") + +} \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.5/Ex10_5.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.5/Ex10_5.R new file mode 100644 index 00000000..6ec000a8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.5/Ex10_5.R @@ -0,0 +1,33 @@ + +# Chapter 10 +# Example 10.5 page no. 340 from the pdf.. +# The t-statistic for a test on a single mean when Variance is Unknown.. + +# given H0- mean = 46kWh +# H1 - mean < 46kWh + +alpha <- 0.05 + +n <- 12 + +# using t-staistic + +m <- 42 + +sd <- 11.9 + +sd1 <- sd/sqrt(n) + +# one sided testing +p_value <- pt((m-46)/sd1,n-1) + + +if(p_value < 0.05){ + + print("Since the p_value is less than 0.05 we reject the null hypothesis that mu= 46kWh") + +}else{ + + print("Since the p_value is more than 0.05, we cannot reject H0 and conclude that the average no. of kWh used is not significantly less than 46") + +} diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.6/Ex10_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.6/Ex10_6.R new file mode 100644 index 00000000..0102070c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.6/Ex10_6.R @@ -0,0 +1,40 @@ + +# Chapter 10 +# Example 10.6 page no. 344 from the pdf.. +# The 2 Sample Pooled t-test.. + +# 2 sample t- test +n1 <- 12 + +n2 <- 10 + +x1 <- 85 + +x2 <- 81 + +s1 <- 4 + +s2 <- 5 + +# Null H0- mu1-mu2= 2 +# alternate H1 mu1-mu2 >2 +# using 2 sample pooled t-test.. + +deg_f <- n1+n2-2 + +sp <- sqrt((s1*s1*(n1-1)+s2*s2*(n2-1))/deg_f) + +p_value <- 1-pt(((x1-x2-2)/(sp*sqrt(1/n1+1/n2))),deg_f) + +if(p_value < 0.05){ + + print("Since the p_value is less than 0.05 we reject the null hypothesis that mu1-mu2=2") + +}else{ + + print("Since the p_value is more than 0.05, we cannot reject H0 and conclude that material 1 wear exceeds that of 2 by more than 2 units") + +} + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.7/Ex10_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.7/Ex10_7.R new file mode 100644 index 00000000..3bd73777 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.7/Ex10_7.R @@ -0,0 +1,28 @@ + +# Chapter 10 +# Example 10.7 page no. 351 from the pdf.. +# Choice of Sample Size for Testing Mean.. + +# given the hypothesis test, using alpha= 0.05, +# to find the sample size if power of our test is to be 0.95 when true mean is 69 kg. +# Null - mu = 68 kg. +# alternative - mu > 68 kg. + +mu = 68 + +mu1 = 69 + +alpha = 0.05 + +sig <- 5 + +delta <- mu1-mu + +z_alpha <- abs(qnorm(0.05)) + +n <- ((z_alpha+z_alpha)^2)*(sig*sig)/(delta*delta) + +cat("The sample size required if the test is to reject the null hypothesis 95% of the time when in fact, mu is as large as 69 kg is",n) + +# example 10.8 is bit absurd all they have done is mere division and making conclusions based on that so I an not coding example 10.8 + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.9/Ex10_9.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.9/Ex10_9.R new file mode 100644 index 00000000..6a51a0ab --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH10/EX10.9/Ex10_9.R @@ -0,0 +1,26 @@ + +# Chapter 10 +# Example 10.9 page no. 362 from the pdf.. +# One Sample Test on a Single Proportion.. + +# given H0 - p=0.7 +# H1 alternative - p!=0.7 + +# test staistic - binomial + +x <- 8 # no. of heat pumps installed in sample + +n <- 15 # no. of randomly selected homes.. + +# it is a binomial variable and 2 sided hypothesis test.. +p_value <- pbinom(x,n,0.7)*2 + +if(p_value > 0.10){ + + cat("As the p value is",p_value,"there is insufficient reason to doubt the builder's claim so cannot reject null hypothesis") + +}else{ + + print("The evidence supports alternative hypothesis and builder claim should be rejected") + +} \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.1/Ex11_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.1/Ex11_1.R new file mode 100644 index 00000000..ceee8400 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.1/Ex11_1.R @@ -0,0 +1,18 @@ + +# Chapter 11 +# Example 11.1 page no. 396 from the pdf.. +# To Estimate the Regression Line.. + + +# to estimate the regression line from the given data.. +x <- c(3,7,11,15,18,27,29,30,30,31,31,32,33,33,34,36,36,36,37,38,39,39,39,40,41,42,42,43,44,45,46,47,50) + +y <- c(5,11,21,16,16,28,27,25,35,30,40,32,34,32,34,37,38,34,36,38,37,36,45,39,41,40,44,37,44,46,46,49,51) + +pol <- data.frame(x,y) + +line_eq <- lm(y~x,data=pol) + +b <-coefficients(line_eq) + +cat("The estimate of regression line is y =",b[1],"+",b[2],"*x") diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.10/Ex11_10.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.10/Ex11_10.R new file mode 100644 index 00000000..6608ad73 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.10/Ex11_10.R @@ -0,0 +1,17 @@ + +# Chapter 11 +# Example 11.10 page no. 433 from the pdf.. +# To find Correlation Coefficient.. + +# to find the correlation coefficient between the 2 variables + +spec_gra <- c(0.414,0.383,0.399,0.402,0.442,0.422,0.466,0.500,0.514,0.530,0.569,0.558,0.577,0.572,0.548,0.581,0.557,0.550,0.531,0.550,0.556,0.523,0.602,0.569,0.544,0.557,0.530,0.547,0.585) + +mod_of_rup <- c(29186,29266,26215,30162,38867,37831,44576,46097,59698,67705,66088,78486,89869,77369,67095,85156,69571,84160,73466,78610,67657,74017,87291,86836,82540,81699,82096,75657,80490) + +cat("The sample correlation coefficient is",cor(spec_gra,mod_of_rup)) + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.11/Ex11_11.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.11/Ex11_11.R new file mode 100644 index 00000000..1a42bc8b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.11/Ex11_11.R @@ -0,0 +1,21 @@ + +# Chapter 11 +# Example 11.11 page no. 434 from the pdf.. +# To do Hypothesis Testing of linear association between two variables + +# Null H0: po =0 +# alternate H1 : p1 !=0 +# alpha = 0.05 + +spec_gra <- c(0.414,0.383,0.399,0.402,0.442,0.422,0.466,0.500,0.514,0.530,0.569,0.558,0.577,0.572,0.548,0.581,0.557,0.550,0.531,0.550,0.556,0.523,0.602,0.569,0.544,0.557,0.530,0.547,0.585) + +mod_of_rup <- c(29186,29266,26215,30162,38867,37831,44576,46097,59698,67705,66088,78486,89869,77369,67095,85156,69571,84160,73466,78610,67657,74017,87291,86836,82540,81699,82096,75657,80490) + +print("The test is shown below as follows:") + +cor.test(spec_gra,mod_of_rup) + +cat("The p-value is very less then 0.05, we reject the null hypothesis of no linear association") + +# example 11.12 is same as example 11.11 except now we have to do hypothesis as p0 = 0.9, just changed the value for testing, so It is same concept just numbers are changed, so I have not solved.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.2/Ex11_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.2/Ex11_2.R new file mode 100644 index 00000000..45373d11 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.2/Ex11_2.R @@ -0,0 +1,20 @@ + +# Chapter 11 +# Example 11.2 page no. 403 from the pdf.. +# Confidence Interval for Slopes of Regression Line.. + +# to find the confidence interval of the given data.. + +x <- c(3,7,11,15,18,27,29,30,30,31,31,32,33,33,34,36,36,36,37,38,39,39,39,40,41,42,42,43,44,45,46,47,50) + +y <- c(5,11,21,16,16,28,27,25,35,30,40,32,34,32,34,37,38,34,36,38,37,36,45,39,41,40,44,37,44,46,46,49,51) + +pol <- data.frame(x,y) + +line <- lm(y~x,data = pol) + +cat("The 95% confidence interval for beta1(i.e slope) in the regression line is",confint(line,'x',level=0.95)) + +# The answer matches with the answer in the T.B upto 3 decimal places, as T.B answer is approximated.. + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.3/Ex11_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.3/Ex11_3.R new file mode 100644 index 00000000..0702fe55 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.3/Ex11_3.R @@ -0,0 +1,37 @@ + +# Chapter 11 +# Example 11.3 page no. 404 from the pdf.. +# Hypothesis Testing On Slope Of Regression Line.. + +# to test the hypothesis of beta1 slope of regression line.. +# Null - beta1 = 1.0, alternative < 1.0 + +x <- c(3,7,11,15,18,27,29,30,30,31,31,32,33,33,34,36,36,36,37,38,39,39,39,40,41,42,42,43,44,45,46,47,50) + +y <- c(5,11,21,16,16,28,27,25,35,30,40,32,34,32,34,37,38,34,36,38,37,36,45,39,41,40,44,37,44,46,46,49,51) + +pol <- data.frame(x,y) + +l <- lm(y~x,data = pol) + +coefficients(l) + +p_value <- function(reg_m,conum,val){ + + coefi <- coef(summary(reg_m)) + t <- (coefi[conum,1]-val)/coefi[conum,2] + pt(abs(t),reg_m$df.residual,lower.tail= F) + +} +cat("Since the p value is",p_value(l,2,1)," less than 0.05 suggesting strong evidence that beta1 < 1.0") + + +# an alternate method is to use the library car and the use linearHypothesis function, since this is one sided hypothesis +# we need to divide the result by 2 as the function does 2 sided hypothesis.. +# If "car" package not installed can be installed by install.packages("car") + +library(car) +linearHypothesis(l,hypothesis.matrix = c(0,1),rhs = 1)/2 +print("Using linearHypothesis function also we get the same result and we can derive the same inference as before.") + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.4/Ex11_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.4/Ex11_4.R new file mode 100644 index 00000000..3cc93c74 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.4/Ex11_4.R @@ -0,0 +1,27 @@ + +# Chapter 11 +# Example 11.4 page no. 406 from the pdf.. +# Confidence Interval For Intercept Of Regression Line.. + +# to find the confidence interval of the given data.. + +x <- c(3,7,11,15,18,27,29,30,30,31,31,32,33,33,34,36,36,36,37,38,39,39,39,40,41,42,42,43,44,45,46,47,50) + +y <- c(5,11,21,16,16,28,27,25,35,30,40,32,34,32,34,37,38,34,36,38,37,36,45,39,41,40,44,37,44,46,46,49,51) + +pol <- data.frame(x,y) + +line <- lm(y~x,data = pol) + +cat("The 95% confidence interval for beta0(i.e intercept) in the regression line is",confint(line,'(Intercept)',level=0.95)) + +# The answer matches with the answer in the T.B upto 2 decimal places, as T.B answer is approximated.. + + + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.5/Ex11_5.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.5/Ex11_5.R new file mode 100644 index 00000000..c710d933 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.5/Ex11_5.R @@ -0,0 +1,20 @@ + +# Chapter 11 +# Example 11.5 page no. 407 from the pdf.. +# Hypothesis Testing on Intercept of Regression line.. + +# Null - beta0 =0 +# alternate - beta0 != 0 + +x <- c(3,7,11,15,18,27,29,30,30,31,31,32,33,33,34,36,36,36,37,38,39,39,39,40,41,42,42,43,44,45,46,47,50) + +y <- c(5,11,21,16,16,28,27,25,35,30,40,32,34,32,34,37,38,34,36,38,37,36,45,39,41,40,44,37,44,46,46,49,51) + +pol <- data.frame(x,y) # making data frame of observations.. + +line <- lm(y~x,data = pol) # regression model.. + +a <- summary(line) # summary of the regression line + +cat("The p-value is",a$coef[1,"Pr(>|t|)"],"which is less than 0.05 hence we conclude that beta0 != 0") + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.6/Ex11_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.6/Ex11_6.R new file mode 100644 index 00000000..20a6a0f2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.6/Ex11_6.R @@ -0,0 +1,26 @@ + +# Chapter 11 +# Example 11.6 page no. 409 from the pdf.. +# To find the confidence interval of the mean response.. + +x <- c(3,7,11,15,18,27,29,30,30,31,31,32,33,33,34,36,36,36,37,38,39,39,39,40,41,42,42,43,44,45,46,47,50) + +y <- c(5,11,21,16,16,28,27,25,35,30,40,32,34,32,34,37,38,34,36,38,37,36,45,39,41,40,44,37,44,46,46,49,51) + +pol <- data.frame(x,y) + +line <- lm(y~x,data = pol) + +# here x0 <- 20% +data <- data.frame(x=20) + +c <- predict(line,data, interval = "confidence") + +cat("When solid reduction is 20%, the confidence interval of chemical oxygen demand is",c[2],c[3]) + +# the may vary slightly due to approximations in T.B. + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.7/Ex11_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.7/Ex11_7.R new file mode 100644 index 00000000..e4d38791 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.7/Ex11_7.R @@ -0,0 +1,26 @@ + +# Chapter 11 +# Example 11.7 page no. 411 from the pdf.. +# To Find Prediction Interval.. + +# To find the 95% prediction interval for y0 when x0 is 20% + +x <- c(3,7,11,15,18,27,29,30,30,31,31,32,33,33,34,36,36,36,37,38,39,39,39,40,41,42,42,43,44,45,46,47,50) + +y <- c(5,11,21,16,16,28,27,25,35,30,40,32,34,32,34,37,38,34,36,38,37,36,45,39,41,40,44,37,44,46,46,49,51) + +pol <- data.frame(x,y) + +line <- lm(y~x,data = pol) + + +# making a new data frame to predict.. + +data <- data.frame(x=20) + +d <- predict(line,data, interval = "prediction") + +cat("The 95% prediction interval for y0 when x0=20% is",d[2],d[3]) + + +# the answer may vary slightly due to approximation.. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.8/Ex11_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.8/Ex11_8.R new file mode 100644 index 00000000..a50aa0cc --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.8/Ex11_8.R @@ -0,0 +1,25 @@ + +# Chapter 11 +# Example 11.8 page no. 420 from the pdf.. +# Computation of Lack of Fit Sum of Squares.. + +# to do lack of fit test + +# to do lack of fit test I used the package "alr3", referance - Internet +# using only anova shows the regression and error, not lack of fit and pure error so I used this package + +install.packages("alr3") # Remove it if you have already Installed the package.. + +library("alr3") + +y <- c(77.4,76.7,78.2,84.1,84.5,83.7,88.9,89.2,89.7,94.8,94.7,95.9) + +x <- c(150,150,150,200,200,200,250,250,250,300,300,300) + +dat <- data.frame(y,x) + +c <- lm(y~x,data=dat) + +cat("The following table shows analysis of variance on temperature field data") + +pureErrorAnova(c) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.9/Ex11_9.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.9/Ex11_9.R new file mode 100644 index 00000000..41cbd90f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH11/EX11.9/Ex11_9.R @@ -0,0 +1,22 @@ + +# Chapter 11 +# Example 11.9 page no. 426 from the pdf.. +# Transformation To Linear Regression Model.. + +# given data on P and V find the constants of the equation PV^gamma = C + +v <- c(50,60,70,90,100) #volume + +p <- c(64.7,51.3,40.5,25.9,7.8) # pressure + +# the model +l <- lm(log(p)~log(v)) + +# coefficients of the model.. +co <- coefficients(l) + +# we modelled the data as lnP = lnC - gamma*lnV + additive error. + +cat("The value of C is",exp(co[1]),"and the vlaue of gamma is",-co[2]) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.1/Ex12_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.1/Ex12_1.R new file mode 100644 index 00000000..b0f41432 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.1/Ex12_1.R @@ -0,0 +1,27 @@ + +# Chapter 12 +# Example 12.1 page no. 445 from the pdf.. +# Estimation Of Equation Of Regression Line.. + +y <- c(0.90,0.91,0.96,0.89,1.00,1.10,1.15,1.03,0.77,1.07,1.07,0.94,1.10,1.10,1.10,0.91,0.87,0.78,0.82,0.95) + +x1 <- c(72.4,41.6,34.3,35.1,10.7,12.9,8.3,20.1,72.2,24.0,23.2,47.4,31.5,10.6,11.2,73.3,75.4,96.6,107.4,54.9) + +x2 <- c(76.3,70.3,77.1,68.0,79.0,67.4,66.8,76.9,77.7,67.7,76.8,86.6,76.9,86.3,86.0,76.3,77.9,78.7,86.8,70.9) + +x3 <- c(29.18,29.35,29.24,29.27,29.78,29.39,29.69,29.48,29.09,29.60,29.38,29.35,29.63,29.56,29.48,29.40,29.28,29.29,29.03,29.37) + +dat <- data.frame(y,x1,x2,x3) + +line <- lm(y~x1+x2+x3,data=dat) + +c <- coefficients(line) + +cat("The regression estimate of the above data is",c[1],"+",c[2],"*x1 +",c[3],"*x2 +",c[4],"*x3") + +pre <- data.frame(x1 = 50,x2 = 76.0,x3 = 29.30) + +# Prediction of values.. +cat("The prediction of the line for this values is") + +predict(line,pre) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.10/Ex12_10.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.10/Ex12_10.R new file mode 100644 index 00000000..a3807810 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.10/Ex12_10.R @@ -0,0 +1,38 @@ + +# Chapter 12 +# Example 12.10 page no. 477 from the pdf.. +# to predict all possible regression lines + +# refer ex10 page no. 478 on pdf. + +# using leaps library if not installed can be done by +# install.packages("leaps") + +# using sequential replacement method.. + +library(leaps) + +y <- c(57.5,52.8,61.3,67.0,53.5,62.7,56.2,68.5,69.2) + +x1 <- c(78,69,77,88,67,80,74,94,102) + +x2 <- c(48.2,45.5,46.3,49.0,43.0,48.0,48.0,53.0,58.0) + +x3 <- c(2.75,2.15,4.41,5.52,3.21,4.32,2.31,4.30,3.71) + + +x4 <- c(29.5,26.3,32.2,36.5,27.2,27.7,28.3,30.3,28.7) + + +dat <- data.frame(y,x1,x2,x3,x4) + +s <- regsubsets(y~.,data = dat,method = "seqrep") + +print("All possible regression line equation coefficients are") + +coef(s,1:4) + +# for final model we need to see adj r squared value..this is just the coefficients for various variables in the model.. + +# as nothing specific is asked here so I have shown what would be the model for all combination of variables.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.11/Ex12_11.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.11/Ex12_11.R new file mode 100644 index 00000000..d646ade9 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.11/Ex12_11.R @@ -0,0 +1,62 @@ + +# Chapter 12 +# Example 12.11 page no. 480 from the pdf.. +# to model the data set using forward selection.. + +# the data set from example 10 is used for modelling.. +y <- c(57.5,52.8,61.3,67.0,53.5,62.7,56.2,68.5,69.2) + +x1 <- c(78,69,77,88,67,80,74,94,102) + +x2 <- c(48.2,45.5,46.3,49.0,43.0,48.0,48.0,53.0,58.0) + +x3 <- c(2.75,2.15,4.41,5.52,3.21,4.32,2.31,4.30,3.71) + + +x4 <- c(29.5,26.3,32.2,36.5,27.2,27.7,28.3,30.3,28.7) + + +dat <- data.frame(y,x1,x2,x3,x4) + +# model..using forward selection + +line <- lm(y~x1,data=dat) +summary(line)$adj.r.sq + +line1 <- lm(y~x2,data=dat) +summary(line1)$adj.r.sq + +line2 <- lm(y~x3,data=dat) +summary(line2)$adj.r.sq + +line3 <- lm(y~x4,data=dat) +summary(line3)$adj.r.sq +# by looking at 4 adj r sq. values x1 has max. increase so x1 in the model +line4 <- lm(y~x1 +x2,data=dat) +summary(line4)$adj.r.sq + +line5 <- lm(y~x1 +x3,data=dat) +summary(line5)$adj.r.sq + +line6 <- lm(y~x1 +x4,data=dat) +summary(line6)$adj.r.sq +# by looking at the adj. r .sq. x1 +x3 combination has the max. value so x1+x3 in the model. + +line7 <- lm(y~x1+x3+x4,data = dat) +summary(line7)$adj.r.sq +# by looking at this estimate, adj. r. sq. is decreases so x4 is excluded from the final model.. + +line8 <- lm(y~x1+x2+x3,data = dat) +summary(line8)$adj.r.sq +cat("The correlation coefficient between x1 and x3 is",cor(x1,x2)) +#although the adj. r .squared is max. for this model,but it is high from x1+x3 by small amount,we will not include x2 as the correlation coefficient between x1 and x2 is high meaning they are dependent.. + +#final model.. +cat("The final model is ") +lm(y~x1+x3,data = dat) +summary(lm(y~x1+x3,data = dat)) +cat("The coefficients of the final model is",coefficients(lm(y~x1+x3,data = dat))) +# we can also solve the same by backward elimination.. +#So both answers are correct.. + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.12/Ex12_12.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.12/Ex12_12.R new file mode 100644 index 00000000..6178d71c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.12/Ex12_12.R @@ -0,0 +1,44 @@ +# Chapter 12 +# Example 12.12 page no.492 from the pdf.. +# Cp Statistic.. + +# to find the relationship between sales for a particular year and factor that affect sales.. + +# Package "leaps" is used if not installed can be done using install.packages("leaps") + +library(leaps) + +x1 <- c(5.5,2.5,8.0,3.0,3.0,2.9,8.0,9.0,4.0,6.5,5.5,5.0,6.0,5.0,3.5) + +x2 <- c(31,55,67,50,38,71,30,56,42,73,60,44,50,39,55) + +x3 <- c(10,8,12,7,8,12,12,5,8,5,11,12,6,10,10) + +x4 <- c(8,6,9,16,15,17,8,10,4,16,7,12,6,4,4) + +y <- c(79.3,200.1,163.2,200.1,146.0,177.7,30.9,291.9,160.0,339.4,159.6,86.3,237.5,107.2,155.0) + +dat <- data.frame(x1,x2,x3,x4,y) + +# I am comparing on basis of Cp values.. + +print("The Cp values for all subsets is") + +leaps(dat[,1:4],y= dat[,5],names = names(dat)[1:4],method ="Cp") + +# if you want to calculate adjusted r -squared or r-squared the code will be same as above just we have to change method = "r2" or method = "adjr2" + +print("From Cp values it seems that x1x2x3 model appears quite good and had lowest Cp value") + +print("Also You can see Cp for full model = 5.0 from the table in output") + +# to obatain PRESS statistic for each model , we can do something like this.. + +# this is only PRESS for full model.. +print("The PRESS for full model x1x2x3x4 is") + +model <- lm(y~.,data = dat) + +sum((model$residuals/(1-hatvalues(model)))^2) +# like this we can take any model and calculate its PRESS statistic.. +# to compare answers from T.B look for Cp stats table and PRESS valuesin the tables and match it, The answer is correct. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.13/Ex12_13.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.13/Ex12_13.R new file mode 100644 index 00000000..4ac2ae09 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.13/Ex12_13.R @@ -0,0 +1,23 @@ + +# Chapter 12 +# Example 12.13 page no.499 from the pdf.. +# Logistic regression model.. + +x <- c(0.10,0.15,0.20,0.30,0.50,0.70,0.95) + +n <- c(47,53,55,52,46,54,52) + +y <- c(8,14,24,32,38,50,50) + +p <- c(17.0,26.4,43.6,61.5,82.6,92.6,96.2)/100 + +dat <- data.frame(x,n,y,p) + +# making a logistic regression.. + +model1 <- glm(p~x,data = dat,family = binomial(link = "logit")) +summary(aov(model1)) +c <- coefficients(model1) +cat("The beta0 and beta1 for the logistic regression function is",c[1],c[2]) + +# the answer may vary slightly.. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.2/Ex12_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.2/Ex12_2.R new file mode 100644 index 00000000..ba7c481e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.2/Ex12_2.R @@ -0,0 +1,19 @@ + +# Chapter 12 +# Example 12.2 page no. 446 from the pdf.. +# to find the estimate of polynomial regression.. + +x <- c(0,1,2,3,4,5,6,7,8,9) + +y <- c(9.1,7.3,3.2,4.6,4.8,2.9,5.7,7.1,8.8,10.2) + +pol <- lm(y~x+I(x^2)) + +c <- coefficients(pol) + +dat <- data.frame(x=2) + + +cat("The fitted polynomial is",c[1],c[2],"*x +",c[3],"*x^2") + +cat("When x=2, the estimate is",predict(pol,dat)) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.3/Ex12_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.3/Ex12_3.R new file mode 100644 index 00000000..56d568eb --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.3/Ex12_3.R @@ -0,0 +1,29 @@ + +# Chapter 12 +# Example 12.3 page no. 447 from the pdf.. +# Estimate the regression coefficients in polynomial model. + +m1 <- c(14.05,14.93,16.56,15.85,22.41,21.66) + +m2 <- c(10.55,9.48,13.63,11.75,18.55,17.98) + +m3 <- c(7.55,6.59,9.23,8.78,15.93,16.44) + +observation <- c(m1,m2,m3) + +temp <- c(rep(75,6),rep(100,6),rep(125,6)) + +m <- c(rep(15,2),rep(20,2),rep(25,2)) + +ster_time <- rep(m,3) + +dat <- data.frame(observation,temp,ster_time) + +pol <- lm(observation ~ temp + ster_time + I(temp^2) + I(ster_time^2) + temp*ster_time,data = dat) + +c <- coefficients(pol) + + +cat("The fitted polynomial is",c[1],c[2],"*x1",c[3],"*x2 +",c[4],"*x1^2 +",c[5],"*x2^2 +",c[6],"*x1*x2") + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.4/Ex12_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.4/Ex12_4.R new file mode 100644 index 00000000..418e9790 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.4/Ex12_4.R @@ -0,0 +1,45 @@ + +# Chapter 12 +# Example 12.3 page no. 449 from the pdf.. +# Linear regression model using matrices.. + +# given - % survival(y) of certain type of animal semen after storage.. +# combinations of concentration of 3 materials used to increase the chance of survival.. +# estimate the linear regression model using the data by matrices form. + +y <- c(25.5,31.2,25.9,38.4,18.4,26.7,26.4,25.9,32.0,25.2,39.7,35.7,26.5) + +x1 <- c(1.74,6.32,6.22,10.52,1.19,1.22,4.10,6.32,4.08,4.15,10.15,1.72,1.70) + +x2 <- c(5.30,5.42,8.41,4.63,11.60,5.85,6.62,8.72,4.42,7.60,4.83,3.12,5.30) + +x3 <- c(10.80,9.40,7.20,8.50,9.40,9.90,8.00,9.10,8.70,9.20,9.40,7.60,8.20) + +# now forming the matrix, + + +xxdash <- matrix(c(length(x1),sum(x1),sum(x2),sum(x3),sum(x1), + sum(x1*x1),sum(x1*x2),sum(x1*x3), + sum(x2),sum(x2*x1),sum(x2*x2),sum(x2*x3), + sum(x3),sum(x3*x1),sum(x3*x2),sum(x3*x3)),byrow = T,nrow = 4) + +# now forming the matrix xdash_y + + +xdash_y <- matrix(c(sum(y),sum(x1*y),sum(x2*y),sum(x3*y)),byrow = T,nrow = 4) + +# now solving the matrix equation xxdash*b = xdash_y using solve function in R + +sol <- solve(xxdash,xdash_y) + +# final answer.. +cat("The regression line is",sol[1,1],"+",sol[2,1],"*x1", + sol[3,1],"*x2",sol[4,1],"*x3") + + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.5/Ex12_5.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.5/Ex12_5.R new file mode 100644 index 00000000..d99f2c79 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.5/Ex12_5.R @@ -0,0 +1,59 @@ + +# Chapter 12 +# example 12.5 page no. 456 from the pdf.. +# to test the hypothesis on the slope of the regression model.. + +# Null - beta2 = -2.5 +# alternate > -2.5 + +# solving example 12.4 again.. +# linear regression model using matrices.. +# given - % survival(y) of certain type of animal semen after storage.. +# combinations of concentration of 3 materials used to increase the chance of survival.. +# estimate the linear regression model using the data by matrices form. + +y <- c(25.5,31.2,25.9,38.4,18.4,26.7,26.4,25.9,32.0,25.2,39.7,35.7,26.5) + +x1 <- c(1.74,6.32,6.22,10.52,1.19,1.22,4.10,6.32,4.08,4.15,10.15,1.72,1.70) + +x2 <- c(5.30,5.42,8.41,4.63,11.60,5.85,6.62,8.72,4.42,7.60,4.83,3.12,5.30) + +x3 <- c(10.80,9.40,7.20,8.50,9.40,9.90,8.00,9.10,8.70,9.20,9.40,7.60,8.20) + +# now forming the matrix, + + +xxdash <- matrix(c(length(x1),sum(x1),sum(x2),sum(x3),sum(x1), + sum(x1*x1),sum(x1*x2),sum(x1*x3), + sum(x2),sum(x2*x1),sum(x2*x2),sum(x2*x3), + sum(x3),sum(x3*x1),sum(x3*x2),sum(x3*x3)),byrow = T,nrow = 4) + +# now forming the matrix xdash_y + + +xdash_y <- matrix(c(sum(y),sum(x1*y),sum(x2*y),sum(x3*y)),byrow = T,nrow = 4) + +# now solving the matrix equation xxdash*b = xdash_y using solve function in R + +sol <- solve(xxdash,xdash_y) + +unit <- matrix(c(c(1,0,0,0),c(0,1,0,0),c(0,0,1,0),c(0,0,0,1)),ncol = 4) + + +# finding inverse of the matrix xxdash.. +inv_xxdash <- solve(xxdash,unit) + +# final answer.. +cat("The regression line is",sol[1,1],"+",sol[2,1],"*x1", + sol[3,1],"*x2",sol[4,1],"*x3") + +# the coefficient of x2 (i.e beta2) is -1.861649 as we can see from the solution.. +# now testing our hypothesis.. + +t.score <- (sol[3,1]+2.5)/(2.073*sqrt(inv_xxdash[3,3])) + +cat("The p-value is",pt(t.score,9,lower.tail = F),"we reject the null hypothesis and conclude beta2 > -2.5") + +# the answer in the T.B is double the value obtained by computation, +#I think they took both sided alternative, but we have to take only one sided alternative as our alternative is beta2 > -2.5, +#hence it is one sided and so T.B answer is wrong.. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.6/Ex12_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.6/Ex12_6.R new file mode 100644 index 00000000..2914b3ec --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.6/Ex12_6.R @@ -0,0 +1,28 @@ + +# Chapter 12 +# Example 12.6 page no. 457 from the pdf.. +# To Construct Confidence Interval for Mean Response.. + +y <-c(25.5,31.2,25.9,38.4,18.4,26.7,26.4,25.9,32.0,25.2,39.7,35.7,26.5) + +x1 <- c(1.74,6.32,6.22,10.52,1.19,1.22,4.10,6.32,4.08,4.15,10.15,1.72,1.70) + +x2 <- c(5.30,5.42,8.41,4.63,11.60,5.85,6.62,8.72,4.42,7.60,4.83,3.12,5.30) + +x3 <- c(10.80,9.40,7.20,8.50,9.40,9.90,8.00,9.10,8.70,9.20,9.40,9.60,8.20) + +dat <- data.frame(y,x1,x2,x3) + +c <- lm(y~x1+x2+x3,data= dat) + +newdat <- data.frame(x1=3,x2=8,x3=9) + +d <- predict(c,newdat,interval = "confidence",level = 0.95,type = "response") + +cat("The 95% confidence interval for the mean response when x1=3%,x2=8% and x3=9% is",d[2],d[3]) + +# the answer may vary slightly from the T.B + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.7/Ex12_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.7/Ex12_7.R new file mode 100644 index 00000000..7b0abe64 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.7/Ex12_7.R @@ -0,0 +1,24 @@ + +# Chapter 12 +# Example 12.7 Page no. 458 from the pdf.. +# Prediction interval Evaluation.. + +y <-c(25.5,31.2,25.9,38.4,18.4,26.7,26.4,25.9,32.0,25.2,39.7,35.7,26.5) + +x1 <- c(1.74,6.32,6.22,10.52,1.19,1.22,4.10,6.32,4.08,4.15,10.15,1.72,1.70) + + +x2 <- c(5.30,5.42,8.41,4.63,11.60,5.85,6.62,8.72,4.42,7.60,4.83,3.12,5.30) + +x3 <- c(10.80,9.40,7.20,8.50,9.40,9.90,8.00,9.10,8.70,9.20,9.40,9.60,8.20) + +dat <- data.frame(y,x1,x2,x3) + +c <- lm(y~x1+x2+x3,data= dat) #modelling the variables of datasaet.. + + +newdat <- data.frame(x1=3,x2=8,x3=9) + +d <- predict(c,newdat,interval = "prediction") + +cat("The 95% prediction interval for the individual response when x1=3%,x2=8% and x3=9% is",d[2],d[3]) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.8/Ex12_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.8/Ex12_8.R new file mode 100644 index 00000000..bc742b61 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.8/Ex12_8.R @@ -0,0 +1,27 @@ + +# Chapter 12 +# Example 12.8 page no. 470 from the pdf.. +# To show Analysis of Variance Table for Grain Radius Data + +pow_temp <- c(150,190,150,150,190,190,150,190) +ext_rate <- c(12,12,24,12,24,12,24,24) +die_temp <- c(220,220,220,250,220,250,250,250) + + + +gra_radius <- c(82,93,114,124,111,129,157,164) + +dat <- data.frame(pow_temp,ext_rate,die_temp,gra_radius) + +# converting into factors.. +dat$pow_temp <- factor(dat$pow_temp) +dat$ext_rate <- factor(dat$ext_rate) +dat$die_temp <- factor(dat$die_temp) + + +l <- lm(gra_radius~pow_temp+ext_rate+die_temp,data = dat) + +# analysis of variance table for grain radius data.. +print("The analysis of variance table for this data is:") +summary(aov(l,data= dat)) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.9/Ex12_9.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.9/Ex12_9.R new file mode 100644 index 00000000..fc26d041 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH12/EX12.9/Ex12_9.R @@ -0,0 +1,22 @@ + +# Chapter 12 +# Example 12.9 page no. 474 from the pdf.. +# to find the model for data which have 3 levels in a variable.. + +y <- c(292,329,352,378,392,410,198,227,277,297,364,375,167,225,247,268,288,342) + +x <- c(6.5,6.9,7.8,8.4,8.8,9.2,6.7,6.9,7.5,7.9,8.7,9.2,6.5,7.0,7.2,7.6,8.7,9.2) + +p <- c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3) + +dat <- data.frame(y,x,factor(p)) + +dat$factor.p. <- relevel(dat$factor.p.,ref=3) + +c <- lm(y ~ x +factor.p.,data= dat) + +cat("The model suggests") + +coefficients(c) # Coefficients of the model.. + +summary(c) # Summary of the regression model.. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.1/Ex13_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.1/Ex13_1.R new file mode 100644 index 00000000..6e0f05e2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.1/Ex13_1.R @@ -0,0 +1,20 @@ + +# Chapter 13 +# Example 13.1 page no. 513 from the pdf.. +# One way ANOVA.. + +# H0: mu1=mu2=mu3=mu4=mu5 +# H1 : atleast two of means not equal.. + +a <- c(551,457,450,731,499,632,595,580,508,583,633,517,639,615,511,573,648,677,417,449,517,438,415,555,563,631,522,613,656,679) + +b <- c(rep(1,6),rep(2,6),rep(3,6),rep(4,6),rep(5,6)) + +dat <- data.frame(a,b) + +c <- aov(a~factor(b),data = dat) + +summary(c) + +cat("Since the p-value is 0.00875 we reject null hypothesis and and conclude aggregates don't have same mean absorption") + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.2/Ex13_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.2/Ex13_2.R new file mode 100644 index 00000000..67189cec --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.2/Ex13_2.R @@ -0,0 +1,23 @@ + +# Chapter 13 +# Example 13.2 page no. 514 from the pdf.. +# One way ANOVA.. + +# NULL : H0: mu1=mu2=mu3=mu4 +# alternate : H1: at least two are not equal + + +a <- c(49.20,44.54,45.80,95.84,30.10,36.50,82.30,87.85,105.00,95.22,97.50,105.00,58.05,86.60,58.35,72.80,116.70,45.15,70.35,77.40,97.07,73.40,68.50,91.85,106.60,0.57,0.79,0.77,0.81,62.10,94.95,142.50,53.00,175.00,79.50,29.50,78.40,127.50,110.60,57.10,117.60,77.71,150.00,82.90,111.50) + +b <- c(rep(1,20),rep(2,9),rep(3,9),rep(4,7)) + +dat <- data.frame(a,b) + +c <- aov(a~factor(b),data = dat) # anova + +summary(c) # Analysis of Variance table + +cat("Since the p-value is 0.022,we reject the null hypothesisand conclude alkaline levels for the four drug groups are not the same") + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.3/Ex13_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.3/Ex13_3.R new file mode 100644 index 00000000..099b0a6b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.3/Ex13_3.R @@ -0,0 +1,24 @@ + +# Chapter 13 +# Example 13.3 page no. 517 from the pdf.. +# Bartlett Test.. + +# to test the following hypothesis +# NULL : H0: sig1^2=sig2^2=sig3^2=sig4^2 +# alternate : H1: at least two are not equal + +# using bartlett test.. +a <- c(49.20,44.54,45.80,95.84,30.10,36.50,82.30,87.85,105.00,95.22,97.50,105.00,58.05,86.60,58.35,72.80,116.70,45.15,70.35,77.40,97.07,73.40,68.50,91.85,106.60,0.57,0.79,0.77,0.81,62.10,94.95,142.50,53.00,175.00,79.50,29.50,78.40,127.50,110.60,57.10,117.60,77.71,150.00,82.90,111.50) + +b <- c(rep("I",20),rep("J",9),rep("K",9),rep("L",7)) + +dat <- data.frame(a,b) + +bartlett.test(a~b,data = dat) # display of Bartlett test.. + +cat("The p-value is",bartlett.test(a~b,data = dat)$p.value,"we do not reject the null hypothesis and conclude popn. variances are not significantly different") + +# the T.B has done this by comparing the areas in the left tail of bartlett distribution,using bartlett test function directly gives p-value in R, so it is more handy.. + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.4/Ex13_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.4/Ex13_4.R new file mode 100644 index 00000000..eae770a4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.4/Ex13_4.R @@ -0,0 +1,38 @@ + +# Chapter 13 +# Example 13.4 page no. 522 from the pdf.. +# Contrasts Sum Of Squares Corresponding to orthogonal Contrasts.. + +# from ex 13.1.. +# w1 = mu1+mu2-mu3-mu5, w2 = mu1+mu2+mu3-4mu4+ mu5. +# w3 = mu1 -mu2 , w4 = mu3-mu5. + +a <- c(551,457,450,731,499,632,595,580,508,583,633,517,639,615,511,573,648,677,417,449,517,438,415,555,563,631,522,613,656,679) + +b <- c(rep(1,6),rep(2,6),rep(3,6),rep(4,6),rep(5,6)) + +# making a data frame and re-classifying the data. +dat <- data.frame(a,b) +dat$b <- as.factor(dat$b) + +# the ANOVA.. +l <- lm(a~b,data = dat) +anova(l) + +# contrasts coefficients.. +contrastmatrix <- cbind(c(1,1,-1,0,-1),c(1,1,1,-4,1),c(1,-1,0,0,0), + c(0,0,1,0,-1)) +contrasts(dat$b) <- contrastmatrix + + +l_contrast <- aov(a~b,data = dat) + + +print("The Analysis of Variance Table Using ortogonal contrats is:") +summary(l_contrast, split = list(b = list("(1,2)vs (3,5)"=1,"1,2,3,5 vs 4"=2))) + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.5/Ex13_5.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.5/Ex13_5.R new file mode 100644 index 00000000..47bc8262 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.5/Ex13_5.R @@ -0,0 +1,26 @@ + +# Chapter 13 +# Example 13.5 page no. 529 from the pdf.. +# Dunnett Test.. + +# To compare each catalyst with control using 2 sided hypothesis.. +# Package used "DescTools", if already installed delete the below line from the code.. +install.packages("DescTools") + +library(DescTools) + +co <- c(50.7,51.5,49.2,53.1,52.7) + +cat1 <- c(54.1,53.8,53.1,52.5,54.0) + +cat2 <- c(52.7,53.9,57.0,54.1,52.5) + +cat3 <- c(51.2,50.8,49.7,48.0,47.2) + +DunnettTest(list(co,cat1,cat2,cat3)) + +# The value of Diff column in the table varies slightly from the T.B, due to approximatons.. +# Like d1 and d3 in T.B are 2.14 and -2.14, and from computation coming out to be 2.06 and -2.06 so that's due to approximations or different method to approach the same problem but final inferences are same.. + +print("From the Table looking at p-value we conclude that catalyst 2 is significantly different from the mean yield of the reaction using the control..") + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.6/Ex13_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.6/Ex13_6.R new file mode 100644 index 00000000..cf4f109e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.6/Ex13_6.R @@ -0,0 +1,36 @@ + +# Chapter 13 +# Example 13.8 page no. 537 from the pdf.. +# Randomized Complete Block Diagram.. + +# to to test hypothesis(0.05 level) that machines perform at the same mean rate of speed +# 6 different operators used in randomized block experiment to compare 4 machines.. + +m1 <- c(42.5,39.3,39.6,39.9,42.9,43.6) + +m2 <- c(39.8,40.1,40.5,42.3,42.5,43.1) + +m3 <- c(40.2,40.5,41.3,43.4,44.9,45.1) + +m4 <- c(41.3,42.2,43.5,44.2,45.9,42.3) + +dat <- rbind(m1,m2,m3,m4) # combining rows to make matrix.. + +a <- c(t(as.matrix(dat))) # concatenate different rows into a vector.. + +b <- c("o1","o2","o3","o4","o5","o6") # treatment levels + +n_tr <- 6 # no. of treatment levels + +n_cont <- 4 # no. of control blocks.. + +operator <- gl(n_tr,1,n_cont*n_tr,factor(b)) # vector of treatment factors corresponding to each element of vector a.. + +machines <- gl(n_cont,n_tr,n_tr*n_cont) # vector of blocking factors corresponding to each element in vector a.. + +print("The Analysis of Variance table is:") + +summary(aov(a~operator+machines)) # anova table display.. + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.7/Ex13_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.7/Ex13_7.R new file mode 100644 index 00000000..5093588a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH13/EX13.7/Ex13_7.R @@ -0,0 +1,32 @@ + +# Chapter 13 +# Example 13.7 page no. 549 from the pdf.. +# Random Effects Model.. +# to find the batch variance component from the data.. + +m1 <- c(9.7,5.6,8.4,7.9,8.2,7.7,8.1) + +m2 <- c(10.4,9.6,7.3,6.8,8.8,9.2,7.6) + +m3 <- c(15.9,14.4,8.3,12.8,7.9,11.6,9.8) + +m4 <- c(8.6,11.1,10.7,7.6,6.4,5.9,8.1) + +m5 <- c(9.7,12.8,8.7,13.4,8.3,11.7,10.7) + +dat <- cbind(m1,m2,m3,m4,m5) + +b <- c(t(as.matrix(dat))) + +a <- c("b1","b2","b3","b4","b5") + +n_batch <- 5 # n. of treatment groups + +n_row <- 7 # no. of rows.. + +batch <- gl(n_batch,1,n_row*n_batch,factor(a)) # vector of treatment factors corresponding to each element of vector b.. + +summary(c <- aov(b~batch)) + +cat("From the table we can calculate the estimated variance from the mean sq. values which comes out to be",(18.149-4.068)/n_row) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.1/Ex14_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.1/Ex14_1.R new file mode 100644 index 00000000..19b03b0f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.1/Ex14_1.R @@ -0,0 +1,40 @@ + +# Chapter 14 +# Example 14.1 page no. 571 from the pdf.. +# Two Factor Analysis of Variance.. + +# H0`: alpha1=alpha2=alpha3=0 +#H0``:beta1=beta2=beta3=beta4=0 +#H0```:(alpha*beta)11=(alpha*beta)12...=(alpha*beta)34=0 +# H1`: atleast one of alpha non zero +# H1``: atleast one of the beta non zero +#H1```:atleast one of the (alpha*beta) non zero.. + +v1 <- c(34.0,32.7,32.0,33.2,28.4,29.3) + +v2 <- c(30.1,32.8,30.2,29.8,27.3,28.9) + +v3 <- c(29.8,26.7,28.7,28.1,29.7,27.3) + +v4 <- c(29.0,28.9,27.6,27.8,28.8,29.1) + +observations <- c(v1,v2,v3,v4) + +prop_type <- c(rep(1,6),rep(2,6),rep(3,6),rep(4,6)) + +a <- c(rep(1,2),rep(2,2),rep(3,2)) + +missile_sys <- c(rep(a,4)) + +dat <- data.frame(observations,prop_type,missile_sys) + +d <- aov(observations~factor(missile_sys)*factor(prop_type),data = dat) + +summary(d) # analysis of variance table.. + +cat("We reject H0` and conclude that different missile have different propellent rates as p- value is 0.0169") + +cat("We reject H0``and conclude that mean propellent rates are not same for 4 propellent types as p- value is 0.0010") + +cat("p-value is approx. 0.0513, so interaction is barely significant.") + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.2/Ex14_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.2/Ex14_2.R new file mode 100644 index 00000000..46386b42 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.2/Ex14_2.R @@ -0,0 +1,47 @@ + +# Chapter 14 +# Example 14.2 page no. 571 from the pdf.. +# Single Degree Of Freedom Sum Of Squares.. + +# to choose 2 orthogonal contrasts to partition the sum of sqaures for missile systems into +# single-degree-of-freedom components to be used in comparing systems 1 and 2 versus 3 and system 1 with system 2. + + +v1 <- c(34.0,32.7,32.0,33.2,28.4,29.3) + +v2 <- c(30.1,32.8,30.2,29.8,27.3,28.9) + +v3 <- c(29.8,26.7,28.7,28.1,29.7,27.3) + +v4 <- c(29.0,28.9,27.6,27.8,28.8,29.1) + +observations <- c(v1,v2,v3,v4) + +prop_type <- c(rep(1,6),rep(2,6),rep(3,6),rep(4,6)) + +a <- c(rep(1,2),rep(2,2),rep(3,2)) + +missile_sys <- c(rep(a,4)) + +dat <- data.frame(observations,prop_type,missile_sys) + +dat$missile_sys <- as.factor(dat$missile_sys) + +contrastmatrix <- cbind(c(1,1,-2),c(1,-1,0)) + +contrasts(dat$missile_sys) <- contrastmatrix + +missile_contrast <- aov(observations~missile_sys,data = dat) + + +print("The Sum of Squares for missiles systems to be used in comparing systems 1 and 2 versus 3 and system 1 versus 2 can be seen from the analysis of variance table below.") +summary(missile_contrast, split = list(missile_sys = + list("(1,2) vs 3"=1,"1 vs 2"=2))) + + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.3/Ex14_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.3/Ex14_3.R new file mode 100644 index 00000000..c5e5000f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.3/Ex14_3.R @@ -0,0 +1,28 @@ + +# Chapter 14 +# Example 14.3 page no. 574 from thr pdf.. +# Evaluate Analysis of Variance table and derive conclusion,also test on main effects.. + +m1 <- c(288,488,670,360,465,720) + +m2 <- c(385,482,692,411,521,724) + +m3 <- c(488,595,761,462,612,801) + +obs <- c(m1,m2,m3) + +power_supp <- c(rep(1:3,6)) + + +flow_rate <- c(rep(1,6),rep(2,6),rep(3,6)) + +dat <- data.frame(obs,power_supp,flow_rate) + +d <- aov(obs~factor(flow_rate)*factor(power_supp),data = dat) + +summary(d) + +cat("p-value for test of interaction is 0.4484 so we conclude there is no significant interaction") + +# duncan test can be done by duncan.test, in agricolae library, I am having some problems with the package it is not installing the package and showing some error, so I cannot use duncan.test function.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.4/Ex14_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.4/Ex14_4.R new file mode 100644 index 00000000..fb4c8afd --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.4/Ex14_4.R @@ -0,0 +1,31 @@ + +# Chapter 14 +# Example 14.4 page no. 581 from the pdf.. +# Anova for 3 factor experiment.. + +m1 <- c(10.7,10.3,11.2,10.9,10.5,12.2,10.8,10.2,11.6,12.1,11.1,11.7,11.3,10.5,12.0,11.5,10.3,11.0) + +m2 <- c(11.4,10.2,10.7,9.8,12.6,10.8,11.8,10.9,10.5,11.3,7.5,10.2,11.5,10.5,10.2,10.9,9.9,11.5) + +m3 <- c(13.6,12.0,11.1,10.7,10.2,11.9,14.1,11.6,11.0,11.7,11.5,11.6,14.5,11.5,11.5,12.7,10.9,12.2) + + +obs <- c(m1,m2,m3) + +operator <- c(rep(1,18),rep(2,18),rep(3,18)) + +catalyst <- c(rep(1:3,18)) + +a <- c(rep("15 min",3),rep("20 min",3)) + +washing_time <- c(rep(a,9)) + +dat <- data.frame(obs,operator,catalyst,washing_time) + +d <- aov(obs~(factor(operator)*factor(catalyst)*factor(washing_time)),data = dat) + +print("The Analysis of Variance Table is shown as follows:") + +summary(d) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.5/Ex14_5.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.5/Ex14_5.R new file mode 100644 index 00000000..e3733f9e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.5/Ex14_5.R @@ -0,0 +1,37 @@ + +# Chapter 14 +# Example 14.5 page no. 584 from the pdf.. +# Pooling in Multifactor Model.. + +# to find the anova table from the following data set by removing some interactions and then look at the effect.. + +m1 <- c(43,49,44,47) + +m2 <- c(64,68,97,102) + +m3 <- c(49,57,51,55) + +m4 <- c(70,76,103,106) + +obs <- c(m1,m2,m3,m4) + +a <- c(rep("L",4),rep("H",4)) +temp <- c(rep(a,2)) + +batch <- c(rep(1,8),rep(2,8)) + +b <- c(rep("Low",2),rep("high",2)) +string_rate <- c(rep(b,4)) + +pressure <- c(rep(c("Low","High"),8)) + +dat <- data.frame(obs,batch,temp,string_rate,pressure) # making data frame + +cat("The anova table after removing particular interactions is") + +summary(aov(obs~factor(batch)+factor(temp)*factor(pressure)*factor(string_rate),data = dat)) # taking the elements of interest for interaction.. + +# we can also use "update" function by writitng the full model of 4 variables and subtracting the undesired interactions,but it will be very tedious.. + +# the answer may vary slightly.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.6/Ex14_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.6/Ex14_6.R new file mode 100644 index 00000000..7c0bd3ae --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH14/EX14.6/Ex14_6.R @@ -0,0 +1,30 @@ + +# Chapter 14 +# Example 14.6 page no. 589 from the pdf.. +# Factorial Experiments for Random Effects.. + +# to determine which are the important sources of variation in an industrial process + +op1 <- c(66.9,68.3,69.0,69.3,68.1,67.4,69.8,70.9,67.2,67.7,67.5,71.4) + +op2 <- c(66.3,68.1,69.7,69.4,65.4,66.9,68.8,69.6,65.8,67.6,69.2,70.0) + +op3 <- c(65.6,66.0,67.1,67.9,66.3,66.9,66.2,68.4,65.2,67.3,67.4,68.7) + + +obs <- c(op1,op2,op3) + +operator <- c(rep(1,12),rep(2,12),rep(3,12)) + +batch <- c(rep(1:4,9)) + + +dat <- data.frame(obs,operator, batch) + +print("The analysis of variance table for this example is:") + +summary(aov(obs~factor(operator)+ factor(batch) + factor(batch)*factor(operator)),data = dat) +# interaction in this case is the product of operator and batch components. + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.1/Ex15_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.1/Ex15_1.R new file mode 100644 index 00000000..a2ad797d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.1/Ex15_1.R @@ -0,0 +1,22 @@ + +# Chapter 15 +# Example 15.1 page no. 601 from the pdf.. +# 2^2 factorial Experiment.. + +# 2^2 factorial with no interaction +obs <- c(50,70,80,100) + +a_no <- c(rep(1,2),rep(-1,2)) + +b_no <- c(rep(c(-1,1),2)) + +cat("The main effects are A =",(sum(obs[1:2])-sum(obs[3:4]))/2) + +cat("B = ",(obs[4]+obs[2])/2-(obs[1]+obs[3])/2) + +cat("The interaciton effect is",(obs[1]+obs[4])/2-(obs[2]+obs[3])/2) + +obs1 <- c(50,70,80,40) + +cat("The interaction effect in this case is",(obs1[2]+obs1[3])/2-(obs1[1]+obs1[4])/2) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.2/Ex15_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.2/Ex15_2.R new file mode 100644 index 00000000..7414cf20 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.2/Ex15_2.R @@ -0,0 +1,31 @@ + +# Chapter 15 +# example 15.2 page no. 613 from the pdf +# Factorial Experiment in a Regression Setting.. + +hold_tim <- c(0.5,0.8,0.5,0.8) + +flex_time <- c(0.10,0.10,0.20,0.20) + +yield <- c(28,39,32,46) + +dat <- data.frame(hold_tim,flex_time,yield) + +dat$hold_tim <- factor(dat$hold_tim) +dat$flex_time <- factor(dat$flex_time) + + +f <- function(x){ + + dat$yield[x] + +} + +levels(dat$hold_tim) <- c(-1,1) +levels(dat$flex_time) <- c(-1,1) + +cat("The regression equation is",(f(1)+f(2)+f(3)+f(4))/4,"+",(f(2)+f(4)-f(1)-f(3))/4,"*x1 +",(f(3)+f(4)-f(1)-f(2))/4,"*x2") + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.4/Ex15_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.4/Ex15_4.R new file mode 100644 index 00000000..5d3f4aef --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.4/Ex15_4.R @@ -0,0 +1,17 @@ + +# Chapter 15 +# example 15.4 page no. 619 +# Standard Errors of the least Sqaures Regression Coefficients + +# given data and anova table, to find the standard errors of the least squares regression coefficients.. + +# Note 15.3 - Theoretical with nothing to compute.. + +# standard errors of all coefficients for the 2^k factorial are equal so.. +# from anova table given s^2 = 2.46 + +cat("The standard error of the least squares regression coefficients are",sqrt(2.46/(2^4*2))) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.6/Ex15_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.6/Ex15_6.R new file mode 100644 index 00000000..e80ee1c6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.6/Ex15_6.R @@ -0,0 +1,31 @@ + +# Chapter 15 +# example 15.6 page no.633 from the pdf.. +# use a half replicate to study the effects of five factors each at 2 levels on some response.. +# to perform analysis of variance on the data below testing all main effects for the significance at the 0.05 level.. + +response <- c(11.3,15.6,12.7,10.4,9.2,11.0,8.9,9.6,14.1,14.2,11.7,9.4,16.2,13.9,14.7,13.2) +treatment <- c("a","b","c","d","e","abc","abd","acd","bcd","abe","ace","ade","bce","bde","cde","abcde") +cat("The sum of squares and effects for the main effects are") + +a <- sum(response)-2*sum(response[which(treatment %in% c("b","c","d","e","bcd","bce","bde","cde"))]) + +b <- sum(response)-2*sum(response[which(treatment %in% c("a","c","d","e","acd","ace","ade","cde"))]) + +c <- sum(response)-2*sum(response[which(treatment %in% c("b","a","d","e","abd","abe","ade","bde"))]) + +d <- sum(response)-2*sum(response[which(treatment %in% c("b","c","a","e","abc","abe","ace","bce"))]) + +e <- sum(response)-2*sum(response[which(treatment %in% c("b","c","d","a","abc","abd","acd","bcd"))]) + +cat("The sum of squares and effects for the main effects are") + +cat("SSA=",a^2/16,"and A=",a/8) + +cat("SSB=",b^2/16,"and B=",b/8) + +cat("SSC=",c^2/16,"and C=",c/8) + +cat("SSD=",d^2/16,"and D=",d/8) + +cat("SSE=",e^2/16,"and E=",e/8) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.7/Ex15_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.7/Ex15_7.R new file mode 100644 index 00000000..2e5bdf54 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.7/Ex15_7.R @@ -0,0 +1,14 @@ + +# Chapter 15 +# example 15.7 page no. 639 +# to construct a 2 level screening design with 6 variables containing 12 design points.. +# used package FrF2, if not installed can be installed using install.packages("FrF2") + +library(FrF2) + +print("The 2 level scrrening design with 6 variables containing 12 design points is") + +pb(12,6,randomize = F,default.levels = c("-","+")) + +# the answer may differ but the concept is same, the T.B as well as the software answers are correct, R has selected randomly the design, +#if we set randomize= T, then every time the instruction is executed then every time a diferent design will appear, so that's why the design is correct. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.8/Ex15_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.8/Ex15_8.R new file mode 100644 index 00000000..d7a182c2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH15/EX15.8/Ex15_8.R @@ -0,0 +1,46 @@ + +# Chapter 15 +# example 15.8 page no. 640 from the pdf.. +# Response Surface Analysis.. + +# a central composite design is given on page no.641 of the pdf,to determine the impact that x1 and x2 have on % conversion process.. +#Package used - rsm if not installed can be done using install.packaged("rsm") +library(rsm) + +x1 <- c(-1,1,-1,1,-1.414,1.414,0,0,0,0,0,0) + +x2 <- c(-1,-1,1,1,0,0,-1.414,1.414,0,0,0,0) + +y <- c(43,78,69,73,48,78,65,74,76,79,83,81) + +dat <- data.frame(x1,x2,y) + +res_model <- rsm(y~FO(x1,x2,x1^2,x2^2,x1*x2),data = dat) + +print("The coefficients of the resulting second order response model is given in coded variables as") + +coefficients(res_model) + +print("The detailed response surface model is given below") + +summary(res_model) + + +# the natural model.. +e1 <- c(200,250,200,250,189.65,260.35,225,225,225,225,225,225) + +e2 <- c(15,15,25,25,20,20,12.93,27.07,20,20,20,20) + +dat1 <- data.frame(e1,e2,y) + +print("The natural surface model is shown below:") + +nat_model <- lm(y~e1+e2+I(e1^2)+I(e2^2)+I(e1*e2),data = dat1) + +summary(nat_model) + +print("The coefficients of the natural surface model is given as follows:") + +coefficients(nat_model) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.1/Ex16_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.1/Ex16_1.R new file mode 100644 index 00000000..053ee5be --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.1/Ex16_1.R @@ -0,0 +1,26 @@ + +# Chapter 16 +# Example 16.1 page no. 658 from the pdf.. +# use sign test to test the hypothesis.. + +# Package used "BSDA", referance- Internet.. + +install.packages("BSDA") # package for sign testing + +library("BSDA") + +#NULL H0:mu=1.8 +#alternate: mu!= 8 + +dat <- c(1.5,2.2,0.9,1.3,2.0,1.6,1.8,1.5,2.0,1.2,1.7) + + +SIGN.test(dat,md=1.8) + +cat("Since The p-value is",SIGN.test(dat,md=1.8)$p.value,"we do not reject the null hypothesis.") + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.2/Ex16_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.2/Ex16_2.R new file mode 100644 index 00000000..446e45ed --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.2/Ex16_2.R @@ -0,0 +1,28 @@ + +# Chapter 16 +# Example 16.2 page no. 659 from the pdf.. +# Hypothesis Testing Using Sign Test.. +# to test the hypothesis with 0.05 level of significance + +# Null :mu1-mu2 =0 +#alternate:mu1-mu2 !=0 + + +install.packages("BSDA") # package for sign testing +#if already installed comment it.. + + +library("BSDA") + +rad_tires <- c(4.2,4.7,6.6,7.0,6.7,4.5,5.7,6.0,7.4,4.9,6.1,5.2,5.7,6.9,6.8,4.9) + +bel_tires <- c(4.1,4.9,6.2,6.9,6.8,4.4,5.7,5.8,6.9,4.9,6.0,4.9,5.3,6.5,7.1,4.8) + +diff <- data.frame(rad_tires,bel_tires) + +SIGN.test(rad_tires,bel_tires,alternative = "greater",paired =T) + +cat("Since the p-value is",SIGN.test(rad_tires,bel_tires,alternative = "greater",paired =T)$p.value,"we reject null, so on average radial tires do improve fuel economy") + + +#the answer is slightly different than in the T.B as in T.B normal approximation is used.. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.3/Ex16_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.3/Ex16_3.R new file mode 100644 index 00000000..6c84db23 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.3/Ex16_3.R @@ -0,0 +1,18 @@ + +# Chapter 16 +# Example 16 page no. 661 from the pdf.. +#use signed rank test to test the hypothesis.. + +#NULL H0:mu=1.8 +#alternate: mu!= 8 + +dat <- c(1.5,2.2,0.9,1.3,2.0,1.6,1.8,1.5,2.0,1.2,1.7) + +wilcox.test(dat,alternative = "two.sided",mu=1.8) + + +cat("The p-vaue is more than 0.05,we don't reject null and conclude median operating time not significantly different from 1.8hrs") + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.4/Ex16_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.4/Ex16_4.R new file mode 100644 index 00000000..0373a695 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.4/Ex16_4.R @@ -0,0 +1,18 @@ + +# Chapter 16 +# Example 16.4 page no. 662 from the pdf.. +#use signed rank test to test the hypothesis.. + +# to do hypothesis testing on effect of sample questions on one's gre score.. + +# NUll H0: mu1-mu2=50 +#alternate:mu1-mu2 <50 + +with_sample <- c(531,621,663,579,451,660,591,719,543,575) + +without_sample <- c(509,540,688,502,424,683,568,748,530,524) + +wilcox.test(with_sample,without_sample,mu=50,paired = T,alternative = "less") + +cat("since the p-value is",wilcox.test(with_sample,without_sample,mu=50,paired = T,alternative = "less")$p.value,"we reject null and conclude that sample problems don't increase graduate record score by as much as 50 points on average..") + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.5/Ex16_5.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.5/Ex16_5.R new file mode 100644 index 00000000..8d281f5e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.5/Ex16_5.R @@ -0,0 +1,15 @@ + +# Chapter 16 +# Example 16.5 page no. 666 from the pdf.. +# to perform wilcoxin rank sum test... + +# Null H0 :mu1=mu2 +#alternate: mu1!=mu2 + +brand_a <- c(2.1,4.0,6.3,5.4,4.8,3.7,6.1,3.3) + +brand_b <- c(4.1,0.6,3.1,2.5,4.0,6.2,1.6,2.2,1.9,5.4) + +wilcox.test(brand_a,brand_b,alternative = "two.sided") + +cat("Since the p-value is",wilcox.test(brand_a,brand_b,alternative = "two.sided")$p.value,"we do not reject null and conclude that there is no significant difference in median nicotine contents of the above two brand of cigarettes") diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.6/Ex16_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.6/Ex16_6.R new file mode 100644 index 00000000..295e99a4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.6/Ex16_6.R @@ -0,0 +1,24 @@ + +# Chapter 16 +# Example 16.6 page no. 668 from the pdf.. +# Kruskal-Wallis Test.. + +# to do hypothesis testing of propellent burning rates for 3 missile system using kruskal wallis test.. + +#Null: H0: mu1=mu2=mu3 +#alternate : the means are not equal. +#alpha = 0.05 + +m1 <- c(24.0,16.7,22.8,19.8,18.9) + +m2 <- c(23.2,19.8,18.1,17.6,20.2,17.8) + +m3 <- c(18.4,19.1,17.3,17.3,19.7,18.9,18.8,19.3) + +obs <- c(m1,m2,m3) + +miss_sys <- c(rep(1,5),rep(2,6),rep(3,8)) + +kruskal.test(obs,factor(miss_sys)) + +cat("Since the p-value is",kruskal.test(obs,factor(miss_sys))$p.value,"we failed to reject null that propellent burning rates are same for the 3 missile system") diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.7/Ex16_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.7/Ex16_7.R new file mode 100644 index 00000000..9cf7d2c3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.7/Ex16_7.R @@ -0,0 +1,22 @@ + +# Chapter 16 +# Example 16.7 page no. 672 from the pdf.. +# Runs Test.. + +# to do hypothesis testing of randomness of the sequence.. + +# Null :H0= sequence is random +# alternate: H1= sequence is is not random.. + +# package used - "randtests", referance - internet.. +install.packages("randtests") # package for runs.test +# comment it if already installed.. + +library("randtests") + +content <- c(3.6,3.9,4.1,3.6,3.8,3.7,3.4,4.0,3.8,4.1,3.9,4.0,3.8,4.2,4.1) + +runs.test(content,alternative = "two.sided") + + +cat("The p-value is more than 0.1 we don't reject the null and conclude that sequence of measured values varies randomly") diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.8.9/Ex16_8&9.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.8.9/Ex16_8&9.R new file mode 100644 index 00000000..f8e66635 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH16/EX16.8.9/Ex16_8&9.R @@ -0,0 +1,26 @@ + +# Chapter 16 +# Example 16.8 page no. 675 and example 16.9 page no.677 from the pdf.. +# Rank Correlation Coefficient.. + +# to find the rank correlation coefficient between tar and nicotine content in cigarettes.. +# I am solving ex 8 and 9 in this code only as in 8 correlation coefficient is asked and in 9th hypothesis testing of the sam eproblem is done + +# to do hypothesis testing of correlation between tar and nicotine content in cigarettes +# null H0:rho=0 +# alternate H1: rho>0 +# alpha =0.01 + +tar <- c(14,17,28,17,16,13,24,25,18,31) + +nicotine_cont <- c(0.9,1.1,1.6,1.3,1.0,0.8,1.5,1.4,1.2,2.0) + +cor.test(tar,nicotine_cont,method = "spearman",alternative = "greater") + +cat("From the test we can see the value of rank correlation coefficint(rho) is 0.9665698 indicating high positive correlation between the two variables..") + +cat("Since the p-value is very small,",cor.test(tar,nicotine_cont,method = "spearman",alternative = "greater")$p.value,"we reject null hypothesis and conclude that there is significant correlation between the two variables..") + +# ignore the warning in each case.. + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.1/Ex17_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.1/Ex17_1.R new file mode 100644 index 00000000..77a0c115 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.1/Ex17_1.R @@ -0,0 +1,13 @@ + +# Chapter 17 +# Example 17.1 page no. 694 from the pdf.. +# Expected Number of samples required.. + +# given n = 4 ,r = 1 +# By graph we can see beta = 0.84 + +beta <- 0.84 + +cat("The mean of samples requires to detect the shift is",1/(1-beta)) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.2/Ex17_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.2/Ex17_2.R new file mode 100644 index 00000000..53269334 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.2/Ex17_2.R @@ -0,0 +1,54 @@ + +# Chapter 17 +# Example 17.2 page no. 697 from the pdf.. +# Plot Xbar and S chart.. + +# also the questions asks UCL and LCL caculation but their computation is easy relatively, invovles only multiplication and division.. +# So I am plotting the S and Xbar Charts.. + +# 25 samples of size 5 each used to establish the quality control parameters.To plot the xbar and S control charts. +# library used - qicharts2. + +install.packages("qicharts2") + +library(qicharts2) + +m1 <- c(62.255,62.187,62.421,62.301,62.400,62.372,62.297,62.325,62.327,62.297,62.315,62.297,62.375,62.317,62.299,62.308,62.319,62.333,62.313,62.375,62.399,62.309,62.293,62.388,62.324) + +m2 <- c(62.301,62.225,62.377,62.315,62.375,62.275,62.303,62.362,62.297,62.325,62.366,62.322,62.287,62.321,62.307,62.319,62.357,62.362,62.387,62.321,62.308,62.403,62.293,62.308,62.318) + +m3 <- c(62.289,62.337,62.257,62.293,62.295,62.315,62.337,62.351,62.318,62.303,62.308,62.344,62.362,62.297,62.383,62.344,62.277,62.292,62.315,62.354,62.292,62.318,62.342,62.315,62.315) + +m4 <- c(62.189,62.297,62.295,62.317,62.272,62.372,62.392,62.371,62.342,62.307,62.318,62.342,62.319,62.372,62.341,62.319,62.315,62.327,62.318,62.342,62.372,62.295,62.315,62.392,62.295) + +m5 <- c(62.311,62.307,62.222,62.409,62.372,62.302,62.344,62.397,62.318,62.333,62.319,62.313,62.382,62.319,62.394,62.378,62.295,62.314,62.341,62.375,62.299,62.317,62.349,62.303,62.319) + +obseravation <- c(m1,m2,m3,m4,m5) + +samples <- c(rep(1:25,5)) + + +dat <- data.frame(obseravation,samples) + + +print("The xbar and S chart for the above data is:") + + +# Run the below two code individually.. +#xbar chart +qic(obseravation, + x= samples, + data = dat, + chart = 'xbar', + xlab = 'Sample Number') + +# S chart +qic(obseravation, + x = samples, + chart = 's', + xlab = 'Sample Number', + data = dat) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.3/Ex17_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.3/Ex17_3.R new file mode 100644 index 00000000..382335d5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.3/Ex17_3.R @@ -0,0 +1,24 @@ +# Chapter 17 +# Example 17.3 page no. 700 from the pdf.. +# UCL and LCL for preliminary control chart values. + +# given data on no. of defective components in sample sizes of 50. + +def_comp <- c(8,6,5,7,2,5,3,8,4,4,3,1,5,4,4,2,3,5,6,3) + +samples <- c(1:20) + +dat <- data.frame(samples,def_comp) + +m <- mean(dat$def_comp/50) + +u <- m + 3*sqrt(m*(1-m)/50) + +l <- m- 3*sqrt(m*(1-m)/50) + +cat("The LCL and UCL are",l,"and", u,"respectively") + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.4/Ex17_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.4/Ex17_4.R new file mode 100644 index 00000000..94b5d1a6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.4/Ex17_4.R @@ -0,0 +1,17 @@ + +# Chapter 17 +# Example 17.4 page no. 701 from the pdf.. +# Find Sample Size per subgroup.. + +# to find the sample size per subgroup producing a prob. of 0.5 that a process shift to p=p1= 0.05 will be detected. +#given in control prob. of a defective= 0.01 + +p = 0.01 + +p1 = 0.05 + +cat("The appropriate sample size is",(9/(p1-p)^2)*p*(1-p)) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.5/Ex17_5.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.5/Ex17_5.R new file mode 100644 index 00000000..ee58538e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH17/EX17.5/Ex17_5.R @@ -0,0 +1,30 @@ + +# Chapter 17 +# Examples 17.5 page no.702 from the pdf.. +# Control Charts for Defects C chart.. + +# given - no. of defects in 20 successive samples of sheet metal rolls each 100 feet long. +# to develop a control chart. + +# package used - qicharts2 +# if not installed can be installed by install.packages("qicharts2") + +library(qicharts2) + +lambd <- 5.95 + +num_def <- c(8,7,5,4,4,7,6,4,5,6,3,7,5,9,7,7,8,6,7,4) + +samples <- c(1:20) + +dat <- data.frame(samples, num_def) + +# C control chart for the above preliminary data. +qic(num_def, + x = samples, + chart = 'c', + xlab = 'Sample', + ylab = 'Number of defects', + data = dat) + +cat("The UCL and LCL for the above preliminary data are",lambd+3*sqrt(lambd),"and",lambd-3*sqrt(lambd),"respectively.") diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.1/Ex18_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.1/Ex18_1.R new file mode 100644 index 00000000..8779d9ac --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.1/Ex18_1.R @@ -0,0 +1,27 @@ + +# Chapter 18 +# Example 18.1 page no. 711 from the pdf.. +# To find the posterior probability distribution.. + +b <- function(p,x){ + + choose(2,x)*p^x*(1-p)^(2-x) + +} + +p1 <- c(0.1,0.2) + +pi <- c(0.6,0.4) + +m <- c(b(0.1,0)*pi[1]+b(0.2,0)*pi[2],b(0.1,1)*pi[1]+b(0.2,1)*pi[2],b(0.1,2)*pi[1]+b(0.2,2)*pi[2]) + +post_p1 <- c(b(0.1,0)*pi[1]/m[1],b(0.1,1)*pi[1]/m[2],b(0.1,2)*pi[1]/m[3]) + +post_p2 <- c(1,1,1)-post_p1 + +cat("The posterior for p=0.1 given x is",post_p1,"x ranges from 0 to 2") + +cat("The posterior for p=0.2 given x is",post_p2,"x ranges from 0 to 2") + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.11/Ex18_11.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.11/Ex18_11.R new file mode 100644 index 00000000..d29f1d5b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.11/Ex18_11.R @@ -0,0 +1,20 @@ + +# Chapter 18 +# Example 18.11 page no. 718 from the pdf.. +# to find the bayes estimate for example 18.9, under absolute error loss, when x = 1 is observed.. + +# Note - Example 18.10 is theoretical with nothing to compute.. + +# refer example 18.9.. +# package used "polynom" if not installed can be installed by executing install.packages("polynom") on console.. + +library(polynom) + +# we see that for for x = 1 the distribution becomes , +# 6x(1-x) + +p <- polynomial(coef = c(0,6,-6)) + +eq <- integral(p)- 0.5 + +cat("The bayes estimate under absolute error loss for x = 1 is",Re(polyroot(eq)[1])) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.4/Ex18_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.4/Ex18_4.R new file mode 100644 index 00000000..58f2dda1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH18/EX18.4/Ex18_4.R @@ -0,0 +1,31 @@ + +# Chapter 18 +# Example 18.4 page no. 713 from the pdf.. +# Posterior Mean and Posterior Mode.. + +# Note - Example 18.2 and 18.3 are theoretical with nothing to compute.. + +# given a distribution as on example 18.2 on page no. 712 of pdf +# to find the posterior mean and mode when x=1 + +# the posterior distribution function for 0% filter(a=="H"| b=="H") + +cat("The probability that we get atleast one head in the tosses is",nrow(c)/nrow(a)) + +# another method to solve the same problem, by using law of large numbers + + +d <- c("HH","TT","TH","HT") + +e <- sample(d,10000,replace = T) + +cat("The approximate probability of getting atleast one head in the two tosses is",sum(e=="HH"|e=="HT"|e=="TH")/10000) + +# the answer here is near to 0.75 but not exactly 0.75, if we increase the number of trials say 200000 it will be more close to 0.75. +# if we make this say tending to infinity then it will be exactly 0.75.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.25/Ex2_25.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.25/Ex2_25.R new file mode 100644 index 00000000..6f63ad55 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.25/Ex2_25.R @@ -0,0 +1,15 @@ +# Chapter 2 +# Example 2.25 page no. 53 from the pdf.. +# Probability Using Law of Large Numbers.. + +# Probability can also be calculated using direct formula(ratio) but the code will be very straight forward.. +# Let's look at another way to achieve the same result. +# To find the probability of getting less than 4 in rolling a die, if even number has twice the probability than odd number.. + +a <- c(1,2,2,3,4,4,5,6,6) + +b <- sample(a,10000,replace=T) # using law of large numbers + +cat("The probability of getting a number less than 4 is approximately",sum(b < 4)/10000) + +#this answer is slighty different than the answer in textbook which is 0.444. If we increase the number of trials then the probability will be more close to the answer in textbook \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.3/Ex2_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.3/Ex2_3.R new file mode 100644 index 00000000..082fee4f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.3/Ex2_3.R @@ -0,0 +1,13 @@ +# Chapter 2 +# Example 2.3 page no. 37 from the pdf.. +# to find the sample space. + +a <- c(rep("D",2),rep("N",2)) + +b<- c("D", "N") + +c <- c(rep("D",4),rep("N",4)) + +# final answer +print("The sample space is: ") +paste(c,rep(paste(a,rep(b)))) #merging in specific order to find the sample space. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.30/Ex2_30.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.30/Ex2_30.R new file mode 100644 index 00000000..9847df22 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.30/Ex2_30.R @@ -0,0 +1,21 @@ +# Chapter 2 +# Example 2.30 page no. 57 from the pdf.. +# Probability Using Law of Large Numbers and using union property.. + + +#to find the probability the sum of die roll (ROLLED TWICE) is 7 or 11 +#Using law of large numbers.. + +a <- c(1:6) + +b <- sample(a,200000,replace=T) + sample(a,200000,replace=T) # b is a sample of sum of 2 die rolls, with 10^6 times trials + + +cat("The approximate value of probability of getting the sum as either 7 or 11 is",sum(b==7|b==11)/200000) + + + +# This is approximate as the textbook and standard answer is 2/9, if we increase the number of trials then we would get very close to the final answer.. +# A word of note- I have skipped some problems as you may have seen, as many problems are of same type just the numbers are changed, the concept is same, so I solved the relevant questions. + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.34/Ex2_34.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.34/Ex2_34.R new file mode 100644 index 00000000..773fa60d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.34/Ex2_34.R @@ -0,0 +1,22 @@ + +# Chapter 2. +# Example 2.34 page no.63 from the pdf.. +# Conditional Probability Problem.. + + +p_departs_ontime <- 0.83 +P_arrives_ontime <- 0.82 +p_departs_arrives_ontime <- 0.78 + +# to find probability that it arrives on time given it departs in time +# Using conditional probability .. + +cat("The probability that the plane arrives on time given that it departs on time is",p_departs_arrives_ontime/p_departs_ontime) + +# to find probability that it departs on time given that it arrives on time.. + +cat("The probability that the plane departs on time given that it arrives on time is",p_departs_arrives_ontime/P_arrives_ontime) + + + +#The answer in the textbook is approximated to 0.94 and 0.95 respectively .. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.37/Ex2_37.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.37/Ex2_37.R new file mode 100644 index 00000000..37f5d62a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.37/Ex2_37.R @@ -0,0 +1,29 @@ + +# Chapter 2 +# Example 2.37 page no. 66 from the pdf.. +# Independence and Multiplication Rule.. + + +# bag1 = 4 white and 3 black balls +#bag2= 3 white and 5 black balls +# to dind probability of ball drawn from 2nd bag is black ? given a ball drawn from first is unseen and dropped in second bag + +p_b1 <- 3/7 +p_w1 <- 4/7 + +p_b2_b1 <- 6/9 # if first black ball dropped in second bag +p_b2_w1 <- 5/9 # if first white ball drawn is dropped into second bag.. + +# Using independence and multiplicative rule + +cat("The probability that the second ball drawn is black in this case is",p_b1*p_b2_b1+p_w1*p_b2_w1) + + + + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.43/Ex2_43.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.43/Ex2_43.R new file mode 100644 index 00000000..07e6c5eb --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.43/Ex2_43.R @@ -0,0 +1,26 @@ +# Chapter 2. +# Example 2.43 from the pdf.. +# Bayes Rule.. + +# given different parameters to find which plan was most likely used and thus responsible.. +# to find P(Pj\D) for j = 1,2,3.. + +# a vector of P(Pj) for j = 1,2,3.. +a <- c(0.30,0.20,0.50) + +# a vector of P(D|Pj) for j = 1,2,3.. +b <- c(0.01,0.03,0.02) + +# Bayes Rule Formula.. +f <- function(x){ + + a[x]*b[x]/sum(a*b) + +} + +cat("The value of P(Pj|D) for j = 1,2,3 is",f(1:3)) + +cat("We can see that for plan 3 has the highest conditional probability, hence a defective for a random product is most likely the result of the use of plan 3") + + +# Some Problems are not solved because they are one and the same of what I have solved just numbers are changed and they are easy too.. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.8/Ex2_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.8/Ex2_8.R new file mode 100644 index 00000000..bf7d4206 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH2/EX2.8/Ex2_8.R @@ -0,0 +1,11 @@ +# Chapter 2 +# Example 2.8 page no. 40 from the Pdf.. +# To find the Intersection of the two sets + +a <- c("a","e","i","o","u") + +b <- c("l","r","s","t") + +intersect(a,b) #displays the common elements in a and b. If there is no element common then denotes a vector of 0 length + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.10/Ex3_10.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.10/Ex3_10.R new file mode 100644 index 00000000..bc6d7298 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.10/Ex3_10.R @@ -0,0 +1,25 @@ + +# Chapter 3 +# Example 3.10 page no. 86 from the pdf.. +# Cumulative Distribution function.. + +# to find cummulative distribution of the example 3.9 +# refer Example 3.9 page no. 85 from the pdf. +# the probability distribution of the example is choose(4,x)/16 where x is from 0 to 4 +a <- function(x){ + + choose(4,x)/16 +} + + +cat("The cummulative probability distribution of the above problem is "," ") + +# ANswer.. +for(i in 0:4){ + + cat(" ", sum(a(0:i))) +} + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.11/Ex3_11.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.11/Ex3_11.R new file mode 100644 index 00000000..fd616078 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.11/Ex3_11.R @@ -0,0 +1,29 @@ + +# Chapter 3 +# Example 3.11 Page no. 89 from the pdf.. +# Probability Density FUnction Problem.. + +# A part of the Problem.. +# to check the probability density function + +a <- function(x){ + + x*x/3 +} + +# to check the conditions of probability density function + + +cat("the Integration is",integrate(a,-1,2)$value,"nearly 1 with very small margin of error we can say that it is a prob. density function") + +# B Part of the Problem.. +# to find P(00 + +h1 <- sum(a(0:2,1)) + +# to find a(x,1)= a(x,1)/h1 + +b <- function(x){ + + a(x,1)/h1 + +} + +cat("The conditional probability function under the condition y=1 is"," ") + +c <- c(b(0),b(1),b(2)) + +d <- t(data.frame(0:2,c)) + +rownames(d) <- c("X","f(x|1)") + +d + + + + + + + + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.20/Ex3_20.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.20/Ex3_20.R new file mode 100644 index 00000000..56d625e2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.20/Ex3_20.R @@ -0,0 +1,42 @@ +# chapter 3 +# Example 3.19 and 3.20 both are same in concept, just the function is changed, I am solving 3.20, so you can do the same for 3.19.. +# Chapter 3.20 page no 100 from the pdf.. +# Mariginal and Conditional Densities Evaluation.. + +# given the joint distribution function +a <- function(x,y){ + + x*(1+3*y*y)/4 + +} + +# with limits 02) +# if the package is already installed remove the installed.packages("pracma") from your code.. + +install.packages("pracma") +library("pracma") + +f <- function(x,y,z){ + + exp(-x-y-z) + +} + + +# Answer.. +cat("The value of P(x1<2,12) is",integral3(f,0,2,1,3,2,22)) + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.8/Ex3_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.8/Ex3_8.R new file mode 100644 index 00000000..25eefa06 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.8/Ex3_8.R @@ -0,0 +1,26 @@ + +# Chapter 3 +# Example 3.8 page no. 84 from the pdf.. +# Discrete Probability Problem.. + +# From 3.1 to 3.8 the problems are too easy and theoretical.. +# to find the probability distribution of number if defective laptops if 2 are drawn at a time from 20. + +#making a general function for the above distribution.. +a <- function(x){ + + choose(3,x)*choose(17,2-x)/choose(20,2) + +} + +# The Distribution.. +cat("The probability distribution for x=0 is",a(0)) + +cat("The probability distribution value for x=1 is",a(1)) + +cat("The probability distribution for x=2 is",a(2)) + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.9/Ex3_9.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.9/Ex3_9.R new file mode 100644 index 00000000..80505dd2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH3/EX3.9/Ex3_9.R @@ -0,0 +1,21 @@ +# Chapter 3 +# Example 3.9 page no. 85 from the pdf.. +# Discrete Probability Distribution Problem.. + +# to find probability distribution of no. of cars with side airbags among next 4 cars, given prob. of selling is 0.5 +# for ex. to sell 3 cars with air sidebags , partition 4 into two - with 3 bags and with 1 bag +# done in 4 choose 3 ways + +# generalise +cat("The probability distribution in this problem is:"," ") + +for(i in 0:4){ + + cat(" ",choose(4,i)/16) + + } + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.1/Ex4_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.1/Ex4_1.R new file mode 100644 index 00000000..4d7c1f9a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.1/Ex4_1.R @@ -0,0 +1,27 @@ + +# Chapter 4 +# Example 4.1 Page no. 113 from the pdf.. +# Expected Value Evaluation Problem + +# to find the expectation value +# out of 7, 4 good and 3 defective components, and sample of 3 is taken, find the expectation value + +a <- function(x){ + + choose(4,x)*choose(3,3-x)/choose(7,3) + +} + + +b <- a(0:3) # to create a series of vector for X.. + +cat("The expectation value of this problem is",weighted.mean(0:3,b)) + + + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.10/Ex4_10.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.10/Ex4_10.R new file mode 100644 index 00000000..cfb87699 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.10/Ex4_10.R @@ -0,0 +1,18 @@ +# Chapter 4 +# example 4.10 page no. 121 from the pdf.. +# Mean And Variance of Continuous Random Variable.. + +# given a random variable X having the prob. density +# find the mean and variance of X.. + +f <- function(x){ + + 2*(x-1) + +} + +cat("The mean is mu = E(X) =",integrate(function(x){x*f(x)},1,2)$value) + +cat("And the Variance is E(X^2)-[E(x)]^2 = ",integrate(function(x){x*x*f(x)},1,2)$value - (integrate(function(x){x*f(x)},1,2)$value)^2) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.11/Ex4_11.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.11/Ex4_11.R new file mode 100644 index 00000000..c63cab7e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.11/Ex4_11.R @@ -0,0 +1,18 @@ + +# Chapter 4 +# Example 4.11 page no. 122 from the pdf.. +# Variance of a new Random variable + + +# given a random variable find the variance of another random variable + +#pdf for X +a <- c(1/4,1/8,1/2,1/8) + +# finding variance for 2x+3 + +# E[(2x+3-6)^2] + +varia <- weighted.mean(4*0:3*0:3-12*0:3+9,a) + +cat("The variance of g(X)=2X+3 is",varia) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.12/Ex4_12.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.12/Ex4_12.R new file mode 100644 index 00000000..e9d850ff --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.12/Ex4_12.R @@ -0,0 +1,22 @@ + +# Chapter 4 +#example 4.12 page no. 123 from the pdf.. +# Variance of a new Random variable given the Density Function.. + +# given a random variable find the variance of g(X)=4X+3 + +f <- function(x){ + + x*x/3 + +} + +# using theorem 4.3 as given on page no. 122 + +cat("The variance of random variable g(4X+3) is",integrate(function(x){f(x)*((4*x+3-8)^2)},-1,2)$value) + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.13/Ex4_13.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.13/Ex4_13.R new file mode 100644 index 00000000..b531d05c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.13/Ex4_13.R @@ -0,0 +1,33 @@ + +# Chapter 4 +# Example 4.13 page no. 124 +# Covariance of 2 Random Variables.. + + +# to find the covariance between two variables X and Y + +a <- matrix(c(3/28,3/14,1/28,9/28,3/14,0,3/28,0,0),nrow = 3) + +# individual column sum +ax <- apply(a,2,sum) + +# indivdual row sum +ay <- apply(a,1,sum) + +# E[X].. + +ex <- sum(0:2*ax) + +# E[Y].. + +ey <- sum(0:2*ay) + +# given E[XY]=3/14 + +# using covariance formula +# E[XY]-E[X]*E[Y] + +covar <- 3/14-ex*ey + +cat("The covariance between the random variable X and Y is",covar) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.14/Ex4_14.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.14/Ex4_14.R new file mode 100644 index 00000000..37d030d5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.14/Ex4_14.R @@ -0,0 +1,42 @@ + +# Chapter 4 +# Example 4.14 page no. 125 from the pdf.. +# Covariance Of Two Random Variables given Joint Density Function.. + + +# given a joint density function of 2 random variables X and Y +# find the covariance of X and Y.. + +f <- function(x,y){ + + 8*x*y + +} + +g <- function(x){ + + 4*(x^3) + +} + +h <- function(y){ + + 4*y*(1-y*y) + +} + +# finding E(X) and E(Y) from marginal densities.. + +mu_x <- integrate(function(x){x*g(x)},0,1)$value + +mu_y <- integrate(function(y){y*h(y)},0,1)$value + +# E(XY) from joint probability distributon.. +E_XY <- integrate(function(y){ + + sapply(y,function(y){ + + integrate(function(x){f(x,y)*x*y},y,1)$value + })},0,1) + +cat("The covariance of X and Y is",E_XY$value-mu_x*mu_y) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.15/Ex4_15.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.15/Ex4_15.R new file mode 100644 index 00000000..d64ec288 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.15/Ex4_15.R @@ -0,0 +1,40 @@ + +# Chapter 4 +# Example 4.15 page no. 126 from the pdf.. +# Correlation Coefficient Evaluation + +# to find the correlation coefficient between two variables x and y.. +# Refer Example 4.13 page 124 from the pdf.. + +a <- matrix(c(3/28,3/14,1/28,9/28,3/14,0,3/28,0,0),nrow = 3) + +# individual column sum +ax <- apply(a,2,sum) + +# indivdual row sum +ay <- apply(a,1,sum) + +# E[X].. + +ex <- sum(0:2*ax) + +# E[Y].. + +ey <- sum(0:2*ay) + +# variance(x).. + +variax <- sum(0:2*0:2*ax)-ex^2 + +# variance(y).. + +variay <- sum(0:2*0:2*ay)-ey^2 + +# covariance.. + +covaria <- 3/14-ex*ey +# correlation coefficient + +corr <- covaria/(sqrt(variax)*sqrt(variay)) + +cat("The correlation coefficient in this case is", corr) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.16/Ex4_16.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.16/Ex4_16.R new file mode 100644 index 00000000..b889dc11 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.16/Ex4_16.R @@ -0,0 +1,49 @@ +# Chapter 4 +# Example 4.16 page no. 126 from the pdf.. +# Correlation Coefficient Of 2 Random Variables Given Joint Density Function.. + + +# given a joint density function of 2 random variables X and Y +# find the correlation coefficient of X and Y.. + +f <- function(x,y){ + + 8*x*y + +} + +g <- function(x){ + + 4*(x^3) + +} + +h <- function(y){ + + 4*y*(1-y*y) + +} + +# finding E(X) and E(Y) from marginal densities.. +mu_x <- integrate(function(x){x*g(x)},0,1)$value + +mu_y <- integrate(function(y){y*h(y)},0,1)$value + +# finding sigma_x and sigma_y from marginal densities.. +sig_x <- integrate(function(x){x*x*g(x)},0,1)$value - mu_x^2 + +sig_y <- integrate(function(y){y*y*h(y)},0,1)$value - mu_y^2 + +# E(XY) from joint probability distributon.. +E_XY <- integrate(function(y){ + + sapply(y,function(y){ + + integrate(function(x){f(x,y)*x*y},y,1)$value + })},0,1) + +# finding sigma_xy +sig_xy <- E_XY$value-mu_x*mu_y + +cat("The correlation coefficient of X and Y is",sig_xy/sqrt(sig_x*sig_y)) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.17/Ex4_17.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.17/Ex4_17.R new file mode 100644 index 00000000..b8ca6055 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.17/Ex4_17.R @@ -0,0 +1,14 @@ + +# Chapter 4 +# Example 4.17 page no. 128 as given in the pdf.. +# Expectation Value of Linear Combination Of Random Variables.. + +# given a random variable and its distribution find the value of E(2X-1) +# Refer example 4.4 on page 115 from the pdf.. + +px <- c(1/12,1/12,1/4,1/4,1/6,1/6) + +x <- 4:9 + +cat("The value of E(2X-1) is",weighted.mean(2*x-1,px)) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.18/Ex4_18.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.18/Ex4_18.R new file mode 100644 index 00000000..6a82bb43 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.18/Ex4_18.R @@ -0,0 +1,18 @@ + +# Chapter 4 +# Example 4_18 page no. 129 from the pdf.. +# Expectation Value of Linear Combination Of Random Variables + +# given X a random variable find the expected value of another random variable 4X+3 + +f <- function(x){ + + x*x/3 + +} + +# using property E(aX+b)= aE(X)+b + + +cat("The value of E(4X+3) is",4*integrate(function(x){x*f(x)},-1,2)$value + 3) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.19/Ex4_19.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.19/Ex4_19.R new file mode 100644 index 00000000..df45b29d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.19/Ex4_19.R @@ -0,0 +1,24 @@ + +# Chapter 4 +# Example 4.19 page no. 129 from the pdf.. +# Expectation Value of Linear Combination Of Random Variables.. + + +# finding expected value using properties.. + + +a <- c(1/3,1/2,0,1/6) + +# find E[(X-1)^2] + +# E[X^2-2X+1] + +#E[X] +ex <- weighted.mean(0:3,a) + +#E[X^2] +ex2 <- weighted.mean(0:3*0:3,a) + +# using properties + +cat("The Expected Value of Y =(X-1)^2 is:",1*ex2 -2*ex +1) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.2/Ex4_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.2/Ex4_2.R new file mode 100644 index 00000000..753e6c9d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.2/Ex4_2.R @@ -0,0 +1,21 @@ + +# Chapter 4 +# Example 4.2 Page no. 113 from the pdf.. +# Expected Value Evaluation Problem + +# To find the Expected commission.. + +p <- 0.7 + +q <- 0.4 + +dat <- c(0,1000,1500,2500) + +# Distribution.. +weights <- c((1-p)*(1-q),p*(1-0.4),(1-p)*q,p*q) + +cat("The expected commission is",weighted.mean(dat,weights)) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.20/Ex4_20.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.20/Ex4_20.R new file mode 100644 index 00000000..49e34335 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.20/Ex4_20.R @@ -0,0 +1,20 @@ + +# Chapter 4 +# example 4.20 page no. 130 from the pdf.. +# Expectation Value Evaluation Using Properties Given a Density Function.. + + +# given a density function of a random variable find the value of E(X^2+X-2) using properties.. + +f <- function(x){ + + 2*(x-1) + +} + +# using properties.. + +cat("The value of E(X^2+X-2) is",integrate(function(x){x*x*f(x)},1,2)$value + integrate(function(x){x*f(x)},1,2)$value - integrate(function(x){2*f(x)},1,2)$value) + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.21/Ex4_21.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.21/Ex4_21.R new file mode 100644 index 00000000..74b5cc2c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.21/Ex4_21.R @@ -0,0 +1,28 @@ + +# Chapter 4 +# example 4.21 on page no. 131 from the pdf.. +# Expected Value of 2 Independent Random Variable.. + +# to prove with example for 2 independent random variables E(XY) = E(x)*E(Y) + +# XY function +f <- function(x,y){ + + x*(1+3*y*y)/4 + +} + +E_XY <- integrate(function(y){ + + sapply(y,function(y){ + + integrate(function(x){f(x,y)*x*y},0,2)$value + })},0,1) + +# finding E(X) and E(Y) value +E_X <- integrate(function(x){x*x/2},0,2)$value + +E_Y <- integrate(function(y){y*(1+3*y*y)/2},0,1)$value + +cat("The value of E(XY) is",E_XY$value,"and the value of E(X)*E(Y) is",E_X*E_Y,"Hence proved.") + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.3/Ex4_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.3/Ex4_3.R new file mode 100644 index 00000000..6526cc93 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.3/Ex4_3.R @@ -0,0 +1,21 @@ + +# Chapter 4 +# Example 4.3 page no. 114 from the pdf.. +# Expected Value of probability density function + +# given that a(x) if x>100 else 0 + +a <- function(x){ + + 20000/(x*x*x) + +} + +a1 <- function(x){ + + x*a(x) + +} + +cat("The Expected life of this type of device is:",integrate(a1,lower = 100,upper = Inf)$value) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.4/Ex4_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..df94fe69 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,20 @@ + +# Chapter 4 +# Example 4.4 Page no. 115 from the pdf.. +# Expected Value of a new Random Variable.. + +# given a probability distribution find a expected value of a new random variable +# new random variable 2x-1 + +# P(X=x) +px <- c(1/12,1/12,1/4,1/4,1/6,1/6) + +# x +x <- 4:9 + +# g(x)=2x-1 + +cat("The Attendant can expect to receive :",weighted.mean(2*x-1,px)) + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.5/Ex4_5.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..4c0c41a5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,15 @@ +# Chapter 4 +# example 4.5 page no. 115 from the pdf. +# Expected Value of New Random Variable + +# to find expected value given a random variable f(x)= x^2/3 of g(X)= 4X +3 + +f <- function(x){ + + (4*x+3)*x*x/3 + +} + +cat("The expected value is",integrate(f,-1,2)$value) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.6/Ex4_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.6/Ex4_6.R new file mode 100644 index 00000000..98c5edf0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.6/Ex4_6.R @@ -0,0 +1,23 @@ +# Chapter 4 +# Example 4.6, page no. 116 from the pdf.. +# Expected value of Discrete Joint Probability Distribution + + +# given 2 random variables with joint prob. distribution, +# find the expected value g(X,Y) = XY. + +f <- matrix(c(3/28,3/14,1/28,9/28,3/14,0,3/28,0,0),ncol = 3) + + +ans <- 0 + +for(x in 0:2){ + + for(y in 0:2){ + + ans <- ans + x*y*f[x+1,y+1] + + } +} + +cat("The expected value of g(X,Y)= XY is",ans) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.7/Ex4_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.7/Ex4_7.R new file mode 100644 index 00000000..2a0d6e96 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.7/Ex4_7.R @@ -0,0 +1,35 @@ + +# Chapter 4 +# Example 4.7 page no. 116 from the pdf.. +# Expected Value of Joint Density Function + + +# to find the expected value of density function + +# given function + +a <- function(x,y){ + + (x*(1+3*y*y))/4 + +} + +# making a expectation value function + +b <- function(x,y){ + a(x,y)*y + +} + +# using the expression to find the expectation value + +print("The Value of E(Y/X) is") + +integrate(function(y){ + + sapply(y,function(y){ + + integrate(function(x)b(x,y),0,2)$value + }) +},0,1) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.8/Ex4_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.8/Ex4_8.R new file mode 100644 index 00000000..9ff06bc3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.8/Ex4_8.R @@ -0,0 +1,31 @@ + +# Chapter 4 +# Example 4.8 page no. 120 from the pdf.. +# Variance Of Discrete Distribution.. + +# given two distribution finding out which set has higher variance + +# first distribution +a <- c(0.3,0.4,0.3) + +b <- weighted.mean(1:3,a) + +c1 <- function(x){ + + (x-b)*(x-b) + +} + +d <- sum(c1(1:3)*a) + +# second Distribution.. +a1 <- c(0.2,0.1,0.3,0.3,0.1) + +b1 <- weighted.mean(0:4,a1) # since b and b1 are same.. + + +d1 <- sum(c1(0:4)*a1) + +cat("Since Variance of B is",d1,"and Variance of A is",d,"Variance of B is greater than A") + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.9/Ex4_9.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.9/Ex4_9.R new file mode 100644 index 00000000..da86f1c3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH4/EX4.9/Ex4_9.R @@ -0,0 +1,18 @@ + +# Chapter 4 +# Example 4.9 page no. 121 from the pdf.. +# Variance using Expectation formula.. + + +# calculate variance using expectation formula + + +# given data + +a <- c(0.51,0.38,0.10,0.01) + +# using E[x^2]-(E[X])^2 + +varia <- weighted.mean(0:3*0:3,a)- (weighted.mean(0:3,a))^2 + +cat("The value of Variance is:",varia) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.1/Ex5_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.1/Ex5_1.R new file mode 100644 index 00000000..99c885f3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.1/Ex5_1.R @@ -0,0 +1,14 @@ + +# Chapter 5 +# Example 5.1 Page no. 145 from the pdf.. +# Binomial Distribution Problem.. + +# to find the prob. that exactly 2 in 4 components test survive.. + +# given prob. of component surviving test 0.75 + +cat("The probability that exactly 2 will surivie in this test out of 4 is",dbinom(2,4,prob = 0.75)) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.10/Ex5_10.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.10/Ex5_10.R new file mode 100644 index 00000000..e791f86e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.10/Ex5_10.R @@ -0,0 +1,14 @@ + +# Chapter 5 +# example 5.10, page no. 154 from the pdf.. +# Hypergeometric Probability function.. + +# given - lot of 100 items in which 12 are defective.. +# to find the prob. that in a sample of 10, 3 are defective.. +# answer can be found using hypergeometric probability function + +cat("The probability that in a sample of 10 =, 3 are found to be defective is",dhyper(3,m = 12,n = 88,k = 10)) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.11/Ex5_11.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.11/Ex5_11.R new file mode 100644 index 00000000..8236f751 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.11/Ex5_11.R @@ -0,0 +1,18 @@ + +# Chapter 5 +# Example 5.11 page no. 155 from the pdf.. +# Mean And Variance Of Hypergeometric Experiment.. + +# to find the mean and variance of the random variable which has hypergeometric distribution.. + +# mean.. +me <- sum(0:3*dhyper(0:3,3,37,5)) + +# variance.. +v <- sum(0:3*0:3*dhyper(0:3,3,37,5))-me*me + +cat("The mean of this experiment is",me,"And Variance is",v) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.12/Ex5_12.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.12/Ex5_12.R new file mode 100644 index 00000000..719784d2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.12/Ex5_12.R @@ -0,0 +1,14 @@ + +# Chapter 5 +# example 5.12, page no. 155 from the pdf.. +# Relation Between Hypergeometric and Binomial Distribution.. + +# given - out of 5000, 1000 are slightly blemished.. +# to find the prob. that exactly 3 are blemished if one purchases 10 tires at random + +# since the N is large (5000) relative to sample size 10 we can do approx. to binomial distribution.. + + +cat("The probability of obtaining exactly 3 blemished tires from 10 randomly purchased samples is",dbinom(3,10,0.2)) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.13/Ex5_13.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.13/Ex5_13.R new file mode 100644 index 00000000..e8591b3b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.13/Ex5_13.R @@ -0,0 +1,16 @@ + +# Chapter 5 +# Example 5.13 page no. 156 from the pdf.. +# Multivariate Hypergeometric Distribution.. + +# to find the multinomial hypergeometric distribution of the following problem.. +# Package Used - "extraDistr" , referance- Internet.. + +# If you have already installed it remove the command below.. +install.packages("extraDistr") # this package contain functions for various types of prob. distribution + +library("extraDistr") # to use this package.. + +#to find the prob. of 1 out 3 , 2 out 0f 4 and 1 out of 3, if 5 people are randomly selected from 10 people + +cat("The probability that the 5 randomly selected from 10 has the above distribution is",dmvhyper(matrix(c(1,2,2),ncol = 3),c(3,4,3),5)) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.14/Ex5_14.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.14/Ex5_14.R new file mode 100644 index 00000000..78516188 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.14/Ex5_14.R @@ -0,0 +1,22 @@ + +# Chapter 5 +# example 5.14 page no. 159 from the pdf.. +# Negative Binomial Distribution Problem.. + +# given A has 0.55 prob. of winning over B + +# prob. that A will win in 6 games given that if any team win 4 out 7 wins then that team winner + +# using negative binomial distribution we get.. + +cat("The probability that A will win the series in 6 games is",dnbinom(2,4,0.55)) + +cat("The probability that team A will win the series is",pnbinom(3,4,0.55)) +# for this atleast 4 matches to be won I can also use dnbinom but I have to sum all from size 4 to 7 + + +# now A and B are playing and winning series decided by 3 wins out of 5 games + +cat("The probability that A will win the playoff is",pnbinom(2,3,0.55)) + +#The answer in the textbook is approximated to 4 decimal places.. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.15/Ex5_15.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.15/Ex5_15.R new file mode 100644 index 00000000..51d65dfe --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.15/Ex5_15.R @@ -0,0 +1,12 @@ + +# Chapter 5 +# example 5.15 page no. 160 from the pdf.. +# Geometric Distribution Problem.. + +# find prob. that 5th item inspected is first defective found given 1 in every 100 items is defective.. + +# using geometric distribution.. + +cat("The probability that 5th item inspected is found to be defective is",dgeom(4,0.01)) + +# the answer in textbook is approximated, 4 digits to the decimal.. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.16/Ex5_16.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.16/Ex5_16.R new file mode 100644 index 00000000..6cdcd989 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.16/Ex5_16.R @@ -0,0 +1,14 @@ + +# Chapter 5 +# example 5.16, page no. 160 from the pdf.. +# Geometic Distribution Problem.. + +# p = 0.05 of a connection during busy time.. +# to find the prob. that 5 attempts are necessary for a successful call. + +cat("The probability that 5 attempts are necessary for a successful call is",dgeom(4,0.05)) + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.17/Ex5_17.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.17/Ex5_17.R new file mode 100644 index 00000000..5baa53f1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.17/Ex5_17.R @@ -0,0 +1,15 @@ + +# Chapter 5 +# Example 5.17 page no. 162 from the pdf.. +# Poisson Distribution Problem.. + +# given - avg no. of radioactive particle entering in 1msec is 4, + +# to find- prob. of 6 particles entering in a given msec.. + +# using poisson distribution.. + +cat("The probability of 6 particles entering in a given millisecond is",dpois(6,4)) + +# the answer in the textbook is 0.1042 approx. to 4 decimal places.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.18/Ex5_18.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.18/Ex5_18.R new file mode 100644 index 00000000..75d81e3e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.18/Ex5_18.R @@ -0,0 +1,16 @@ + +# Chapter 5 +# example 5.18, page no. 162 from the pdf.. +# Poisson Distribution Problem.. + +# avg no. of oil takers arriving each day = 10, +# facilities at port can handle 15 tankers per day. +# to find the prob. that on a given day tankers have to be turned away.. + + +cat("The probability that on a given day tankers have to be turned away is",ppois(15,10,lower.tail = F)) + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.19/Ex5_19.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.19/Ex5_19.R new file mode 100644 index 00000000..a9f0a1f6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.19/Ex5_19.R @@ -0,0 +1,29 @@ + +# Chapter 5 +# ex. 5.19 page no. 164 from the pdf.. +# Approximation of Binomial By a Poisson Distribution.. + +# given P(accident on given day)=0.005 and independent of each other.. + +# to find a. prob. of accident on 1 day from 400 days.. + +# this is the case of binomial distribution but in this case we can use poisson approx. + +# lambda= np=2 in this case.. + +# answer using binomial .. +cat("The probability that there will be accident on 1 day in a given period of 400 days is",dbinom(1,400,0.005)) + +# answer using poisson.. +cat("Using poisson distribution the above answer becomes",dpois(1,2)) +# so when n is very large and p is very small we can convert binomial to poisson.. +# the margin of error is 1.2e-06 which negligible so we can use this conversion + +# to find prob. of accident for atmost 3 days from 400 days.. + +# again we can use poisson here.. + +cat("The probability that there are atmost 3 days with an accident is",ppois(3,2)) + +# the answer in the T.B is approx. to 3 decimal places 0.857. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.2.a/Ex5_2a.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.2.a/Ex5_2a.R new file mode 100644 index 00000000..4f476102 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.2.a/Ex5_2a.R @@ -0,0 +1,12 @@ + +# Chapter 5 +# Example 5.2a page no. 146 from the pdf.. +# Binomial Distribution Problem.. + +# to find probability that atleast 10 survive in a sample of 15 people from a rare blood disease which have the probability of recovering from it 0.4. + +cat("The probability of atleast 10 will survive from a sample of 15 people is ", 1-pbinom(9,size = 15,prob= 0.4)) + +#this problem can also be solved by dbinom function but we need to do it from 0 to 9 so pbinom function is simple to use in this example.. + +#The answer in the book is approximated to 0.0338. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.2.b.c/Ex5_2b_2c.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.2.b.c/Ex5_2b_2c.R new file mode 100644 index 00000000..e36436ea --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.2.b.c/Ex5_2b_2c.R @@ -0,0 +1,24 @@ + +# Chapter 5 +# Example 5.2b and 5.2c page no. 146 from the pdf.. +# Binomial Distribution Problem.. + +# to find probability that from 3 to 8 survive in a sample of 15 people from a rare blood disease which have the probability of recovering from it 0.4. + +cat("The probability that from 3 to 8 survive is",pbinom(8,15,0.4)-pbinom(2,15,0.4)) + +# the answer in the textbook is 0.8779 which is rounded off to the answer I got here.. + +#to find probability that exactly 5 survive in a sample of 15 people from a rare blood disease which have the probability of recovering from it 0.4. + +cat("The probabilty that exactly 5 survive is",dbinom(5,15,0.4)) + +# the answer in the textbook is rounded off to 0.1859 and the deviation from the answer in both cases is less than 2%.. + + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.20/Ex5_20.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.20/Ex5_20.R new file mode 100644 index 00000000..a4aa3936 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.20/Ex5_20.R @@ -0,0 +1,15 @@ + +# Chapter 5 +# example 5.20 page no. 164 from the pdf.. +# Approximation of Binomial By a Poisson Distribution.. + +# 1 in every 100 items produced has one or more bubbles means p = 0.001.. +# to find the prob. that a random sample of 8000 will yield fewer than 7 items processing bubbles, +# in short find P(X < 7) + +# since p is very close to 0 and n is very large we can approx. it with Poisson distribution.. + +cat("The prob. that the random sample of 8000 will yield fewer than 7 items possessing bubbles is",ppois(6,8)) + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.3/Ex5_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.3/Ex5_3.R new file mode 100644 index 00000000..2c0dc542 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.3/Ex5_3.R @@ -0,0 +1,15 @@ + +# Chapter 5 +# problem 5.3 on page 146 of pdf.. +# Binomial Distribution Problem.. + +# given - p = 0.03, n = 20 + +cat("The probability that there will be at least one defective item among these 20 is",1- dbinom(0,20,0.03)) + +# problem 5.3 b part.. +# testing of each shipment viewed as a bernoulli trial with p = 0.4562 from previous part.. + +cat("The probability that there will be exactly 3 shipments each containing at least one defective device among the 20 that are selected and tested from the shipment is",dbinom(3,10,0.4562)) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.4/Ex5_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.4/Ex5_4.R new file mode 100644 index 00000000..4fe15278 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.4/Ex5_4.R @@ -0,0 +1,14 @@ + +# Chapter 5 +# example 5.4 page no. 148 from pdf.. +# Binomial Distribution problem + +# given p = 0.3, n = 10, binomial distribution + +cat("The probability that exactly 3 wells have the impurity assuming that the conjecture is correct is",dbinom(3,10,0.3)) + +# example 5.4 b part.. + +cat("The probability that more than 3 wells are impure is",pbinom(3,10,0.3,lower.tail = F)) +# the answer in the T.B is approx. to 0.3504.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.6/Ex5_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.6/Ex5_6.R new file mode 100644 index 00000000..e78f021e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.6/Ex5_6.R @@ -0,0 +1,15 @@ + +# Chapter 5 +# example 5.6, page no. 148 from the pdf.. +# Binomial Distribution Problem.. + +# Note- Example 5.5 not solved as the solution involves only the multiplication of 2 numbers.. + +# given - p = 0.3, n = 10, binomial distribution + + +cat("The probability that more than 6 are found to contain the impurity from 10 wells is",1-pbinom(5,10,0.3)) + +print("As the prob. is 0.0473 approx., this casts considerable doubt on conjecture and suggests that the impurity problem is more severe.") + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.7/Ex5_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.7/Ex5_7.R new file mode 100644 index 00000000..a6b068cc --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.7/Ex5_7.R @@ -0,0 +1,22 @@ + +# Chapter 5 +# Example 5.7 page no. 150 from the pdf.. +# Multinomial Distribution.. + +# to find the prob. of 6 randomly arriving planes which are distributed in 3 runways and each have a ideal arriving prob. + +p_runways <- c(2/9,1/6,11/18) + +# prob. of runway 1 :2 + # runway 2: 1 + # runway 3 : 3 + +x <- c(2,1,3) # a particular case of the distrbution of 6 randomly arriving, written in a vactor + +# this is the case of multinomial distribution + +cat("The probability of this type of distribution of 6 randomly arriving airplanes is",dmultinom(x,6,p_runways)) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.8/Ex5_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.8/Ex5_8.R new file mode 100644 index 00000000..99f875f8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.8/Ex5_8.R @@ -0,0 +1,16 @@ + +# Chapter 5 +# example 5.8 page no. 153 from pdf.. +# Hypergeometric Distribution In Acceptance Sampling.. + +# radom sampling, testing 3 of the parts out of 10 +# condition - if none of the 3 is defective then the lot is accepted + +# assume lot is truly unacceptable.. +cat("The probability that the sampling plan finds the lot acceptable is",dhyper(0,m = 2,n = 8,k = 3)) + +cat("Thus if the lot is truly unacceptable with 2 defective parts, this sampling plan will allow acceptance roughly",dhyper(0,2,8,3)*100,"% of the time, so this plan should be considered faulty.") + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.9/Ex5_9.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.9/Ex5_9.R new file mode 100644 index 00000000..536748d1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH5/EX5.9/Ex5_9.R @@ -0,0 +1,14 @@ + +# Chapter 5 +# Example 5.9 Page no. 154 from the pdf.. +# Hypergeometric Distribution Problem.. + +# to find prob. that exactly 1 defective if there are 3 in the entire lot of 40 and 5 are selected randomly + +# this is the problem of hypergeometric distribution.. + +cat("The probability that exactly 1 is found defective from 5 randomly selected components is",dhyper(1,3,37,5)) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.1/Ex6_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.1/Ex6_1.R new file mode 100644 index 00000000..5bbe8cad --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.1/Ex6_1.R @@ -0,0 +1,23 @@ + +# Chapter 6 +# Example 6.1 page no. 171 from the pdf.. +# Uniform Distribution Problem.. + +# to find the prob. density function of uniform distribution over 0 to 4 + +a <- function(x){ + + if(x>=0 & x<=4){ + + dunif(x,0,4) + + } + +} + +# P(X>=3) + +cat("The probability that any conference last at least 3 hours is",1-punif(3,0,4)) + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.11/Ex6_11.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.11/Ex6_11.R new file mode 100644 index 00000000..e05651a2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.11/Ex6_11.R @@ -0,0 +1,18 @@ + +# Chapter 6 +# Example 6.11 page no. 184 from the pdf.. +# Applications of Normal Distribution.. + +# Note - We just have to calculate d in example 6.10, also many questions of same type have been solved previously.. + +# given mean resistance= 40 and sd= 2 , normal distribution + + +# to find %age of resistors exceeding 43 ohms + +cat("The %age of resistors having resistance exceeding 43ohms is",100*pnorm(43,40,2,lower.tail = F),"%") + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.12/Ex6_12.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.12/Ex6_12.R new file mode 100644 index 00000000..845bf68d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.12/Ex6_12.R @@ -0,0 +1,13 @@ + +# Chapter 6 +# Example 6.12 page no.184 from the pdf.. +# Applications of Normal Distribution.. + +# to find the % of resistance exceeding 43 ohms from example 6.11, if resistance is measured to the nearest ohm. + +# mean resistance = 40, sd= 2, normal distribution.. + +# here we will assign measurement of 43 ohms to all resistors whose value are greater than 43 and lesser than 43.5 + + +cat("The difference between resistance that exceed 43 ohms and that exceeds beyond 43 is",-pnorm(43.5,mean = 40,sd=2,lower.tail = F)+pnorm(43,mean = 40,sd=2,lower.tail = F),"so this value in %age represents all resistance grater than 43 and less than 43.5 that are now being recorded as 43ohms") diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.13/Ex6_13.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.13/Ex6_13.R new file mode 100644 index 00000000..dbfb38ef --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.13/Ex6_13.R @@ -0,0 +1,14 @@ + +# Chapter 6 +# Example 6.13 page no. 185 from the pdf.. +# Applications of Normal Distribution.. + +# given - avg score of the class- 74,sd=7.. +# given - 12% score "A"s and grades followsa normal distribution + +# to find the lowest possible score for A and highest for B.. + + +cat("The percentile for 0.12 in this distribution is",qnorm(0.12,74,7,lower.tail = F),"marks") + +cat("The lowest score for A is 83","and The highest score for B is 82") diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.14/Ex6_14.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.14/Ex6_14.R new file mode 100644 index 00000000..a666f0bf --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.14/Ex6_14.R @@ -0,0 +1,12 @@ + +# Chapter 6 +# example 6.14 page no.185 from the pdf.. +# Applications of Normal Distribution.. + +# given - mean 74, sd - 7 +# to find the sixth decile.. + +cat("The sixth decile is",qnorm(0.6,mean = 74,sd = 7)) + + +# the answer varies slightly due to approximation used in the T.B diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.15/Ex6_15.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.15/Ex6_15.R new file mode 100644 index 00000000..3bf6b6d7 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.15/Ex6_15.R @@ -0,0 +1,19 @@ + +# Chapter 6 +# Example 6.15 Page no. 191 from the pdf.. +# Normal Approximation To the Binomial.. + +# given- P(patient recovers from disease)=0.4 +# to find prob. that less than 30 survive if 100 have prone to this diesease + +# since n=100, this binomial variable can be approx. to normal model +p_survive=0.4 + +mu <- 100*p_survive + +sig <- sqrt(100*p_survive*(1-p_survive)) + +# no. of people are integers, so we need to use approx, and so to obtain prob, we need to find area to the left of 29.5 + +cat("The probability that fewer than 30 of the 100 patients survive is given by",pnorm(29.5,mu,sig)) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.16/Ex6_16.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.16/Ex6_16.R new file mode 100644 index 00000000..437bd907 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.16/Ex6_16.R @@ -0,0 +1,24 @@ + +# Chapter 6 +# Example 6.16 page no. 192 from the pdf.. +# Normal Approximation To the Binomial.. + +# to find the prob. that sheer guesswork yields from 25 to 30 correct answer for 80 of the 200 +# problem about which student has no knowledge.. + +# since the sample size is large we can do normal approx. + +p <- 0.25 # prob. of guessing a correct answer. + +n <- 80 + +# now using normal approx. mu = p*n and sd <- sqrt(n*p*(1-p)) + +mu = p*n + +sd <- sqrt(n*p*(1-p)) + + +cat("The prob. of correctly guessing from 25 to 30 questions is",pnorm(30.5,mu,sd)-pnorm(24.5,mu,sd)) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.17/Ex6_17.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.17/Ex6_17.R new file mode 100644 index 00000000..25cdfc53 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.17/Ex6_17.R @@ -0,0 +1,25 @@ + +# Chapter 6 +# Example 6.17 page no. 197 from the pdf.. +# Exponential Distribution Problem.. + +# given - T- time of failure +# T is exponential distribution beta=5 +# find prob. that atleast 2 are functioning at the end of 8 years, if 5 of these components are taken.. + + +bet <- 5 + +# first to find probability of a component functioning after 8 years + + +a <- pexp(8,rate=1/bet,lower.tail = F) + +# finding total probability.. + +cat("The probability that atleast 2 are still functioning from 5 components after 8 years is",1-pbinom(1,5,a)) + +# the answer in the textbook is approximated to 0.2(P(T>8)) so there is also small error in the final probab. + +# using computation we can reduce such error by a large extent.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.18/Ex6_18.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.18/Ex6_18.R new file mode 100644 index 00000000..09abb8b5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.18/Ex6_18.R @@ -0,0 +1,14 @@ + +# Chapter 6 +# Example 6.18 page no. 178. +# Gamma Distribution Problem.. + +# given - beta- 1/5, alpha- 2 + +# to find the probability up to a minute will elapse by the time 2 calls have come in to the switchboard.. + +cat("The probability that up to a minute will elapse by the time 2 calls have come in to the switchboard is",pgamma(1,shape = 2,scale = 1/5)) + + +# the answer in T.B is approx. to 0.96 + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.19/Ex6_19.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.19/Ex6_19.R new file mode 100644 index 00000000..0f311be6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.19/Ex6_19.R @@ -0,0 +1,20 @@ + +# Chapter 6 +# Example 6.19 page no.198 from the pdf.. +# Application of Gamma Distribution.. + +# given - X is survival time..has gamma distribution with +# alpha = 5, beta =10 + +# find P(rat survives <=60) or P(X<=60) + +# using gamma distribution.. + + +cat("The probability that the rat survives no longer than 60 days is",pgamma(60,shape=5,scale= 10)) + +# The answer in the T.B is approx. to 3 decimal places.. + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.2/Ex6_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.2/Ex6_2.R new file mode 100644 index 00000000..5c2dca67 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.2/Ex6_2.R @@ -0,0 +1,16 @@ + +# Chapter 6 +# Example 6.2 page no.178 from the pdf.. +# NOrmal Distribution Problem.. + +# given standard normal distribution.. + + +cat("The area under the curve to the right of 1.84 is",pnorm(1.84,lower.tail = F)) + + +cat("The area under the curve that lies between z=-1.97 to z=0.86 is",pnorm(0.86)-pnorm(-1.97)) + + +# the answer in the textbook is approx.to 4 decimal places.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.20/Ex6_20.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.20/Ex6_20.R new file mode 100644 index 00000000..e8d17ac4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.20/Ex6_20.R @@ -0,0 +1,19 @@ + +# Chapter 6 +# ex. 6.20 page no. 199 from the pdf.. +# Application of Gamma Distribution.. + + +# given - beta= 4, alpha= 2, +# changes were made to tighten quality control requirement, +# after these 20 months were passed, so we are asked to find that if the quality control tightening was effective.. + + +cat("The p-value for such time is",pgamma(20,shape = 2,scale = 4,lower.tail = F)) + +print("Since the p- value is less so conditions of gamma distributions with alpha=2,beta=4 are not supported by data, hence we can conclude that quality control work was effective.") + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.21/Ex6_21.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.21/Ex6_21.R new file mode 100644 index 00000000..be21c003 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.21/Ex6_21.R @@ -0,0 +1,18 @@ + +# Chapter 6 +# Example 6.21 page 199 from the pdf.. +# Function Which resembles Exponential Distribution.. + +# given a density function which resembles exponential function +# with beta= 4 +# to find P(Y > 6) + + +cat("The value of P(Y > 6) is",pexp(6,rate = 1/4,lower.tail = F)) + +cat("the above statement can interpret as the prob. that the washing machine wil require major repair after year 6 is",pexp(6,rate = 1/4,lower.tail = F)) + +cat("The prob. that a major repair is necessary in the first year is",pexp(1,rate = 1/4)) + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.22/Ex6_22.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.22/Ex6_22.R new file mode 100644 index 00000000..70e451ae --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.22/Ex6_22.R @@ -0,0 +1,17 @@ + +# Chapter 6 +# Example 6.22 page no. 202 from the pdf.. +# Lognormal Distribution Problem.. + +# given X= pollutant concentration,follows log normal distribution +# parameters of X- mu= 3.2 and sd = 1 + +# to find P(X>8)..? + +#Using lognormal distribution + +cat("The probability that the concentration exceeds 8 parts per million is",plnorm(8,meanlog = 3.2,sdlog = 1)) + +# the error in the T.B and computed answer is 0.0001621 which is very small and can be neglected.. + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.23/Ex6_23.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.23/Ex6_23.R new file mode 100644 index 00000000..69d731e0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.23/Ex6_23.R @@ -0,0 +1,10 @@ + +# Chapter 6 +# example 6.23 page number - 203 from pdf.. +# Lognormal Distribution Problem.. + +# given a lognormal distribution with mu = 5.149 and sigma = 0.737 +# to find the 5th percentile of the life of electronic control... + + +cat("The 5th percentile of such an distribution is",qlnorm(0.05,meanlog = 5.149, sdlog = 0.737)) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.24/Ex6_24.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.24/Ex6_24.R new file mode 100644 index 00000000..a2f82f73 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.24/Ex6_24.R @@ -0,0 +1,12 @@ + +# Chapter 6 +# Example 6.24 on page no. 204 of pdf.. +# Weibull Distribution Problem.. + +# given X is weibull distribution with alpha = 0.01 and beta = 2 +# to find P(X < 8) + +cat("The probability that life of X falls before 8 hours of usge is",pweibull(8,shape = 2,scale = sqrt(100))) + +# Note - Chapter 7 contains only theoretical problems, so I am not solving that chapter, the chapter contains 7 problems total and all are theoretical with nothing or very less to compute anything.. +# I will start with 8th Chapter.. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.3/Ex6_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.3/Ex6_3.R new file mode 100644 index 00000000..88e5d80b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.3/Ex6_3.R @@ -0,0 +1,11 @@ + +# Chapter 6 +# Example 6.3 page no. 179 from the pdf.. +# Normal Distribution.. + +# to find the k such that.. + +cat("The value of k such that P(Z>k)= 0.3015 is",qnorm(0.3015,lower.tail = F)) + +cat("The value of k such that P(k 362) + +cat("The probability that X assumes a value greater than 362 is",pnorm(362,mean = 300,sd = 50,lower.tail = F)) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.6/Ex6_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.6/Ex6_6.R new file mode 100644 index 00000000..f2a91050 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.6/Ex6_6.R @@ -0,0 +1,15 @@ + +# Chapter 6 +# Example 6.6 page no. 181 from the pdf.. +# Using Normal Curve In Reverse.. + + +# given population mean= 40, sd= 6 + +cat("The value of x that has 45% of the area to the left is",qnorm(0.45,40,6)) + +# the deviation of this value from the T.B is less than 2%. + +cat("The value of x that has 14% of the area to the right is",qnorm(0.14,40,6,lower.tail = F)) + +#The answer in T.B is approximated to 2 decimal places.. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.7/Ex6_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.7/Ex6_7.R new file mode 100644 index 00000000..6baadbc1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.7/Ex6_7.R @@ -0,0 +1,18 @@ + +# CHapter 6 +# Example 6.7 page no. 182 from the pdf.. +# Applications of Normal Distribution.. + +# given - average battery life- 3 years +# standars deviation - 0.5 +# to find P(X<2.3) + +cat("The probability that a given battery will last less than 2.3 years is",pnorm(2.3,mean = 3,sd= 0.5)) + + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.8/Ex6_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.8/Ex6_8.R new file mode 100644 index 00000000..9f9013b5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.8/Ex6_8.R @@ -0,0 +1,17 @@ + +# Chapter 6 +# example 6.8 page no. 182 from the pdf.. +# Applications of Normal Distribution.. + + +# given distribution of life of bulb - normal, mean= 800, sd=40hrs + +cat("The probability that a bulb burns between 778 and 834 hours is",pnorm(834,800,40)-pnorm(778,800,40)) + + +# making a visual of distribution +# Optional not compulsory.. +x <- seq(680,920,length=200) +y <- dnorm(x,800,40) +plot(x,y,type="l") +abline(v = c(778,834)) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.9/Ex6_9.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.9/Ex6_9.R new file mode 100644 index 00000000..80a70f47 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH6/EX6.9/Ex6_9.R @@ -0,0 +1,14 @@ + +# Chapter 6 +# Example 6.9 page no. 182 from the pdf.. +# Applications of Normal Distribution.. + + +# given normal, mean= 3,sd= 0.005 + +# specification on diameter of ball bearing 3+0.01 and 3-.01 + +cat("On average",2*pnorm(2.99,3,0.005)*100,"% of ball bearings will be scrapped") + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.1/Ex8_1.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.1/Ex8_1.R new file mode 100644 index 00000000..ade4ce3c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.1/Ex8_1.R @@ -0,0 +1,18 @@ + +# Chapter 8 +# Example 8.1 page no. 228 from the pdf.. +# Sample Mode Evaluation.. + +# to find the mode of the given data +mod <- function(v){ + + a <- unique(v) + a[which.max(tabulate(match(v,a)))] + + +} +set <- c(0.32,0.53,0.28,0.37,0.47,0.43,0.36,0.42,0.38,0.43) + +cat("The sample mode is",mod(set)) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.10/Ex8_10.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.10/Ex8_10.R new file mode 100644 index 00000000..cf253b66 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.10/Ex8_10.R @@ -0,0 +1,11 @@ + +# Chapter 8 +# Example 8.9 page no. 249 from the pdf.. +# The t- distribution Problem + + +# find k such that P(k 30) + + +cat("The probability that the average transport time was more than 30 min. is",pnorm(30+0.5,mean = 28,sd= 5/sqrt(40),lower.tail = F)) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.6/Ex8_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.6/Ex8_6.R new file mode 100644 index 00000000..5890709f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.6/Ex8_6.R @@ -0,0 +1,25 @@ + +# Chapter 8 +# Example 8.6 page no. 240 from the pdf.. +# Sampling Distribution of the difference of 2 means.. + +# given information about 2 manufacturers + + +A <- c(6.5,0.9,36) + + +B <- c(6,0.8,49) + + +# prob. 36 tubes from A have mean lifetime at least 1 more than mean of sample of 49 from B?? + +diff_mean <- A[1]-B[1] + +diff_sd <- sqrt((A[2]*A[2]/A[3])+ (B[2]*B[2]/B[3])) + +cat("The probability that the mean lifetime for 36 tubes from A will be at least 1 year longer than the mean lifetime for 49 tubes from B is",pnorm(1,diff_mean,diff_sd,lower.tail = F)) + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.7/Ex8_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.7/Ex8_7.R new file mode 100644 index 00000000..99edde7f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.7/Ex8_7.R @@ -0,0 +1,27 @@ + +# Chapter 8 +# Example 8.7 page no. 245 from the pdf.. +# The Chi-squared Distribution Problem.. + +# given mu=3,sd=1,data of 5 batteries, +# to show whether manufacturer should be convinced that batteries have a sd of 1.. + +sd = 1 + +obs <- c(1.9,2.4,3.0,3.5,4.2) + +chi.sq <- var(obs)*(length(obs)-1)/(sd^2) + +cat("The value of chi^2 is",chi.sq,"with 4 degrees of freedom") + +cat("Since 95% of the chisq values with 4 degrees of freedom fall between",qchisq(0.025,df=4),"and",qchisq(0.975,df= 4),"the computed value with sig^2= 1 is reasonable and therefore manufacturer has no reason to suspect that the sd is other than 1") + + + + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.8/Ex8_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.8/Ex8_8.R new file mode 100644 index 00000000..d3572472 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH8/EX8.8/Ex8_8.R @@ -0,0 +1,10 @@ + +# Chapter 8 +# Example 8.8 page no. 249 from the pdf.. +# The t-distribution Problem.. + +# to find the t value with left tail area 0.025 and degrees of freedom =14 + +cat("The t value with degrees of freedom 14 and leaves an area of 0.025 to the left is",qt(0.025,df= 14)) + +# Note- In example 8.9 the degrees of freedom is not mentioned so I am not solving example 8.9, I think the solution is wrong.. diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.10/Ex9_10.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.10/Ex9_10.R new file mode 100644 index 00000000..ab75e20f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.10/Ex9_10.R @@ -0,0 +1,26 @@ + +# Chapter 9 +# Example 9.10 page no. 286 from the pdf.. +# Confidence Interval for the difference between 2 means.. + +# to find 96% confidence interval for the given information +# given.. +a_mu <- 36 + +b_mu <- 42 + +n_a <- 50 + +n_b <- 75 + +sd_a <- 6 + +sd_b <- 8 + +c <- qnorm(0.98)*sqrt((sd_a*sd_a/n_a)+(sd_b*sd_b/n_b)) + +d <- b_mu - a_mu + +cat("The 96% confidence interval of the difference in average gas mileage is",d-c,d+c) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.11/Ex9_11.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.11/Ex9_11.R new file mode 100644 index 00000000..c2f1ef59 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.11/Ex9_11.R @@ -0,0 +1,32 @@ + +# Chapter 9 +# Example 9.11 page no. 288 from the pdf.. +# COnfidence Interval Evaluation Using Pooled Estimate of Variance.. + +# to find the 90% confidence interval of the given data + +# the variance of both sampling stations are equal and and independent +n1 <- 12 + +x1 <- 3.11 + +s1 <- 0.771 + +n2 <- 10 + +x2 <- 2.04 + +s2 <- 0.448 + +# WE NEED to find pooled estimate for equal variances.. + +sp <- sqrt(((n1-1)*s1*s1+(n2-1)*s2*s2)/(n1+n2-2)) + +dfs <- n1+n2-2 + +c <- qt(0.95,dfs)*sp*sqrt((1/n1)+(1/n2)) + +cat("The 90% confidence interval for mu1-mu2 is",x1-x2-c,x1-x2+c) + +# the answer in the textbook is approximated to 3 decimal places.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.12/Ex9_12.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.12/Ex9_12.R new file mode 100644 index 00000000..b394497b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.12/Ex9_12.R @@ -0,0 +1,21 @@ + +# Chapter 9 +# Example 9.12 page no. 290 from the pdf.. +# Confidence Interval Evaluation For difference of 2 means when their variance is not equal and Unknown.. + +# given unequal variances,independent samples,approx. normal + +a <- c(3.84,3.07,15) # parameters for 1st station + +b <- c(1.49,0.80,12) #parameters for second station + +# to find the 95% ci for mu1-mu2 + +v <- (((a[2]*a[2]/a[3] + b[2]*b[2]/b[3])^2)/((((a[2]*a[2]/a[3])^2)/(a[3]-1))+(((b[2]*b[2]/b[3])^2)/(b[3]-1)))) + +c <- qt(0.975,v)*sqrt((a[2]*a[2]/a[3]) + (b[2]*b[2]/b[3])) + +cat("The 95% confidence interval for mu1-mu2 is",a[1]-b[1]-c,a[1]-b[1]+c,"milligram") + + +# The answer in T.B is rounded to 2 decimal places. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.13/Ex9_13.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.13/Ex9_13.R new file mode 100644 index 00000000..f0bf343a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.13/Ex9_13.R @@ -0,0 +1,16 @@ + +# Chapter 9 +# Example 9.13 page no. 293 from the pdf.. +# to find Confidence Intervals for Paired Observations.. + +levels_plasma <- c(2.5,3.1,2.1,3.5,3.1,1.8,6.0,3.0,36.0,4.7,6.9,3.3,4.6,1.6,7.2,1.8,20.0,2.0,2.5,4.1) + +levels_fat <- c(4.9,5.9,4.4,6.9,7.0,4.2,10.0,5.5,41.0,4.4,7.0,2.9,4.6,1.4,7.7,1.1,11.0,2.5,2.3,2.5) + + +cat("The 95% confidence interval for paired observation is", " ") + +t.test(x= levels_plasma,y= levels_fat,paired=TRUE,aternative="two.sided")$conf.int + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.14/Ex9_14.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.14/Ex9_14.R new file mode 100644 index 00000000..da1670cc --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.14/Ex9_14.R @@ -0,0 +1,15 @@ + +# Chapter 9 +# Example 9.14 page no. 297 from the pdf.. +# Estimating a Proportion for Single Sample.. + + +# to calculate the 95% confidence interval +# given +n <- 500 # size of random sample + +x <- 340 # number subscribed to HBO from te size of random sample + +cat("The confidence interval for the actual proportion of families with TV sets in the city subscribed to HBO is"," ") + +prop.test(340,500,0.68)$conf.int diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.15/Ex9_15.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.15/Ex9_15.R new file mode 100644 index 00000000..23ff0b94 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.15/Ex9_15.R @@ -0,0 +1,20 @@ + +# Chapter 9 +# Example 9.15 page no. 299 from the pdf.. +# Evaluate sample size for estimating a Proportion for Single Sample.. + +# to find the sample size required to be 95% confident that our estimate of p in ex9.14 is within 0.02 of the true value.. +# Refer example 9.14 page no. 297 from the pdf.. + +n <- 500 + +x <- 340 + +p_hat <- x/n + +e <- 0.02 + +sample_size <- qnorm(0.975)^2*p_hat*(1-p_hat)/(e^2) + +cat("If we base our estimate of p on a random sample of size",as.integer(sample_size)+1,"we can be 95% confident that our sample proportion will not differ from the true proportion by more than 0.02") + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.16/Ex9_16.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.16/Ex9_16.R new file mode 100644 index 00000000..fb6c3baa --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.16/Ex9_16.R @@ -0,0 +1,15 @@ + +# CHapter 9 +# Example 9.16 page no. 299 from the pdf.. +# Evaluate sample size for estimating a Proportion for Single Sample.. + +# to find a sample size if we want atleast 95% confidence interval + + +e <- 0.02 # error not exceeding this value + +cat("The sample size if we want atleast 95% confidence interval that our estimate of p is within 0.02 of the true value is",round(qnorm(0.025)*qnorm(0.025)/(4*e*e))) + + +# In Example 9.17 all we have to do is put the values in the formula mentioned in the pdf and get the answer,I have solved some questions based on this but I am not going to solve, that's understood from the questions itself and will be a very straight forward code.. + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.18/Ex9_18.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.18/Ex9_18.R new file mode 100644 index 00000000..cac3c845 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.18/Ex9_18.R @@ -0,0 +1,15 @@ + +# Chapter 9 +# Example 9.18 page no. 304 from the pdf.. +# to obtain confidence interval of variance + +a <- c(46.4,46.1,45.8,47.0,46.1,45.9,45.8,46.9,45.2,46.0) + + +c <- qchisq(0.025,df = length(a)-1) +b <- qchisq(0.975,df= 9) + +cat("The 95% confidence interval for variance is",var(a)*(length(a)-1)/b,var(a)*(length(a)-1)/c) + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.19/Ex9_19.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.19/Ex9_19.R new file mode 100644 index 00000000..2b9a22bb --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.19/Ex9_19.R @@ -0,0 +1,20 @@ + +# Chapter 9 +# Example 9.19 page no. 306 from the pdf.. +# To find Confidence Interval For the Ratio of 2 Variances.. + +# to find 98% confidence interval of 2 independent sample variances.. +n1 <- 15 + +n2 <- 12 + +s1 <- 3.07 + +s2 <- 0.80 + +f1 <- qf(0.99,14,11) + +f2 <- qf(0.99,11,14) + +cat("The 98% confidence interval for the ratio sigma1/sigma2 is",sqrt(s1*s1/(s2*s2*f1)),sqrt(s1*s1*f2/(s2*s2))) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.2/Ex9_2.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.2/Ex9_2.R new file mode 100644 index 00000000..6e977be1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.2/Ex9_2.R @@ -0,0 +1,35 @@ + +# Chapter 9 +# Example 9.2 page no. 271 from the pdf.. +# COnfidence Interval Evaluation.. + +# to find the confidence interval given mu, sigma + +n <- 36 + +mu <- 2.6 + +sig <- 0.3 + +a <- qnorm(0.975)*sig/sqrt(n) + +b <- qnorm(0.995)*sig/sqrt(n) + +cat("The 95% confidence interval for the above parameters is",mu-a,mu+a,"milliliter") + +cat("The 99% confidence interval for the above parameters is",mu-b,mu+b,"milliliter") + + +# the similar question can be addressed as shown below +set.seed(100) +v <- rnorm(36,2.6,0.3) +t.test(v,conf.level = 0.95)$conf.int + +# but as we can see each time different ci are there, if n becomes very large then it will be very close to the standard answer.. + + + + + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.22/Ex9_22.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.22/Ex9_22.R new file mode 100644 index 00000000..18217ad5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.22/Ex9_22.R @@ -0,0 +1,23 @@ + +# Chapter 9 +# example 9.22 page no. 311 from the pdf.. +# Maximum Likelihood Estimation Problem.. + +# Note - Example 9.20 and 9.21 are theoretical with nothing to Compute.. + +# given survival time in months for 10 rats, to find the maximum estimate of the mean survival time.. +# package used "stats4", if it is not installed on your studio then you need to execute the following instruction - install.packages("stats4") + +library(stats4) + +y <- c(14,17,27,18,12,8,22,13,19,12) + +f <- function(lambda){ -sum(dpois(y, lambda, log = TRUE))} + +ans <- mle(f, start = list(lambda = 1), nobs = NROW(y)) + +print("The maximum likelihood estimate of the mean survival time is") + +coef(ans) + +# same is the concept for example 9.23 just we have to change the function and vector of observations.. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.3/Ex9_3.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.3/Ex9_3.R new file mode 100644 index 00000000..a2dd6f6d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.3/Ex9_3.R @@ -0,0 +1,15 @@ + +# Chapter 9 +# Example 9.3 page no. 273 from the pdf.. +# To Find the sample size.. + + +# to find the samaple size if we want to be 95% confident that our estimate of mu in ex. 9.2 is off by less than 0.05 + +sd <- 0.3 + +n <- ((qnorm(0.975)*sd)/0.05)^2 + +cat("We can be 95% confident that a random sample of size",as.integer(n)+1,"will provide an estimate xbar differing from mu by an amount less than 0.05") + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.4/Ex9_4.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.4/Ex9_4.R new file mode 100644 index 00000000..f733879c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.4/Ex9_4.R @@ -0,0 +1,16 @@ + +# Chapter 9 +# example 9.4 page no. 274 +# To find 95% bound for mean.. + +# to find the 95% bound for the mean reaction time + +avg_t <- 6.2 + +n <- 25 + +s_d <- 2 + +cat("The 95% bound is given by",avg_t+qnorm(0.95)*s_d/sqrt(n)) + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.5/Ex9_5.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.5/Ex9_5.R new file mode 100644 index 00000000..7232b12c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.5/Ex9_5.R @@ -0,0 +1,18 @@ + +# Chapter 9 +# Example 9.5 page no. 275 from the pdf.. +# To Find 95% Confidence Interval for mean.. + + +# to calculate the 95% confidence interval for the contents of 7 containers of sulphuric acid + + +a <- c(9.8,10.2,10.4,9.8,10.0,10.2,9.6) + + +cat("The confidence interval for the above data sample is"," ") + +t.test(a,conf.level = 0.95)$conf.int + + + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.6/Ex9_6.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.6/Ex9_6.R new file mode 100644 index 00000000..63ca9221 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.6/Ex9_6.R @@ -0,0 +1,17 @@ + +# Chapter 9 +# Example 9.6 page no. 276 from the pdf.. +# To Find 99% Confidence Interval.. + +# to find 99% confidence interval on the mean SAT maths score. +# Since random sample is large 500 we can use normal approximation.. + +mu <- 501 + +sd <- 112 + +n <- 500 + +sd1 <- sd/sqrt(n) + +cat("The 99% confidence interval for the above example is",mu+qnorm(0.005)*sd1, mu-qnorm(0.005)*sd1) diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.7/Ex9_7.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.7/Ex9_7.R new file mode 100644 index 00000000..12e411b5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.7/Ex9_7.R @@ -0,0 +1,17 @@ + +# Chapter 9 +# Example 9.7 page no. 278 from the pdf.. +# To find 95% Prediction Interval.. + +# to find the 95% prediction interval for the loan amount. +# given .. +mu <- 257300 + +sd <- 25000 + +n <- 50 + +c <- sqrt(1+1/n) + +cat("The 95% prediction interval for the future loan amount is",mu-qnorm(0.9750,lower.tail = T)*sd*c,mu+qnorm(0.9750,lower.tail = T)*sd*c) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.8/Ex9_8.R b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.8/Ex9_8.R new file mode 100644 index 00000000..426a6d64 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/CH9/EX9.8/Ex9_8.R @@ -0,0 +1,19 @@ + +# Chapter 9 +# Example 9.8 page no. 279 from the pdf.. +# to find 99% prediction interval.. + +# sample size = 30,mean = 96.2%, sd = 0.8 + +mu <- 96.2 + +sd <- 0.8 + +n <- 30 + +c <- sqrt(1+1/n) + +t_val <- abs(qt(0.005,df= 29)) + +cat("The prediction interval for a new observation is",mu-t_val*sd*c,"and",mu+t_val*sd*c) + diff --git a/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/README.txt b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/README.txt new file mode 100644 index 00000000..83122f40 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_And_Scientists_by_Ronald_E._Walpole,_Raymond_H._Myers,_Sharon_L._Myers,_Keying_Ye/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Dubey Varshit Shailendra +Course: Second Year B.tech +Branch: Electronics Engineering +College/Institute/Organization: College Of Engineering Pune + +About The Book + +Book: Probability And Statistics For Engineers And Scientists +Author: Ronald E. Walpole, Raymond H. Myers, Sharon L. Myers, Keying Ye +Publisher: Pearson Education, Boston Usa +Year Of Publication: 2016 +ISBN: 978-0-321-62911-1 +Edition: 9 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.1/ex_1_1.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.1/ex_1_1.R new file mode 100644 index 00000000..cdb2f139 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.1/ex_1_1.R @@ -0,0 +1,14 @@ +complain = c(32,17,5,4,3,3,1,1) +n= sum(complain) +rf=complain/n +cat("Relative frequency :", rf) + +a =function(x){ +sum( rf[1:x]) +} + +cat("CRF:") +for (i in 1:8) { +cat( a(i)," ") +} + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.10/ex_1_10.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.10/ex_1_10.R new file mode 100644 index 00000000..0e9ea5f3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.10/ex_1_10.R @@ -0,0 +1,4 @@ +#The summary of AQI data for year 2003 are as follows + +data=c(1, 2, 5, 8, 10, 11, 11, 12, 12, 17, 19, 19, 31, 37, 88) +quantile(data) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.12/ex_1_12.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.12/ex_1_12.R new file mode 100644 index 00000000..51e8851e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.12/ex_1_12.R @@ -0,0 +1,4 @@ +data=c(1, 2, 5, 8, 10, 11, 11, 12, 12, 17, 19, 19, 31, 37, 88) +cat("Mean :", mean(data)) +cat("Variance :", var(data)) +cat("Standard deviation :", sd(data)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.13/ex_1_13.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.13/ex_1_13.R new file mode 100644 index 00000000..f8dc1f0b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.13/ex_1_13.R @@ -0,0 +1,17 @@ +domestic =c(1995 , 2001 , 2004, 2000 , 2002 , 2002 , 2000 , 2001, 1999 , 2002 , 2004, 2001, 2002 ,1996, + 1990, 1995 , 1992 ,1995 , 1999 , 1996 , 1999 , 1999 ,1998 , 2001, 2002 , 2004 ,2004 , 2004, + 2001, 1997 , 2002 , 2001 , 2002 ,2001, 2000 , 2002 , 1999 , 2001, 2002 ,2000 , 2003, 2001 , + 2001 , 1999 , 2002 , 2001 , 2002 , 2001 , 2000 , 2002 ,2001 , 2002, 2000 , 2000 , 2002 , 2001 , + 2002 , 2002 , 2001 , 2001 ,2002 ,2002 , 2003 , 2003 , 2002, 2001 , 2002 , 2001, 2002 , 2003 , + 2002 +) + +summary(domestic) + +foriegn =c(1997 ,2000, 2002 ,2002 ,2001 , 2003 , 1995 , 1990 , 1992 ,1991 , 1997 , 2000 , 2000, 1998 , + 2000 , 1998, 2001 , 2004 , 2001 , 2000, 2001 , 2000 , 2002 , 2003 ,2003 , 2002 ,2002 , 2002 , + 2003 , 1999 , 2000 , 2001 , 2003, 2003 , 2000 , 2001) +summary(foriegn) + +hist(domestic,xlab = "Year of car advertised",main = "Domestic",xlim = c(1988,2006),breaks = 16) +hist(foriegn,xlab = "Year of car advertised",main = "Foreign",xlim = c(1988,2006),breaks = 16) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.14/ex_1_14.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.14/ex_1_14.R new file mode 100644 index 00000000..92268f4e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.14/ex_1_14.R @@ -0,0 +1,12 @@ +prev_mean = 500 +prev_Sd = 125 + +#a +# Increase the price of each lawnmower by $50.00. +cat("Changed mean= ",prev_mean+50) +cat("SD remains unchanged") + +#b +# Increase the price of each lawnmower by 10%. +cat("Changed mean= ",(1.1)*prev_mean) +cat("Changed sd= ",prev_Sd*(1.1)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.16/ex_1_16.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.16/ex_1_16.R new file mode 100644 index 00000000..c5d22c12 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.16/ex_1_16.R @@ -0,0 +1,9 @@ +# Mean,sd and no. of observations for CO and SO2 are as follows: +CO =c( 37298.013 , 84369.21 ,3143) +SO2 =c( 5616.0483 , 18869.243 ,3143) + +z_CO = (189966.99-CO[1]) /CO[2] +z_SO = (91310.67-SO2[1]) /SO2[2] + +cat("The z-score when carbon monoxide emission estimates at 189,966.99 :",z_CO) +cat("The z-score when sulfur dioxide emission estimates at 91,310.67 :",z_SO) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.17/ex_1_17.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.17/ex_1_17.R new file mode 100644 index 00000000..22176867 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.17/ex_1_17.R @@ -0,0 +1,7 @@ +#Boxplots + +boston =c(0,0,0,0,0,0,0,0,0,4,0,3,9,8,1,4,1) +houston =c(51,36,32,27,38,65,26,46,38,51,42,28,21,31,22,28,18) +Newyork =c(15,30,4,11,13,17,11,22,14,22,19,19,27,11,6,15,11) + +boxplot(boston,houston,Newyork,names = c("Boston","Houston","New YOrk")) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.2/ex_1_2.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.2/ex_1_2.R new file mode 100644 index 00000000..d08ce176 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.2/ex_1_2.R @@ -0,0 +1,28 @@ +LA_days= c(155,138,36,5) +O_days= c(233,39,1,1) + +n1=sum(LA_days) +rf1 =LA_days/n1 +n2=sum(O_days) +rf2=O_days/n2 +cat("Relative frequency for LA:", rf1) +cat("Relative frequency for Oriando :",rf2) + + +a =function(x){ + sum( rf1[1:x]) +} +cat("Cumilative frequency for LA: ") +for (i in 1:4) { + cat( a(i)," ") +} + +b =function(x){ + sum( rf2[1:x]) +} +cat("Cumilative frequency for Ontario: " ) +for (i in 1:4) { + cat( b(i)," ") +} + + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.3/ex_1_3.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.3/ex_1_3.R new file mode 100644 index 00000000..c6fc43e0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.3/ex_1_3.R @@ -0,0 +1,23 @@ +source =c("Fuel","Industrial","Transport","Misc") +CO1990 =c(5.510,5.582,76.635,11.122) +CO2000 =c(4.500,7.521,76.383,20.806) +data1 <- data.frame(CO1990, source) +data2 <- data1[order(data1[,1],decreasing=TRUE),] +barplot(data2[,1],names.arg=data2[,2],ylim = c(0,100),space = 0) + +data3 <- data.frame(CO2000,source) +data4 <- data3[order(data3[,1],decreasing=TRUE),] + barplot(data4[,1],names.arg=data4[,2],ylim = c(0,100),space = 0) + +VOC1990 =c(1.005,10.000,8.988,1.059) +VOC2000 =c(1.206,8.033,8.396,2.710) + +data5 <- data.frame(VOC1990, source) +data6 <- data5[order(data5[,1],decreasing=TRUE),] +barplot(data6[,1],names.arg=data6[,2],ylim = c(0,100),space = 0) + +data7 <- data.frame(VOC2000,source) +data8 <- data7[order(data7[,1],decreasing=TRUE),] +barplot(data8[,1],names.arg=data8[,2],ylim = c(0,100),space = 0) + +#Graph for VOC compounds plotted in book is incorrect diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.4/ex_1_4.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.4/ex_1_4.R new file mode 100644 index 00000000..b5ca71b5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.4/ex_1_4.R @@ -0,0 +1,36 @@ +#Number of AQI exceedences for 1990, 1998, and 2006 + +year1 =c(42,0,5,0,9,11,51,2,161,15,39,18,0,2,14) +year2 =c(50,0,10,24,7,17,38,14,49,14,37,39,0,3,44) +year3 =c(18,1,5,13,6,6,18,11,34,11,18,36,2,5,18) + + +dat=data.frame(year1,year2,year3) +library(ggplot2) + +plot1= ggplot(dat,aes(x=year1)) + geom_dotplot(dotsize = 0.75,binwidth = 3.5) +xlab("1990") +plot2= ggplot(dat,aes(x=year2)) + geom_dotplot(dotsize = 0.75,binwidth = 3.5) + xlim(0,150) +xlab("1998") +plot3= ggplot(dat,aes(x=year3)) + geom_dotplot(dotsize = 0.75,binwidth = 4.0) + xlim(0,150) +xlab("2006") + +library(grid) +grid.newpage() +grid.draw(rbind(ggplotGrob(plot1), ggplotGrob(plot2),ggplotGrob(plot3), size = "last")) + +#Number of AQI exceedences by city + + +boston =c(0,0,0,0,0,0,0,0,0,4,0,3,9,8,1,4,1) +houston =c(51,36,32,27,38,65,26,46,38,51,42,28,21,31,22,28,18) +Newyork =c(15,30,4,11,13,17,11,22,14,22,19,19,27,11,6,15,11) + +dat1=data.frame(boston,houston,Newyork) + + +plot4= ggplot(dat1,aes(x=boston)) + geom_dotplot(dotsize = 0.75,binwidth = 1.0) +xlab("Boston") +xlim(0,70) +plot5= ggplot(dat1,aes(x=houston)) + geom_dotplot(dotsize = 0.5,binwidth = 1.5) +xlab("Houston") +xlim(0,70) +plot6= ggplot(dat1,aes(x=Newyork)) + geom_dotplot(dotsize = 0.5,binwidth = 1.5) +xlab("New York") +xlim(0,70) + +grid.newpage() +grid.draw(rbind(ggplotGrob(plot4), ggplotGrob(plot5),ggplotGrob(plot6), size = "last")) + + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.8/ex_1_8.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.8/ex_1_8.R new file mode 100644 index 00000000..7ab60499 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.8/ex_1_8.R @@ -0,0 +1,3 @@ +data =c(12, 8, 10, 5, 17, 19, 31, 11, 88, 11, 19, 37, 1, 2, 12 ) +cat("Mean =",mean(data)) +cat("Median =",median(data)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.9/ex_1_9.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.9/ex_1_9.R new file mode 100644 index 00000000..5c5a98cf --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH1/EX1.9/ex_1_9.R @@ -0,0 +1,3 @@ +n=c(3133,2065) +x=c(13.67,8.97) +cat(" the mean transportation time in Alabama is ",weighted.mean(x,n),"min") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.10/ex_10_10.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.10/ex_10_10.R new file mode 100644 index 00000000..c3e52101 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.10/ex_10_10.R @@ -0,0 +1,10 @@ +n= 36 +mu =15 +sample_mean=17 +sd = 3 +alpha =0.05 + +stat = (sample_mean-mu)/(sd/sqrt(n)) +p_value= pnorm(stat,lower.tail = F) +cat("Thus the p-value for this test is ",p_value," and we would reject H0 for any significance level + greater than or equal to this p-value") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.11/ex_10_11.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.11/ex_10_11.R new file mode 100644 index 00000000..50fe3373 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.11/ex_10_11.R @@ -0,0 +1,10 @@ +n= 100 +mu =2 +sample_mean=2.005 +sd = 0.03 +alpha =0.05 + +stat = (sample_mean-mu)/(sd/sqrt(n)) +p_value= pnorm(stat,lower.tail = F) +cat("The probability of getting a sample of holes created with this drill with a mean diameter + that is at least 1.67 standard deviations away from the depth setting of 2 inches is ",2*p_value) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.12/ex_10_12.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.12/ex_10_12.R new file mode 100644 index 00000000..b146c237 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.12/ex_10_12.R @@ -0,0 +1,17 @@ +#H0 : mu<2 +#H1 : mu>2 + +data=c(0.406 ,0.685 ,4.778 ,1.725 ,8.223, 2.343 ,1.401 ,1.507 ,0.294, 2.230, 0.538, 0.234 ,4.025 ,3.323, 2.920, 5.088 ,1.458, 1.064, 0.774 ,0.761 ,5.587 ,0.517, 3.246, 2.330 ,1.064 ,2.563 ,0.511 ,2.782 ,6.426 ,0.836 ,0.023 ,0.225, 1.514 ,3.214 ,3.810 ,3.334 ,2.325 ,0.333 ,7.514 ,0.968 ,3.491, 2.921 , + 1.624, 0.334, 4.490, 1.267, 1.702, 2.634 ,1.849 ,0.186) + +# install the package DescTools + +library(DescTools) +p_value =ZTest(data,alternative = "greater",mu=2,sd_pop = sd(data),conf.level = 0.95)$p.value +alpha =0.05 + +if(p_value>alpha){ + cat("Null hypothesis is accepted") +}else{ + cat("Null hypothesis is rejected") +} diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.13/ex_10_13.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.13/ex_10_13.R new file mode 100644 index 00000000..5954d6ed --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.13/ex_10_13.R @@ -0,0 +1,17 @@ +#H0 : mu<=100 +#H1 : mu=103 + +n= 30 +mu =100 +sd = 4 +alpha =0.01 + +z = qnorm(alpha,lower.tail = F) +sample_mean = mu + z*sd/sqrt(n) + +true_mean =103 +s = sd/sqrt(n) + +#P(X<= sample_mean) +p_value = pnorm(sample_mean,true_mean,s) +cat("Therefore, the probability of type II error when true avg pressure is 103 =",p_value ) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.14/ex_10_14.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.14/ex_10_14.R new file mode 100644 index 00000000..b16ffe08 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.14/ex_10_14.R @@ -0,0 +1,6 @@ +mu0 =100 +mu1= 103 +sd=4 +alpha = beta =0.01 +n = ((qnorm(alpha)+qnorm(beta))^2)*sd*sd/((mu1 - mu0)^2) +cat("By taking ",ceiling(n),"measurements, we can reduce to 0.01 while also holding at 0.01. ") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.15/ex_10_15.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.15/ex_10_15.R new file mode 100644 index 00000000..8051ee1f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.15/ex_10_15.R @@ -0,0 +1,19 @@ +#H0 : mu=1200 +#H1 : mu=not=1200 + +n= 10 +mu =1200 +sample_mean=1290 +sd = 110 +alpha =0.05 + +t = (sample_mean -mu)/(sd/sqrt(n)) + +#using rejection region approach +compare = qt(1 - alpha/2,df=n-1,lower.tail = T) + +if(tcompare){ + cat("Hypothesis is accepted"); +} else{ + cat("Hypothesis is rejected") +} + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.18/ex_10_18.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.18/ex_10_18.R new file mode 100644 index 00000000..a780b6f9 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.18/ex_10_18.R @@ -0,0 +1,17 @@ +#H0 : p<=0.10 +#H1 : p>0.10 + +n=100 +p_bar=0.15 +p0=0.10 +alpha=0.01 + +z=(p_bar-p0)/sqrt(p0*(1-p0)/n) +compare= qnorm(alpha,lower.tail = F) + +if(zmu2 + +sm <- c(35.22,24.44,9) +nm <- c(31.56,20.03,9) + +diff_mean = sm[1]-nm[1] +D0=0 +alpha=0.05 + +s = sqrt(((sm[3]-1)*sm[2] + (nm[3]-1)*nm[2])/(sm[3]-1 + nm[3]-1)) +t = (diff_mean - D0)/(s*sqrt(1/sm[3] + 1/nm[3])) + +compare= qt(alpha,df=sm[3]-1 + nm[3]-1,lower.tail = F) + +if(talpha){ + cat("Hypothesis is accepted"); +} else{ + cat("Hypothesis is rejected") +} + +# Mean calculated for class III is incorrect and therefore gives the wrong answer. diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.23/ex_10_23.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.23/ex_10_23.R new file mode 100644 index 00000000..e22a4f57 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.23/ex_10_23.R @@ -0,0 +1,15 @@ +#H0 : mu1 - mu2 =D0 +#H1 : mu1 - mu2 not=D0 + +C1 = c( 5.83, 5.66, 4.75, 3.00, 3.37, 3.63, 4.00, 4.63, 4.25, 4.13 ) +C2 = c( 3.38, 2.81, 7.00, 1.50, 5.88, 5.25, 4.08, 7.63, 4.50, 4.88 ) + +p_value= t.test(C1,C2)$p.value +alpha= 0.05 +if(p_value>alpha) +{ + cat("Hypothesis accepted") +}else{ + cat("Hypothesis is rejected") +} + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.24/ex_10_24.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.24/ex_10_24.R new file mode 100644 index 00000000..cbc0bb94 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.24/ex_10_24.R @@ -0,0 +1,17 @@ +#H0 :muD >=0 +#H1 :muD < 0 + +A = c(38.25,31.68,26.24,41.29,44.81,46.37,35.42,38.41,42.68,46.71,29.20,30.76) +B = c(38.25,31.71,26.25,41.33,44.80,46.39,35.46,38.42,42.70,46.76,29.18,30.79) + +p_value= t.test(A,B,paired = TRUE,alternative = "less")$p.value + +alpha= 0.05 +if(p_value>alpha) +{ + cat("Null Hypothesis accepted") +}else{ + cat("Hypothesis is rejected") +} + + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.25/ex_10_25.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.25/ex_10_25.R new file mode 100644 index 00000000..903852f5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.25/ex_10_25.R @@ -0,0 +1,15 @@ +#H0 : muD=0 +#H1 : muD not=0 + +E = c( 2727.6, 2902.6, 2463.1 ,3744.5 ,3855.3, 3807.3, 3610.1 ,3596.3 ,3457.0 ,3507.1, 3184.2, 3104.7 ) +A = c( 2741.0 ,2885.0 ,2476.0 ,3745.0 ,3862.0 ,3812.0 ,3609.0 ,3568.0 ,3465.0 ,3541.0 ,3213.0, 3092.0) + +alpha= 0.05 +p_value=t.test(E,A,paired = TRUE)$p.value +if(p_value>alpha) +{ + cat("Null Hypothesis accepted") +}else{ + cat("Hypothesis is rejected") +} + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.26/ex_10_26.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.26/ex_10_26.R new file mode 100644 index 00000000..ace5f920 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.26/ex_10_26.R @@ -0,0 +1,33 @@ +#H0 : sigma1^2 = sigma2^2 +#H1 : sigma1^2 < sigma2^2 + + +n1= 10 +n2= 20 +var1=0.003 +var2=0.001 +alpha=0.05 + +F = var1/var2 + +#Left-tailed test +compare= qf(1-alpha,n1 -1,n2 -1,lower.tail = T) + +if(Falpha) +{ + cat("Null Hypothesis accepted") +}else{ + cat("Hypothesis is rejected") +} + +#Note: t.test function cnnot be used as numeric vector of data values is not given. diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.27/ex_10_27.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.27/ex_10_27.R new file mode 100644 index 00000000..af480ba2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.27/ex_10_27.R @@ -0,0 +1,18 @@ +#H0 : p1=4/7,p2=2/7,p3=1/7 +#H1 : The proportions differ from those indicated in the null hypothesis. + +X=c(20,16,14) +p=c(4/7,2/7,1/7) +n=50 +EX=n*p +alpha=0.05 + +stat= sum(((X-EX)^2)/EX) +compare= qchisq(1-alpha,df=2,lower.tail = T) + + +if(statalpha){ + cat("Hypothesis is accepted"); +} else{ + cat("Hypothesis is rejected") +} diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.30/ex_10_30.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.30/ex_10_30.R new file mode 100644 index 00000000..449d62de --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.30/ex_10_30.R @@ -0,0 +1,34 @@ +#H0 : Y follows a Poisson distribution +#H1 : Y does not follow a Poisson distribution + +x= rep(0:2, times=c(32,12,6)) +table(x) +mean(x) +probs = dpois(0:1, lambda=mean(x)) +comp= 1- sum(probs) + +stat = chisq.test(x=c(32,12,6), p= c(probs,comp),simulate.p.value = TRUE)$statistic + +alpha= 0.05 +#degree of freedom = (3-1)- 1, as 1 parameter is estimated +compare = qchisq(1- alpha,df=1) + +if(stat0.05) +{ + cat("Hypothesis is accepted") +} else{ + cat("Hypothesis is rejected") +} + +#Both solutions generate same results diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.31/ex_10_31.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.31/ex_10_31.R new file mode 100644 index 00000000..1ffdd5a1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.31/ex_10_31.R @@ -0,0 +1,19 @@ +#H0 : F(y) is exponential with theeta=2 +#H1 : F(y) is not exponential with theeta=2 + +y = c(0.023,0.406,0.538,1.267,2.343,2.563,3.334,3.491,5.088,5.587) +Fy= 1- exp(-y/2) +n=10 +i = 1:10 + +D_plus = i/n - Fy +D_minus = Fy - (i-1)/n +D = max(max(D_plus),max(D_minus)) + +# the critical value for a two-sided test with n = 10 and alpha= 0.05 is 0.409. +D0=0.409 +if(D0>D){ + cat("Hypothesis is accepeted") +} else{ + cat("Hypothesis is rejected") +} diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.32/ex_10_32.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.32/ex_10_32.R new file mode 100644 index 00000000..304f72f2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.32/ex_10_32.R @@ -0,0 +1,6 @@ +data =c(0.3780, 0.5090, 0.6230 ,0.6860 ,0.7350 , 0.7520, 0.7580, 0.8690, 0.8890, 0.8890, 0.8990, 0.9370, 0.9820 ,1.0220 ,1.0370 , 1.0880, 1.1230 ,1.2060, 1.3340 ,1.4230 +) + +ks.test(data,"pnorm",mean(data),sd(data)) + +# the answers are different from those given in the book. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.33/ex_10_33.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.33/ex_10_33.R new file mode 100644 index 00000000..ec0e106c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.33/ex_10_33.R @@ -0,0 +1,9 @@ +data =c(70,29,60,28,64,32,44,24,35,31,38,35,52,23,40,28,46,33,46,27,37,34,41,28) + +#Exponential Distribution +ks.test(data,"pnorm",mean(data),sd(data)) + +#Lognormal Distribution +ks.test(log(data),"pnorm",mean(data),sd(data)) + +# the answers are different from those given in the book. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.8/ex_10_8.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.8/ex_10_8.R new file mode 100644 index 00000000..ed4c1c98 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH10/EX10.8/ex_10_8.R @@ -0,0 +1,20 @@ +#H0 : mu =2 +#H1 : mu Not = 2 + +n= 100 +mu =2 +sample_mean=2.005 +sd = 0.03 +alpha =0.05 + +stat = (sample_mean-mu)/(sd/sqrt(n)) + +compare = qnorm(alpha/2,lower.tail = F) + +if(stat15 + +n= 36 +mu =15 +sample_mean=17 +sd = 3 +alpha =0.05 + +stat = (sample_mean-mu)/(sd/sqrt(n)) + +compare = qnorm(alpha,lower.tail = F) + +if(statcompare){ + cat("Null hypothesis is accepted") +} else{ + cat("Null hypothesis is rejected") +} + +#b +cat("y =",coef[1]," + ",coef[2],"x1 ",coef[3],"x2") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.18/ex_11_18.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.18/ex_11_18.R new file mode 100644 index 00000000..d38e295b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.18/ex_11_18.R @@ -0,0 +1,25 @@ +#H0 : beta2 =0 , (No quadratic relationship exists +#H1 : beta2 >0 , (The peak power load increases at an increasing rate as the daily maximum temperature increases.) + +x = c(95,82,90,81,99,100,93,95,93,87) +y = c(214,152,156,129,254,266,210,204,213,150) +n=10 +k=2 +dof=n- (k+1) + +pol<- data.frame(x,y) +line <- lm(y~x+I(x^2),data = pol) +summary(line) +T =coef(summary(line))[3,3] +compare= qt(1-0.05,df=dof) +if(T < compare) +{ + cat("Null Hypothesis is accepted") +} else{ + cat("Null Hypothesis is rejected") +} +s=coef(summary(line))[3,2] +t =qt(1- 0.05,df=dof) +beta2 =coef(summary(line))[3,1] + +cat(" confidence interval for the parameter beta2 as follows:",beta2- t*s," - ",beta2+ t*s) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.19/ex_11_19.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.19/ex_11_19.R new file mode 100644 index 00000000..25be8ae5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.19/ex_11_19.R @@ -0,0 +1,22 @@ +#H0 : beta3 =0 +#H1 : beta3 <0 + +y =c(121,169,172,116,53,177,31,94,72,171,23,177,178,65,146,129,40,167,115,123,44,73,8,90,71,37,111,89,72,35,86,40,44,36,78,47,56,75,46,6) +x1=c(6490,7244,7943,6478,3138,8747,2020,4090,3230,8786,1986,9653,9429,2782,8444,6316,2363,7915,6928,5526,3077,6600,2732,7014,8321,2422,9581,9326,6818,4831,9630,2905,6308,1908,8542,4750,6056,7052,7794,1701) +x2=c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) + +fit=lm(y~x1+x2+I(x1*x2)) +x=summary(fit) +coef =coefficients(x) +cat("The regression equation is y= ",coef[1]," + ",coef[2],"x1 + ",coef[3],"x2 ",coef[4],"x1*x2") + +anova(fit) +dof=36 +T =coef(summary(fit))[4,3] +compare= qt(0.05,df=dof) +if(T > compare) +{ + cat("Null Hypothesis is accepted") +} else{ + cat("Null Hypothesis is rejected") +} diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.2/ex_11_2.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.2/ex_11_2.R new file mode 100644 index 00000000..3594a952 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.2/ex_11_2.R @@ -0,0 +1,9 @@ +x = c(95,82,90,81,99,100,93,95,93,87) +y = c(214,152,156,129,254,266,210,204,213,150) +n=length(x) + +pol <- data.frame(x,y) + +line_eq <- lm(y~x,data=pol) + +cat("s=",summary(line_eq)$sigma) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.20/ex_11_20.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.20/ex_11_20.R new file mode 100644 index 00000000..bb580a19 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.20/ex_11_20.R @@ -0,0 +1,19 @@ +x = c(95,82,90,81,99,100,93,95,93,87) +y = c(214,152,156,129,254,266,210,204,213,150) + +pol<- data.frame(x,y) +line <- lm(y~x+I(x^2),data = pol) +coef = coefficients(line) +y_cap = function(xp){ + coef[1] + coef[2]*xp + coef[3]*xp*xp +} + +cat(" the electrical usage for a particular day on which the high temperature is 90F, y_cap=", y_cap(90)) +data <- data.frame(x=90) + +d <- predict(line,data, interval = "prediction") + +cat("The 95% prediction interval for y0 when x0=90 is",d[2],"-" ,d[3]) + +f <- predict(line,data,interval = "confidence") +cat("The 95% prediction interval for y0 when x0=90 is",f[2],"-" ,f[3]) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.21/ex_11_21.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.21/ex_11_21.R new file mode 100644 index 00000000..fb10e430 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.21/ex_11_21.R @@ -0,0 +1,24 @@ +speed =c(340,570,340,570,340,570,340,570,440,440,440,440,305,635,440,440,440,440,305,635,440,440,440,440) +life =c(70,29,60,28,64,32,44,24,35,31,38,35,52,23,40,28,46,33,46,27,37,34,41,28) +feed =c(0.00630,0.00630,0.01410,0.01416,0.00630,0.00630,0.01416,0.01416,0.00905,0.00905,0.00905,0.00905,0.00905,0.00905,0.00472,0.01732, + 0.00905,0.00905,0.00905,0.00905,0.00472,0.01732, 0.00905, 0.00905) +depth =c(0.02100,0.02100,0.02100,0.02100,0.02100,0.04000,0.04000,0.04000, 0.02900, 0.02900, 0.02900, 0.02900, 0.02900, 0.02900, 0.02900, 0.02900, + 0.01350, 0.04550,0.02900,0.02900,0.02900,0.02900, 0.01350,0.04550 ) + +dat= data.frame(life,speed,feed,depth) +fit =lm(life~speed+feed+depth) +#a +cor(dat) + +#b +x=summary(fit) +coef= coefficients(x) +cat("the leastsquares equation : Tool life = ",coef[1],coef[2],"Speed ",coef[3],"Feed rate ",coef[4],"Depth of cut") + + +#c +y =data.frame(depth=0.03,speed=450,feed =0.01) + +val= predict(fit,y,interval = "confidence") +cat(" A tool that is used to cut depths of 0.03 inch at a speed of 450 fpm with a feed rate of 0.01 ipr is expected to last on the average ",val[1]) +cat(" we are 95% confident that the mean life of such a tool used to cut depths of 0.03 inch at a speed of 450 fpm with a feed rate of 0.01 ipr will be between",val[2],"-",val[3]) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.22/ex_11_22.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.22/ex_11_22.R new file mode 100644 index 00000000..57810bf4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.22/ex_11_22.R @@ -0,0 +1,17 @@ +# A Test for a Portion of a Model + + +y=c(48.5,55.0,68.0,137.0,309.4,17.5,19.6,24.5,34.8,32.0,28.0,49.9,59.9,61.5,60.0,65.9,67.9,68.9,69.9,70.5,72.9,72.5,72.0,71.0,76.0,72.9,73.0,70.0,76.0,69.0,75.5,76.0,81.8,84.5,83.5,86.0,86.9,86.9,86.9,87.9,88.1,85.9,89.5,87.4,87.9,88.0,90.0,96.0,99.9,95.5,98.5,100.1,99.9,101.9,101.9,102.3,110.8,105.0,98.9,106.3,106.5,116.0,108.0,107.5,109.9,110.0,120.0,115.0,113.4,114.9,115.0,115.0,117.9,110.0,115.0,124.0,129.9,124.0,128.0,132.4,139.3,139.3,139.7,142.0,141.3,147.5,142.5,148,149,150,172.9,190,280) +area =c(1.1,1.01,1.45,2.4,3.3,0.4,1.28,0.74,0.78,0.97,0.84,1.08,0.99,1.01,1.34,1.22,1.28,1.29,1.52,1.25,1.28,1.28,1.36,1.20,1.46,1.56,1.22,1.40,1.15,1.74,1.62,1.66,1.33,1.34,1.40,1.15,1.58,1.58,1.58,1.71,2.10,1.27,1.34,1.25,1.68,1.55,1.55,1.36,1.51,1.54,1.51,1.85,1.62,1.40,1.92,1.42,1.56,1.43,2.00,1.45,1.65,1.72,1.79,1.85,2.06,1.76,1.62,1.80,1.98,1.56,2.19,2.07,1.99,1.55,1.67,2.40,1.79,1.89,1.88,2.00,2.05,2.00,2.03,2.12,2.08,2.19,2.40,2.40,3.05,2.04,2.25,2.57,3.85) +bedroom =c(3,3,3,3,4,1,3,3,2,3,3,2,2,3,3,3,3,3,3,3,3,3,3,3,3,4,3,2,2,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,3,4,3,3,3,3,3,3,4,4,3,4,4,3,4,3,3,3,4,4,3,3,4,4,3,3,4,4,4,3,3,4,4,4,5,4,3,4,4,4) +bathroom =c(1,2,2,3,3,1,1,1,1,1,1,2,1,2,2,1,2,2,2,2,2,1,2,2,rep(2,59),3,2,2,2,2,2,3,2,3,3) +style =c(0,0,0,1,rep(0,31),1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,0,1,1,1,0,1,0,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,1,1,0) + +# Multiple regression model for selling price of houses +fit =lm(y~area+bathroom+style) +summary(fit) + +# Full model for selling prices +# Multiple regression model for selling price of houses +fit =lm(y~area+bedroom+bathroom+style) +summary(fit) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.23.b/ex_11_23_b.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.23.b/ex_11_23_b.R new file mode 100644 index 00000000..72764951 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.23.b/ex_11_23_b.R @@ -0,0 +1,13 @@ +speed =c(340,570,340,570,340,570,340,570,440,440,440,440,305,635,440,440,440,440,305,635,440,440,440,440) +life =c(70,29,60,28,64,32,44,24,35,31,38,35,52,23,40,28,46,33,46,27,37,34,41,28) +feed =c(0.00630,0.00630,0.01410,0.01416,0.00630,0.00630,0.01416,0.01416,0.00905,0.00905,0.00905,0.00905,0.00905,0.00905,0.00472,0.01732, + 0.00905,0.00905,0.00905,0.00905,0.00472,0.01732, 0.00905, 0.00905) +depth =c(0.02100,0.02100,0.02100,0.02100,0.02100,0.04000,0.04000,0.04000, 0.02900, 0.02900, 0.02900, 0.02900, 0.02900, 0.02900, 0.02900, 0.02900, + 0.01350, 0.04550,0.02900,0.02900,0.02900,0.02900, 0.01350,0.04550 ) + +dat= data.frame(life,speed,feed,depth) +fit =lm(life~speed+feed+depth+I(speed*feed)+I(feed*depth)+I(speed*depth)+I(speed*depth*feed)) +x=summary(fit) +coef =coefficients(x) +cat("the leastsquares equation : Tool life = ",coef[1],coef[2],"Speed ",coef[3],"Feed ",coef[4],"Depth + ",coef[5],"speed*feed + ",coef[6], +"feed*depth + ",coef[7],"speed*depth ",coef[8],"speed*feed*depth") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.25/ex_11_25.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.25/ex_11_25.R new file mode 100644 index 00000000..78421d97 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH11/EX11.25/ex_11_25.R @@ -0,0 +1,30 @@ +# Correspondence between Means and Model Parameters + +y =c(0.065,0.073,0.068,0.036,0.078,0.082,0.050,0.043,0.048,0.046,0.061,0.062) +x1 =c(0,0,0,1,0,0,1,1,0,0,1,1) +x2 =c(0,0,0,0,1,1,1,1,0,0,0,0) +x3 =c(0,0,0,0,0,0,0,0,1,1,1,1) + +# a +# Main effects model +fit =glm(y~x1+x2+x3) +coef=coefficients(summary.glm(fit)) +cat(" The least-squares prediction equation is yv= ",coef[1],coef[2],"x1 + ",coef[3],"x2 ",coef[4],"x3") + +# b +# Complete model including interactions +fit1 =glm(y~x1+x2+x3+(x1*x2)+(x1*x3)) +coef1=coefficients(summary.glm(fit1)) +cat(". The least-squares prediction equation is ",coef1[1],coef1[2],"x1 +",coef1[3],"x2 ",coef1[4],"x3 ",coef1[5],"x1*x2 + ",coef1[6],"x1*x3") + +# c +# H0:The interaction terms do not contribute to the model.(beta4 =beta5 =0) +# H1: At least one of interaction parameters is nonzero. + +F_value= 64.04 +compare =qf(1- 0.05,2,6) +if(F_value =1) = 1- P(X=0) +none_defective <- dbinom(0,4,prob = 0.10) +cat("Proability that atleast one bulb is defective :" , 1- none_defective) + +# c) +n=4 +p=0.1 +E =n*p +V =n*p*(1-p) + +E_Y_sq = V+ E^2 +cat("E(C) =", 3*E_Y_sq) +cat(" we could expect to pay an average of $",3*E_Y_sq*10, "in repair costs for each shipment of four fuses. ") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.12/ex_5_12.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.12/ex_5_12.R new file mode 100644 index 00000000..9c4843b8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.12/ex_5_12.R @@ -0,0 +1,10 @@ +# Probability battery exceeding lifetime of 4 hours is 0.135 + +# a + cat("probability that only one battery lasts 4 hours or more is ", dbinom(1,3,prob = 0.135)) + +#b +# probability that at least one battery lasts 4 hours or more = P(Y>=1)= 1- P(Y=0) + no_battery <- dbinom(0,3,prob = 0.135) + cat(" probability that at least one battery lasts 4 hours or more is " , 1- no_battery) + \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.13/ex_5_13.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.13/ex_5_13.R new file mode 100644 index 00000000..63cc371a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.13/ex_5_13.R @@ -0,0 +1,14 @@ +#a +cat("The probability of exactly 3 out of 10 plants calling in orders is ", + dbinom(3,10,prob = 0.2)) + +#b +# The probability of at most 3 out of 10 plants calling in orders = P(Y<=3) = p(0)+p(1)+p(2)+p(3) +cat("The probability of at most 3 out of 10 plants calling in orders is " , pbinom(3,10,prob = 0.2)) + +#c +# The probability of at least 3 out of 10 plants calling in orders = 1- P(Y<3) +cat(" The probability of at least 3 out of 10 plants calling in orders is" , 1- pbinom(2,10,prob = 0.2)) + + + \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.15/ex_5_15.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.15/ex_5_15.R new file mode 100644 index 00000000..4a2b8be2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.15/ex_5_15.R @@ -0,0 +1,14 @@ +# a +# The probability that the firm will get none of those contracts = P(X=0) + +cat("the probability that the firm will get none of those contracts" ,dbinom(0,8,prob = 0.40)) + +#b +# The probability that the firm will get five out of eight contracts = P(X=5) + +cat(" the probability that the firm will get five out of eight contracts", dbinom(5,8,prob = 0.40)) + +#c +# The probability that the firm will get all eight contracts + +cat(" the probability that the firm will get all eight contracts" , dbinom(8,8,prob = 0.40)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.17/ex_5_17.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.17/ex_5_17.R new file mode 100644 index 00000000..bc5ace16 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.17/ex_5_17.R @@ -0,0 +1,10 @@ +# the probability that the first applicant having advanced training is found on the fifth interview = P(Y=5) +# using geomatric distribution +library(stats) +p=0.30 +cat(" the probability that the first applicant having advanced training is found on the fifth interview is", dgeom(4,0.30) ) +cat("Total cost of interviewing is ", 300/p) + +# V(C)=(300^2)V(Y) + +cat("V(C) is" , ((300^2)*(1-p))/(p^2)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.18/ex_5_18.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.18/ex_5_18.R new file mode 100644 index 00000000..420002a7 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.18/ex_5_18.R @@ -0,0 +1,8 @@ +#Using negative binomial distribution + +r=3 +p=0.2 +E = 10*(r/p) + r*20 +V= 10*10*(r*(1-p)/(p^2)) + +cat(", the total time to use up the kits has an expected value of ",E," minutes and a standard deviation of",sqrt(V),"minutes") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.19/ex_5_19.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.19/ex_5_19.R new file mode 100644 index 00000000..6cf27b7e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.19/ex_5_19.R @@ -0,0 +1,7 @@ +# Prob of the applicants for a certain position have +#advanced training in computer programming of the applicants for a certain position +#have advanced training in computer programming of the applicants for a certain position have +#advanced training in computer programming = 0.30 + +cat(" The probability that the third qualified applicant is found on the fifth interview" , + dnbinom(2,3,0.30)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.2/ex_5_2.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.2/ex_5_2.R new file mode 100644 index 00000000..35dfdbd1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.2/ex_5_2.R @@ -0,0 +1,15 @@ +a <- function(x){ + + ((factorial(6)/factorial(6-x))*(factorial(4)/factorial(4-(2-x))))/(factorial(10)/factorial(8)) + +} + +# The Distribution.. +cat("The probability distribution for x=0 is",a(0)) + +cat("The probability distribution value for x=1 is",2*a(1)) + +cat("The probability distribution for x=2 is",a(2)) + + + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.20/ex_5_20.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.20/ex_5_20.R new file mode 100644 index 00000000..d9da0f6a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.20/ex_5_20.R @@ -0,0 +1,18 @@ +# average no. of accidents in a week is 3 + +# using poisson distriution + +#a +cat("Prob of no accidents in a week p(0)= ", dpois(0,3)) + +#b +cat("Prob of two accidents in a given week p(2)= ", dpois(2,3)) + +#c Prob atmost 4 accidents occur in a given week is +# p(0)+p(1)+p(2)+p(3) + +cat("Prob atmost 4 accidents occur in a given week is ", ppois(4,3)) + +#d Average no. of accidents on a given day = 3/7 +d <- 3/7 +cat("Prob of two accidents on any given day is ", dpois(2,d)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.22/ex_5_22.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.22/ex_5_22.R new file mode 100644 index 00000000..e750788c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.22/ex_5_22.R @@ -0,0 +1,5 @@ +# using hypergeometric distribution + +# the probability that the female is selected for one of the jobs =P(Y=1) = p(1) + +cat("the probability that the female is selected for one of the jobs is", dhyper(1,1,5,2)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.23.a/ex_5_23_a.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.23.a/ex_5_23_a.R new file mode 100644 index 00000000..348b588a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.23.a/ex_5_23_a.R @@ -0,0 +1,6 @@ +# using hypergeometric distribution + +#a +# the probability that all five boxes will fit properly = P(Y=0) = p(0) + +cat("The probability that all five boxes will fit properly is", dhyper(0,2,18,5)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.3/ex_5_3.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.3/ex_5_3.R new file mode 100644 index 00000000..caece917 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.3/ex_5_3.R @@ -0,0 +1,18 @@ +a <- function(x){ + + (0.8^x)*(0.2^(2-x)) +} + +# The Distribution.. +cat("The distribution function for b<0 is",0) + +cat("The distribution function for 0=2 is",a(2) + 2*a(1) + a(0) ) + +b= c(0,1,2,3) +fb= c(0,0.04,0.36,1) +plot(b,fb) + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.4/ex_5_4.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.4/ex_5_4.R new file mode 100644 index 00000000..e2702e7e --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.4/ex_5_4.R @@ -0,0 +1,14 @@ +mp =c(3,9,16,21,30,40,55,75,92) +year1 =c(7.6,12.8,5.3,10.8,17.3,15.1,18.6,11.3,1.2) +year2 =c(6.4,11.6,5.2,9.0,12.5,12.2,22.5,16.0,4.6) + +mean1 =weighted.mean(mp,year1/100) +mean2 =weighted.mean(mp,year2/100) + +sd1=sqrt(sum(((mp- mean1)^2)*year1/100)) +sd2=sqrt(sum(((mp- mean2)^2)*year2/100)) + +cat("mean for year 1990s: ",mean1) +cat("mean for year 2050s: ",mean2) +cat("SD for year 1990s: ",sd1) +cat("SD for year 2050s: ",sd2) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.5/ex_5_5.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.5/ex_5_5.R new file mode 100644 index 00000000..979ef9a0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.5/ex_5_5.R @@ -0,0 +1,9 @@ +px <- c(0.1,0.5,0.4) +x <- 0:2 +E <- weighted.mean(x,px) +cat("expected daily demand for the tool is ",E) + +V <- sum(((x - E)^2)*px) +cat("variance is:", V) + + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.6/ex_5_6.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.6/ex_5_6.R new file mode 100644 index 00000000..3fe37f52 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.6/ex_5_6.R @@ -0,0 +1,13 @@ +px <- c(0.1,0.5,0.4) +x <- 0:2 +E <- weighted.mean(x,px) + +# E(100X) = 100 E(X) +cat("Daily cost of using tool" , 100*E) + + +V <- sum(((x - E)^2)*px) +cat("variance is:", V) + +# V(100X) =(100^2)V(X) +cat("Variance of daily cost is ", 100*100*V) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.7/ex_5_7.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.7/ex_5_7.R new file mode 100644 index 00000000..b04ed674 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.7/ex_5_7.R @@ -0,0 +1,10 @@ +prob_marks <- c(0.1,0.2,0.4,0.2,0.1) +marks <- 0:4 +E <- weighted.mean(marks,prob_marks) + +cat("Mean score is:" , E) + +V <- sum(((marks-E)^2)*prob_marks) +cat("Standard deviation is ", sqrt(V)) + + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.8.a/ex_5_8_a.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.8.a/ex_5_8_a.R new file mode 100644 index 00000000..9ab620d5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.8.a/ex_5_8_a.R @@ -0,0 +1,6 @@ +mean <- 120 +sd <- 10 +lower_limit <- 100 +k <- (mean - lower_limit)/sd + +cat(1-1/k*k, "fraction of days will have prod. between 100 and 140" ) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.8.b/ex_5_8_b.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.8.b/ex_5_8_b.R new file mode 100644 index 00000000..dcbd35a3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH5/EX5.8.b/ex_5_8_b.R @@ -0,0 +1,5 @@ +mean <- 120 +sd <-10 +fraction <- 0.90 +k <-( 1/(1-fraction))^0.5 +cat("shortest interval is from ", mean-(k*sd), "-",mean+(k*sd)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.1/ex_6_1.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.1/ex_6_1.R new file mode 100644 index 00000000..16b0a2e5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.1/ex_6_1.R @@ -0,0 +1,7 @@ +a <- function(x){ + 0.5*exp(-x*0.5) +} + + +cat("the probability that battery will last longer than 400 hours",integrate(a,4,'infinite')$value) +cat("probability that the lifetime exceeds 9 is",integrate(a,9,'infinity')$value) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.10/ex_6_10.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.10/ex_6_10.R new file mode 100644 index 00000000..f27c4db3 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.10/ex_6_10.R @@ -0,0 +1,11 @@ + +# using exponential distribution , alpha=1 +# As Y= X1 + X2 , alpha =2 beta =400 + +#b +cat("Expected value E(Y) =", 2 * 400) + +#c +# using Gamma distriution + cat(" The probability that the system will survive for more than 1000 hours is equal to P(Y>1000) =", + 1 - pgamma(1000,shape = 2 ,scale = 400)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.11/ex_6_11.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.11/ex_6_11.R new file mode 100644 index 00000000..7d9616b5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.11/ex_6_11.R @@ -0,0 +1,7 @@ +alpha <- 3 +beta <- 2 +sd <- ((alpha * beta * beta)^2) +cat("P(|Y-6| >=14 ) = " , (3.46/14)^2) + + +cat(" Because P(Y>20 min) is so small, we must conclude that our new maintenance man is somewhat slower than his predecessor. ") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.12/ex_6_12.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.12/ex_6_12.R new file mode 100644 index 00000000..7d1992c5 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.12/ex_6_12.R @@ -0,0 +1 @@ +cat("P(Z< =1.53) =",pnorm(1.53,lower.tail = TRUE)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.13/ex_6_13.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.13/ex_6_13.R new file mode 100644 index 00000000..cc0e3436 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.13/ex_6_13.R @@ -0,0 +1,16 @@ +# using normal distribution + +#a +cat("P(Z <= 1) =", pnorm(1,lower.tail = TRUE)) + +#b +cat("P(Z < -1.5) =" , pnorm(-1.5,lower.tail = TRUE)) + +#c +cat("P(Z > 1) =", pnorm(1,lower.tail = FALSE)) + +#d +cat("P(-1.5 <= Z < =0.5) =", pnorm(0.5)-pnorm(-1.5)) + +#e +cat("The value of z such that P(Z<=z)= 0.99 is",qnorm(0.99,lower.tail = T)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.14/ex_6_14.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.14/ex_6_14.R new file mode 100644 index 00000000..43790e83 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.14/ex_6_14.R @@ -0,0 +1,7 @@ + +# area using normal distribution + + +# given population mean = 16 and sd = 1 + +cat(" the probability that the machine will dispense more than 17 ounces of liquid into any one bottle. ",pnorm(17,16,1,lower.tail = F)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.15/ex_6_15.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.15/ex_6_15.R new file mode 100644 index 00000000..46338b9d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.15/ex_6_15.R @@ -0,0 +1,9 @@ + +# using normal distribution + +z <- qnorm(0.05,lower.tail = F) +cat("The value of z such that P(Z>=z)= 0.05 is" ,z) +sd <- 1.2 +cat("Therefore, the proper setting for the dial so that 17-ounce bottles will overflow only 5% of the time is when mean =", + 17 - sd*z) + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.16/ex_6_16.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.16/ex_6_16.R new file mode 100644 index 00000000..d5a737b8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.16/ex_6_16.R @@ -0,0 +1,18 @@ + +# using normal distribution + +#a +# SAT mathematics scores mean = 480 and sd = 100 +a <- pnorm(550,480,100,lower.tail = T) +cat(" percent of students would score less than 550 in a typical year is P(X<550)", a * 100) + +#b +# ACT mathematics scores mean = 18 and sd = 6 +b <- (550-480)/100 +cat(" The engineering school set as a comparable standard on the ACT math test would be" , 18 + 6*b) + +#c +cat(" the probability that a randomly selected student will score over 700 on the SAT math test = P(X>700)", + pnorm(700,480,100,lower.tail = F)) + + \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.17.a/ex_6_17_a.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.17.a/ex_6_17_a.R new file mode 100644 index 00000000..88606da8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.17.a/ex_6_17_a.R @@ -0,0 +1,16 @@ + +# mean and sd of the batting league is 0.358 and 0.027 respectively + +#a +# z sore for Ted Williams is (0.406-0.358)/0.027 +z1 <- (0.406-0.358)/0.027 +cat("z-score for Ted Williams is ", z1) +cat("Percentile score for Ted Williams is", pnorm(z1,lower.tail = T)) + +# z score for George Brett is (0.390-0.358)/0.027 +z2 <- (0.390-0.358)/0.027 +cat("z score for George Brett is ", z2) +cat("Percentile score for George Brett is",pnorm(z2,lower.tail = T)) + + +cat("The percentile score for Ted Williams is 0.96 while that for George Brett is 0.88. Both the performances are outstanding; however, Ted Williams did slightly better than George Brett. ") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.17.b/ex_6_17_b.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.17.b/ex_6_17_b.R new file mode 100644 index 00000000..d3c46459 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.17.b/ex_6_17_b.R @@ -0,0 +1,5 @@ + +#b + +cat(" The chance of the League leader hitting over 0.400 in a given year can be ", + pnorm(0.400,0.358,0.027,lower.tail = F)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.18/ex_6_18.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.18/ex_6_18.R new file mode 100644 index 00000000..3ebd1bcf --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.18/ex_6_18.R @@ -0,0 +1,8 @@ +octane =c(88.5 ,95.6 ,88.3 ,94.2 ,89.2, 93.3 ,89.8 ,91.8 ,90.4, 92.2 ,87.7, 93.3 ,87.6 ,92.7, 88.3 ,91.8 ,89.6, 91.6, 89.3, 92.2, 83.4, 94.7 ,84.3 ,93.2 ,85.3, 92.3, 87.4, 90.4, 89.7, 91.2, 86.7, 91.1 ,86.7, 91.0, 87.9 ,90.4, 88.9 ,91.1, 90.3 ,91.0, 87.5, 91.0, 88.2, 90.3 ,88.6, 90.1 ,91.2, 92.6, 91.6 ,92.2 ,91.5, 94.2, 90.8, 93.4 ,90.9 ,93.0, 89.3 ,89.8, 90.5, 90.0, 88.6, 87.8, 88.3 ,88.5 ,89.0 ,88.7 ,94.4, 90.6 ,90.7 ,100.3 ,93.7, 89.9, 98.8 ,90.1, 96.1 ,89.9, 92.7 ,91.1 ,92.7) +summary(octane) +p_value =pnorm(96,mean=mean(octane),sd = sd(octane),lower.tail = FALSE) +cat("P(ocatane rating) > 96 =",p_value) + +hist(octane) + + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.2/ex_6_2.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.2/ex_6_2.R new file mode 100644 index 00000000..06719c98 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.2/ex_6_2.R @@ -0,0 +1,12 @@ +a <- function(x){ + 0.5*exp(-x*0.5) +} + +#a +cat(" the probability that the lifetime of a particular battery of this type is less than 200 hours", + integrate(a,0,2)$value) +# ans given in book is wrong ,P(X<2)= 0.6321 + +#b +cat(" the probability that a battery of this type lasts more than 30 hours given that it has already been in use for more than 200 hours. ", + (integrate(a,3,'infinity')$value)/(integrate(a,2,'infinity')$value)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.20/ex_6_20.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.20/ex_6_20.R new file mode 100644 index 00000000..3b187861 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.20/ex_6_20.R @@ -0,0 +1,12 @@ +percentile =c(5,10,20,30,40,50,60,70,80,90,95,99.9) +z_score =(qnorm(percentile /100)) + +florida =c(180.448,198.383,220.102,235.762,249.11,261.651,278.539,303.200,324.918,342.853,414.209) + +qqnorm(florida,ylim = c(150,500),xlim =c(-3,3)) +qqline(florida) + +nebraska =c(165.275,178.736,195.036,206.79,216.832,226.219,235.606,245.649,257.402,273.702,287.163,340.716) + +qqnorm(nebraska,ylim = c(100,350),xlim=c(-3,3)) +qqline(nebraska) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.22/ex_6_22.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.22/ex_6_22.R new file mode 100644 index 00000000..58fe457c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.22/ex_6_22.R @@ -0,0 +1,6 @@ +CO =c( 1.7, 1.8, 2.1, 2.4, 2.4, 3.4, 3.5, 4.1, 4.2, 4.4, 4.9, 5.1, 8.3, 9.3, 9.5) +qqnorm(CO) + +i =1:15 +z =i/(15+1) +z_score =qnorm(z) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.23/ex_6_23.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.23/ex_6_23.R new file mode 100644 index 00000000..e3627493 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.23/ex_6_23.R @@ -0,0 +1,19 @@ + +# Given X = beryllium contamination follows lognormal distribution +# Parameters of X ,mu = -2.291 , sd = 1.276 + +# Using lognormal distribution +#a +cat(" the probability that wipe sample will have beryllium contamination exceeding 0.50 gm/100 cm2 = P(X>0.50) " + , 1 - plnorm(0.50,meanlog = -2.291,sdlog = 1.276)) + +#b +cat("The 95th percentile for contamination distribution is", qlnorm(0.95,meanlog = -2.291,sdlog = 1.276)) +cat("The result exceeds the DOE safety limit of 0.20 and thus, we can conclude that the beryllium contamination at this smelter is at an unhealthy level for workers") + + +#c +cat("E(X)= ", exp(-2.291 + (1.276^2)/2)) +cat("V(X)= ", (exp((2*(-2.291)) + (1.276^2)))*((exp(1.276^2)) - 1 )) + + \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.24/ex_6_24.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.24/ex_6_24.R new file mode 100644 index 00000000..1b8fdeab --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.24/ex_6_24.R @@ -0,0 +1,12 @@ + +# Let X denote the proportion of the total supply sold in a given week +# Given alpha = 4, beta = 2 + +# Using beta distribution + +#a +cat(" The expected proportion of supply sold in a given week is ", 4/(4+2)) + +#b +cat("P(X>0.90) = 1 - P(X<=0.90) =", 1 - pbeta(0.90,4,2)) +cat("It is not very likely that 90% of the stock will be sold in a given week. ") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.25/ex_6_25.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.25/ex_6_25.R new file mode 100644 index 00000000..fa1fc07a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.25/ex_6_25.R @@ -0,0 +1,11 @@ +lifetime_sqroot =c(0.637, 1.531, 0.733, 2.256, 2.364 ,1.601, 0.152 ,1.826 ,1.868, 1.126, 0.828 ,1.184, 0.484 ,1.207, 0.719, 0.715 ,0.474 ,1.525, 1.709, 1.305, 2.186, 1.228, 2.006 ,1.032, 1.802 ,1.668 ,1.230, 0.577, 1.274, 1.623 ,1.313 ,0.542, 1.823, 0.880 ,1.526, 2.535, 1.793 ,2.741, 0.578, 1.360 ,2.868, 1.493 ,1.709, 0.872, 1.032, 0.914 ,1.952 ,0.984 ,2.119, 0.431) + +#Exponential density plot + +hist(lifetime_sqroot^2,breaks = 9,probability = TRUE,main = "Histogram of Lifetime",xlab = "Lifetime",ylab = "Probability") + +# Weibull distribution plot differs from the one given in textbook +#Weibull distribution + +hist(lifetime_sqroot,breaks = 12,probability = TRUE,main = "Histogram of Sq root of Lifetime",xlab = "sq root",ylab = "Probability") + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.26/ex_6_26.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.26/ex_6_26.R new file mode 100644 index 00000000..e254869a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.26/ex_6_26.R @@ -0,0 +1,11 @@ + +# USing Weibull Distribution + +Theeta =50 +gama = 2 + +#a +cat("P(X>10) = ", 1 - pweibull(10,shape = gama,scale = sqrt(Theeta))) + +#b +cat(" Expected lifetime of thermisters is E(X) =", (Theeta^(1/gama))*(gamma(1+(1/gama)))) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.27/ex_6_27.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.27/ex_6_27.R new file mode 100644 index 00000000..dd2c0d44 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.27/ex_6_27.R @@ -0,0 +1,7 @@ +cables =c(5300,5410,5500,5700,5710,5750,5800,5810,5870,5900,5900,5990,6050,6180,6180,6190,6240,6250,6300,6330,6360,6370,6380,6410,6470,6480,6590,6600,6740,6780,6820,6870) + +L =c(-3.481,-2.772,-2.351,-2.046,-1.806,-1.606,-1.434,-1.281,-1.144,-1.019,-0.903,-0.794,-0.692,-0.594,-0.501,-0.411,-0.323,-0.238,-0.154,-0.071,0.012,0.094,0.177,0.262,0.349,0.439,0.533,0.635,0.747,0.875,1.031,1.252) +fit =lm(L~log(cables)) +plot(log(cables),L,main = "Plot of LF( x ) versus ln( x ) for the cable strength data") +abline(reg = fit) + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.4/ex_6_4.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.4/ex_6_4.R new file mode 100644 index 00000000..c21957a1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.4/ex_6_4.R @@ -0,0 +1,13 @@ +a = function(x){ + if(x<0){ + 0 + } else if(x>=0 && x<=1){ + x + } else if(x>=1 && x<=2){ + 0.5 + } else { + 0 + } +} + +cat("the probability that demand will exceed 150 gallons on a given week",integrate(Vectorize(a),1.5,2)$value) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.5/ex_6_5.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.5/ex_6_5.R new file mode 100644 index 00000000..e046ad54 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.5/ex_6_5.R @@ -0,0 +1,13 @@ +a = function(x){ + 3*x*x*x +} + +E= integrate(a,0,1)$value + +cat(" on the average, the lathe is in use ", E*100,"percent of the time") + +b =function(x){ + 3*x*x*x*x +} + +cat("Variance is ",integrate(b,0,1)$value - E^2 ) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.6/ex_6_6.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.6/ex_6_6.R new file mode 100644 index 00000000..96e842a1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.6/ex_6_6.R @@ -0,0 +1,15 @@ +a = function(x){ + if(x<0){ + 0 + } else if(x>=0 && x<=1){ + x*x + } else if(x>=1 && x<=2){ + x/2 + } else { + 0 + } +} + +b =integrate(Vectorize(a),0,1)$value +c= integrate(Vectorize(a),1,2)$value +cat("The expected weekly demand for kerosene is ",b+c," gallons") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.7/ex_6_7.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.7/ex_6_7.R new file mode 100644 index 00000000..b5275ded --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.7/ex_6_7.R @@ -0,0 +1,7 @@ +E =445 +V =236 +sd =sqrt(V) +p= 0.75 +k =sqrt((1/(1-p))) + +cat(" This interval isgiven by ",E- k*sd," - ",E+ k*sd) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.8.a/ex_6_8_a.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.8.a/ex_6_8_a.R new file mode 100644 index 00000000..6e7d7bcf --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.8.a/ex_6_8_a.R @@ -0,0 +1,10 @@ + +# Unniform distriution problem + +#a +# the probability that the delivery time is two or more days = P(X>=2) + +cat(" the probability that the delivery time is two or more days is " , 1-punif(2,1,5)) + + + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.9.a/ex_6_9_a.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.9.a/ex_6_9_a.R new file mode 100644 index 00000000..eb7b91fe --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.9.a/ex_6_9_a.R @@ -0,0 +1,11 @@ + +# Using exponential distriution + +#a +# The probability that any given plant processes more than 5 tons of raw sugar on a given day = P(Y>=5) + +mean <- 4 +Theeta <- 1/mean +a <- 1 - pexp(5, rate = Theeta) +cat("The probability that any given plant processes more than 5 tons of raw sugar on a given day is", a) + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.9.b/ex_6_9_b.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.9.b/ex_6_9_b.R new file mode 100644 index 00000000..481f0356 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH6/EX6.9.b/ex_6_9_b.R @@ -0,0 +1,10 @@ + +# Using binomial distribution +#b + +mean <- 4 +Theeta <- 1/mean +a <- 1 - pexp(5, rate = Theeta) + +cat(" the probability that exactly two of the three plants process more than 5 tons of raw sugar on a given day" + , dbinom(2,3,prob = a) ) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.10/ex_7_10.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.10/ex_7_10.R new file mode 100644 index 00000000..70d6f41d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.10/ex_7_10.R @@ -0,0 +1,49 @@ + +# to find the covariance between two variables X and Y + +rm("c") + +a <- matrix(c(0.04,0,0,0.16,0.10,0,0.20,0.30,0.20), nrow = 3, ncol = 3) + + +# individual column sum +ax <- apply(a,2,sum) + + +# indivdual row sum +ay <- apply(a,1,sum) + +# E[X].. +ex <- sum(0:2*ax) + +# E[Y].. +ey <- sum(0:2*ay) + + +# E(XY).. +exy <- 0 + +for(i in 0:2){ + + for(j in 0:2){ + + exy <- exy + i*j*a[i+1,j+1] + + } +} +Cov <- exy - ex*ey +cat("CoV(X1,X2 =)", Cov) + +df<- function(l,m) +{ + (l-m) * (l-m) +} +cat("V(X1) = " , sum(df((0:2),ey)*ay)) +cat("V(X2) =" , sum(df((0:2),ex)*ax)) + +V1 <- sum(df((0:2),ey)*ay) +V2 <- sum(df((0:2),ex)*ax) + +Ro <- Cov/(sqrt(V1 * V2)) + +cat("Correlation = ", Ro) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.12/ex_7_12.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.12/ex_7_12.R new file mode 100644 index 00000000..d3f557ee --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.12/ex_7_12.R @@ -0,0 +1,37 @@ +a <- function(x) +{ + x*(3*x*x) +} +EX1 =integrate(a,0,1)$value + +b <- function(y) +{ + y*1.5*(1- y^2) +} +EX2 =integrate(b,0,1)$value + +c <- function(x) +{ + x*x*(3*x*x) +} +EX1sq =integrate(c,0,1)$value + +d <-function(y) +{ + y*y*1.5*(1- y^2) +} +EX2sq =integrate(d,0,1)$value + +VX1 = EX1sq - EX1^2 +VX2 = EX2sq - EX2^2 + +e <- function(x) +{ + 1.5*(x^4) +} +EX1X2 =integrate(e,0,1)$value + +Cov = EX1X2 - EX1*EX2 + +cat("E(Y) = ",EX1 - EX2) +cat("V(Y) = ",VX1 + VX2 + 2*1*(-1)*Cov) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.13/ex_7_13.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.13/ex_7_13.R new file mode 100644 index 00000000..27612b0c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.13/ex_7_13.R @@ -0,0 +1,8 @@ +# The dollar amount spent per week is given by Y =3X1 +5X2 +# given, E(X1) = 40 , V(X1) = 4 +# E(X2) = 65, V(X2) = 8 + +cat("E(Y) = 3E(X1) + 5(E(X2) :" , 3*40 + 5*65) +cat("V(Y) = (3^2)*V(X1) + (5^2)*V(X2))" , (3^2)*4 + (5^2)*8) + + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.15/ex_7_15.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.15/ex_7_15.R new file mode 100644 index 00000000..c289dbde --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.15/ex_7_15.R @@ -0,0 +1,13 @@ + +# to find the probability that three bulbs have no defects, one has a type A defect, and two have type B defects out of 6 +# bulbs chosen from a lot + +# Using multinomial distribution + +p_bulb <- c(0.70,0.20,0.10) + +# No. of bulbs chosen without defect, with defect A, with defect B are: +x <- c(3,1,2) + +cat(" the probability that three bulbs have no defects, one has a type A defect, and two have type B defects is", + dmultinom(x,6,p_bulb)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.19/ex_7_19.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.19/ex_7_19.R new file mode 100644 index 00000000..e3449dd2 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.19/ex_7_19.R @@ -0,0 +1,14 @@ + +a <- function(x1,x2){ + 0.5 +} + +b <- function(x2){ + 0.5 * x2 +} + +c <- function(x1){ + x1 * a(x1,1)/b(1) +} + +cat(" the conditional expectation of amount of sales X1 given that X2 = 1 is ", integrate(Vectorize(c),0,1)$value) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.2/ex_7_2.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.2/ex_7_2.R new file mode 100644 index 00000000..58db78b6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.2/ex_7_2.R @@ -0,0 +1,39 @@ + +# Joint Probability Distribution +# a +library(MASS) +# formula for Joint Probability Distribution + +a <- function(x,y) +{ + if(x+y <= 2) + { + if(x==1 || y==1) + { + ans = ( 2 * (1/3) * (1/3)) + + } + else{ + ans = ((1/3) * (1/3)) + } + } + + else{ + ans = (0) + } +} + +for(i in 0:2){ + for(j in 0:2) + { + cat("p(", i,",",j,") =") + print(fractions(a(i,j))) + } + +} + +# b +# the probability that one of the customers visits counter B given that one of the customers is known to have +# visited counter A. +cat("P(X2 =1 | X1 =1) =", a(1,1)/(a(1,0) + a(1,1) + a(1,2))) + \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.20/ex_7_20.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.20/ex_7_20.R new file mode 100644 index 00000000..ed2a9584 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.20/ex_7_20.R @@ -0,0 +1,12 @@ + +# E(Y) = E(E(Y|p)) +# using binomial distribution +# E(Y|p)= E(n*p) = n*E(p) +# given , n=10 + +a <- function(p) +{ + 10 * (4*p) +} + +cat(" the expected value of Y for any given day", integrate(a,0,0.25)$value) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.3/ex_7_3.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.3/ex_7_3.R new file mode 100644 index 00000000..c409239f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH7/EX7.3/ex_7_3.R @@ -0,0 +1,19 @@ + +# Joint Density Function of Continuous Random Variable.. + +a <- function(x1,x2){ + 2 * (1-x1) + +} + + +# to find the probability of a region A:{(x1,x2)| 0= 150) +x <- (150 - diff_mean)/sqrt(diff_sd*diff_sd*(1/A[3] + 1/B[3])) + +#degree of freedom = 6+4-2 +cat(" probability that the sample mean tensile proof stress for group 1 is at least 150 MPa larger than that for group 2 is ",pt(x,df=8,lower.tail = F)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.11/ex_8_11.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.11/ex_8_11.R new file mode 100644 index 00000000..ec0f669d --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.11/ex_8_11.R @@ -0,0 +1,13 @@ +A <- c(10.18,12.19,12) +B <- c(-14.71,4.40,12) +mu <- 0 +#a +#P(d>=10.18) +a <- (A[1]- mu)/(A[2]/sqrt(A[3])) + +cat("probability of observing a mean difference of a At least 10.18 kN for EOF measurements is",pt(a,df=A[3]-1,lower.tail = F)) + +#b +#P(d<= -14.71) +b <- (B[1]- mu)/(B[2]/sqrt(B[3])) +cat("probability of observing a mean difference of a At most -14.71 kN for EOF measurements is", pt(b,df=B[3]-1,lower.tail = T)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.12/ex_8_12.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.12/ex_8_12.R new file mode 100644 index 00000000..f6773e0c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.12/ex_8_12.R @@ -0,0 +1,13 @@ +p1= 0.04 +p2= 0.025 +n1 = 200 +n2 = 200 +diff_mean = p1-p2 +diff_sd = sqrt(p1*(1-p1)/n1 + p2*(1-p2)/n2) + +cat("P(|p1 - p2|) =", pnorm(0.02,diff_mean,diff_sd,lower.tail = FALSE) ) + +# There is a fairly high chance (38.88%) of observing a difference of at most 2 percentage points between the sample proportion defectives + +#Answer given in book is wrong. Answer will be twice of what given in book. + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.13.a/ex_8_13_a.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.13.a/ex_8_13_a.R new file mode 100644 index 00000000..3b5ae1af --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.13.a/ex_8_13_a.R @@ -0,0 +1,16 @@ +n1 = 10 +n2 = 10 + +# 2 cases: s1*s1 > 2*s2*s2 and s2*s2 > 2*s1*s1 +# Let s1^2/s2^2 =X + +# The probability of observing one sample variance at least 2 times larger than the other is +#P(X<0.5) + P(X>2) + +# Using F distribution + +cat("P(F(9,9)<0.5) + P(F(9,9)>2) = ", pf(0.5,9,9) + pf(2,9,9,lower.tail = F)) + +cat(" There is approximately ", (pf(0.5,9,9) + pf(2,9,9,lower.tail = F))*100, " chance that one sample variance will be at least 2 times larger than the other +, even if the population variances are equal.") + \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.13.b/ex_8_13_b.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.13.b/ex_8_13_b.R new file mode 100644 index 00000000..9802da02 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.13.b/ex_8_13_b.R @@ -0,0 +1,15 @@ +n1 = 10 +n2 = 10 + +# 2 cases: s1*s1 > 4*s2*s2 and s2*s2 > 4*s1*s1 +# Let s1^2/s2^2 =X + +# The probability of observing one sample variance at least 2 times larger than the other is +#P(X<0.25) + P(X>4) + +# Using F distribution + +cat("P(F(9,9)<0.25) + P(F(9,9)>4) = ", pf(0.25,9,9) + pf(4,9,9,lower.tail = F)) + +cat(" There is approximately ", (pf(0.25,9,9) + pf(4,9,9,lower.tail = F))*100, " chance that one sample variance will be at least 2 times larger than the other + , even if the population variances are equal.") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.14/ex_8_14.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.14/ex_8_14.R new file mode 100644 index 00000000..63337272 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.14/ex_8_14.R @@ -0,0 +1,33 @@ +m1 =c(16.1,16.2,16.0,16.1,16.5,16.8,16.1,15.9,15.7,16.2,16.4,16.5,16.7,17.1,17.0,16.2,17.1,15.8,16.4,15.4) +m2 =c(16.2,16.4,16.1,16.2,16.1,15.9,16.9,16.2,16.7,16.9,16.9,16.9,16.2,16.2,16.8,16.7,16.9,16.2,16.2,15.1) +m3 =c(15.9,15.8,15.7,15.9,16.4,16.1,16.2,16.8,16.1,16.1,17.1,17.2,16.4,17.0,16.4,16.6,16.2,17.1,16.7,15.0) +m4 =c(16.0,16.1,16.3,16.4,16.4,16.3,16.5,16.1,16.4,17.0,16.2,16.1,15.8,16.9,16.5,16.2,16.0,16.9,16.8,15.2) +m5 =c(16.1,16.2,16.1,16.6,16.2,16.4,16.5,16.4,16.8,16.4,16.1,16.4,16.6,16.1,16.2,17.0,16.1,16.2,16.1,14.9) + +obseravation <- c(m1,m2,m3,m4,m5) + +samples <- c(rep(1:20,5)) + + +dat <- data.frame(obseravation,samples) + + +print("The xbar and S chart for the above data is:") + +#install the package qicharts for xbar chart + +library(qicharts) +# Run the below two code individually.. +#xbar chart +qic(obseravation, + x= samples, + data = dat, + chart = 'xbar', + xlab = 'Sample Number') + +#install the package qcc for R chart + +# R chart +library(qcc) +dat1=data.frame(m1,m2,m3,m4,m5) +qcc(dat1,type = "R") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.15/ex_8_15.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.15/ex_8_15.R new file mode 100644 index 00000000..56867201 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.15/ex_8_15.R @@ -0,0 +1,36 @@ +m1 =c(16.1,16.2,16.0,16.1,16.5,16.8,16.1,15.9,15.7,16.2,16.4,16.5,16.7,17.1,17.0,16.2,17.1,15.8,16.4,15.4) +m2 =c(16.2,16.4,16.1,16.2,16.1,15.9,16.9,16.2,16.7,16.9,16.9,16.9,16.2,16.2,16.8,16.7,16.9,16.2,16.2,15.1) +m3 =c(15.9,15.8,15.7,15.9,16.4,16.1,16.2,16.8,16.1,16.1,17.1,17.2,16.4,17.0,16.4,16.6,16.2,17.1,16.7,15.0) +m4 =c(16.0,16.1,16.3,16.4,16.4,16.3,16.5,16.1,16.4,17.0,16.2,16.1,15.8,16.9,16.5,16.2,16.0,16.9,16.8,15.2) +m5 =c(16.1,16.2,16.1,16.6,16.2,16.4,16.5,16.4,16.8,16.4,16.1,16.4,16.6,16.1,16.2,17.0,16.1,16.2,16.1,14.9) + +obseravation <- c(m1,m2,m3,m4,m5) + +samples <- c(rep(1:20,5)) + + +dat <- data.frame(obseravation,samples) + + +print("The xbar and S chart for the above data is:") + + +#Use the package qicharts + +library(qicharts) +# Run the below two code individually.. +#xbar chart +qic(obseravation, + x= samples, + data = dat, + chart = 'xbar', + xlab = 'Sample Number') + +# S chart +qic(obseravation, + x = samples, + chart = 's', + xlab = 'Sample Number', + data = dat) + +#UCL and LCL values have been rounded off. \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.16/ex_8_16.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.16/ex_8_16.R new file mode 100644 index 00000000..44bd25b6 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.16/ex_8_16.R @@ -0,0 +1,21 @@ +rm("c") +x =c(3,1,4,2,0,2,3,3,5,4,1,1,1,2,0,3,2,2,4,1,3,0,2,3) + +sample =1:24 +dat <- data.frame(sample,x) + +p <- mean(dat$x/50) + + +u <- p + 3*sqrt(p*(1-p)/50) + +l <- p- 3*sqrt(p*(1-p)/50) + +cat("The LCL and UCL are",0,"and", u,"respectively") + +#Since l is neg. , we take lower limit to be 0. + +#install the package qcc + +library(qcc) +qcc(dat$x, sizes =50,type="p") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.17/ex_8_17.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.17/ex_8_17.R new file mode 100644 index 00000000..68c28bd8 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.17/ex_8_17.R @@ -0,0 +1,14 @@ +defective =c(6,3,4,0,2,7,3,1,0,0,4,3,2,2,6,5,0,7,2,1) +sample =1:20 +dat <- data.frame(sample,defective) +n=20 +c =sum(defective)/n +u =c + 3*sqrt(c) +l =c - 3*sqrt(c) + +cat("The LCL and UCL are",0,"and", u,"respectively") +#Since l is neg. , we take lower limit to be 0. + +# install the package qcc. +library(qcc) +qcc(dat$defective, type = "c") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.18/ex_8_18.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.18/ex_8_18.R new file mode 100644 index 00000000..19ce29c4 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.18/ex_8_18.R @@ -0,0 +1,23 @@ +defect =c(1,4,1,2,1,4,3,5,3,1,2,1) +hours =c(58.33,80.22,209.24,164.70,253.70,426.90,380.20,527.70,319.30,340.20,78.70,67.27) +part =1:12 +dat = data.frame(part,defect,hours) +u_bar= sum(dat$defect)/sum(dat$hours) + +ucl1=u_bar + 3*sqrt(u_bar/dat$hours[1]) +ucl2=u_bar + 3*sqrt(u_bar/dat$hours[2]) + +u1 =dat$defect[1]/dat$hours[1] +u2 =dat$defect[2]/dat$hours[2] + + +#install the package qicharts for u chart + +library(qicharts) +# Run the below code .. +# u chart +qic(defect,hours, + x= part , + data = dat, + chart = 'u', + xlab = 'Sample Number') diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.19/ex_8_19.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.19/ex_8_19.R new file mode 100644 index 00000000..b8e11e27 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.19/ex_8_19.R @@ -0,0 +1,20 @@ +m1 =c(16.1,16.2,16.0,16.1,16.5,16.8,16.1,15.9,15.7,16.2,16.4,16.5,16.7,17.1,17.0,16.2,17.1,15.8,16.4) +m2 =c(16.2,16.4,16.1,16.2,16.1,15.9,16.9,16.2,16.7,16.9,16.9,16.9,16.2,16.2,16.8,16.7,16.9,16.2,16.2) +m3 =c(15.9,15.8,15.7,15.9,16.4,16.1,16.2,16.8,16.1,16.1,17.1,17.2,16.4,17.0,16.4,16.6,16.2,17.1,16.7) +m4 =c(16.0,16.1,16.3,16.4,16.4,16.3,16.5,16.1,16.4,17.0,16.2,16.1,15.8,16.9,16.5,16.2,16.0,16.9,16.8) +m5 =c(16.1,16.2,16.1,16.6,16.2,16.4,16.5,16.4,16.8,16.4,16.1,16.4,16.6,16.1,16.2,17.0,16.1,16.2,16.1) + +obseravation <- c(m1,m2,m3,m4,m5) +m =mean(obseravation) +sigma1 =0.361 +sigma2 =0.367 +USL =17 +LSL =16 +zUSL = (USL - m)/sigma1 +zLSL = (m - LSL)/sigma2 +zmin = min(zUSL,zLSL) +Cpk =zmin/3 +cat("The area below zLSL is",1- pnorm(zLSL)) +cat("The area above zUSL is",1- pnorm(zUSL) ) +prop= 1- pnorm(zLSL) + 1- pnorm(zUSL) +cat("proportion out of specification =",prop) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.2/ex_8_2.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.2/ex_8_2.R new file mode 100644 index 00000000..0c59546f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.2/ex_8_2.R @@ -0,0 +1,41 @@ + +# given, mean =10, sd=10 + +# area for the region P(a<=X<=b) =0.95 +# area for the region P(X<=b) +x <- (1-0.95)/2 +0.95 + +ll <- qnorm(x,lower.tail = FALSE) +ul <- qnorm(x,lower.tail = T) +cat("Therefore , Z lies between", ll," to ",ul) + +y =function(n){ + a <- ( 10 + (ll*(10/sqrt(n)))) + b <- ( 10 + (ul*(10/sqrt(n)))) + output <- list(a,b) + return(output) +} + +output1 <- y(25) +cat("interval when n=25 is ") +cat("lower limit") +output1[1] +cat("Upper limit") +output1[2] + + +output2 <- y(50) +cat("interval when n=50 is ") +cat("lower limit") +output2[1] +cat("Upper limit") +output2[2] + + +output3 <- y(100) +cat("interval when n=100 is ") +cat("lower limit") +output3[1] +cat("Upper limit") +output3[2] + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.3/ex_8_3.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.3/ex_8_3.R new file mode 100644 index 00000000..aa9611fa --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.3/ex_8_3.R @@ -0,0 +1,17 @@ +# given , sigma =2 , n=100 + +#a +# according to central limit theorem +sigma =2 +n = 100 +sd = sigma/sqrt(n) +cat("the probability that the average fracture strength of glass exceeds 14.5 is",pnorm(14.5,14,sd,lower.tail = F), + "which is very small") + +#b +x <- (1-0.95)/2 +0.95 + +ll <- qnorm(x,lower.tail = F) +ul <- qnorm(x,lower.tail = T) +cat("The limit is a = ", 14+ ll*sd,"to b = ",14 + ul*sd) + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.4/ex_8_4.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.4/ex_8_4.R new file mode 100644 index 00000000..a622ea2c --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.4/ex_8_4.R @@ -0,0 +1,20 @@ +#given sigma=1, n=25 +sigma =1 + +#a +n = 25 +sd <= sigma/sqrt(n) + +cat(" the probability that the sample mean will be within 0.3 ounces of the true population mean is", + pnorm(.3/sd) - pnorm(-0.3/sd)) + +#b + +# given, P(-0.3<|X-mu|<0.3) = 0.95 +x <- (1-0.95)/2 +0.95 + +ll <- qnorm(x,lower.tail = F) +ul <- qnorm(x,lower.tail = T) + +n<- (ul/0.3)^2 +cat("Value of n so that the sample mean will be within 0.3 ounces of the population mean with probability 0.95 is ",n) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.5/ex_8_5.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.5/ex_8_5.R new file mode 100644 index 00000000..53e78c19 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.5/ex_8_5.R @@ -0,0 +1,19 @@ + +# Application of t distribution +#a +xbar1 <- 2000 + +mu <- 3000 + +sd <- 989 + +n <- 12 + +t_value = (xbar1-mu)/(sd/sqrt(n)) +cat("The required probability is ", pt(t_value, df = n-1)) + +#b +xbar2 <- 2500 + +t_value = (xbar2-mu)/(sd/sqrt(n)) +cat("The required probability is ", pt(t_value, df = n-1)) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.6/ex_8_6.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.6/ex_8_6.R new file mode 100644 index 00000000..be732d02 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.6/ex_8_6.R @@ -0,0 +1,10 @@ +Y <- 12 +p <- 0.2 +n <- 100 +mu <- p +sd <- sqrt(p*(1-p)/n) + + +z_value = (Y/n - mu)/sd +cat("The required probability is ", pnorm(z_value)) +cat("There is only a small probability of" ,pnorm(z_value) , " of accepting any lot that has 20% nonconforming wafers. ") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.7/ex_8_7.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.7/ex_8_7.R new file mode 100644 index 00000000..e8d532e0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.7/ex_8_7.R @@ -0,0 +1,10 @@ +# USing chi-square distribution +# give, vraiance =0.8,n =10 +var=0.80 +n =10 +ll = 0.05 +ul = 0.95 +a= var*qchisq(0.05,df=9)/(n-1) +b= var*qchisq(0.95,df=9)/(n-1) +cat("value of a and b such that the sample variance of the amounts dispensed will be between a and b with probability 0.90 is", + a,"-",b ) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.8/ex_8_8.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.8/ex_8_8.R new file mode 100644 index 00000000..c6668133 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.8/ex_8_8.R @@ -0,0 +1,20 @@ +# using chi-sq distribution + +# given , variance =100 , n=25 + +var =100 +n=25 + +#a +#P(S^2 > 50) +a <- (n-1)*50/var +cat("approximate probability = ", pchisq(a,df=n-1,lower.tail = F)) + +#b +#P(S^2 > 150) +b <- (n-1)*150/var +cat("approximate probability = ", pchisq(b,df=n-1,lower.tail = F)) + +#c +cat("E(S^2) = ", var) +cat("V(S^2) = ", 2*var*var/(n-1)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.9/ex_8_9.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.9/ex_8_9.R new file mode 100644 index 00000000..c90245f9 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH8/EX8.9/ex_8_9.R @@ -0,0 +1,14 @@ +rm("c") +#Sampling Distribution of the difference of 2 means.. + +# Mean, variance and no. of samples for both machines are as follows + +A <- c(1,200,25) +B <- c(1,200,25) + +diff_mean <- A[1]-B[1] + +diff_sd <- sqrt((A[2]/A[3])+(B[2]/B[3])) + +cat(" the probability that the difference in sample means for two machines will be at most 10 ml is ", + pnorm(10,diff_mean,diff_sd) - pnorm(-10,diff_mean,diff_sd) ) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.10/ex_9_10.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.10/ex_9_10.R new file mode 100644 index 00000000..6dd7cd3b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.10/ex_9_10.R @@ -0,0 +1,11 @@ +#Determining sample size +#Given , confidence limit =90% +#Because no prior knowledge of p is available, use p= 0.5 + +alpha=1-0.90 +B =0.05 +p=0.5 +a <- qnorm(alpha/2,lower.tail = F) + +cat("A random sample of at least ",round(((a/B)^2)*p*(1-p))," workers is required in order to estimate the true proportion favoring + the revised policy to within 0.05. ") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.11/ex_9_11.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.11/ex_9_11.R new file mode 100644 index 00000000..b4390893 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.11/ex_9_11.R @@ -0,0 +1,14 @@ +readings <- c(9.54,9.61,9.32,9.48,9.70,9.26) + +var= (sd(readings))^2 +n=6 + +# given Confidence interval =90% +alpha= 1-0.90 + +# Using chi-sq distribution + +a <- qchisq(1 - (alpha/2),df= n-1,lower.tail = F) +b <- qchisq((alpha/2),df= n-1,lower.tail = F) + +cat("Thus, confidence interval is ", (n-1)*var/b," - ", (n-1)*var/a) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.12/ex_9_12.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.12/ex_9_12.R new file mode 100644 index 00000000..e89e1eff --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.12/ex_9_12.R @@ -0,0 +1,14 @@ + +# Mean , variance and no. of observations for both machines are as follows: +A <- c(12,6,100) +B <- c(9,4,100) + +# given confidence nterval =90% +alpha = 1-0.90 +diff_mean <- A[1] - B[1] + +diff_sd <- sqrt(A[2]/A[3] + B[2]/ B[3]) + + +a = qnorm(alpha/2, lower.tail = F) +cat("We are about 90% confident that the difference in mean daily downtimes is between, ", diff_mean - a*diff_sd," - ", diff_mean + a*diff_sd," min") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.13/ex_9_13.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.13/ex_9_13.R new file mode 100644 index 00000000..e7d5faf1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.13/ex_9_13.R @@ -0,0 +1,20 @@ +# Mean , variance and no. of observations for 3 machines are as follows: + +A <- c(12,6,100) +B <- c(9,4,100) +C <- c(14,5,100) + +#Expected daily cost for downtime on 3 machines is 3*mu1 + 5*mu2 + 2*mu3 + +mu = 3*A[1] + 5*B[1] + 2*C[1] +cat("The estimated daily cost is ",mu ) + +var = 9*A[2]/A[3] + 25*B[2]/B[3] + 4*C[2]/C[3] +cat("Estimated variance is ", var) + +# Confidence interval =95% +alpha=1-0.95 +z = qnorm(1 - alpha/2) + +cat(" We are 95% confident that the mean daily cost of downtimes on these machines is between $", + mu - z*sqrt(var)," and $",mu + z*sqrt(var)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.14/ex_9_14.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.14/ex_9_14.R new file mode 100644 index 00000000..38e5836f --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.14/ex_9_14.R @@ -0,0 +1,18 @@ +# Mean , variance and no. of observations for 2 batches are as follows: + +A <- c(0.22,0.0010,4) +B <- c(0.17,0.0020,5) + +diff_mean= A[1]-B[1] + +common_var = ((A[3]-1)*A[2] + (B[3]-1)*B[2])/ (A[3]+B[3]-2) +sigma = sqrt(common_var) + +# Confidence interval =95% +alpha=1-0.95 +t = qt(alpha/2, df=A[3]+B[3]-2,lower.tail = F) + +c = t*sigma*sqrt(1/A[3]+ 1/B[3]) + +cat("Thus, we are 95% confident that the difference in the mean porosity measurements for two batches is between ", + diff_mean - c," and ", diff_mean +c) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.15/ex_9_15.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.15/ex_9_15.R new file mode 100644 index 00000000..455bbe7b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.15/ex_9_15.R @@ -0,0 +1,26 @@ + +#Normal Distributions with Common Variance + + +M1 <- c(9.17,12.85,5.16,6.37,6.64,8.42,7.33,8.91,9.45,11.39,10.90,6.34,10.46,14.30,13.70) +A <- c(mean(M1),sd(M1),length(M1)) + +M2 <- c(18.86,8.86,17.11,17.38,9.38,11.64,11.25,15.00,12.77,18.89,16.88,12.43) +B <- c(mean(M2),sd(M2),length(M2)) + +diff_mean= A[1]-B[1] + + +common_var = ((A[3]-1)*A[2]*A[2] + (B[3]-1)*B[2]*B[2])/ (A[3]+B[3]-2) +sigma = sqrt(common_var) + + +# Confidence interval =95% +alpha=1-0.95 +t = qt( alpha/2, df=A[3]+B[3]-2,lower.tail = F) + + +c = t*sigma*sqrt(1/A[3]+ 1/B[3]) + +cat("Thus, we are 95% confident that the difference in the mean denier is between ", + diff_mean - c," and ", diff_mean +c) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.16/ex_9_16.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.16/ex_9_16.R new file mode 100644 index 00000000..6765a168 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.16/ex_9_16.R @@ -0,0 +1,9 @@ + +#Normal Distributions with Common Variance +rm("c") +previous = c(13.18, 9.42, 10.55, 10.11, 7.28, 8.53, 7.52, 8.04, 8.34, 6.91, 10.70, 9.21, 7.84, 9.46, 6.49) + + +after = c(5.31, 5.77, 3.36, 5.26, 2.43, 6.08, 3.77, 3.20, 3.49, 3.39, 2.99, 4.79, 6.99, 4.81, 3.99, 4.41, 7.12, 3.83, 3.57, 5.41) + +t.test(previous,after) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.17/ex_9_17.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.17/ex_9_17.R new file mode 100644 index 00000000..d6b84612 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.17/ex_9_17.R @@ -0,0 +1,24 @@ +# Mean , variance and no. of observations for 3 batches are as follows: + +A <- c(0.22,0.0010,4) +B <- c(0.17,0.0020,5) +C <- c(0.12,0.0018,10) + +mu =( A[1]*A[3] + B[1]*B[3])/(A[3]+B[3]) + +# Difference between average f 2 batches and the 3rd batch +diff_mean = mu - C[1] + +diff_sd = sqrt(((A[3]-1)*A[2] + (B[3]-1)*B[2] + (C[3]-1)*C[2])/(A[3]+B[3]+C[3]- 3)) + +a1 = A[3]/(A[3]+B[3]) +a2 = B[3]/(A[3]+B[3]) +a3 = -1 + +#Given , confidence interval =95% +alpha= 1-0.95 +b = qt(alpha/2,df= A[3]+B[3]+C[3]-3,lower.tail = F)*diff_sd*sqrt(a1*a1/A[3] + a2*a2/B[3] + a3*a3/C[3]) + +cat(" we are 95% confident that the difference between the mean of the third batch and the average + of means of the first two batches is between ", diff_mean - b ," - ", diff_mean + b) + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.18/ex_9_18.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.18/ex_9_18.R new file mode 100644 index 00000000..4fd93c8b --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.18/ex_9_18.R @@ -0,0 +1,8 @@ +#Normal Distributions with Unequal Variances + +M1 <- c(9.17,12.85,5.16,6.37,6.64,8.42,7.33,8.91,9.45,11.39,10.90,6.34,10.46,14.30,13.70) + + +M3 <- c(12.17,11.22,11.42,11.73,12.33,12.21,12.21,10.93,12.16,11.61,10.41,11.91) + +t.test(M1,M3) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.19/ex_9_19.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.19/ex_9_19.R new file mode 100644 index 00000000..50ace14a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.19/ex_9_19.R @@ -0,0 +1,9 @@ +#Two sample T test for Chemical vs Atmospheric + +chemical <- c(2.30143,2.29890,2.29816,2.30182,2.29869,2.29940,2.29849,2.29889,2.30074,2.30054) + + +atmp <- c(2.31017,2.30986,2.31010,2.31001,2.31010,2.31024,2.31028,2.31163,2.30956) + +t.test(chemical,atmp) + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.20/ex_9_20.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.20/ex_9_20.R new file mode 100644 index 00000000..3ad3a523 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.20/ex_9_20.R @@ -0,0 +1,19 @@ + +#Large Sample Confidence Interval for a Difference in Proportions +#Data for motors + +n1 = 250 +y1 = 25 +p1 = y1/n1 +n2 = 200 +y2 = 30 +p2 = y2/n2 + +diff_prop = p1 - p2 + +# givem confidence interval =95% +aplha = 1-0.95 +a = qnorm(aplha/2, lower.tail = F)*sqrt(p1*(1-p1)/n1 + p2*(1-p2)/n2) + + +cat("We are 95% confident that the true difference in proportion of defective motors produced by two shifts is between " ,diff_prop -a," - ", diff_prop+a) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.21/ex_9_21.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.21/ex_9_21.R new file mode 100644 index 00000000..d9e5e9e1 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.21/ex_9_21.R @@ -0,0 +1,16 @@ +p11=0.7 +p12=0.9 +p21=0.8 +p22=0.9 + +#Estimated mean +p= (p12 - p11) - (p22 - p21) + +#Estimated variance +var= sum(p11*(1-p11),p12*(1-p12),p21*(1-p21),p22*(1-p22))/100 + +# givem confidence interval =95% +aplha = 1-0.95 +a = qnorm(aplha/2, lower.tail = F)*sqrt(var) + +cat("we are 95% confident that the difference in the change in probability for males and females is between ",p-a," - ",p+a) \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.22/ex_9_22.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.22/ex_9_22.R new file mode 100644 index 00000000..6b2b4bbf --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.22/ex_9_22.R @@ -0,0 +1,11 @@ +#Confidence Interval for a Ratio of Population Variances + +n1 =10 +var1 =2.31 +n2 =16 +var2= 3.68 +x = var2/var1 + +#given , confidence interval=90% +alpha=1-0.90 +cat(" we are 90% confident that the ratio is between ",x/qf(alpha/2,n2 -1,n1 -1,lower.tail = F)," - ", x*qf(alpha/2,n1 -1,n2-1,lower.tail = F)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.23/ex_9_23.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.23/ex_9_23.R new file mode 100644 index 00000000..47636877 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.23/ex_9_23.R @@ -0,0 +1,10 @@ +#Prediction interval +mu =16.1 +s=0.01 +n=16 + +#Given, confidence interval =95% +alpha=1-0.95 +x= qt(alpha/2,df = n-1,lower.tail = F)*s*sqrt(1 + 1/n) +cat("We are about 95% confident that the next observation will lie between ", mu-x ," - ", mu+x) + diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.24/ex_9_24.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.24/ex_9_24.R new file mode 100644 index 00000000..074b1276 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.24/ex_9_24.R @@ -0,0 +1,9 @@ +n=45 +mu=498 +s=4 +delta=0.90 +alpha=1-0.95 +cat("For these data, k=2.021") +k=2.021 +cat(" We are 95% confident that 90% of the population resistances in the population lie between " + ,mu- k*s,"-",mu+ k*s) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.25/ex_9_25.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.25/ex_9_25.R new file mode 100644 index 00000000..fa5ea544 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.25/ex_9_25.R @@ -0,0 +1,7 @@ + +# find the confidence coefficient + +delta=0.90 +n=50 +a= 1 - n*(delta^(n-1)) + (n-1)*(delta^n) +cat("We are ",a*100," confident that the interval (2,150, 2,610) contains at least 90% of the lifelength measurements for the population under study. ") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.29/ex_9_29.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.29/ex_9_29.R new file mode 100644 index 00000000..948c3c57 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.29/ex_9_29.R @@ -0,0 +1,13 @@ + +#Method of maximum liklihood + +X <- c( 0.406, 2.343, 0.538, 5.088, 5.587, 2.563, 0.023, 3.334, 3.491, 1.267) +mean = mean(X)*10 + +#Given confidence interval=95% + +alpha =1-0.95 +a <- qchisq(alpha/2,df=2*(length(X)),lower.tail = F) +b <- qchisq(alpha/2,df=2*(length(X))) + +cat(" We are about 95% confident that the true mean lifelength is between",2*mean/a, "and", 2*mean/b ) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.30/ex_9_30.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.30/ex_9_30.R new file mode 100644 index 00000000..976544fe --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.30/ex_9_30.R @@ -0,0 +1,11 @@ +data=c(0.406 ,0.685 ,4.778 ,1.725 ,8.223, 2.343 ,1.401 ,1.507 ,0.294, 2.230, 0.538, 0.234 ,4.025 ,3.323, 2.920, 5.088 ,1.458, 1.064, 0.774 ,0.761 ,5.587 ,0.517, 3.246, 2.330 ,1.064 ,2.563 ,0.511 ,2.782 ,6.426 ,0.836 ,0.023 ,0.225, 1.514 ,3.214 ,3.810 ,3.334 ,2.325 ,0.333 ,7.514 ,0.968 ,3.491, 2.921 , + 1.624, 0.334, 4.490, 1.267, 1.702, 2.634 ,1.849 ,0.186) +x =mean(data) +t=5 +n=50 +alpha=0.05 +z =qnorm(1- alpha/2) +u = exp(-t/x) + (z/sqrt(n))*(t/x)*exp(-t/x) +l = exp(-t/x) - (z/sqrt(n))*(t/x)*exp(-t/x) + +cat(" we are about 95% confident that the probability is between ",l,"and",u) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.4/ex_9_4.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.4/ex_9_4.R new file mode 100644 index 00000000..e03356a0 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.4/ex_9_4.R @@ -0,0 +1,13 @@ +#Confidence interval evalualtion +#For confidence coefficient to be 95%, , it leaves (1 - 0.025 = 0.975) area to the left + +n <- 50 + +mu <- 2.268 + +sig <- 1.932 + +a <- qnorm(0.975)*sig/sqrt(n) + + +cat("The 95% confidence interval for the above parameters is",mu-a,mu+a," hours") \ No newline at end of file diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.6/ex_9_6.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.6/ex_9_6.R new file mode 100644 index 00000000..634f7dfe --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.6/ex_9_6.R @@ -0,0 +1,6 @@ +# Determining Sample Size to Estimate Mean... + +sigma =2 +B = 0.1 + +cat("Thus, at least ", round((qnorm(0.975)*sigma/B)^2) ,"employees should be sampled to achieve the desired results. ") diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.7/ex_9_7.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.7/ex_9_7.R new file mode 100644 index 00000000..1440ab07 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.7/ex_9_7.R @@ -0,0 +1,12 @@ +# givn confidence level =95%, we'll calculate z(1- 0.95) + +n <- 50 + +mu <- 2.266 + +sig <- 1.935 + +a <- qnorm(0.05, lower.tail = F) + +# To calculate lower limit +cat("Lower limit is ", mu - a*sig/sqrt(n) ) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.8/ex_9_8.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.8/ex_9_8.R new file mode 100644 index 00000000..31436a7a --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.8/ex_9_8.R @@ -0,0 +1,13 @@ + +# Using T distribution + +uts <- c(253,261,258,255,256) + +mu = mean(uts) +sig = sd(uts) +n = 5 +alpha = 1 -0.95 + +a <- qt(alpha/2, df= n-1) + +cat("Therefore, the interval is ", mu + a*sig/sqrt(n), " - ", mu - a*sig/sqrt(n)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.9/ex_9_9.R b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.9/ex_9_9.R new file mode 100644 index 00000000..de5cff25 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/CH9/EX9.9/ex_9_9.R @@ -0,0 +1,9 @@ +# confidence interval =90% + +alpha = 1-0.90 +p =0.20 +n =100 +a =qnorm(1 - alpha/2,lower.tail = F) + +cat(" the true probability p of finding this microorganism in a sample is somewhere between ", p - a*sqrt(p*(1-p)/n), + " - ", p + a*sqrt(p*(1-p)/n)) diff --git a/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/README.txt b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/README.txt new file mode 100644 index 00000000..a78b7f09 --- /dev/null +++ b/Probability_And_Statistics_For_Engineers_by_Richard_L._Scheaffer,_Madhuri_S._Mulekar,_James_T._Mcclave/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Shikha Vyas +Course: B.e +Branch: Information Technology +College/Institute/Organization: Institute Of Engineering And Technology, Davv, Indore + +About The Book + +Book: Probability And Statistics For Engineers +Author: Richard L. Scheaffer, Madhuri S. Mulekar, James T. Mcclave +Publisher: Brooks/cole 20 Channel Center Street Boston, Ma 02 +Year Of Publication: 2010 +ISBN: 978-0-534-40302-7 +Edition: 5 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/README.txt b/README.txt new file mode 100644 index 00000000..f2adb34b --- /dev/null +++ b/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: +Course: +Branch: +College/Institute/Organization: + +About The Book + +Book: +Author: +Publisher: +Year Of Publication: +ISBN: +Edition: + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/R_Book_by_R_Author/CH4/EX4.1.a/Ex4_1a.R b/R_Book_by_R_Author/CH4/EX4.1.a/Ex4_1a.R new file mode 100644 index 00000000..9f5c2c22 --- /dev/null +++ b/R_Book_by_R_Author/CH4/EX4.1.a/Ex4_1a.R @@ -0,0 +1,30 @@ +#install.packages("IPSUR") +#install.packages("prob") +library(IPSUR) +read(IPSUR) +library(prob) +read(prob) + +#First we set up the sample space with the rolldie function +S <- rolldie(2, makespace = TRUE) +#Next, we add random variables U and V with the addrv function. +S <- addrv(S, FUN = max, invars = c("X1", "X2"), name = "U") +S <- addrv(S, FUN = sum, invars = c("X1", "X2"), name = "V") +head(S) +UV <- marginal(S, vars = c("U", "V")) +xtabs(round(probs, 3) ~ U + V, data = UV) +marginal(UV, vars = "U") +marginal(UV, vars = "V") + +temp <- xtabs(probs ~ U + V, data = UV) +rowSums(temp) +colSums(temp) +colSums(temp) + +' +data = sample(1:6,10000000,replace=TRUE)+sample(1:6,10000000,replace=TRUE) +table(data)/length(data) +sum(table(data)/length(data)) + +table(sample(1:6,10000000,replace=TRUE))/length(sample(1:6,10000000,replace=TRUE)) +' \ No newline at end of file diff --git a/R_Book_by_R_Author/CH4/EX4.1.c/Ex4_1c.R b/R_Book_by_R_Author/CH4/EX4.1.c/Ex4_1c.R new file mode 100644 index 00000000..2977158e --- /dev/null +++ b/R_Book_by_R_Author/CH4/EX4.1.c/Ex4_1c.R @@ -0,0 +1,10 @@ +" +the random variable X has distribution funtion F + +F(x) = 0 -- { x <= 0} +F(x) = 1 - exp(-x^2) -- {x >0} + +P{X>1} = ? +" +P = 1 - (1 - exp(-(1^2))) +P \ No newline at end of file diff --git a/R_Book_by_R_Author/README.txt b/R_Book_by_R_Author/README.txt new file mode 100644 index 00000000..3783a1bf --- /dev/null +++ b/R_Book_by_R_Author/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Xyz +Course: B Tech +Branch: Physics +College/Institute/Organization: India + +About The Book + +Book: R Book +Author: R Author +Publisher: R Publisher +Year Of Publication: 2016 +ISBN: R-124-789-256 +Edition: 5 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.1/Ex1_1.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.1/Ex1_1.R new file mode 100644 index 00000000..0f60d2ef --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.1/Ex1_1.R @@ -0,0 +1,7 @@ +#Example 1 Chapter 1 +n=50 #n is no. of tickets +r=2 #no of tickets to be choosen +ways_of_selection = length(combn(n,r))/r +selecting_t10_among_first2 = length(combn(1,1)) * length(combn(n-1,1)) +P = selecting_t10_among_first2/ways_of_selection +print(P) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.10/Ex1_10.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.10/Ex1_10.R new file mode 100644 index 00000000..a081ee0a --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.10/Ex1_10.R @@ -0,0 +1,6 @@ +#Example 10 Chapter 1 +#8 letters on 8 envelope +ways_8_letters = factorial(8) +prob_all_true = 1/factorial(8) +prob_not_all_true = 1-prob_all_true +print(prob_not_all_true) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.11/Ex1_11.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.11/Ex1_11.R new file mode 100644 index 00000000..e6ddeb6a --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.11/Ex1_11.R @@ -0,0 +1,6 @@ +#Example 11 Chapter 1 +ptest=1/5 +P_T1bar=1-ptest +P_T2bar=1-ptest +P_testmiss_atleast1 = 1-P_T1bar*P_T2bar +print(P_testmiss_atleast1) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.12/Ex1_12.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.12/Ex1_12.R new file mode 100644 index 00000000..d3796cff --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.12/Ex1_12.R @@ -0,0 +1,10 @@ +#Example 12 chapter 1 page no. 21 +P_A= 1/4 #prob of spade +P_B= 12/52 #prob of court +P_C= 4/52 #prob of jack +P_AB= 3/52 +P_BC= 4/52 +P_CA= 1/52 +P_ABC= 1/52 +P_AorBorC= P_A+P_B+P_C-P_AB-P_BC-P_CA+P_ABC +print(P_AorBorC) \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.13/Ex1_13.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.13/Ex1_13.R new file mode 100644 index 00000000..9aebf4b8 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.13/Ex1_13.R @@ -0,0 +1,6 @@ +#Example 13 chapter 1 page no. 22 +P_A= 3/8 +P_B= 1/2 +P_AB= 1/4 +P_AcBc= 1-(P_A + P_B - P_AB) +print( P_AcBc) \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.15/Ex1_15.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.15/Ex1_15.R new file mode 100644 index 00000000..89ce0495 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.15/Ex1_15.R @@ -0,0 +1,7 @@ +#Example 15 chapter 1 page no. 23 +p= 1/2 +q= 1-p +P_A= p/(1-(q^3)) #prob of A to win +P_B= (q*p)/(1-(q^3)) #prob of B to win +P_C= (q^2)*p/(1-(q^3)) #prob of C to win +cat("prob of A to win",P_A,"\nprob of B to win",P_B,"\nprob of C to win",P_C) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.2/Ex1_2.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.2/Ex1_2.R new file mode 100644 index 00000000..a8007872 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.2/Ex1_2.R @@ -0,0 +1,10 @@ +#Example 2 Chapter 1 +screw=10 +defective=2 +r=2 #no of screws drawn from box +ways_drawing_r_screw = length(combn(screw,r))/r +ways_drawing_good_screw = length(combn(screw-defective,r))/r +P_no_defective = ways_drawing_good_screw/ways_drawing_r_screw +print(P_no_defective) #answer given is wrong in the book +P_1_defective = length(combn(2,1))*length(combn(8,1)) / ways_drawing_r_screw +print(P_1_defective) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.24/Ex1_24.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.24/Ex1_24.R new file mode 100644 index 00000000..e7842e57 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.24/Ex1_24.R @@ -0,0 +1,10 @@ +#Example 24 chapter 1 page no 28 +PABC=c(500,300,200) +P_A = PABC[1]/sum(PABC) +P_B = PABC[2]/sum(PABC) +P_C = PABC[3]/sum(PABC) +P_DwhenA=1/100 +P_DwhenB=2/100 +P_DwhenC=4/100 +P_AwhenD=P_DwhenA*P_A/(P_DwhenA*P_A+P_DwhenB*P_B+P_DwhenC*P_C) +print(P_AwhenD) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.27/Ex1_27.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.27/Ex1_27.R new file mode 100644 index 00000000..f11d2f30 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.27/Ex1_27.R @@ -0,0 +1,5 @@ +#Example 27 chapter 1 page no 30 +P_A = 4/36 # prob of sum=5 on rolling 2 dice +P_B = 6/36 #prob of sum=7 on rolling 2 dice +lemda = 1-(P_A+P_B) # prob neither 5 nor 7 as the sum +cat("prob of sum=5 to come before",P_A/(1-lemda)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.29/Ex1_29.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.29/Ex1_29.R new file mode 100644 index 00000000..a274a34a --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.29/Ex1_29.R @@ -0,0 +1,6 @@ +#Example 29 chapter 1 page no 30 +P_A=1/3 # prob that A hits the target +P_B=1/5 +cat("prob that both hits the target",P_A*P_B) +cat("prob of atleast one hit the target",P_A+P_B-P_A*P_B) +cat("prob of no one hit the target",1-(P_A+P_B-P_A*P_B)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.3/Ex1_3.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.3/Ex1_3.R new file mode 100644 index 00000000..ddb433e1 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.3/Ex1_3.R @@ -0,0 +1,9 @@ +#Example 3 chapter 1 +lot = 25 +r = 5 #takes 5 motors for sample +ways_selecting_good_motors = length(combn(20,5))/5 #lot containing 5 defective +total_ways = length(combn(25,5))/5 +P_selecting_5defective_lot = ways_selecting_good_motors/total_ways +print(P_selecting_5defective_lot) +P_rejecting_1defective_lot = length(combn(1,1))*length(combn(24,4))/4 / total_ways +print(P_rejecting_1defective_lot) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.31/Ex1_31.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.31/Ex1_31.R new file mode 100644 index 00000000..4dcc411f --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.31/Ex1_31.R @@ -0,0 +1,5 @@ +#Example 31 chapter 1 page no 32 +P_A = 2/3 # prob of white ball from bag1 +P_B = 2/4 #prob of white ball from bag 1 +P_AorB = 1 - (1-P_A)*(1-P_B) +cat("prob of atleast 1 white",P_AorB) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.34/Ex1_34.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.34/Ex1_34.R new file mode 100644 index 00000000..13e71d31 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.34/Ex1_34.R @@ -0,0 +1,8 @@ +#Example 34 chapter 1 page no 33 +P_A = 0.7 # prob of A speak truth +P_B = 0.65 #prob of B speak truth +P_AandB = P_A*P_B +P_AandBbar = P_A*(1-P_B) +P_AbarandB = (1-P_A)*P_B +P_AbarandBbar = (1-P_A)*(1-P_B) +cat("prob of A and B in contradiction state",P_AandBbar+P_AbarandB) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.5/Ex1_5.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.5/Ex1_5.R new file mode 100644 index 00000000..b608566b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.5/Ex1_5.R @@ -0,0 +1,21 @@ +#Example 5 Chapter 1 +d1 = c( 1,2,3,4,5,6 ) +d2 = c( 1,2,3,4,5,6 ) +P<-function(d){ + a=expand.grid(d1,d2) + b=rowSums(a) + count=0 + for(i in (1:length(b))) + { + if(b[i]==d) + { + count=count+1 + } + } + return (count) +} +Psum7or8 = (P(7)+P(8))/36 +print(Psum7or8) +Psum7or11 = (P(7)+P(11))/36 +Pnot7not11 = 1-Psum7or11 +print(Pnot7not11) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.52/Ex1_52.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.52/Ex1_52.R new file mode 100644 index 00000000..e5ca5b36 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.52/Ex1_52.R @@ -0,0 +1,9 @@ +#Example 52 chapter 1 page no. 45 +P_G = 1/3 #prob of guess +P_U = 1/6 # prob unfair means +P_S = 1 - P_G -P_U #answer bu skill +P_c_when_G = 1/4 +P_c_when_U = 1/8 +P_c_when_S = 1 +cat("prob that answer by skill",P_S*P_c_when_S/(P_c_when_U*P_U + P_c_when_G*P_G + + P_S*P_c_when_S)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.54/Ex1_54.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.54/Ex1_54.R new file mode 100644 index 00000000..d08acb0e --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.54/Ex1_54.R @@ -0,0 +1,14 @@ +#Example 54 chapter 1 page no 47 +P_0rec0sent = 0.94 +P_1rec1sent = 0.91 +P_1rec0sent = 1-P_0rec0sent +P_0rec1sent = 1-P_1rec1sent +p1=0.55 +p0=1-p1 +cat("prob of 1 recieved",P_1rec0sent*p0 + P_1rec1sent*p1) +cat("prob of 0 recieved",P_0rec0sent*p0 + P_0rec1sent*p1) +P_1sent1rec = P_1rec1sent*p1/(P_1rec1sent*p1 + P_1rec0sent*p0) +cat("prob that 1 was transmitted when 1 was recieved",P_1sent1rec) +P_0sent0rec = P_0rec0sent*p0/(P_0rec1sent*p1 + P_0rec0sent*p0) +cat("prob that 0 was transmitted when 0 was recieved",P_0sent0rec) +cat("prob of error",P_0rec1sent*p1 + P_1rec0sent*p0) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.55/Ex1_55.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.55/Ex1_55.R new file mode 100644 index 00000000..33f4f8fb --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.55/Ex1_55.R @@ -0,0 +1,10 @@ +#Example 55 chapter 1 Page no 48 +defective = 0.02 +P_good_when_good = 0.95 +P_def_when_def = 0.94 +good=1-defective +P_def_when_good = 1-P_good_when_good +P_good_when_def = 1 - P_def_when_def +P_actuallydefective_reported_def = P_def_when_def*defective/(P_def_when_def*defective + + P_def_when_good*good) +print(P_actuallydefective_reported_def) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.6/Ex1_6.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.6/Ex1_6.R new file mode 100644 index 00000000..1e1d2408 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.6/Ex1_6.R @@ -0,0 +1,11 @@ +#Example 6 Chapter 1 +W=10 +B=9 +R=8 +Blue=3 +s=W+B+R+Blue +ways_drawing_10_balls = length(combn(s,10))/10 +P_2blue_at_11th_draw = 2/20 +P_2blue_till_11th_draw = length(combn(Blue,1)) * length(combn(s-Blue,9))/9 * P_2blue_at_11th_draw / ways_drawing_10_balls +print(P_2blue_till_11th_draw) + diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.7/Ex1_7.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.7/Ex1_7.R new file mode 100644 index 00000000..ddae7bd9 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.7/Ex1_7.R @@ -0,0 +1,9 @@ +#Example 7 Chapter 1 +P_Student_fail_in_Physics=0.3 +P_Student_fail_in_Maths=0.25 +P_fail_inboth=0.1 +P_fail_in_M_failed_in_P = P_fail_inboth/P_Student_fail_in_Physics +print(P_fail_in_M_failed_in_P) +P_fail_in_M_or_P = P_Student_fail_in_Maths + P_Student_fail_in_Physics -P_fail_inboth +print(P_fail_in_M_or_P) + \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.8/Ex1_8.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.8/Ex1_8.R new file mode 100644 index 00000000..989a6ea5 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH1/EX1.8/Ex1_8.R @@ -0,0 +1,18 @@ +#Example 8 Chapter 1 +P<-function(d){ + v=c(1:200) + count=0 + for(i in (1:length(v))) + { + if(v[i]%%d==0) + { + count=count+1 + } + } + return (count/200) +} +P_div_6=P(6) +P_div_8=P(8) +P_6_And_8=P(24) +P_6_or_8= P(6)+P(8)-P(24) +print(P_6_or_8) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.11/Ex2_11.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.11/Ex2_11.R new file mode 100644 index 00000000..8a5f96d8 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.11/Ex2_11.R @@ -0,0 +1,6 @@ +#Example 11 chapter 2 page no 69 +func<-function(x){ + x*(2-x) +} +k=1/integrate(func,lower=0,upper=2)$value +print(k) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.13/Ex2_13.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.13/Ex2_13.R new file mode 100644 index 00000000..c8855c60 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.13/Ex2_13.R @@ -0,0 +1,10 @@ +#Example 13 chapter 2 page no. 71 +x1<-function(a){ + 0 +} +x2<-function(a){ + 1+a +} +lemda=1/(integrate(x2,1,4)$value) +P_x3 = lemda*integrate(x2,1,3)$value +print(P_x3) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.14/Ex2_14.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.14/Ex2_14.R new file mode 100644 index 00000000..039f22b1 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.14/Ex2_14.R @@ -0,0 +1,24 @@ +#Example 14 Chapter 2 +rm(list = ls()) + +Fx<-function(x){ + y=c() + for (i in (1:length(x))){ + if(x[i]<=0){y[i]=0} + else if(x[i]>=1){y[i]=1} + else {y[i]=x[i]} + } + return(y) +} +fx<-function(x){ + y=c() + for (i in (1:length(x))){ + if(x[i]<=0){y[i]=0} + else if(x[i]>=1){y[i]=0} + else {y[i]=1} + } + return(y) +} +plot(Fx,-2, 2) #distribution function +plot(fx,-2, 2) #probability density function + diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.16/Ex2_16.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.16/Ex2_16.R new file mode 100644 index 00000000..a2227f96 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.16/Ex2_16.R @@ -0,0 +1,6 @@ +#Example 16 chapter 2 page no. 73 +fx<-function(a){ #prob density function for daily consumption + 1/9 *a*exp(-a/3) +} +P_x12 = integrate(fx,0,12)$value #probabilty that consumption is in supply limit of 12 MkWH +print(1-P_x12) #prob of X greater than 12 supply insufficient diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.17/Ex2_17.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.17/Ex2_17.R new file mode 100644 index 00000000..962294f5 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.17/Ex2_17.R @@ -0,0 +1,6 @@ +#Example 17 chapter 2 page no. 74 +fx<-function(a){ #prob density function + 1/2 *a +} +P_x = integrate(fx,1/2,3/4)$value +print(P_x) #prob of area under line y=x/2 from x=1/2 to x=3/4 \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.18/Ex2_18.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.18/Ex2_18.R new file mode 100644 index 00000000..19e5462f --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.18/Ex2_18.R @@ -0,0 +1,8 @@ +#Example 18 chapter 2 page no. 74 +fx<-function(a){ #prob density function + 2*exp(-2*a) +} +P_x1to3 = integrate(fx,1,3)$value +print(P_x1to3) #prob of 1<=x<=3 +px1by2 = integrate(fx,1/2,Inf)$value +cat("prob of X more than 0.5 is",px1by2) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.19/Ex2_19.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.19/Ex2_19.R new file mode 100644 index 00000000..b40e3078 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.19/Ex2_19.R @@ -0,0 +1,7 @@ +#Example 19 chapter 2 page no. 76 +Fx<-function(a){ #prob density function + return(1 - 4/(a^2)) +} +P_x3 = Fx(3) +print(P_x3) #prob of X less than equal to 3 +cat("prob of 4<=x<=5 is",Fx(5)-Fx(4)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.20/Ex2_20.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.20/Ex2_20.R new file mode 100644 index 00000000..59ec4af7 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.20/Ex2_20.R @@ -0,0 +1,6 @@ +#Example 20 chapter 2 page no 76 +func<-function(x){ + 1/(1+x^2) +} +k=1/integrate(func,lower=-Inf,upper=Inf)$value +print(k) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.25/Ex2_25.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.25/Ex2_25.R new file mode 100644 index 00000000..42ab65f5 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.25/Ex2_25.R @@ -0,0 +1,13 @@ +#Example 25 chapter 2 page no.85 +X=c(0:7) +a=10 #for euation 10k^2 + 9k -1 = 0 +b=9 +c=-1 +k1<-(-b + sqrt(b^2 - 4*a*c))/(2*a) +k2<-(-b - sqrt(b^2 - 4*a*c))/(2*a) +print(k1) #selecting k1 as the value of k +k=k1 +P_X = c(0,k,2*k,2*k,3*k,k*k,2*k*k,7*k*k+k) +cat("prob of 1.52",(P_X[4]+P_X[5])/(1-P_X[1]-P_X[2]-P_X[3])) + + \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.26/Ex2_26.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.26/Ex2_26.R new file mode 100644 index 00000000..ec6bb37b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH2/EX2.26/Ex2_26.R @@ -0,0 +1,14 @@ +#Example 26 Chapter2 page no. 86 +P<-function(x){ + a=c(1,2,3,4,5) + for(i in (1:length(a))) + { + if(x==a[i]){return(x/15)} + } + return(0) +} +P_X_1_or_2 = P(1)+P(2) +print(P_X_1_or_2) +#prob of x bw 1/2 and 5/2 when given x greater than 1 +p = P(2)/(1-P(1)) +print(p) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.1/Ex3_1.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.1/Ex3_1.R new file mode 100644 index 00000000..0c3c9f22 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.1/Ex3_1.R @@ -0,0 +1,4 @@ +#Example 1 Chapter 3 +x=c(1/6,1/6,1/6,1/6,1/6,1/6) +g_x=c(10,20,10,20,50,70) +cat("expected value is ",x%*%g_x) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.11/Ex3_11.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.11/Ex3_11.R new file mode 100644 index 00000000..324dfe6b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.11/Ex3_11.R @@ -0,0 +1,4 @@ +#Example 11 chapter 3 page no 108 +X=c(1,1.5,2) # amount that can be drawn taking 2 coins from bag +P_x=c(3/10,6/10,1/10) +cat("expected amount that can be drawn",X%*%P_x) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.15/Ex3_15.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.15/Ex3_15.R new file mode 100644 index 00000000..5237a341 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.15/Ex3_15.R @@ -0,0 +1,6 @@ +#Example 15 chapter 3 page no. 110 +x=c(-2:3) +k=0.4/6 +px=c(0.1,k,0.2,2*k,0.3,3*k) +Ex=x%*%px +print(Ex) # expected value of X diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.17/Ex3_17.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.17/Ex3_17.R new file mode 100644 index 00000000..1ef64169 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.17/Ex3_17.R @@ -0,0 +1,11 @@ +#Example 17 chapter 3 page no 111 +Fx<-function(x){ + (1/6)*x*exp(-x/6) +} +En=integrate(Fx,0,Inf)$value +variance<-function(x){ + (1/6)*((x-En)^2)*exp(-x/6) +} +cat("expected lifetime",En) +v=integrate(variance,0,Inf) +cat("variance of X",v$value) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.18/Ex3_18.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.18/Ex3_18.R new file mode 100644 index 00000000..252d768f --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.18/Ex3_18.R @@ -0,0 +1,6 @@ +#Example 18 chapter 3 page no 113 +X=c(3:6) +PX=c(1/8,5/8,2/8,0) +gx=c(10000,2500,-7000,0) +EgX=PX%*%gx +cat("ecpected profit of rs",EgX) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.2/Ex3_2.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.2/Ex3_2.R new file mode 100644 index 00000000..283773ab --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.2/Ex3_2.R @@ -0,0 +1,4 @@ +#Example 2 Chapter3 +x=c(0,1,2,3) +p_x=c(1/8,3/8,3/8,1/8) +cat("expected value of no of h in 3 coin toss ",x%*%p_x) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.3/Ex3_3.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.3/Ex3_3.R new file mode 100644 index 00000000..2f7d43e0 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.3/Ex3_3.R @@ -0,0 +1,15 @@ +#Example 3 Chapter 3 +n=25 +d=5 #defective items +r=4 #4 are choosen +x=c(0,1,2,3,4) #no of defectives +t= ncol(combn(n,r)) +P_x=c(ncol(combn(n-d,r))/t,ncol(combn(5,1))*ncol(combn(20,3))/t, + ncol(combn(20,2))*ncol(combn(5,2))/t,ncol(combn(20,1))*ncol(combn(5,3))/t, + ncol(combn(5,4))/t) +cat("expected no of defective ",x%*%P_x) #without replacement + +p=5/25 #prob of getting defective +q = 1 - p #prob of not defective +P_x_withreplace = dbinom(x,r,p) +cat("expected no of defective ",x%*%P_x_withreplace) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.4/Ex3_4.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.4/Ex3_4.R new file mode 100644 index 00000000..c318aa8c --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.4/Ex3_4.R @@ -0,0 +1,9 @@ +#Example 4 Chapter 3 +r=3 #sample size +n=12 +d=3 #defective items +x=c(0,1,2,3) #x denotes no of defectives in sample +t= ncol(combn(n,r)) +P_x=c(ncol(combn(n-d,r))/t,ncol(combn(d,1))*ncol(combn(n-d,r-1))/t, + ncol(combn(n-d,1))*ncol(combn(d,r-2))/t,ncol(combn(d,r))/t) +cat("expected no of defective ",x%*%P_x) #without replacement diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.40/Ex3_40.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.40/Ex3_40.R new file mode 100644 index 00000000..936415af --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.40/Ex3_40.R @@ -0,0 +1,7 @@ +#Example 40 Chapter 3 page no. 155 +lemda=1 #mean rate 1 per week +t=3 +m=0 +cat("prob no failure in 3 weeks ",ppois(m,t,lemda)) +cat("prob lessthan 5 failure in 10 weeks ",ppois(5,10,lemda)) +#ppois funtion for poisson distribution \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.7/Ex3_7.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.7/Ex3_7.R new file mode 100644 index 00000000..a59c4fb8 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.7/Ex3_7.R @@ -0,0 +1,6 @@ +#Example 7 Chapter 3 Page no. 106 +n=4 # no. of toss +x=c(0,1,2,3,4) # no of heads can be +p=1/2 #Prob of getting head +p_x = dbinom(x,n,p) +cat("expected no of head ",x%*%p_x) \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.8/Ex3_8.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.8/Ex3_8.R new file mode 100644 index 00000000..ec064e5e --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH3/EX3.8/Ex3_8.R @@ -0,0 +1,5 @@ +#Example 8 Chapter 3 page no 107 +p=4/52 +x=c(1,2,3,4,5,6,7,8,9,10,10,10,10) +px=rep(p,times=13) +cat("expected points ",x%*%px) \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.1/Ex4_1.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.1/Ex4_1.R new file mode 100644 index 00000000..b8aa9725 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.1/Ex4_1.R @@ -0,0 +1,9 @@ +#Example 1 Chapter 4 page no.167 +n=10 +x=c(0:10) +f=c(6,20,28,12,8,6,0,0,0,0,0) +mean=sum(x*f)/sum(f) +p=mean/n +q=1-p +data.frame(x,sum(f)*dbinom(x,n,p)) +#this dataframe shows the frequency in binomial distribution \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.13/Ex4_13.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.13/Ex4_13.R new file mode 100644 index 00000000..17801233 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.13/Ex4_13.R @@ -0,0 +1,7 @@ +#Example 13 chapter 4 page no176 +p=0.1 +n=20 +x=c(0:20) +P=dbinom(x,n,p) +P_xmorethan5=1-(P[1]+P[2]+P[3]+P[4]+P[5]) #prob of 5 or more machine damage +print(P_xmorethan5) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.16/Ex4_16.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.16/Ex4_16.R new file mode 100644 index 00000000..3303a9aa --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.16/Ex4_16.R @@ -0,0 +1,4 @@ +#example 16 chapter 4 page no 186 +m=2 +px4=dpois(4,m) +print(px4) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.17/Ex4_17.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.17/Ex4_17.R new file mode 100644 index 00000000..b8965479 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.17/Ex4_17.R @@ -0,0 +1,4 @@ +#example 17 chapter 4 page no 186 +m=400*0.02 +px4=dpois(5,m) +print(px4) #book has an error of 0.002 diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.18/Ex4_18.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.18/Ex4_18.R new file mode 100644 index 00000000..f381103b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.18/Ex4_18.R @@ -0,0 +1,5 @@ +#example 18 chapter 4 page no 186 +m=0.00005*10000 +p<-function(x){return(dpois(x,m))} +cat("prob of 2 flat tyre among 10000",p(2)) +cat("prob of atmost 2 flat tyre among 10000",p(0)+p(1)+p(2)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.19/Ex4_19.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.19/Ex4_19.R new file mode 100644 index 00000000..7ddb57b6 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.19/Ex4_19.R @@ -0,0 +1,5 @@ +#example 19 chapter 4 page no 186 +m=0.02*200 +p<-function(x){return(dpois(x,m))} +cat("prob of 5 defective in 200",p(5)) +cat("prob of 5 or less defective",p(0)+p(1)+p(2)+p(3)+p(4)+p(5)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.2/Ex4_2.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.2/Ex4_2.R new file mode 100644 index 00000000..1d595577 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.2/Ex4_2.R @@ -0,0 +1,9 @@ +#Example 2 Chapter 4 page no.167 +n=5 +x=c(0:n) +f=c(2,14,20,34,22,8) +mean=sum(x*f)/sum(f) +p=mean/n +q=1-p +data.frame(x,sum(f)*dbinom(x,n,p)) +#this dataframe shows the frequency in binomial distribution \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.20/Ex4_20.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.20/Ex4_20.R new file mode 100644 index 00000000..48d6bad5 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.20/Ex4_20.R @@ -0,0 +1,4 @@ +#example 20 chapter 4 page no 186 +m=1600*(1/2^5) +px5=dpois(5,m) +print(px5) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.22/Ex4_22.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.22/Ex4_22.R new file mode 100644 index 00000000..94d10ab0 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.22/Ex4_22.R @@ -0,0 +1,13 @@ +#Example 22 chapter 4 page no 188 +n=10 +p=1/100 +m=n*p +p0=round(dpois(0,m),3) +cat("prob of no defective blade",p0) +p1=round(dpois(1,m),4) +cat("prob of one defective blade",p1) +p2=round(dpois(2,m),4) +cat("prob of two defective blade",p2) +cat("packets with 0 defective blade",10000*p0) +cat("packets with 1 defective blade",10000*p1) +cat("packets with 2 defective blade",10000*p2) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.27/Ex4_27.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.27/Ex4_27.R new file mode 100644 index 00000000..c7bb3ad8 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.27/Ex4_27.R @@ -0,0 +1,9 @@ +#Example 27 chapter 4 page no 190 +x=c(0:4) +days=c(21,18,7,3,1) +xbar=x%*%days/sum(days) +px=dpois(x,xbar) +expectedfreq=round(px*sum(days),2) +df=data.frame(x,expectedfreq) +print("expected freq are") +print(df) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.28/Ex4_28.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.28/Ex4_28.R new file mode 100644 index 00000000..9fd11b6c --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.28/Ex4_28.R @@ -0,0 +1,9 @@ +#Example 28 chapter 4 page no 191 +x=c(0:10) +f=c(1,4,15,22,21,20,8,6,2,0,1) +xbar=x%*%f/sum(f) +px=dpois(x,xbar) +expectedfreq=round(px*sum(f),0) +df=data.frame(x,expectedfreq) +print("expected freq are") +print(df) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.4/Ex4_4.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.4/Ex4_4.R new file mode 100644 index 00000000..38ade920 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.4/Ex4_4.R @@ -0,0 +1,8 @@ +#Example 4 Chapter 4 page no. 171 +p=2/10 +n=10 +x=c(0:n) +px=dbinom(x,n,p) +Pxlessthan_equal3 = px[1]+px[2]+px[3]+px[4] +print(Pxlessthan_equal3) +cat("for 100 samples ",100*Pxlessthan_equal3) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.5/Ex4_5.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..de878f17 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,6 @@ +#Example 5 Chapter 4 page no. 171 +p=10/100 +x=c(0:5) +P=dbinom(x,5,p) +Pxmorethan_equal1=1-P[1] +print(Pxmorethan_equal1) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.6/Ex4_6.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.6/Ex4_6.R new file mode 100644 index 00000000..6b279a69 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.6/Ex4_6.R @@ -0,0 +1,6 @@ +#Example 6 Chapter 4 page no 171 +p=2/6 +n=8 +x=c(0:n) +P=dbinom(x,n,p) +cat("percentage of getting 3 success",100*P[4]) \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.7/Ex4_7.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.7/Ex4_7.R new file mode 100644 index 00000000..5196f604 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.7/Ex4_7.R @@ -0,0 +1,8 @@ +#Example 7 Chapter 4 page no, 171 +n=12 +x=c(0:n) +p=0.1 +P=dbinom(x,n,p) +cat("prob of exactly 2 defective", P[3]) +cat("prob of at least 2 defective", 1-P[1]-P[2]) +cat("prob of no defective", P[1]) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.8/Ex4_8.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.8/Ex4_8.R new file mode 100644 index 00000000..8f4ffbd0 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH4/EX4.8/Ex4_8.R @@ -0,0 +1,7 @@ +#Example 8 Chapter 4 page no. 172 +P=65/100 +n=10 +X=c(1:n) +PX=dbinom(X,n,P) +Pxmorethan_equal7= PX[7] + PX [8] + PX[9] +PX[10] +print(Pxmorethan_equal7) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.10/Ex5_10.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.10/Ex5_10.R new file mode 100644 index 00000000..c26b006b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.10/Ex5_10.R @@ -0,0 +1,11 @@ +#Example 10 chapter 5 page no 219 +x40=0.3 #for x<=40 +x50=0.3+0.33 # for x<=50 +xmorethan50 = 0.37 +z1=qnorm(x40) +z2=qnorm(x50) +v=(50-40)/(z2-z1) +u=40-z1*v +px50to60=pnorm(60,u,v)-pnorm(50,u,v) +cat("frequency in interval 50 to 60 is ",round(100*px50to60,digits = 0)) +#book has error in answer. \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.11/Ex5_11.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.11/Ex5_11.R new file mode 100644 index 00000000..c9cdb11a --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.11/Ex5_11.R @@ -0,0 +1,13 @@ +#Example 11 Chapter 5 Page no 220 +u=64.5 #mean height in inches of 300 students +n=300 +sd=3.3 +cat("students with height less than 5 feet",round(n*pnorm(60,u,sd),digits = 0)) +p = (pnorm(69,u,sd)-pnorm(60,u,sd)) +cat("students having height bw 5 ft to 5ft 9 inch ",as.integer(n*p)) +x=1-0.99 +z1=qnorm(x/2) +z2=0-z1 +x1=sd*z1+u +x2=sd*z2+u +cat("99% students are bw height(in inches)",round(x1,0),round(x2,0)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.12/Ex5_12.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.12/Ex5_12.R new file mode 100644 index 00000000..545eb781 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.12/Ex5_12.R @@ -0,0 +1,9 @@ +#Example 12 chapter 5 page no 221 +x45=0.31 #30%people under 45 +x64=1-0.08 +z1=qnorm(x45) +z2=qnorm(x64) +v=(64-45)/(z2-z1) +u=45-z1*v +cat("mean=",u," and standard deviation = ",v) +#answer given approximate in book diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.13/Ex5_13.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.13/Ex5_13.R new file mode 100644 index 00000000..7c828956 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.13/Ex5_13.R @@ -0,0 +1,7 @@ +#Example_13 chapter 5 page no. 222 +u= 65 +sd= sqrt(25) +q = pnorm(70,u, sd) +p=1-q +cat("prob 2 out of 3 have more than 70 marks",dbinom(2,3,p)) +#book has error in the answer \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.14/Ex5_14.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.14/Ex5_14.R new file mode 100644 index 00000000..734e54f0 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.14/Ex5_14.R @@ -0,0 +1,7 @@ +#Example 14 chapter 5 page no. 227 +u=0 +sd=3 +v=9*9+16*9 #3x+4y=5 and 3x+4y=10 +px5to10 = pnorm(10,u,sqrt(v)) - pnorm(5,u,sqrt(v)) +print(px5to10) +# value of answer is 0.0023 more in book \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.17/Ex5_17.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.17/Ex5_17.R new file mode 100644 index 00000000..10fdcf5b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.17/Ex5_17.R @@ -0,0 +1,6 @@ +#Example 17 Chapter 5 page no 229 +lemda=1/2 +px2=1-pexp(2,lemda) +print(px2) #prob repair time exceed 2 hr +px10whenx9 = (1-pexp(10,lemda))/(1-pexp(9,lemda)) +print(px10whenx9) #prob repair takes at least 10hr if had taken 9hr diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.19/Ex5_19.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.19/Ex5_19.R new file mode 100644 index 00000000..f6f2b08e --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.19/Ex5_19.R @@ -0,0 +1,9 @@ +#Example 19 chapter 5 page no 230 +n=12 #coin tossed 12 times +p=1/2 +q=1-p +u=n*p #mean of binomial distribution +sd=sqrt(n*p*q) +patmost4heads = pnorm(4.5,u,sd) +pexact4heads = pnorm(4.5,u,sd)-pnorm(3.5,u,sd) +cat("prob exact 4 head ",pexact4heads,"\nprob of atmost 4 head ",patmost4heads) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.3/Ex5_3.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.3/Ex5_3.R new file mode 100644 index 00000000..f90ca675 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.3/Ex5_3.R @@ -0,0 +1,11 @@ +#Example 3 chapter 5 page no. 201 +min=0 #arrival at 9:00 AM +max=30 #arrival at 9:30 AM +px10to15 = punif(15-10,min,max) +px25to30 = punif(30-25,min,max) +pwait5min = px10to15 + px25to30 +print(pwait5min) +px0to5 = punif(5-0,min,max) +px15to20 = punif(20-15,min,max) +pwait10min = px0to5 +px15to20 +print(pwait10min) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.5/Ex5_5.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.5/Ex5_5.R new file mode 100644 index 00000000..1de064cb --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.5/Ex5_5.R @@ -0,0 +1,7 @@ +#Example 5 Chapter 5 page no. 203 +min=0 +max=10 +#given equa has solution (-infi,-1) and (2,infi) +#4x^2 + 4(lemda)x + lemda +2 +Prootsreal=punif(10-2,min,max) +print(Prootsreal) \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.6/Ex5_6.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.6/Ex5_6.R new file mode 100644 index 00000000..4cb57e80 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.6/Ex5_6.R @@ -0,0 +1,7 @@ +#Example 6 chapter 5 page no 203 +u=1 #mean of uniform distribution +v=4/3 #variance of uniform distribution +b = (2*u+sqrt(12*v))/2 +a = 2*u-b +pxlessthan0 = dunif(1,a,b) +print(pxlessthan0) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.7/Ex5_7.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.7/Ex5_7.R new file mode 100644 index 00000000..caeaec9d --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.7/Ex5_7.R @@ -0,0 +1,11 @@ +#Example 7 chapter 5 page no. 216 +n=1000 #sample of 1000 cases +u=14 #mean +sd=2.5 +p<-function(x){return(pnorm(x,u,sd))} +px12to15 = p(15)-p(12) +cat("candidates with score 12 to 15 ",as.integer(n*px12to15)) +px10 = p(10) +cat("candidates with score less than 10 ",as.integer(n*px10)) +px20=p(20) +cat("candidates with score more than 20 ",as.integer(n*(1-px20))) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.8/Ex5_8.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.8/Ex5_8.R new file mode 100644 index 00000000..3af46f9c --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.8/Ex5_8.R @@ -0,0 +1,7 @@ +#Example 8 chapter5 page no 217 +n=500 #500 workers +u=75 #mean 75 rs +sd=15 #sd 15 rs +p<-function(x){return(pnorm(x,u,sd))} +cat("workers getting more than Rs.90 are ",as.integer(n*(1-p(90)))) +cat("workers getting less than Rs.45 are ",as.integer(n*(p(45)))) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.9/Ex5_9.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.9/Ex5_9.R new file mode 100644 index 00000000..a1a06239 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH5/EX5.9/Ex5_9.R @@ -0,0 +1,10 @@ +#Example 9 chapter 5 page no 218 +A=0.58 # under 75 +B=0.38 # from 75 to 80 +C=0.04 # above 80 +z1=qnorm(A) +z2=0-qnorm(C) #for z greater than z2 +v=(80-75)/(z2-z1) +u=75-z1*v +cat("mean=",u," and standard deviation = ",v) +#book has variance error of 0.27 and mean has value 0.06 more diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.10/Ex6_10.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.10/Ex6_10.R new file mode 100644 index 00000000..e736821b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.10/Ex6_10.R @@ -0,0 +1,6 @@ +#Example 10 chapter 6 page no 247 +maths=c(10,15,12,17,13,16,24,14,22) +rxi = rank(maths) +statistics=c(30,42,45,46,33,34,40,35,39) +ryi = rank(statistics) +cor(rxi,ryi) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.13/Ex6_13.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.13/Ex6_13.R new file mode 100644 index 00000000..f94a12a8 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.13/Ex6_13.R @@ -0,0 +1,8 @@ +#Example 13 chapter 6 page no 253 +x=c(0:4) +y=c(1,1.8,1.3,2.5,6.3) +fit<-lm(y~poly(x,2,raw = "True")) +plot(x,y,main = "scatterplot") +parabola=fit$coefficient[3]*x^2 + fit$coefficient[2]*x +fit$coefficient[1] +lines(x,parabola,col="red") +cat("y =",fit$coefficient[3],"x^2 +",fit$coefficient[2],"x +",fit$coefficient[1]) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.14/Ex6_14.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.14/Ex6_14.R new file mode 100644 index 00000000..149f3dd3 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.14/Ex6_14.R @@ -0,0 +1,9 @@ +#Example 14 chapter 6 page no 254 +x=seq(1,4.0,0.5) +y=c(1.1,1.3,1.6,2.6,2.7,3.4,4.1) +fit<-lm(y~poly(x,2,raw = "True")) +plot(x,y,main = "scatterplot") +parabola=fit$coefficient[3]*x^2 + fit$coefficient[2]*x +fit$coefficient[1] +lines(x,parabola,col="red") +cat("y =",fit$coefficient[3],"x^2 +",fit$coefficient[2],"x +",fit$coefficient[1]) + \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.15/Ex6_15.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.15/Ex6_15.R new file mode 100644 index 00000000..e26ea107 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.15/Ex6_15.R @@ -0,0 +1,8 @@ +#Example 15 chapter 6 page no 257 +x=c(-5:4) +y=c(45,52,54,63,62,68,75,76,92,88) +fit<-lm(y~poly(x,1,raw = "True")) +plot(x,y,main = "scatterplot") +best_line=fit$coefficient[2]*x + fit$coefficient[1] +lines(x,best_line,col="red") +cat("y =",fit$coefficient[2],"x +",fit$coefficient[1]) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.16/Ex6_16.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.16/Ex6_16.R new file mode 100644 index 00000000..d0e370b6 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.16/Ex6_16.R @@ -0,0 +1,10 @@ +#Example 16 chapter 6 page no 254 +x=seq(20,380,40) #air velocity +y=c(0.18,0.37,0.35,0.78,0.56,0.75,1.18,1.36,1.17,1.65) #Evaporation coefficient +fit<-lm(y~poly(x,1,raw = "True")) +plot(x,y,main = "scatterplot") +line1= fit$coefficient[2]*x +fit$coefficient[1] +lines(x,line1,col="red") +cat("y =",fit$coefficient[2],"x +",fit$coefficient[1]) +y=predict(fit,data.frame(x=190)) +cat(y,"mm^2/sec is evaporation coeff for air velocity 190 cm/sec") diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.17/Ex6_17.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.17/Ex6_17.R new file mode 100644 index 00000000..3f390535 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.17/Ex6_17.R @@ -0,0 +1,10 @@ +#Example 17 chapter 6 page no 263 +x=c(1:9) +y=c(9,8,10,12,11,13,14,16,15) +fit<-lm(y~poly(x,1,raw = "True")) +plot(x,y,main = "scatterplot") +line1= fit$coefficient[2]*x +fit$coefficient[1] +lines(x,line1,col="red") +cat("y =",fit$coefficient[2],"x +",fit$coefficient[1]) +y=predict(fit,data.frame(x=6.2)) +cat(y,"is the estimated value for x=6.2") diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.18/Ex6_18.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.18/Ex6_18.R new file mode 100644 index 00000000..19e547e9 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.18/Ex6_18.R @@ -0,0 +1,7 @@ +#Example 18 chapter 6 page no 264 +n=10 +xbar = 50/n +ybar = -30/n +sum_xy = -115 +cov_xy = sum_xy/n - xbar*ybar +print(cov_xy) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.2/Ex6_2.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.2/Ex6_2.R new file mode 100644 index 00000000..3cf68594 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.2/Ex6_2.R @@ -0,0 +1,4 @@ +#Example 2 chapter 6 page no. 240 +X=c(-10,-5,0,5,10) +y=c(5,9,7,11,13) +print(cor(X,y)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.22/Ex6_22.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.22/Ex6_22.R new file mode 100644 index 00000000..ff9d3fb5 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.22/Ex6_22.R @@ -0,0 +1,10 @@ +#Example 22 chapter 6 page no 271 +x=c(0:8) +y=c(12,10.5,10,8,7,8,7.5,8.5,9) +fit<-lm(y~poly(x,2,raw = "True")) +plot(x,y,main = "scatterplot") +parabola=fit$coefficient[3]*x^2 + fit$coefficient[2]*x +fit$coefficient[1] +lines(x,parabola,col="red") +cat("y =",fit$coefficient[3],"x^2 +",fit$coefficient[2],"x +",fit$coefficient[1]) +y=predict(fit,data.frame(x=6.5)) +cat(y,"predicted drying time in hours for x=6.5gms") diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.27/Ex6_27.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.27/Ex6_27.R new file mode 100644 index 00000000..1b934acb --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.27/Ex6_27.R @@ -0,0 +1,6 @@ +#Example 27 chapter 6 page no 248 +x=c(68,64,75,50,64,80,75,40,55,64) +rxi = rank(x) +y=c(62,58,68,45,81,60,68,48,50,74) +ryi = rank(y) +cor(rxi,ryi) #answer vary slighty from book diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.28/Ex6_28.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.28/Ex6_28.R new file mode 100644 index 00000000..195dc11f --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.28/Ex6_28.R @@ -0,0 +1,8 @@ +#Example 28 chapter 6 page no. 276 +n=5 +x=c(1:n) +y=c(2,5,3,8,7) +fit<-lm(y~poly(x,1,raw = "True")) +yi=predict(fit,data.frame(x)) +error=sqrt(sum((y-yi)^2)/n) +cat("error of estimates",error) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.3/Ex6_3.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.3/Ex6_3.R new file mode 100644 index 00000000..a5d62e3d --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.3/Ex6_3.R @@ -0,0 +1,4 @@ +#Example 3 chapter 6 page no. 240 +X=c(1:9) +y=c(9,8,10,12,11,13,14,16,15) +print(cor(X,y)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.4/Ex6_4.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.4/Ex6_4.R new file mode 100644 index 00000000..000e1e5d --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.4/Ex6_4.R @@ -0,0 +1,13 @@ +#Example 4 chapter 6 page no. 240 +n=11 +X=c(45,55,56,58,60,65,68,70,75,80,85) +u=X-rep(65,11) +y=c(56,50,48,60,62,64,65,70,74,82,90) +v=y-rep(65,11) +ubar=mean(u) +vbar=mean(v) +var_u=(sum(u*u))/n - (ubar^2) +var_v=(sum(v*v))/n - (vbar^2) +var_uv=(sum(u*v))/n - ubar*vbar +r = var_uv / (sqrt(var_u*var_v)) +cat("corr coeff is ",r) #answer given in book is wrong (calculation error) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.5/Ex6_5.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.5/Ex6_5.R new file mode 100644 index 00000000..13ef99e9 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.5/Ex6_5.R @@ -0,0 +1,4 @@ +#Example 5 chapter 6 page no. 240 +X=c(65,66,67,67,68,69,70,72) +y=c(67,68,65,68,72,72,69,71) +print(cor(X,y)) \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.7/Ex6_7.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.7/Ex6_7.R new file mode 100644 index 00000000..47bcaf0c --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.7/Ex6_7.R @@ -0,0 +1,4 @@ +#Example 2 chapter 6 page no. 240 +X=c(1,3,5,7,8,10) +y=c(8,12,15,17,18,20) +print(cor(X,y)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.8/Ex6_8.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.8/Ex6_8.R new file mode 100644 index 00000000..8da561d4 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.8/Ex6_8.R @@ -0,0 +1,6 @@ +#Example 8 chapter 6 page no 245 +rankx=c(2,1,4,3) +ranky=c(1,3,2,4) +name=c("ram","shyam","hari","sohan") +a=data.frame(name,rankx,ranky) +cor(a["rankx"],a["ranky"]) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.9/Ex6_9.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.9/Ex6_9.R new file mode 100644 index 00000000..c0eaf756 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH6/EX6.9/Ex6_9.R @@ -0,0 +1,11 @@ +#Example 9 chapter 6 page no 247 +rankj1=c(1,6,5,10,3,2,4,9,7,8) +rankj2=c(6,4,9,8,1,2,3,10,5,7) +rankj3=c(3,5,8,4,7,10,2,1,6,9) +name=c("c1","c2","c3","c4","c5","c6","c7","c8","c9","c10") +a=data.frame(name,rankj1,rankj2,rankj3) +r12 = cor(a["rankj1"],a["rankj2"]) +r23 = cor(a["rankj2"],a["rankj3"]) +r13 = cor(a["rankj1"],a["rankj3"]) +cat(r12,r23,r13) +#book has a calcultion error in r23 value \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.1/Ex7_1.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.1/Ex7_1.R new file mode 100644 index 00000000..a64cc26d --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.1/Ex7_1.R @@ -0,0 +1,12 @@ +#Example 1 chapter 7 page no 295 +l = 6 #arrival_rate persons per hour +u = 60/3 # mean service rate per hour +ls = l/(u-l) # average number of person in the system +cat(ls,"average no of persons in the system") +pts10=exp(-(u-l)*10/60) +cat(pts10,"prob to spent more than 10min in queue") +ptq10=(l/u)*exp(-(u-l)*10/60) +cat(ptq10,"prob to waits more than 10min in queue") +cat(l/u, "prob that an arrival has to wait") +cat(l/u*100,"% of the day phone is busy") +cat(u/(u-l),"avg length of non empty queues") diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.10/Ex7_10.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.10/Ex7_10.R new file mode 100644 index 00000000..3e6dc740 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.10/Ex7_10.R @@ -0,0 +1,18 @@ +#Example 9 chapter 7 page no 309 +l =6 # arrival rate trains per hour +u=12 #service rate trains per hour +N=3 # maximum 3 in the queue +rho = l/u +p0=(1-rho)/(1-(rho^(N+1))) +cat("Prob of no train",p0) +p1=p0*rho +cat("Prob of 1 train",p0*rho) +p2=p0*rho^2 +cat("Prob of 2 train",p0*rho^2) +p3=p0*rho^3 +cat("Prob of 3 train",p0*rho^3) +En=p1+(2*p2)+(3*p3) +cat("avg no of train in the system",round(En,0)) +ws = En/(u*(1-p0)) +cat("avg waiting time in minutes",ws*60) + diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.13/Ex7_13.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.13/Ex7_13.R new file mode 100644 index 00000000..803e942e --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.13/Ex7_13.R @@ -0,0 +1,20 @@ +#Example 13 chapter 7 page no 319 +l1=14 #avg arrival rate for withdrawers +u1=20 #avg service rate for withdrawers +rho=l1/u1 +Ew = l1/(u1*(u1-l1)) +cat("avg waiting time in the queue in minutes",Ew*60) +l2=16 +Ew = l2/(u1*(u1-l2)) +cat("avg waiting time in the queue for depositers in minutes",Ew*60) +l=l1+l2 +c=2 +P0=1/(1+ l/u1 + (((l/u1)^2)/2)*c*u1/(c*u1-l) ) +print(P0) +EW=u1*((l/u1)^c)*P0/((c*u1-l)^2) +cat("avg waiting time in the queue in minutes for a withdrawer+depositer",EW*60) +u2=120/7 +P0=1/(1+ l/u2 + (((l/u2)^2)/2)*c*u2/(c*u2-l) ) +print(P0) +EW=u2*((l/u2)^c)*P0/((c*u2-l)^2) +cat("avg waiting time in the queue in minutes for a withdrawer+depositer",EW*60) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.15/Ex7_15.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.15/Ex7_15.R new file mode 100644 index 00000000..e8720723 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.15/Ex7_15.R @@ -0,0 +1,12 @@ +#Example 15 chapter 7 page no 322 +l=10 #arrival rate vehicles per hour +c=2 +u1=60/4 #service rate vehicles per hour +rho=l/u1 +P0=1/(1+ l/u1 + (((l/u1)^2)/2)*c*u1/(c*u1-l) ) +print(P0) +P_C=P0*(rho^2)*2*u1/(2*(2*u1-l)) +cat("prob vehicle has to wait",P_C) +busy=l/(u1*c) +cat("prob of the day busy",l/(u1*c)) +cat("pumps are idle for percentage = ",100*(1-busy)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.16/Ex7_16.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.16/Ex7_16.R new file mode 100644 index 00000000..f1a1072c --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.16/Ex7_16.R @@ -0,0 +1,15 @@ +#Example 16 chapter 7 page no 323 +l=12 #arrival rate customers per hour +c=2 +u1=60/6 #service rate customers per hour +rho=l/(u1*c) +P0=1/(1+ l/u1 + (((l/u1)^2)/2)*c*u1/(c*u1-l) ) +print(P0) +P_C=P0*((l/u1)^2)*2*u1/(2*(2*u1-l)) +cat("prob customer has to wait",P_C) +Em=P0*((l/u1)^2)*l*u1/((2*u1-l)^2) +cat("avg queue length",Em) +En=(Em+l/u1) +cat("avg customers in the system",round(En,0)) +Ev=En/l +cat("avg time spent in the system in minutes",Ev*60) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.2/Ex7_2.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.2/Ex7_2.R new file mode 100644 index 00000000..7eedc33d --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.2/Ex7_2.R @@ -0,0 +1,9 @@ +#Example 2 chapter 7 page no 297 +l = 4 #arrival_rate persons per hour +u = 60/12 # mean service rate per hour +ls = l/(u-l) # average number of person in the system +cat(ls,"average no of persons in the system") +rho = l/u +cat(rho/((1-rho)^2), "variance of queue length") +cat((1-rho)*8,"hrs expected idle time in a day of 8 hrs") +cat(rho^5,"prob of more than 5 customers") diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.3/Ex7_3.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.3/Ex7_3.R new file mode 100644 index 00000000..d0d55c25 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.3/Ex7_3.R @@ -0,0 +1,13 @@ +#Example 3 chapter 7 page no 297 +l = 30 /(60*24) #arrival_rate trains per minute +u = 1/36 # mean service rate per minute +ls = l/(u-l) # average number of trains in the system +cat(ls,"average no of trains in yard") +rho = l/u +cat(rho^11, "prob trains exceed 10") #answer given is wrong in the book +lnew=33/(60*24) +rhonew = lnew/u +lsnew = lnew/(u-lnew) # average number of trains in the system +cat(round(lsnew,digits = 0),"average no of trains in yard") +cat(rhonew^11, "prob trains exceed 10") +#answer given is wrong in the book \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.4/Ex7_4.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.4/Ex7_4.R new file mode 100644 index 00000000..d36824f9 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.4/Ex7_4.R @@ -0,0 +1,7 @@ +#Example 4 chapter 7 page no 298 +l = 10 #arrival_rate sets per day +u = 16 # mean service sets per day +rho = l/u +cat((1-rho)*8,"hrs expected idle time in a day of 8 hrs") +ls = l/(u-l) # average number of sets in the system +cat(round(ls,digits = 0),"average number of sets in the system") diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.6/Ex7_6.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.6/Ex7_6.R new file mode 100644 index 00000000..c358e417 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.6/Ex7_6.R @@ -0,0 +1,8 @@ +#ExAMPLE 6 chapter 7 page no 300 +l=30 #arrival rate customer per hour +u=40 #services per hour +cat("avg line length/customer in the system",l/(u-l)) +cat("avg waiting line length",((l*l)/(u*(u-l)))) +cat("avg waiting time in the queue in minutes",(l/(u*(u-l)))*60) #book has calculation error +cat("avg waiting time in the system in minutes",1/(u-l)*60) + diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.7/Ex7_7.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.7/Ex7_7.R new file mode 100644 index 00000000..a0a18562 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.7/Ex7_7.R @@ -0,0 +1,12 @@ +#Example7 chapter 7 page no 301 +l= 5 #break downs per hout +u=7 #repairs per hour +cat("avg units per hour",l/(u-l)) +cat("loss due to machines idle",8*15*l/(u-l)) +cat("repair man charge",8*8) +costA=8*15*l/(u-l)+8*8 +u2=9 +cat("avg units per hour for B",l/(u2-l)) +cat("loss due to machines idle for B",8*15*l/(u2-l)) +costB =8*15*l/(u2-l) +10*8 +cat("cost of A",costA,"\ncost of B",costB) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.9/Ex7_9.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.9/Ex7_9.R new file mode 100644 index 00000000..96d34277 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH7/EX7.9/Ex7_9.R @@ -0,0 +1,10 @@ +#Example 9 chapter 7 page no 309 +l =3 # arrival rate per hour +u=60/36 #service rate customers per hour +N=4 # maximum 4 customers in the queue +rho = l/u +p0=(1-rho)/(1-(rho^(N+1))) +cat("Prob of no customer",p0) +En=(rho/(1-rho))*(1 - ((N+1)*(rho^(N+1))*(1-rho)/(1-(rho^(N+1))))) +cat("avg no of customer in the system",round(En,0)) +#book has calculation mistake \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.1/Ex8_1.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.1/Ex8_1.R new file mode 100644 index 00000000..534c8226 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.1/Ex8_1.R @@ -0,0 +1,14 @@ +#Example 1 chapter 8 page no 371 +rho=0.75 +u=60/10.5 #avg service rate per hour +l=rho*u +sd=8.8 #in minutes +var=(8.8/60)^2 # in hours square +EWq1=(1/l)*(((rho^2) +((l^2)*var))/(2*(1-rho))) +cat("avg waiting time in minutes",EWq*60) +u = 60/8 #new service rate per hour +rho=l/u +var=(6/60)^2 #in hours square +EWq2=(1/l)*(((rho^2) +((l^2)*var))/(2*(1-rho))) +cat("avg waiting time is reduced now in minutes by",EWq1*60-EWq2*60) +cat("percentage reduction in waiting time",(EWq1*60-EWq2*60)/(EWq1*60)*100) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.10/Ex8_10.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.10/Ex8_10.R new file mode 100644 index 00000000..23e46c8a --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.10/Ex8_10.R @@ -0,0 +1,8 @@ +#Example 10 chapter 8 page no 356 +P=matrix(c(0.8,0.6,0.2,0.4),2,2) +p0 = matrix(c(0.5,0.5),1,2) +p1=p0%*%P +cat("prob of A B after 1 year",p1) +p2=p1%*%P +cat("prob of A B after 2 year",p2) +#answer vary from the book as book has wrong calculation \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.12/Ex8_12.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.12/Ex8_12.R new file mode 100644 index 00000000..a5a284f8 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.12/Ex8_12.R @@ -0,0 +1,7 @@ +#Example 12 chapter 8 page no 358 +P=matrix(c(0.1,0.6,0.3,0.5,0.2,0.4,0.4,0.2,0.3),3,3) +p0 = matrix(c(0.7,0.2,0.1),1,3) +P2=P%*%P +p2=p0%*%P2 +cat("prob of X2 = C after 2 year",p2[3]) +cat("prob of x3=B X2=C x1=C x0=B",p0[2]*P[2,3]*P[3,3]*P[3,2]) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.14/Ex8_14.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.14/Ex8_14.R new file mode 100644 index 00000000..84507634 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.14/Ex8_14.R @@ -0,0 +1,14 @@ +#Example 14 chapter 8 page no. 359 +P_ABC = matrix(c(200,500,300),1,3) +tpm = matrix(c(160/200,20/200,20/200,35/500,450/500,15/500,25/300,20/300,255/300),3,3,TRUE) +feb1=P_ABC%*%tpm +cat("on 1st Feb",P_ABC%*%tpm) +mar1=feb1%*%tpm +cat("on 1st March",round(mar1,0)) +apr1=mar1%*%tpm +cat("on 1st April",round(apr1)) +b=matrix(c(0,0,1),3,1) +A=matrix(c(-0.2,0.07,0.083,0.1,-0.1,0.067,1,1,1),3,3,byrow = TRUE) +cat("customers in steady state condition",round(solve(A,b),3)*1000) + + \ No newline at end of file diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.15/Ex8_15.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.15/Ex8_15.R new file mode 100644 index 00000000..ff793d3b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.15/Ex8_15.R @@ -0,0 +1,10 @@ +#Example 15 chapter 8 page no 361 +P = matrix(c(0,1,0,1/6,1/2,1/3,0,2/3,1/3),3,3,TRUE) +p0 = matrix(c(1,0,0),1,3) # for 0,1,2 books initially 0 book +p1= p0%*%P +p2= p1%*%P +p3= p2%*%P +cat("prob of 2 books after 3 weeks",p3[3]) +b=matrix(c(0,0,1),3,1) +A=matrix(c(-1,1/6,0,1,-1/2,2/3,1,1,1),3,3,byrow = TRUE) +cat("prob of 2 book in long run",round(solve(A,b),3)[3]) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.16/Ex8_16.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.16/Ex8_16.R new file mode 100644 index 00000000..a3ac5c94 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.16/Ex8_16.R @@ -0,0 +1,7 @@ +#Example 16 chapter 8 page no. 363 +tpm=matrix(c(0,3/4,1/4,0,0,1/2,1/2,0,0,0,1/2,1/2,1,0,0,0),4,4,TRUE) +b=matrix(c(0,0,0,1),4,1) +A=matrix(c(-1,0,0,1,3/4,-1/2,0,0,0,0,1/2,-1,1,1,1,1),4,4,byrow = TRUE) +px=(solve(A,b)) +x=c(125,0,0,75) +cat("expected maintenance per day",x%*%px) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.17/Ex8_17.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.17/Ex8_17.R new file mode 100644 index 00000000..b201f16b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.17/Ex8_17.R @@ -0,0 +1,12 @@ +#Example 17 chapter 8 page no. 364 +p0=matrix(c(0,0,1,0,0),1,5) #5 states for 0 5 10 15 20 rs +tpm=matrix(c(1,0,0,0,0,1/2,0,1/2,0,0,0,1/2,0,1/2,0,0,0,1/2,0,1/2,0,0,0,0,1),5,5,TRUE) +p1=p0%*%tpm +p2=p1%*%tpm +p3=p2%*%tpm +p4=p3%*%tpm +p5=p3%*%tpm +cat("prob gambler looses all money at 5th game",p5[1]) +p6=p5%*%tpm +p7=p6%*%tpm +cat("prob that game last more than 7 terms",p7[2]+p7[3]+p7[4]) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.18/Ex8_18.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.18/Ex8_18.R new file mode 100644 index 00000000..4c16be6a --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.18/Ex8_18.R @@ -0,0 +1,5 @@ +#Example 18 chapter 8 page no. 366 +tpm=matrix(c(0.9,0.1,0.5,0.5),2,2,TRUE) +b=matrix(c(0,1),2,1) +A=matrix(c(-0.1,0.5,1,1),2,2,byrow = TRUE) +cat("prob in steady state condition",round(solve(A,b),3)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.2/Ex8_2.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.2/Ex8_2.R new file mode 100644 index 00000000..c9d1c44d --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.2/Ex8_2.R @@ -0,0 +1,14 @@ +#Example 2 chapter 8 page no 372 +u=60/10 #avg service rate cars per hour +l=4 #arrival rate in cars per hour +ws=1/(u-l) +print("for case (a) exponential distribution") +cat("time spent in the system in minutes",ws*60) +wq = ws - (1/u) +cat("time spent in the system in minutes",wq*60) +print("for case (b) constant distribution") +ws = 1/u + l/(2*u*(u-l)) +cat("time spent in the system in minutes",ws*60) +wq=ws - 1/u +cat("time spent in the system in minutes",wq*60) +print("hense constant distribution is more favourable due to reduced waiting time") diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.3/Ex8_3.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.3/Ex8_3.R new file mode 100644 index 00000000..7e6e47c3 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.3/Ex8_3.R @@ -0,0 +1,7 @@ +#Example 3 chapter 8 page no. 348 +p0 = matrix(c(0.4 , 0.6) , 1,2) +p=matrix(c(0.7,0.4,0.3,0.6),2,2) +p1=p0%*%p +cat("prob distribution after step 1",p1) +p2=p1%*%p +cat("prob distribution after step 2 ",p2) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.4/Ex8_4.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.4/Ex8_4.R new file mode 100644 index 00000000..61e3560b --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.4/Ex8_4.R @@ -0,0 +1,4 @@ +#Example 4 chapter 8 page no 349 +ABC = matrix(c(400,500,600),1,3) +tpm = matrix(c(325/400,1/10,25/600,2/16,7/10,0,1/16,2/10,23/24),3,3) +cat("no. of clients of A B C after 1 year",round(ABC%*%tpm,digits = 0)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.9/Ex8_9.R b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.9/Ex8_9.R new file mode 100644 index 00000000..8b2a4073 --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/CH8/EX8.9/Ex8_9.R @@ -0,0 +1,8 @@ +#Example 9 chapter 8 page no. 355 +P=matrix(c(0,1/2,1,1/2),2,2) +P1=matrix(c(5/6,1/6),1,2) +P3 = (P1 %*% P) %*% P +cat("prob that he takes bus on third day=",P3[1]) +b=matrix(c(0,1),2,1) +A=matrix(c(-1,0.5,1,1),2,2,byrow = TRUE) +cat("prob of bus and scooter in steady state condition",round(solve(A,b),2)) diff --git a/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/README.txt b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/README.txt new file mode 100644 index 00000000..f403f94f --- /dev/null +++ b/Statistics_And_Probability_Theory_by_Dr._K.c._Jain_And_Dr._M.l._Rawat/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Diksha Bothra +Course: B.tech +Branch: Computer Science And Engineering +College/Institute/Organization: Poornima College Of Engineering + +About The Book + +Book: Statistics And Probability Theory +Author: Dr. K.c. Jain And Dr. M.l. Rawat +Publisher: College Book Centre, Jaipur +Year Of Publication: 2013 +ISBN: 9788190548229 +Edition: 10 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.1a/Ex10_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.1a/Ex10_1a.R new file mode 100644 index 00000000..7e0ed32f --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.1a/Ex10_1a.R @@ -0,0 +1,22 @@ + # Page no. : 410 + +# Inference about the Difference between the two Population Means Sigma 1 and Sigma 2 known + +sigma1 <- 9 +sigma2 <- 10 +sample_size1 <- 36 +sample_size2 <- 49 +sample_mean1 <- 40 +sample_mean2 <- 35 + +point_estimate <- sample_mean1 - sample_mean2 + +z_value <- qnorm(0.975) # alpha/2 = 0.05/2 = 0.025 = 1- 0.025 = 0.975 + +standard_error <- sqrt((((sigma1)^2)/(sample_size1)) + (((sigma2)^2)/(sample_size2))) + +IE1 <- point_estimate + z_value*standard_error +IE2 <- point_estimate - z_value*standard_error + +cat("The interval estimation for the given information at 95% confidence level is ",IE2 ,"to" + , IE1) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.1b/Ex10_1b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.1b/Ex10_1b.R new file mode 100644 index 00000000..96e4f44f --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.1b/Ex10_1b.R @@ -0,0 +1,43 @@ + # Page no. : 410 - 412 + +# Hypothesis Tests About Difference between two Means + +sigma1 <- 10 +sigma2 <- 10 +alpha <- 0.05 +n1 <- 30 +n2 <- 40 +xbar1 <- 82 +xbar2 <- 78 +D0 <- 0 + +z_value <- ((xbar1 - xbar2) - D0) / sqrt(((sigma1)**2/n1) + ((sigma2)**2/n2)) + +# P-value Approach + +# Two Tail Test + +pval <- 2 * pnorm(z_value, lower.tail = F) + +if(pval <= alpha) +{ + cat("Since P-Value",pval,"is less than or equal to 0.05 therefore we can reject Null Hypothesis") +} else { + cat("Since P-Value",pval,"is more than 0.05 therefore we cannot reject Null Hypothesis") +} + +# Critical Value Approach + +z_half_alpha <- qnorm(0.975) # alpha/2 = 0.05/2 = 0.025 = 1- 0.025 = 0.975 +critical_value_1 <- -z_half_alpha +critical_value_2 <- z_half_alpha + +if(z_value >= critical_value_2 || z_value <= critical_value_1) +{ + cat("Since Z-value",z_value,"does not lie in the range",critical_value_1,"to",critical_value_2, + "therefore we can reject Null Hypothesis") +} else { + cat("Since Z-value",z_value,"lie in the range",critical_value_1,"to",critical_value_2, + "therefore we cannot reject Null Hypothesis") +} + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.2a/Ex10_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.2a/Ex10_2a.R new file mode 100644 index 00000000..61ed0ecc --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.2a/Ex10_2a.R @@ -0,0 +1,27 @@ + # Page no. : 415 - 417 + +# Inference about the Difference between the two Population Means Sigma 1 and Sigma 2 Unknown + +s1 <- 150 +s2 <- 125 +n1 <- 28 +n2 <- 22 +xbar1 <- 1025 +xbar2 <- 910 + +point_estimate <- xbar1 - xbar2 + +numerator <- ((((s1)**2 /n1) + ((s2)**2 /n2))**2) +denomenator <- ((1 /(n1 -1)) * (((s1)**2 / n1)**2)) + ((1 /(n2 -1)) * (((s2)**2 / n2)**2)) + +df <- numerator / denomenator # Degree of Freedom + +t_value <- qt(0.975,df) # alpha/2 = 0.05/2 = 0.025 = 1- 0.025 = 0.975 + +standard_error <- sqrt((((s1)^2)/(n1)) + (((s2)^2)/(n2))) + +IE1 <- point_estimate + t_value*standard_error +IE2 <- point_estimate - t_value*standard_error + +cat("The interval estimation for the given information at 95% confidence level is ",IE2 , + "to", IE1) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.2b/Ex10_2b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.2b/Ex10_2b.R new file mode 100644 index 00000000..23e84988 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.2b/Ex10_2b.R @@ -0,0 +1,21 @@ + # Page no. : 418 - 419 + +# Hypothesis Tests About Difference between two Means + +x <- c(300, 280, 344, 385, 372, 360, 288, 321, 376, 290, 301, 283) +y <- c(274, 220, 308, 336, 198, 300, 315, 258, 318, 310, 332, 263) + +DF <- data.frame(x,y) + +test <- t.test(DF$x, DF$y, paired = F, alternative = "greater") +test + +# Upper Tail Test + +if(test$p.value <= 0.05) # 95% Confidence Level +{ + cat("Since P-Value",test$p.value,"is less than or equal to 0.05 therefore we can reject + Null Hypothesis") +} else { + cat("Since P-Value",test$p.value,"is more than 0.05 therefore we cannot reject Null Hypothesis") +} diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.3a/Ex10_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.3a/Ex10_3a.R new file mode 100644 index 00000000..e6f735c7 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.3a/Ex10_3a.R @@ -0,0 +1,31 @@ + # Page no. : 424 - 425 + +# Inference About the Difference Between Two Population Means Matched samples + +workers <- c(1,2,3,4,5,6) +method_1 <- c(6.0,5.0,7.0,6.2,6.0,6.4) +method_2 <- c(5.4,5.2,6.5,5.9,6.0,5.8) +diff <- method_1 - method_2 + +dataFrame <- data.frame(workers, method_1, method_2, diff) + +test <- t.test(dataFrame$method_1, dataFrame$method_2, paired = T) +test + +# Two Tail Test + +if(test$p.value <= 0.05) +{ + cat("Since P-Value",test$p.value,"is less than or equal to 0.05 therefore we can + reject Null Hypothesis") +} else { + cat("Since P-Value",test$p.value,"is more than 0.05 therefore we cannot reject Null Hypothesis") +} + +# Interval Estimate + +IE1 <- test$conf.int[1] +IE2 <- test$conf.int[2] + +cat("The interval estimation for the given information at 95% confidence level is ",IE1 ,"to", + IE2) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.4a/Ex10_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.4a/Ex10_4a.R new file mode 100644 index 00000000..11403541 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.4a/Ex10_4a.R @@ -0,0 +1,28 @@ + # Page no. : 431 + +# Inference About the Difference Between Two Population Proportions + +n1 <- 250 +n2 <- 300 +x1 <- 35 +x2 <- 27 +alpha <- 0.1 + +pbar1 <- x1 / n1 +pbar2 <- x2 / n2 + +qbar1 <- 1 - pbar1 +qbar2 <- 1 - pbar2 + +# Interval Estimation + +diff_prop <- pbar1 - pbar2 + +z_half_alpha <- qnorm(0.95) # alpha / 2 = 0.1 / 2 = 0.05 = 0.95 (1 - 0.05) + +margin_of_error <- z_half_alpha * sqrt((pbar1 * qbar1)/n1 + (pbar2 * qbar2)/n2 ) + +IE1 <- diff_prop + margin_of_error +IE2 <- diff_prop - margin_of_error + +cat("The interval estimation for the given information at 90% confidence level is ",IE2 ,"to", IE1) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.4b/Ex10_4b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.4b/Ex10_4b.R new file mode 100644 index 00000000..a8f34b19 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH10/EX10.4b/Ex10_4b.R @@ -0,0 +1,24 @@ + # Page no. : 432 - 433 + +# Hypothesis Tests About Difference between two Proportions + +pbar1 <- 0.14 +pbar2 <- 0.09 +n1 <- 250 +n2 <- 300 +alpha <- 0.10 # Significance Level + +pbar <- ((n1 * pbar1) + (n2 * pbar2)) / (n1 + n2) # Pooled Estrimator + +z_value <- (pbar1 - pbar2) / sqrt((pbar*(1 - pbar))*((1/n1)+(1/n2))) + +# Two Tail Test + +pval <- 2 * pnorm(z_value, lower.tail = F) + +if(pval <= alpha) +{ + cat("Since P-Value",pval,"is less than or equal to 0.10 therefore we can reject Null Hypothesis") +} else { + cat("Since P-Value",pval,"is more than 0.10 therefore we cannot reject Null Hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.1a/Ex11_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.1a/Ex11_1a.R new file mode 100644 index 00000000..55a47976 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.1a/Ex11_1a.R @@ -0,0 +1,18 @@ + # Page no. : 453 + +# Inferences About the Population Variance + +n <- 20 +variance <- 0.0025 +df <- 19 # Degrees of Freedom + +chisq_1 <- qchisq(0.975,df) +chisq_2 <- qchisq(0.025,df) + +# Interval Estimation + +IE1 <- sqrt((df * variance) / chisq_1) +IE2 <- sqrt((df * variance) / chisq_2) + +cat("Interval Estimation at 95% confidence interval for population standard deviation is",IE1, + "to",IE2) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.1b/Ex11_1b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.1b/Ex11_1b.R new file mode 100644 index 00000000..6ab4a25a --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.1b/Ex11_1b.R @@ -0,0 +1,63 @@ + # Page no. : 455 - 456 + +# Hypothesis Testing + +n <- 24 +alpha <- 0.05 # Significance Level +sigma0_sq <- 4 +variance <- 4.9 + +chisq_value <- ((n - 1) * variance) / sigma0_sq + +df <- n - 1 # Degree of Freedom + +# Upper Tail Test + +# P-value Approach + +pval <- pchisq(chisq_value, df, lower.tail = F) + +if(pval <= alpha) +{ + cat("Since pval",pval,"is less than or equal to 0.05 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.05 therefore we cannot reject Null Hypothesis") +} + +# Critical Value Approach + +chisqvalue <- qchisq(0.95,df) # Chi-square value for 0.95 (1 - 0.05) + +if(chisq_value >= chisqvalue) +{ + cat("Since Chi-square value",chisq_value,"is greater than or equal to Chi-square value",chisqvalue, + "therefore we will reject Null Hypothesis") +} else { + cat("Since Chi-square value",chisq_value,"is less than Chi-square value",chisqvalue, + "therefore we cannot reject Null Hypothesis") +} + + + # Page no. : 456 - 457 + +n <- 30 +alpha <- 0.05 # Significance Level +sigma0_sq <- 100 +variance <- 162 + +chisq_value <- ((n - 1) * variance) / sigma0_sq + +df <- n - 1 # Degree of Freedom + +# Two Tail Test + +# P-value Approach + +pval <- 2 * pchisq(chisq_value, df, lower.tail = F) + +if(pval <= alpha) +{ + cat("Since pval",pval,"is less than or equal to 0.05 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.05 therefore we cannot reject Null Hypothesis") +} diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.2a/Ex11_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.2a/Ex11_2a.R new file mode 100644 index 00000000..dc0982f1 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH11/EX11.2a/Ex11_2a.R @@ -0,0 +1,80 @@ + # Page no. : 462 - 464 + +# Inferences About Two Population Variances + +alpha <- 0.10 # Significance Level +n1 <- 26 +n2 <- 16 +sv1 <- 48 +sv2 <- 20 + +f_value <- (sv1) / (sv2) + +df1 <- n1 - 1 # Degrees of Freedom 1 +df2 <- n2 - 1 # Degrees of Freedom 2 + +# Two Tail Test + +# P-value Approach + +pval <- 2 * pf(f_value,df1,df2,lower.tail = F) + +if(pval <= alpha) +{ + cat("Since pval",pval,"is less than or equal to 0.10 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.10 therefore we cannot reject Null Hypothesis") +} + +# Critical Value Approach + +half_alpha <- alpha / 2 +fval <- qf(0.95,df1,df2) # half_alpha = 0.05 = 1 - 0.05 = 0.95 + +if(f_value >= fval) +{ + cat("Since F value",f_value,"is greater than or equal to F value",fval, + "therefore we will reject Null Hypothesis") +} else { + cat("Since F value",f_value,"is less than F value",fval, + "therefore we cannot reject Null Hypothesis") +} + + # Page no. : 464 + +alpha <- 0.05 # Significance Level +n1 <- 41 +n2 <- 31 +sv1 <- 120 +sv2 <- 80 + +f_value <- (sv1) / (sv2) + +df1 <- n1 - 1 # Degrees of Freedom 1 +df2 <- n2 - 1 # Degrees of Freedom 2 + +# Upper Tail Test + +# P-value Approach + +pval <- pf(f_value,df1,df2,lower.tail = F) + +if(pval <= alpha) +{ + cat("Since pval",pval,"is less than or equal to 0.10 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.10 therefore we cannot reject Null Hypothesis") +} + +# Critical Value Approach + +fval <- qf(0.90,df1,df2) # alpha = 0.05 = 1 - 2 * 0.05 = 0.90 + +if(f_value >= fval) +{ + cat("Since F value",f_value,"is greater than or equal to F value",fval, + "therefore we will reject Null Hypothesis") +} else { + cat("Since F value",f_value,"is less than F value",fval, + "therefore we cannot reject Null Hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.1a/Ex12_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.1a/Ex12_1a.R new file mode 100644 index 00000000..2e3c7c87 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.1a/Ex12_1a.R @@ -0,0 +1,45 @@ + # Page no. : 474 - 476 + +# Goodness of Fit Test A Multinomial Population + +category <- c("Company A","Company B", "Company C") +prop <- c(0.30, 0.50, 0.20) +freq1 <- c(48, 98, 54) +freq2 <- c(60, 100, 40) +diff <- freq1 - freq2 +sq_diff <- (diff)**2 +answer <- sq_diff / freq2 +DF <- data.frame(category, prop, freq1, freq2, diff, sq_diff, answer) + +total_observe_freq <- sum(DF$freq1) +chisq_value <- sum(DF$answer) + +alpha <- 0.05 +df <- nrow(DF) - 1 # Degrees of Freedom + +# Upper Tail Test + +# P-value Approach + +pval <- pchisq(chisq_value,df,lower.tail = F) + +if(pval <= alpha) +{ + cat("Since pval",pval,"is less than or equal to 0.05 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.05 therefore we cannot reject Null Hypothesis") +} + +# Critical Value Approach + +chisqValue <- qchisq(0.95,df) # 1 - alpha = 1 - 0.05 = 0.95 + +if(chisq_value >= chisqValue) +{ + cat("Since Chi-square value",chisq_value,"is greater than or equal to Chi-square value",chisqValue, + "therefore we will reject Null Hypothesis") +} else { + cat("Since Chi-square value",chisq_value,"is less than Chi-square value",chisqValue, + "therefore we cannot reject Null Hypothesis") +} + \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.2a/Ex12_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.2a/Ex12_2a.R new file mode 100644 index 00000000..e0386009 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.2a/Ex12_2a.R @@ -0,0 +1,27 @@ + # Page no. : 480 - 482 + +# Tests of Independence + +gender <- c("Male", "Female") +light <- c(20,30) +regular <- c(40,30) +dark <- c(20,10) +total <- c(80,70) + +DF <- data.frame(gender, light, regular, dark, total) + +test <- chisq.test(DF[,2:4]) +test + +# Upper Tail Test + +if(test$p.value <= 0.05) +{ + cat("Since pval",test$p.value,"is less than or equal to 0.05 therefore we can reject + Null Hypothesis") +} else{ + cat("Since pval",test$p.value,"is greater than 0.05 therefore we cannot reject Null + Hypothesis") +} + + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.3a/Ex12_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.3a/Ex12_3a.R new file mode 100644 index 00000000..ccba989f --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.3a/Ex12_3a.R @@ -0,0 +1,46 @@ + # Page no. : 488 - 490 + +# Goodness of Fit Test Poisson Distribution + +x <- c(0,1,2,3,4,5,6,7,8,9) +observed_freq <- c(2,8,10,12,18,22,22,16,12,6) +y <- x * observed_freq +e <- 2.72 + +mu <- sum(y) / sum(observed_freq) +fun_of_x <- round(((mu)**x) * (e)**(-mu) / factorial(x), 4) # Function of x + +expected_freq <- round(sum(observed_freq)*fun_of_x, 2) + +diff <- observed_freq - expected_freq + +sq_diff <- round((diff)**2,2) + +answer <- round(sq_diff / expected_freq,2) + +DF <- data.frame(x,observed_freq,expected_freq,diff,sq_diff,answer) + +total_observe_freq <- sum(DF$observed_freq) +total_expexted_freq <- sum(DF$expected_freq) + +chisq_value <- sum(DF$answer) + +df <- nrow(DF) - 2 # Degrees of Freedom (k - p - 1 where k = 10, p = 1) + +alpha <- 0.05 + +# Upper Tail Test + +# P-value Approach + +pval <- pchisq(chisq_value,df,lower.tail = F) + +if(pval <= alpha) +{ + cat("Since pval",pval,"is less than or equal to 0.05 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.05 therefore we cannot reject Null Hypothesis") +} + +# In Book it is taken 9 categories but we consider 10 so p-value may vary but answeris correct + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.3b/Ex12_3b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.3b/Ex12_3b.R new file mode 100644 index 00000000..889a6442 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH12/EX12.3b/Ex12_3b.R @@ -0,0 +1,55 @@ + # Page no. : 491 - 494 + +# Goodness of Fit Test Normal Distribution + +data <- c(71,66,61,65,54,93,60,86,70,70,73,73,55,63,56,62,76,54,82,79,76,68,53,58,85,80,56, + 61,61,64,65,62,90,69,76,79,77,54,64,74,65,65,61,56,63,80,56,71,79,84) + +xbar <- mean(data) +s <- sd(data) + +cat("Value of mean is",xbar) +cat("Value of standard variance is",s) + +percentage <- c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9) +z <- c() +test_score <- c() + +for (i in 1:length(percentage)) { + z[i] <- round(qnorm(percentage[i]),2) + test_score[i] <- round(xbar + (z[i] * round(s,2)), 2) +} + +DF <- data.frame(percentage, z, test_score) + +interval <- c("Less than 55.10", "55.10 to 59.68", "59.68 to 63.01", "63.01 to 65.82", + "65.82 to 68.42", "68.42 to 71.02", "71.02 to 73.83", "73.83 to 77.16", + "77.16 to 81.74", "81.74 and over") +observed_freq <- c(5,5,9,6,2,5,2,5,5,6) +expected_freq <- c(5,5,5,5,5,5,5,5,5,5) + +diff <- observed_freq - expected_freq +sq_diff <- (diff)**2 + +answer <- (sq_diff) / expected_freq + +dataset <- data.frame(interval, observed_freq, expected_freq, diff, sq_diff, answer) + +chisq <- sum(dataset$answer) + +alpha <- 0.10 # Significance Level + +df <- nrow(dataset) - 3 # Degrees of Freedom (k - p - 1 where k = 10, p = 2) + +# Upper Tail Test + +# P-value Approach + +pval <- pchisq(chisq,df,lower.tail = F) + +if(pval <= alpha) +{ + cat("Since pval",pval,"is less than or equal to 0.05 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.05 therefore we cannot reject Null Hypothesis") +} diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.1a/Ex13_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.1a/Ex13_1a.R new file mode 100644 index 00000000..21f150ad --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.1a/Ex13_1a.R @@ -0,0 +1,36 @@ + # Page no. : 510 - 512 + +# Analysis of Variance and the Completely Randomized Design + +method_A <- c(58,64,55,66,67) +method_B <- c(58,69,71,64,68) +method_C <- c(48,57,59,47,49) + +DF <- data.frame(method_A,method_B,method_C) + +mean1 <- sum(DF$method_A) / nrow(DF) # Sample Mean 1 +mean2 <- sum(DF$method_B) / nrow(DF) # Sample Mean 2 +mean3 <- sum(DF$method_C) / nrow(DF) # Sample Mean 3 + +variance1 <- sum((DF$method_A - mean1)**2) / (nrow(DF)-1) # Sample Variance 1 +variance2 <- sum((DF$method_B - mean2)**2) / (nrow(DF)-1) # Sample Variance 2 +variance3 <- sum((DF$method_C - mean3)**2) / (nrow(DF)-1) # Sample Variance 3 + +sd1 <- sqrt(variance1) # Sample Standard Variance 1 +sd2 <- sqrt(variance2) # Sample Standard Variance 2 +sd3 <- sqrt(variance3) # Sample Standard Variance 3 + +sample_mean <- (mean1 + mean2 + mean3) / 3 # Overall Sample Mean + +variance <- ((mean1 - sample_mean)**2 + (mean2 - sample_mean)**2 + (mean3 - sample_mean)**2) / (3 - 1) +# Sample Varince for Overall Sample Mean (3 --> Methods) + +sigma_sq <- nrow(DF) * variance # Between-treatment Estimate of Sigma Square + +estimate_sigma_sq <- (variance1 + variance2 + variance3) / 3 # Within-treatment Estimate of Sigma Square + +ratio <- sigma_sq / estimate_sigma_sq + +cat("Ratio of Between-treatment Estimate of Sigma Square by Within-treatment Estimate + of Sigma Square is",ratio) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.2a/Ex13_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.2a/Ex13_2a.R new file mode 100644 index 00000000..45f13621 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.2a/Ex13_2a.R @@ -0,0 +1,54 @@ + # Page no. : 518 + +# Analysis of Variance and the Completely Randomized Design + +method_A <- c(58,64,55,66,67) +method_B <- c(58,69,71,64,68) +method_C <- c(48,57,59,47,49) + +DF <- data.frame(method_A,method_B,method_C) + +k <- ncol(DF) # Number of Treatments +n <- nrow(DF) # Number of Observations for each Treatment +N <- n * k # Total Observations + +df_numerator <- k - 1 # Degrees of Freedom for Numerator +df_denomenator <- N - k # Degrees of Freedom for Denomenator + +alpha <- 0.05 + +x <- c(t(as.matrix(DF))) +f <- c("method_A", "method_B", "method_C") +tm <- gl(k, 1, n*k, factor(f)) +result <- anova(lm(x ~ tm)) # Similar to aov(x ~ tm) + +result + +# Upper Tail Test + +# Critical Value Approach + +fval <- qf(0.95,df_numerator, df_denomenator) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +fvalue <- result$`F value`[1] + +if(fvalue >= fval) +{ + cat("Since F value",fvalue,"is greater than or equal to F value",fval, + "therefore we will reject Null Hypothesis") +} else { + cat("Since fvalue value",fvalue,"is less than fvalue value",fval, + "therefore we cannot reject Null Hypothesis") +} + +# P-value Approach + +pval <- pf(fvalue,df_numerator,df_denomenator,lower.tail = F) + +if(pval <= alpha) +{ + cat("Since pval",pval,"is less than or equal to 0.05 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.05 therefore we cannot reject Null Hypothesis") +} diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.3a/Ex13_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.3a/Ex13_3a.R new file mode 100644 index 00000000..1ff9803f --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.3a/Ex13_3a.R @@ -0,0 +1,98 @@ + # Page no. : 525 - 526 + +# Multiple Comparison Procedures : Fisher's LSD + +method_A <- c(58,64,55,66,67) +method_B <- c(58,69,71,64,68) +method_C <- c(48,57,59,47,49) + +DF <- data.frame(method_A,method_B,method_C) + +k <- ncol(DF) # Number of Treatments +n <- nrow(DF) # Number of Observations for each Treatment +N <- n * k # Total Observations + +x <- c(t(as.matrix(DF))) +f <- c("method_A", "method_B", "method_C") +tm <- gl(k, 1, n*k, factor(f)) +result <- anova(lm(x ~ tm)) # Similar to aov(x ~ tm) + +# Approach - 1 + +# Fisher's LSD Procedure for Method A and Method B + +t_value1 <- (mean(DF$method_A) - mean(DF$method_B)) / sqrt(result$`Mean Sq`[2] * ((1 / n) + + (1 / n))) + +t_value1 <- round(t_value1, 2) + +df <- N - k # Degrees of Freedom + +# Two Tail Test + +# P-value Approach + +alpha <- 0.05 + +pval <- 2 * pt(t_value1, df, lower.tail = T) + +if(pval <= alpha) +{ + cat("Since pval",pval,"is less than or equal to 0.05 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.05 therefore we cannot reject Null Hypothesis") +} + +tval <- qt(0.975,df) # alpha/2 = 0.05 / 2 = 0.025 = (1 - 0.025) = 0.975 +tval <- round(tval, 3) + +LSD <- tval * sqrt(result$`Mean Sq`[2] * ((1 / n) + (1 / n))) +LSD <- round(LSD, 2) + +# Approach - 2 + +# Fisher's LSD Procedure for Method A and Method C + +diff_A_C <- mean(DF$method_A)- mean(DF$method_C) + +if(diff_A_C > LSD) +{ + cat("Since the value of difference", diff_A_C,"is greater than LSD",LSD,"therefore we will reject + Null Hypothesis") +} else{ + cat("Since the value of difference", diff_A_C,"is less than LSD",LSD,"therefore we cannot reject + Null Hypothesis") +} + +# Fisher's LSD Procedure for Method B and Method C + +diff_B_C <- mean(DF$method_B)- mean(DF$method_C) + +if(diff_B_C > LSD) +{ + cat("Since the value of difference", diff_B_C,"is greater than LSD",LSD,"therefore we will reject + Null Hypothesis") +} else{ + cat("Since the value of difference", diff_B_C,"is less than LSD",LSD,"therefore we cannot reject + Null Hypothesis") +} + + + + + + + + + + + + + + + + + + + + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.4a/Ex13_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.4a/Ex13_4a.R new file mode 100644 index 00000000..00d01c34 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.4a/Ex13_4a.R @@ -0,0 +1,38 @@ + # Page no. : 534 + +# Randomized Block Design + +blocks <- c("Controller 1", "Controller 2", "Controller 3", "Controller 4", "Controller 5", "Controller 6") +system_A <- c(15, 14, 10, 13, 16, 13) +system_B <- c(15, 14, 11, 12, 13, 13) +system_C <- c(18, 14, 15, 17, 16, 13) + +DF <- data.frame(blocks, system_A, system_B, system_C) + +k <- ncol(DF) - 1 # Number of Treatments (blocks is not the treatement) +b <- nrow(DF) # Number of blocks +N <- k * b # Total sample Size + +x <- c(t(as.matrix(DF[,-1]))) +f <- c("system_A", "system_B", "system_C") +tm <- gl(k, 1, N, factor(f)) +blk <- gl(b, k, N) +result <- anova(lm(x ~ tm + blk)) # Similar to aov(x ~ tm) + +result + +f_value <- result$`F value`[1] + +# Upper Tail Test + +# P-value Approach + +pval <- result$`Pr(>F)`[1] + +if(pval <= 0.05) +{ + cat("Since pval",pval,"is less than or equal to 0.05 therefore we can reject Null Hypothesis") +} else{ + cat("Since pval",pval,"is greater than 0.05 therefore we cannot reject Null Hypothesis") +} + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.5a/Ex13_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.5a/Ex13_5a.R new file mode 100644 index 00000000..3a80e033 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH13/EX13.5a/Ex13_5a.R @@ -0,0 +1,60 @@ + # Page no. : 542 + +# Factorial Experiment + +program <- c("Three-hour review", "Three-hour review", "One-day program", "One-day program", "10-week course", + "10-week course") +business <- c(500, 580, 460, 540, 560, 600) +engineering <- c(540, 460, 560, 620, 600, 580) +arts_and_science <- c(480, 400, 420, 480, 480, 410) + +DF <- data.frame(program, business, engineering, arts_and_science) + +a <- 3 # Number of levels in Factor A (Unique Programs) +b <- 3 # Number of levels in Factor B (Columns Except program) +r <- 2 # Number of Replications (Each Program has 2 Replications) +N <- a * b * r # Total Observations + +x <- c(t(as.matrix(DF[,-1]))) +f1 <- c("Three-hour review", "One-day program", "10-week course") +f2 <- c("business", "engineering", "arts and science") +tm2 <- gl(a, 1, N, factor(f1)) +tm1 <- gl(b, r * a, N, factor(f2)) +result <- anova(lm(x ~ tm1 * tm2)) # Similar to aov(x ~ tm) + +result + +alpha <- 0.05 + +# Upper Tail Test + +pval1 <- result$`Pr(>F)`[1] +pval2 <- result$`Pr(>F)`[2] +pval3 <- result$`Pr(>F)`[3] + +if(pval1 <= alpha) +{ + cat("Since pval",pval1,"is less than or equal to 0.05 therefore we can reject Null Hypothesis + for Undergraduation.") +} else{ + cat("Since pval",pval1,"is greater than 0.05 therefore we cannot reject Null Hypothesis + for Undergraduation.") +} + +if(pval2 <= alpha) +{ + cat("Since pval",pval2,"is less than or equal to 0.05 therefore we can reject Null Hypothesis + for programs.") +} else{ + cat("Since pval",pval2,"is greater than 0.05 therefore we cannot reject Null Hypothesis + for programs.") +} + +if(pval3 <= alpha) +{ + cat("Since pval",pval3,"is less than or equal to 0.05 therefore we can reject Null Hypothesis + for interaction.") +} else{ + cat("Since pval",pval3,"is greater than 0.05 therefore we cannot reject Null Hypothesis + for interaction.") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.1a/Ex14_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.1a/Ex14_1a.R new file mode 100644 index 00000000..f1852a54 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.1a/Ex14_1a.R @@ -0,0 +1,40 @@ + # Page no. : 565 - 566 + +# Least Squares Method + +restaurant <- c(1,2,3,4,5,6,7,8,9,10) +student_population <- c(2,6,8,8,12,16,20,20,22,26) +quartely_sales <- c(58,105,88,118,117,137,157,169,149,202) + +DF <- data.frame(restaurant, student_population, quartely_sales) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(student_population, quartely_sales)) + geom_point() + + labs(title = "Scatter Plot between Student Population and Quartely Sales",x = "Student + Population (1000s)", y = "Quartely Sales ($1000s)") + + # Page no. : 567 - 569 + +regressor <- lm(quartely_sales ~ student_population, data = DF) +res <- summary(regressor) + +res + +b1 <- res$coefficients[[2]] + +b0 <- res$coefficients[[1]] + +cat("Estimated Regression Equation is y_cap =",b0,"+",b1,"x") + +ggplot(DF,aes(student_population, quartely_sales)) + geom_point() + + geom_smooth(method='lm', se = F) + labs(title = "Scatter Plot between Student Population +and Quartely Sales",x = "Student Population (1000s)", y = "Quartely Sales ($1000s)") + + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.2a/Ex14_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.2a/Ex14_2a.R new file mode 100644 index 00000000..f9a8c607 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.2a/Ex14_2a.R @@ -0,0 +1,35 @@ + # Page no. : 576 - 580 + +# Coefficient of Determination + +restaurant <- c(1,2,3,4,5,6,7,8,9,10) +student_population <- c(2,6,8,8,12,16,20,20,22,26) +quartely_sales <- c(58,105,88,118,117,137,157,169,149,202) + +DF <- data.frame(restaurant, student_population, quartely_sales) + +regressor <- lm(quartely_sales ~ student_population, data = DF) +res <- summary(regressor) + +table <- anova(regressor) + +SSE <- table$`Sum Sq`[2] # Sum of Squares due to Error + +cat("Value of SSE is",SSE) + +SSR <- table$`Sum Sq`[1] # Sum of Squares due to Regression + +cat("Value of SSR is",SSR) + +SST <- SSE + SSR # Total Sum of Squares + +cat("Value of SST is",SST) + +r_sq <- res$r.squared # Coefficient of Determination + +corrcoeff <- sqrt(r_sq) # Correlation Coefficient + +cat("Value of Coefficient of Determination is",r_sq) +cat("Value of correlation Coefficient is",corrcoeff) + + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.3a/Ex14_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.3a/Ex14_3a.R new file mode 100644 index 00000000..7be25335 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.3a/Ex14_3a.R @@ -0,0 +1,61 @@ + # Page no. : 485 - 489 + +# Test of Significance + +restaurant <- c(1,2,3,4,5,6,7,8,9,10) +student_population <- c(2,6,8,8,12,16,20,20,22,26) +quartely_sales <- c(58,105,88,118,117,137,157,169,149,202) + +DF <- data.frame(restaurant, student_population, quartely_sales) + +regressor <- lm(quartely_sales ~ student_population, data = DF) +res <- summary(regressor) + +standard_error_MSE <- res$sigma + +cat("Value of square root of MSE is",standard_error_MSE) + +b1 <- res$coefficients[2] + +tval <- res$coefficients[6] + + +# T Test + +# Two Tail Test + +# P-value Approach + +pval <- round(res$coefficients[8],3) + +if(pval >= 0.01) +{ + cat("Since pval",pval,"is greater than or equal to 0.01 therefore we cannot reject the Null Hypothesis") +} else{ + cat("Since pval",pval,"is less than 0.01 therefore we can reject the Null Hypothesis") + +} + +# F Test + +test <- anova(regressor) + +fval <- test$`F value` + +pval <- round(test$`Pr(>F)`[1],3) # P value is extremely small ie negligible to 0 + +if(pval >= 0.01) +{ + cat("Since pval",pval,"is greater than or equal to 0.01 therefore we cannot reject the Null Hypothesis") +} else{ + cat("Since pval",pval,"is less than 0.01 therefore we can reject the Null Hypothesis") + +} + +# Confidence Interval + +confidence <- confint(regressor, "student_population", level = 0.99) +IE1 <- confidence[1] +IE2 <- confidence[2] + +cat("The 99 % confidence interval is ",IE1, "to", IE2) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.4a/Ex14_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.4a/Ex14_4a.R new file mode 100644 index 00000000..d4518d37 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.4a/Ex14_4a.R @@ -0,0 +1,28 @@ + # Page no. : 595 - 597 + +# Using the Estimated Regression Equation for Estimation and Prediction + +restaurant <- c(1,2,3,4,5,6,7,8,9,10) +student_population <- c(2,6,8,8,12,16,20,20,22,26) +quartely_sales <- c(58,105,88,118,117,137,157,169,149,202) + +DF <- data.frame(restaurant, student_population, quartely_sales) + +regressor <- lm(quartely_sales ~ student_population, data = DF) +res <- summary(regressor) + +pred <- predict(regressor, data.frame(student_population=10), interval="confidence") + +PE <- pred[1] +IE1 <- pred[2] +IE2 <- pred[3] + +cat("Point estimate is ", PE) +cat("Confidence Interval is ",IE1, "to", IE2) + +pred2 <- predict(regressor, data.frame(student_population=10), interval="predict") + +IE1 <- pred2[2] +IE2 <- pred2[3] + +cat("Prediction Confidence Interval is ",IE1, "to", IE2) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.5a/Ex14_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.5a/Ex14_5a.R new file mode 100644 index 00000000..3c15abae --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.5a/Ex14_5a.R @@ -0,0 +1,28 @@ + # Page no. : 605 - 609 + +# Residual Analysis : Validating Model Assumptions + +x <- c(2,6,8,8,12,16,20,20,22,26) # Student Population +y <- c(58,105,88,118,117,137,157,169,149,202) # Sales + +estimated_sales <- 60 + (5 * x) # Regression Equation = 60 + 5 x + +residuals <- y - estimated_sales + +DF <- data.frame(x, y, estimated_sales, residuals) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(x, residuals)) + geom_point() + geom_hline(yintercept = 0, linetype=2) + +labs(title = "Residual Plot", x = "X", y = "Residual") + +ggplot(DF,aes(estimated_sales, residuals)) + geom_point() + geom_hline(yintercept = 0, + linetype=2) + labs(title = "Plot between Estimated Sales and Residuals", x = + "Estimated Sales", y = "Residual") + \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.5b/Ex14_5b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.5b/Ex14_5b.R new file mode 100644 index 00000000..f7c054a7 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.5b/Ex14_5b.R @@ -0,0 +1,49 @@ + # Page no. : 610 - 612 + +# Standardized Residuals + +i <- c(1,2,3,4,5,6,7,8,9,10) +x <- c(2,6,8,8,12,16,20,20,22,26) # Student Population +n <- 10 +s <- 13.829 # Standard error +y <- c(58,105,88,118,117,137,157,169,149,202) # Sales + +estimated_sales <- 60 + (5 * x) # Regression Equation = 60 + 5 x + +x_deviation <- x - mean(x) + +x_deviation_sq <- (x_deviation)**2 + +z <- round(x_deviation_sq / sum(x_deviation_sq),4) + +h <- round((1 / n) + z, 4) + +s_i <- round(s * sqrt(1 -h), 4) # Standard Deviation for Residual i + +residuals <- y - estimated_sales + +standard_residuals <- round((residuals) / (s_i), 4) + +DF <- data.frame(x, y, estimated_sales, x_deviation, x_deviation_sq, z, h, s_i, residuals, standard_residuals) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(x, standard_residuals)) + geom_point() + geom_hline(yintercept = 0, linetype=2) + + labs(title = "Scatter Plot between x and Standard Residuals", x = "X", + y = "Standard Residuals") + +normal_scores <- round(qqnorm(1:10)$x, 2) +standard_residuals <- sort(standard_residuals, decreasing = F) + +table <- data.frame(normal_scores, standard_residuals) + +ggplot(table,aes(normal_scores, standard_residuals)) + geom_point() + + geom_smooth(method = "lm", se = F) + +labs(title = "Scatter Plot between Normal Scores and Standard Residuals", x = "Normal Scores", + y = "Standard Residuals") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.6a/Ex14_6a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.6a/Ex14_6a.R new file mode 100644 index 00000000..8dc2c36d --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.6a/Ex14_6a.R @@ -0,0 +1,11 @@ + # Page no. : 615 + +# Detecting Outliers + +x <- c(1,1,2,3,3,3,4,4,5,6) +y <- c(45,55,50,75,40,45,30,35,25,15) + +DF <- data.frame(x,y) + +ggplot(DF,aes(x, y)) + geom_point()+ geom_smooth(method = "lm", se = F) + +labs(title = "Scatter Plot between x and Y Showing Outlier", x = "X", y = "Y") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.6b/Ex14_6b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.6b/Ex14_6b.R new file mode 100644 index 00000000..81b994d2 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH14/EX14.6b/Ex14_6b.R @@ -0,0 +1,25 @@ + # Page no. : 617 - 618 + +# Detecting Influential Observations + +x <- c(10, 10, 15, 20, 20, 25, 70) +y <- c(135, 130, 120, 115, 120, 110, 100) + +DF <- data.frame(x, y) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF, aes(x, y)) + geom_point() + labs(title = "Scatter Plot between x and y", x = "X", + y = "Y") + +point <- x[7] # From Scatter Plot + +h <- (1 / nrow(DF)) + (((point - mean(DF$x))**2) / (sum((DF$x - mean(DF$x))**2))) + +cat("Leverage at point 7 is", h) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.1a/Ex15_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.1a/Ex15_1a.R new file mode 100644 index 00000000..03ae453e --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.1a/Ex15_1a.R @@ -0,0 +1,52 @@ + # Page no. : 646 - 647 + +# Least Squares Method + +driving_assignment <- c(1,2,3,4,5,6,7,8,9,10) +x <- c(100,50,100,100,50,80,75,65,90,90) # Miles Traveled +y <- c(9.3,4.8,8.9,6.5,4.2,6.2,7.4,6.0,7.6,6.1) # Travel Time (hours) + +DF <- data.frame(driving_assignment, x ,y) + +# Install Library if not installed + +# install.packages("ggpolt2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(x, y)) + geom_point() +labs(title = "Scatter Plot between Miles Traveled + and Travel Time", x = "Miles Traveled", y = "Travel Time in Hours") + + # Page no. : 647 - 648 + +model <- lm(y ~ x, data = DF) +summ <- summary(model) +summ + +b0 <- model$coefficients[1] +b1 <- model$coefficients[2] + +cat("Linear Regression Equation is y_cap =",b0,"+",b1,"x1") + +# F Test + +fval <- summ$fstatistic[1] + +# Upper Tail Test + +# P-value Approach + +alpha <- 0.05 + +pval <- summ$coefficients[8] # P-value + +if(pval >= alpha) +{ + cat("Since pval",pval,"is greater than or equal to 0.01 therefore we cannot reject the Null Hypothesis") +} else{ + cat("Since pval",pval,"is less than 0.05 therefore we can reject the Null Hypothesis") + +} + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.2a/Ex15_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.2a/Ex15_2a.R new file mode 100644 index 00000000..24db0116 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.2a/Ex15_2a.R @@ -0,0 +1,19 @@ + # Page no. : 648 - 649 + +# Two Independent Variables + +driving_assignment <- c(1,2,3,4,5,6,7,8,9,10) +x1 <- c(100,50,100,100,50,80,75,65,90,90) # Miles Traveled +x2 <- c(4,3,4,2,2,2,3,4,3,2) # Number of Deliveries +y <- c(9.3,4.8,8.9,6.5,4.2,6.2,7.4,6.0,7.6,6.1) # Travel Time (hours) + +DF <- data.frame(driving_assignment, x1, x2, y) + +model <- lm(y ~ x1 + x2, data = DF) +summary(model) + +b0 <- model$coefficients[1] +b1 <- model$coefficients[2] +b2 <- model$coefficients[3] + +cat("Multiple Regression Equation is y_cap =",b0,"+",b1,"x1 +",b2,"x2") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.3a/Ex15_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.3a/Ex15_3a.R new file mode 100644 index 00000000..20d5a7ff --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.3a/Ex15_3a.R @@ -0,0 +1,39 @@ + # Page no. : 654 - 655 + +# Multiple Coefficient of Determination + +driving_assignment <- c(1,2,3,4,5,6,7,8,9,10) +x1 <- c(100,50,100,100,50,80,75,65,90,90) # Miles Traveled +x2 <- c(4,3,4,2,2,2,3,4,3,2) # Number of Deliveries +y <- c(9.3,4.8,8.9,6.5,4.2,6.2,7.4,6.0,7.6,6.1) # Travel Time (hours) + +DF <- data.frame(driving_assignment, x1, x2, y) + +model <- lm(y ~ x1 + x2, data = DF) +summ <- summary(model) + +mean_y <- mean(DF$y) # Mean of Travel time + +predicted_travel_time <- round(predict(model), 2) + +DF <- cbind(DF, predicted_travel_time) + +SSR <- sum((DF$predicted_travel_time - mean_y)**2) # Sum of Squares due to Regression + +cat("Value of SSR is",SSR) + +SSE <- sum((DF$y - DF$predicted_travel_time)**2) # Sum of Squares due to Error + +cat("Value of SSE", SSE) + +SST <- SSR + SSE # Total Sum of Squares + +cat("Value of SST", SST) + +r_sq <- summ$r.squared # Multiple Coefficient of Determination + +cat("Value of Multiple Coefficient of Determination is", r_sq) + +adj_r_sq <- summ$adj.r.squared # Adjusted Multiple Coefficient of Determination + +cat("Value of Adjusted Multiple Coefficient of Determination is", adj_r_sq) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.4a/Ex15_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.4a/Ex15_4a.R new file mode 100644 index 00000000..4bd36f03 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.4a/Ex15_4a.R @@ -0,0 +1,84 @@ + # Page no. : 660 - 662 + +# Testing for Significance + +driving_assignment <- c(1,2,3,4,5,6,7,8,9,10) +x1 <- c(100,50,100,100,50,80,75,65,90,90) # Miles Traveled +x2 <- c(4,3,4,2,2,2,3,4,3,2) # Number of Deliveries +y <- c(9.3,4.8,8.9,6.5,4.2,6.2,7.4,6.0,7.6,6.1) # Travel Time (hours) + +DF <- data.frame(driving_assignment, x1, x2, y) + +model <- lm(y ~ x1 + x2, data = DF) +summ <- summary(model) + +SSR <- 21.6252 # Sum of Squares due to Regression + +SSE <- 2.2952 # Sum of Squares due to Error + +n <- nrow(DF) # Total Observations + +p <- 2 # Number of Independent Variables + +MSR <- SSR / p # Mean Square due to Regression + +cat("Value of MSR is",MSR) + +MSE <- SSE / (n - p - 1) # Mean Square due to Error + +# F Test + +fval <- summ$fstatistic[1] + +alpha <- 0.01 + +# Upper Tail Test + +# P-value Approach + +pval <- summ$coefficients[11] + +if(pval >= alpha) +{ + cat("Since pval",pval,"is greater than or equal to 0.01 therefore we cannot reject the Null Hypothesis") +} else{ + cat("Since pval",pval,"is less than 0.01 therefore we can reject the Null Hypothesis") + +} + +s <- summ$sigma # Standard Error of the Estimate + +cat("Value of Standard Error of the Estimate is",s) + +coeff <- as.data.frame(summ$coefficients) + +b1 <- coeff$Estimate[2] +b2 <- coeff$Estimate[3] + +s1 <- coeff$`Std. Error`[2] # Standard Error of the x1 (Miles Traveled) +s2 <- coeff$`Std. Error`[3] # Standard Error of the x2 (Number of Deliveries) + +df <- n - p - 1 # Degrees of Freedom + +# T Test + +tval1 <- round(b1 / s1, 3) +tval2 <- round(b2 / s2, 3) + +# Upper Tail Test + +# P-value Approach + +pval1 <- round(pt(tval1, df, lower.tail = F),5) +pval2 <- round(pt(tval2, df, lower.tail = F),5) + + +if(pval1 >= alpha && pval2 >= alpha) +{ + cat("Since pval1",pval1,"and pval2",pval2,"is greater than or equal to 0.01 therefore we cannot reject the + Null Hypothesis") +} else{ + cat("Since pval1",pval1,"and pval2",pval2,"is less than 0.01 therefore we can reject the Null Hypothesis") + +} + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.5a/Ex15_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.5a/Ex15_5a.R new file mode 100644 index 00000000..711ccccb --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.5a/Ex15_5a.R @@ -0,0 +1,50 @@ + # Page no. : 668 - 671 + +# Categorical Independent Variables + +service <- c(1:10) +month <- c(2,6,8,3,2,7,9,8,4,6) +repair <- c("electrical","mechanical","electrical","mechanical","electrical","electrical", + "mechanical","mechanical","electrical","electrical") +time <- c(2.9, 3.0, 4.8, 1.8, 2.9, 4.9, 4.2, 4.8, 4.4, 4.5) + +DF <- data.frame(service, month, repair, time) + +# With one Independent variable + +regressor <- lm(time ~ month, data = DF) +res <- summary(regressor) + +res + +b0 <- res$coefficients[1] +b1 <- res$coefficients[2] + +cat("Equation is y = ", b0 ,"+",b1,"x1") + +# With Categorical Variable + +DF$repair <- factor(DF$repair, + levels = c('electrical', 'mechanical'), + labels = c(1, 0)) + +regressor <- lm(time ~ month + repair, data = DF) +res <- summary(regressor) + +res + +b0 <- res$coefficients[1] +b1 <- res$coefficients[2] +b2 <- res$coefficients[3] + +# For Electrical Repair + +bterm <- b0 + b2 * 1 + +cat("Equation for electrical is y = ", bterm ,"+",b1,"x1" ) + +# For Mechanical Repair + +bterm2 <- b0 + b2 * 0 + +cat("Equation for mechanical is y = ", bterm2 ,"+",b1,"x1" ) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.6a/Ex15_6a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.6a/Ex15_6a.R new file mode 100644 index 00000000..5ffe5cc8 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.6a/Ex15_6a.R @@ -0,0 +1,40 @@ + # Page no. : 676 - 679 + +# Residual Analysis + +miles <- c(100, 50, 100, 100, 50, 80, 75, 65, 90, 90) +deliveries <- c(4, 3, 4, 2, 2, 2, 3, 4, 3, 2) +time <- c(9.3, 4.8, 8.9, 6.5, 4.2, 6.2, 7.4, 6.0, 7.6, 6.1) + +DF <- data.frame(miles, deliveries, time) + +regressor <- lm(time ~ miles + deliveries, data = DF) +res <- summary(regressor) + +predict <- predict(regressor) +residuals <- DF$time - predict +std_residuals <- rstandard(regressor) + +DF <- cbind(DF, predict, residuals, std_residuals) + +View(DF) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(predict, std_residuals)) + geom_point() + geom_hline(yintercept = 0, + linetype=2) + labs(title = "Plot between predicted values and standardizes residuals", x = + "Prediction", y = "Standardization Residual") + + +leverage <- hatvalues(regressor) +cook_dist <- cooks.distance(regressor) + +DF <- cbind(DF, leverage, cook_dist) + +View(DF) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.6b/Ex15_6b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.6b/Ex15_6b.R new file mode 100644 index 00000000..287af47c --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.6b/Ex15_6b.R @@ -0,0 +1,44 @@ + # Page no. : 679 - 680 + +# Influential Observations + +x <- c(1, 1, 2, 3, 4, 4, 5, 15) +y <- c(18, 21, 22, 21, 23, 24, 26, 39) + +DF <- data.frame(x, y) + +regressor <- lm(y ~ x, data = DF) +res <- summary(regressor) + +lev <- hatvalues(regressor) +DF <- cbind(DF, lev) + +View(DF) + + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(x, y)) + geom_point() + geom_smooth(method = "lm", se = F) + + labs(title = "Plot between x and y", x = "X", y = "Y") + + +cat("Equation is y = ",res$coefficients[1],"+",res$coefficients[2],"x1") + + +# Removing Influential Observation + +x <- c(1, 1, 2, 3, 4, 4, 5) +y <- c(18, 21, 22, 21, 23, 24, 26) + +DF <- data.frame(x, y) + +regressor <- lm(y ~ x, data = DF) +res <- summary(regressor) + +cat("Equation is y = ",res$coefficients[1],"+",res$coefficients[2],"x1") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.7a/Ex15_7a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.7a/Ex15_7a.R new file mode 100644 index 00000000..0c3fa907 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH15/EX15.7a/Ex15_7a.R @@ -0,0 +1,15 @@ + # Page no. : 684 - 686 + +# Logistic Regression + +customer <- c(1,2,3,4,5,6,7,8,9,10) +spending <- c(2.291,3.215,2.135,3.924,2.528,2.473,2.384,7.076,1.182,3.345) +card <- c(1,1,1,0,1,0,0,0,1,0) +coupon <- c(0,0,0,0,0,1,0,0,1,0) + +DF <- data.frame(customer, spending, card, coupon) + +regressor <- glm(coupon ~ spending + card, data = DF) +summary(regressor) + +# Book answer is different \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1a/Ex16_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1a/Ex16_1a.R new file mode 100644 index 00000000..aee57ef1 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1a/Ex16_1a.R @@ -0,0 +1,74 @@ + # Page no. : 714 - 717 + +# General Linear Model + +x <- c(41,106,76,10,22,12,85,111,40,51,9,12,6,56,19) # Months Employed +y <- c(275,296,317,376,162,150,367,308,189,235,83,112,67,325,189) # Scales Sold + +DF <- data.frame(x,y) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF, aes(x,y)) + geom_point() + labs(title = "Scatter Plot between Months + Employed and Scales sold", x = "Months Employed", y = "Scales Sold") + +model <- lm(y ~ x, data = DF) +summary(model) + +b1 <- model$coefficients[1] +b2 <- model$coefficients[2] + +cat("Regression Equation is sales =",b1,"+",b2,"months") +# Book Answer is sales = 111 + 2.38 months (Data is wrongly used in book) + +predicted_scales_sold <- predict(model) + +DF <- cbind(DF, predicted_scales_sold) + +# Standard Residuals + +standard_residuals <- rstandard(model) + +DF <- cbind(DF, standard_residuals) + +ggplot(DF,aes(predicted_scales_sold, standard_residuals)) + geom_point() + + geom_hline(yintercept = 0, linetype=2) + +labs(title = "Scatter Plot between Predicted scales sold and Standard Residuals", + x = "Predicted scales sold", y = "Standard Residuals") + + # Page no. : 716 - 717 + +x2 <- x**2 + +DF2 <- data.frame(x,x2,y) + +model2 <- lm(y ~ x + x2, data = DF2) +summary(model2) + +b1 <- model2$coefficients[1] +b2 <- model2$coefficients[2] +b3 <- model2$coefficients[3] + +cat("Regression Equation is sales =",b1,"+",b2,"months","+",b3,"monthsq") +# Book Answer is sales = 45.3 + 6.34 months - 0.0345 monthsq (Data is wrongly used in book) + +predicted_scales_sold2 <- predict(model2) + +DF2 <- cbind(DF2, predicted_scales_sold2) + +# Standard Residuals + +standard_residuals2 <- rstandard(model2) + +DF2 <- cbind(DF2, standard_residuals2) + +ggplot(DF2,aes(predicted_scales_sold2, standard_residuals2)) + geom_point() + + geom_hline(yintercept = 0, linetype=2) + + labs(title = "Scatter Plot between Predicted scales sold and Standard Residuals", + x = "Predicted scales sold", y = "Standard Residuals") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1b/Ex16_1b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1b/Ex16_1b.R new file mode 100644 index 00000000..ff86c267 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1b/Ex16_1b.R @@ -0,0 +1,32 @@ + # Page no. : 718 - 721 + +# Interaction + +price <- c(2.00, 2.50, 3.00, 2.00, 2.50, 3.00, 2.00, 2.50, 3.00, 2.00, 2.50, 3.00, + 2.00, 2.50, 3.00, 2.00, 2.50, 3.00, 2.00, 2.50, 3.00, 2.00, 2.50, 3.00) +advertising <- c(50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100) +sales <- c(478, 373, 335, 473, 358, 329, 456, 360, 322, 437, 365, 342, 810, 653, 345, 832, 641, + 372, 800, 620, 390, 790, 670, 393) + +DF <- data.frame(price, advertising, sales) + +# Install Library if not install + +# install.packages("dplyr") + +# Import Library + +library(dplyr) + +DF %>% group_by(price,advertising) %>% summarize(Average=mean(sales)) + +model <- lm(sales ~ price + advertising + (price * advertising), data = DF) +res <- summary(model) + +b0 <- res$coefficients[1] +b1 <- res$coefficients[2] +b2 <- res$coefficients[3] +b3 <- res$coefficients[4] + +cat("Equation is sales = ", b0, "+", b1, "Price +",b2, "AdvExp +", b3, "PriAdv") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1c/Ex16_1c.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1c/Ex16_1c.R new file mode 100644 index 00000000..c5648d93 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.1c/Ex16_1c.R @@ -0,0 +1,79 @@ + # Page no. : 721 - 724 + +# Transformations Involving the Dependent Variables + +x <- c(2289,2113,2180,2448,2026,2702,2657,2106,3226,3213,3607,2888) # Weight +y <- c(28.7,29.2,34.2,27.9,33.3,26.4,23.9,30.5,18.1,19.5,14.3,20.9) # Miles Per Gallon + +DF <- data.frame(x,y) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF, aes(x,y)) + geom_point() + labs(title = "Scatter Plot between Weight and Miles + Per Gallon", x = "Weight", y = "Miles Per Gallon") + +model <- lm(y ~ x, data = DF) +summary(model) + +b1 <- model$coefficients[1] +b2 <- model$coefficients[2] + +cat("Regression Equation is sales =",b1,"+",b2,"months") + +# Prediction + +predicted_miles_per_gallon <- predict(model) + +DF <- cbind(DF, predicted_miles_per_gallon) + +# Standard Residuals + +standard_residuals <- rstandard(model) + +DF <- cbind(DF, standard_residuals) + + +ggplot(DF,aes(predicted_miles_per_gallon, standard_residuals)) + geom_point() + + geom_hline(yintercept = 0, linetype=2) + + labs(title = "Scatter Plot between Predicted Miles per Gallon and Standard Residuals", + x = "Predicted Miles per Gallon", y = "Standard Residuals") + +# Log Transformation + +#log_x <- log(x) +log_y <- log(y) + +DF2 <- data.frame(x, log_y) + +options(scipen = 999) # To display not in scientific notation +model <- lm(log_y ~ x, data = DF2) +summary(model) + +b1 <- model$coefficients[1] +b2 <- model$coefficients[2] + +cat("Regression Equation is sales =",b1,"+",b2,"months") + +# Prediction + +predicted_miles_per_gallon <- predict(model) + +DF2 <- cbind(DF2, predicted_miles_per_gallon) + +# Standard Residuals + +standard_residuals <- rstandard(model) + +DF2 <- cbind(DF2, standard_residuals) + + +ggplot(DF2,aes(predicted_miles_per_gallon, standard_residuals)) + geom_point() + + geom_hline(yintercept = 0, linetype=2) + labs(title = "Scatter Plot between Log +Transformation of Predicted Miles per Gallon and Standard Residuals", + x = "Predicted Miles per Gallon", y = "Standard Residuals") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.2a/Ex16_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.2a/Ex16_2a.R new file mode 100644 index 00000000..9aa0bdb8 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.2a/Ex16_2a.R @@ -0,0 +1,56 @@ + # Page no. : 736 - 738 + +# Analysis of a Large Problem + +Sales <- c(3669.88, 3473.95, 2295.10, 4675.56, 6125.96, 2134.94, 5031.66, 3367.45, 6519.45, + 4876.37, 2468.27, 2533.31, 2408.11, 2337.38, 4586.95, 2729.24, 3289.40, 2800.78, + 3264.20, 3453.62, 1741.45, 2035.75, 1578.00, 4167.44, 2799.97) +Time <- c(43.10, 108.13, 13.82, 186.18, 161.79, 8.94, 365.04, 220.32, 127.64, 105.69, 57.72, 23.58, + 13.82, 13.82, 86.99, 165.85, 116.26, 42.28, 52.84, 165.04, 10.57, 13.82, 8.13, 58.44, + 21.14) +Poten <- c(74065.1, 58117.3, 21118.5, 68521.3, 57805.1, 37806.9, 50935.3, 35602.1, 46176.8, 42053.2, + 36829.7, 33612.7, 21412.8, 20416.9, 36272.0, 23093.3, 26878.6, 39572.0, 51866.1, 58749.8, + 23990.8, 25694.9, 23736.3, 34314.3, 22809.5) +AdvExp <- c(4582.9, 5539.8, 2950.4, 2243.1, 7747.1, 402.4, 3140.6, 2086.2, 8846.2, 5673.1, 2761.8, + 1991.8, 1971.5, 1737.4, 10694.2, 8618.6, 7747.9, 4565.8, 6022.7, 3721.1, 861.0, 3571.5, + 2845.5, 5060.1, 3552.0) +Share <- c(2.51, 5.51, 10.91, 8.27, 9.15, 0.15, 8.54, 7.07, 12.54, 8.85, 5.38, 5.43, 8.48, 7.80, + 10.34, 5.15, 6.64, 5.45, 6.31, 6.35, 7.37, 8.39, 5.15, 12.88, 9.14) +Change <- c(0.34, 0.15, -0.72, 0.17, 0.50, 0.15, 0.55, -0.49, 1.24, 0.31, 0.37, -0.65, 0.64, 1.01, + 0.11, 0.04, 0.68, 0.66, -0.10, -0.03, -1.63, -0.43, 0.04, 0.22, -0.74) +Accounts <- c(74.86, 107.32, 96.75, 195.12, 180.44, 104.88, 256.10, 126.83, 203.25, 119.51, 116.26, + 142.28, 89.43, 84.55, 119.51,80.49, 136.58, 78.86, 136.58, 138.21, 75.61, 102.44, + 76.42, 136.58, 88.62) +Work <- c(15.05, 19.97, 17.34, 13.40, 17.64, 16.22, 18.80, 19.86, 17.42, 21.41, 16.32, 14.51, + 19.35, 20.02, 15.26, 15.87, 7.81, 16.00, 17.44, 17.98, 20.99, 21.66, 21.46, 24.78, + 24.96) +Rating <- c(4.9, 5.1, 2.9, 3.4, 4.6, 4.5, 4.6, 2.3, 4.9, 2.8, 3.1, 4.2, 4.3, 4.2, 5.5, 3.6, 3.4, + 4.2, 3.6, 3.1, 1.6, 3.4, 2.7, 2.8, 3.9) + +DF <- data.frame(Sales, Time, Poten, AdvExp, Share, Change, Accounts, Work, Rating) +View(DF) + +library(corrplot) + +matrix <- round(cor(DF), 3) +matrix + +regressor <- lm(Sales ~ Time + Poten + AdvExp + Share + Change + Accounts + Work + Rating, + data = DF) +summary(regressor) + +cat("Equation is Sales = ",regressor$coefficients[1],"+",regressor$coefficients[2],"Time +", + regressor$coefficients[3],"Poten +",regressor$coefficients[4],"AdvExp +",regressor$coefficients[5], + "Share +",regressor$coefficients[6],"Change +",regressor$coefficients[7],"Accounts +", + regressor$coefficients[8],"Work +",regressor$coefficients[8],"Rating") + +# Book Answer is different + +regressor2 <- lm(Sales ~ Poten + AdvExp + Share, data = DF) +summary(regressor2) + +cat("Equation is Sales = ",regressor2$coefficients[1],"+",regressor2$coefficients[3],"Poten +", + regressor2$coefficients[4],"AdvExp +",regressor2$coefficients[5], + "Share") + +# Book Answer is different \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.3a/Ex16_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.3a/Ex16_3a.R new file mode 100644 index 00000000..919e091e --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH16/EX16.3a/Ex16_3a.R @@ -0,0 +1,21 @@ + # Page no. : 745 - 747 + +# Multiple Regression Approach to Experimental Design + +A <- c(58,64,55,66,67) +B <- c(58,69,71,64,68) +C <- c(48,57,59,47,49) + +DF <- data.frame(A,B,C) + +newA <- c(1,1,1,1,1,0,0,0,0,0,0,0,0,0,0) +newB <- c(0,0,0,0,0,1,1,1,1,1,0,0,0,0,0) +y <- c(58,64,55,66,67,58,69,71,64,68,48,57,59,47,49) + +DF2 <- data.frame(newA, newB, y) + +regressor <- lm(y ~ newA + newB, data = DF2) +summary(regressor) + +cat("Equation is y = ",regressor$coefficients[1],"+",regressor$coefficients[2],"A +", + regressor$coefficients[3],"B") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.1a/Ex17_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.1a/Ex17_1a.R new file mode 100644 index 00000000..e7b485b4 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.1a/Ex17_1a.R @@ -0,0 +1,18 @@ + # Page no. : 765 + +# Price Relatives + +year <- c(1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008) + +price_per_gallon <- c(1.30, 1.10,1.09,1.07,1.08,1.11,1.22,1.20,1.03,1.14,1.48,1.42,1.34,1.56,1.85,2.27,2.57,2.80,3.25) + +DF <- data.frame(year,price_per_gallon) + +base_year <- 1990 +base_year_price <- DF$price_per_gallon[DF$year == base_year] + +price_relative <- round(((DF$price_per_gallon) / (base_year_price)) * 100, 2) + +DF <- cbind(DF, price_relative) + +View(DF) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.2a/Ex17_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.2a/Ex17_2a.R new file mode 100644 index 00000000..fdb24859 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.2a/Ex17_2a.R @@ -0,0 +1,29 @@ + # Page no. : 766 + +# Aggregate Price Indexes + +item <- c("Gallon of gasoline","Quart of oil","Tire","Insurance policy") +year_1990 <- c(1.30,2.10,130.00,820.00) +year_2008 <- c(3.25,8.00,140.00,1030.00) +quantity <- c(1000,15,2,1) + +DF <- data.frame(item,year_1990,year_2008,quantity) + +base_year <- 1990 + +sum_of_1990_items <- sum(DF$year_1990) + +sum_of_2008_items <- sum(DF$year_2008) + +aggregate_index_2008 <- (sum_of_2008_items / sum_of_1990_items) * 100 + +cat("The unweighted aggregate index for year 2008 is",aggregate_index_2008) + + +sum_of_1990_items <- sum(DF$year_1990 * DF$quantity) # Weighted Sum + +sum_of_2008_items <- sum(DF$year_2008 * DF$quantity) # Weighted Sum + +aggregate_index_2008 <- (sum_of_2008_items / sum_of_1990_items) * 100 + +cat("The weighted aggregate index for year 2008 is",aggregate_index_2008) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.3a/Ex17_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.3a/Ex17_3a.R new file mode 100644 index 00000000..bbbf6eb0 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.3a/Ex17_3a.R @@ -0,0 +1,24 @@ + # Page no. : 769 - 770 + +# Computing an Aggregate Price Index from Price Relatives + +item <- c("Gallon of gasoline","Quart of oil","Tire","Insurance policy") +year_1990 <- c(1.30,2.10,130.00,820.00) +year_2008 <- c(3.25,8.00,140.00,1030.00) +quantity <- c(1000,15,2,1) + +DF <- data.frame(item,year_1990,year_2008,quantity) + +base_year <- 1990 + +price_relative <- (DF$year_2008 / DF$year_1990) * 100 + +weight <- DF$year_1990 * DF$quantity + +weight_price_relative <- price_relative * weight + +DF <- cbind(DF, price_relative, weight, weight_price_relative) + +aggregate_2008 <- sum(DF$weight_price_relative) / sum(DF$weight) + +cat("Aggregate Price Index for year 2008 is",aggregate_2008) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.4a/Ex17_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.4a/Ex17_4a.R new file mode 100644 index 00000000..24451ec7 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH17/EX17.4a/Ex17_4a.R @@ -0,0 +1,29 @@ + # Page no. : 774 + +# Deflating a Series by Price Indexes + +year <- c(2004,2005,2006,2007,2008) +hourly_wage <- c(15.69,16.12,16.76,17.45,18.07) +CPI <- c(188.9,195.3,201.6,207.3,215.3) + +DF <- data.frame(year, hourly_wage, CPI) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF, aes(year, hourly_wage)) + geom_line() + geom_point() + + labs(title = "Year V/S Hourly Wage Graph", x = "Year", y = "Hourly Wage") + + +deflated_hourly_wage <- (DF$hourly_wage / DF$CPI) * 100 + +DF <- cbind(DF, deflated_hourly_wage) + +ggplot(DF, aes(year, deflated_hourly_wage)) + geom_line() + geom_point() + + ylim(c(7.75,9.0)) + + labs(title = "Year V/S Real Hourly Wage Graph", x = "Year", y = "Real Hourly Wage") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1a/Ex18_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1a/Ex18_1a.R new file mode 100644 index 00000000..a5ebcfc7 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1a/Ex18_1a.R @@ -0,0 +1,19 @@ + # Page no. : 786 - 787 + +# Time Series Patterns + +week <- c(1,2,3,4,5,6,7,8,9,10,11,12) +sales <- c(17,21,19,23,18,16,20,18,22,20,15,22) + +DF <- data.frame(week,sales) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(week,sales)) + geom_line() + geom_point() + ylim(c(0,25)) + labs(title = + "Week V/S Sales Time Series Plot", x = "Weeks", y = "Sales") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1b/Ex18_1b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1b/Ex18_1b.R new file mode 100644 index 00000000..bdb3c6ad --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1b/Ex18_1b.R @@ -0,0 +1,19 @@ + # Page no. : 787 - 788 + +# Time Series Patterns Eg-2 + +week <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22) +sales <- c(17,21,19,23,18,16,20,18,22,20,15,22,31,34,31,33,28,32,30,29,34,33) + +DF <- data.frame(week,sales) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(week,sales)) + geom_line() + geom_point() + ylim(c(0,40)) + +labs(title = "Week V/S Sales Time Series Plot", x = "Weeks", y = "Sales") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1c/Ex18_1c.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1c/Ex18_1c.R new file mode 100644 index 00000000..67c1c27d --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1c/Ex18_1c.R @@ -0,0 +1,19 @@ + # Page no. : 788 - 789 + +# Time Series Patterns Eg-3 + +year <- c(1,2,3,4,5,6,7,8,9,10) +sales <- c(21.6,22.9,25.5,21.9,23.9,27.5,31.5,29.7,28.6,31.4) + +DF <- data.frame(year,sales) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year,sales)) + geom_line() + geom_point() + ylim(c(20,34)) + + labs(title = "Years V/S Sales Time Series Plot", x = "Years", y = "Sales") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1d/Ex18_1d.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1d/Ex18_1d.R new file mode 100644 index 00000000..a6a8f690 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1d/Ex18_1d.R @@ -0,0 +1,19 @@ + # Page no. : 789 - 790 + +# Time Series Patterns Eg-4 + +year <- c(1,2,3,4,5,6,7,8,9,10) +revenue <- c(23.1,21.3,27.4,34.6,33.8,43.2,59.5,64.4,74.2,99.3) + +DF <- data.frame(year,revenue) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year,revenue)) + geom_line() + geom_point() + ylim(c(0,120)) + + labs(title = "Years V/S Revenue Time Series Plot", x = "Years", y = "Revenue") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1e/Ex18_1e.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1e/Ex18_1e.R new file mode 100644 index 00000000..f967a8bf --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1e/Ex18_1e.R @@ -0,0 +1,22 @@ + # Page no. : 790 - 791 + +# Time Series Patterns Eg-5 + +year_quart <- c("Y1 Q1", "Y1 Q2", "Y1 Q3", "Y1 Q4", "Y2 Q1", "Y2 Q2", "Y2 Q3", "Y2 Q4", "Y3 Q1", + "Y3 Q2", "Y3 Q3", "Y3 Q4", "Y4 Q1", "Y4 Q2", "Y4 Q3", "Y4 Q4", "Y5 Q1", "Y5 Q2", + "Y5 Q3", "Y5 Q4") # Years and Quarters +sales <- c(125, 153, 106, 88, 118, 161, 133, 102, 138, 144, 113, 80, 109, 137, 125, 109, 130, 165, + 128, 96) + +DF <- data.frame(year_quart, sales) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year_quart,sales, group = 1)) + geom_line() + geom_point() + ylim(c(0,180)) + + labs(title = "Years/quart V/S Sales Time Series Plot", x = "Year/Quarter", y = "Sales") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1f/Ex18_1f.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1f/Ex18_1f.R new file mode 100644 index 00000000..ed81587a --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.1f/Ex18_1f.R @@ -0,0 +1,21 @@ + # Page no. : 791 - 792 + +# Time Series Patterns Eg-6 + +year_quart <- c("Y1 Q1", "Y1 Q2", "Y1 Q3", "Y1 Q4", "Y2 Q1", "Y2 Q2", "Y2 Q3", "Y2 Q4", "Y3 Q1", + "Y3 Q2", "Y3 Q3", "Y3 Q4", "Y4 Q1", "Y4 Q2", "Y4 Q3", "Y4 Q4") + # Years and Quarters +sales <- c(4.8, 4.1, 6.0, 6.5, 5.8, 5.2, 6.8, 7.4, 6.0, 5.6, 7.5, 7.8, 6.3, 5.9, 8.0, 8.4) + +DF <- data.frame(year_quart, sales) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year_quart,sales, group = 1)) + geom_line() + geom_point() + ylim(c(0.0,9.0)) + + labs(title = "Years/quart V/S Sales Time Series Plot", x = "Year/Quarter", y = "Sales") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.2a/Ex18_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.2a/Ex18_2a.R new file mode 100644 index 00000000..2a267a6d --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.2a/Ex18_2a.R @@ -0,0 +1,93 @@ + # Page no. : 793 - 795 + +# Forecast Accuracy + +week <- c(1,2,3,4,5,6,7,8,9,10,11,12) +sales <- c(17,21,19,23,18,16,20,18,22,20,15,22) +forcast <- c(NA,17,21,19,23,18,16,20,18,22,20,15) + +DF <- data.frame(week,sales,forcast) + +forcast_error <- DF$sales - DF$forcast + +absolute_forecast_error <- abs(forcast_error) + +square_absolute_forcast_error <- absolute_forecast_error**2 + +percent_error <- round((forcast_error / DF$sales) * 100, 2) + +absolute_percent_error <- abs(percent_error) + +DF <- cbind(DF,forcast_error,absolute_forecast_error,square_absolute_forcast_error, + percent_error,absolute_percent_error) + +View(DF) + +total_forcast_error <- sum(DF$forcast_error, na.rm = T) + +total_absolute_forcast_error <- sum(DF$absolute_forecast_error, na.rm = T) + +total_sq_abs_error <- sum(DF$square_absolute_forcast_error, na.rm = T) + +total_percent_error <- sum(DF$percent_error, na.rm = T) + +total_absolute_percent_error <- sum(DF$absolute_percent_error, na.rm = T) + +# Native Value + +MAE <- round(total_absolute_forcast_error / (nrow(DF)-1), 2) # Not including 1st row +# Mean Absolute Error + +MSE <- round(total_sq_abs_error / (nrow(DF)-1), 2) # Not including 1st row +# Mean Square Error + +MAPE <- round(total_absolute_percent_error / (nrow(DF)-1), 2) # Not including 1st row +# Mean Absolute Percent Error + +cat("Value of MAE is",MAE) +cat("Value of MSE is",MSE) +cat("Value of MAPE is",MAPE) + +# Average of Past Values + +forcast2 <- c(NA,17.00,19.00,19.00,20.00,19.60,19.00,19.14,19.00,19.33,19.40,19.00) + +DF2 <- data.frame(week,sales,forcast2) + +forcast_error2 <- DF2$sales - DF2$forcast2 + +absolute_forecast_error2 <- abs(forcast_error2) + +square_absolute_forcast_error2 <- absolute_forecast_error2**2 + +percent_error2 <- round((forcast_error2 / DF2$sales) * 100, 2) + +absolute_percent_error2 <- abs(percent_error2) + +DF2 <- cbind(DF2,forcast_error2,absolute_forecast_error2,square_absolute_forcast_error2, + percent_error2,absolute_percent_error2) + +View(DF2) + +total_forcast_error2 <- sum(DF2$forcast_error2, na.rm = T) + +total_absolute_forcast_error2 <- sum(DF2$absolute_forecast_error2, na.rm = T) + +total_sq_abs_error2 <- sum(DF2$square_absolute_forcast_error2, na.rm = T) + +total_percent_error2 <- sum(DF2$percent_error2, na.rm = T) + +total_absolute_percent_error2 <- sum(DF2$absolute_percent_error2, na.rm = T) + +MAE2 <- round(total_absolute_forcast_error2 / (nrow(DF2)-1), 2) # Not including 1st row +# Mean Absolute Error + +MSE2 <- round(total_sq_abs_error2 / (nrow(DF2)-1), 2) # Not including 1st row +# Mean Square Error + +MAPE2 <- round(total_absolute_percent_error2 / (nrow(DF2)-1), 2) # Not including 1st row +# Mean Absolute Percent Error + +cat("Value of MAE is",MAE2) +cat("Value of MSE is",MSE2) +cat("Value of MAPE is",MAPE2) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.3a/Ex18_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.3a/Ex18_3a.R new file mode 100644 index 00000000..3a35f327 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.3a/Ex18_3a.R @@ -0,0 +1,39 @@ + # Page no. : 798 - 799 + +# Moving Averages + +week <- c(1,2,3,4,5,6,7,8,9,10,11,12) +sales <- c(17,21,19,23,18,16,20,18,22,20,15,22) +forcast <- c(NA,NA,NA,19,21,20,19,18,18,20,20,19) + +DF <- data.frame(week,sales,forcast) + +forcast_error <- DF$sales - DF$forcast + +absolute_forecast_error <- abs(forcast_error) + +square_absolute_forcast_error <- absolute_forecast_error**2 + +percent_error <- round((forcast_error / DF$sales) * 100, 2) + +absolute_percent_error <- abs(percent_error) + +DF <- cbind(DF,forcast_error,absolute_forecast_error,square_absolute_forcast_error, + percent_error,absolute_percent_error) + +View(DF) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(week)) + geom_line(aes(y = forcast), color = "red")+ + geom_line(aes(y = sales), color = "blue") + geom_point(aes(y = forcast)) + + geom_point(aes(y = sales))+ + ylim(c(0,25)) + + labs(title = "Week V/S Sales Time Series Plot", x = "Week", y = "Sales") + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.3b/Ex18_3b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.3b/Ex18_3b.R new file mode 100644 index 00000000..4fb4405c --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.3b/Ex18_3b.R @@ -0,0 +1,28 @@ + # Page no. : 802 - 803 + +# Exponential Smoothing + +week <- c(1,2,3,4,5,6,7,8,9,10,11,12) +sales <- c(17,21,19,23,18,16,20,18,22,20,15,22) +forcast <- c(NA,17.00,17.80, 18.04, 19.03, 18.83, 18.26, 18.61, 18.49, 19.19, 19.35, 18.48) +forcast_error <- sales - forcast +forcast_error_sq <- (forcast_error)**2 + +DF <- data.frame(week, sales, forcast, forcast_error, forcast_error_sq) + +View(DF) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + + ggplot(DF,aes(week)) + geom_line(aes(y = forcast), color = "red")+ + geom_line(aes(y = sales), color = "blue") + geom_point(aes(y = forcast)) + + geom_point(aes(y = sales))+ + ylim(c(0,25)) + + labs(title = "Week V/S Sales Time Series Plot", x = "Week", y = "Sales") + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4a/Ex18_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4a/Ex18_4a.R new file mode 100644 index 00000000..97d87597 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4a/Ex18_4a.R @@ -0,0 +1,24 @@ + # Page no. : 807 - 808 + +# Trend Projection + +year <- c(1,2,3,4,5,6,7,8,9,10) +sales <- c(21.6,22.9,25.5,21.9,23.9,27.5,31.5,29.7,28.6,31.4) + +DF <- data.frame(year,sales) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year,sales)) + geom_line() + geom_point() + ylim(c(20,34)) + + labs(title = "Years V/S Sales Time Series Plot", x = "Years", y = "Sales") + +ggplot(DF,aes(year,sales)) + geom_line() + geom_point() + ylim(c(20,34)) + + geom_smooth(method = "lm", se = F) + + labs(title = "Years V/S Sales Time Series and Linear Function Plot", x = "Years", y = "Sales") + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4b/Ex18_4b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4b/Ex18_4b.R new file mode 100644 index 00000000..73ef16de --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4b/Ex18_4b.R @@ -0,0 +1,35 @@ + # Page no. : 809 - 812 + +# Trend Projection Part-2 + +year <- c(1,2,3,4,5,6,7,8,9,10) +sales <- c(21.6,22.9,25.5,21.9,23.9,27.5,31.5,29.7,28.6,31.4) +forcast <- c(21.5,22.6,23.7,24.8,25.9,27.0,28.1,29.2,30.3,31.4) + +DF <- data.frame(year,sales,forcast) + +regressor <- lm(sales ~ year, data = DF) + +cat("Linear Trend Equation is T =",regressor$coefficients[1],"+",regressor$coefficients[2],"t") + +res <- anova(regressor) + +cat("MSE is ",res$`Sum Sq`[2]/10) + +cat("MSE is ",res$`Mean Sq`[2]) + +regressor +res + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year,sales)) + geom_line() + geom_point() + ylim(c(20,34)) + + geom_smooth(method = "lm", se = F) + + labs(title = "Years V/S Sales Time Series Plot", x = "Years", y = "Sales") + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4c/Ex18_4c.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4c/Ex18_4c.R new file mode 100644 index 00000000..90f96bf4 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.4c/Ex18_4c.R @@ -0,0 +1,28 @@ + # Page no. : 814 - 816 + +# Nonlinear Trend Regression + +year <- c(1,2,3,4,5,6,7,8,9,10) +revenue <- c(23.1,21.3,27.4,34.6,33.8,43.2,59.5,64.4,74.2,99.3) +year_sq <- year**2 + +DF <- data.frame(year,revenue,year_sq) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year,revenue)) + geom_line() + geom_point() + ylim(c(0,120)) + + labs(title = "Years V/S Revenue Time Series Plot", x = "Year", y = "Revenue") + +regressor <- lm(revenue ~ year + year_sq, data = DF) +summary(regressor) +anova(regressor) + +ggplot(DF,aes(year,revenue)) + geom_line() + geom_point() + ylim(c(0,120)) + geom_smooth(method = + "lm", se = F) + + labs(title = "Years V/S Revenue Time Series Plot", x = "Year", y = "Revenue") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.5a/Ex18_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.5a/Ex18_5a.R new file mode 100644 index 00000000..b5ccfe50 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.5a/Ex18_5a.R @@ -0,0 +1,39 @@ + # Page no. : 821 - 822 + +# Seasonality Without Trend + +year_quart <- c("Y1 Q1", "Y1 Q2", "Y1 Q3", "Y1 Q4", "Y2 Q1", "Y2 Q2", "Y2 Q3", "Y2 Q4", "Y3 Q1", + "Y3 Q2", "Y3 Q3", "Y3 Q4", "Y4 Q1", "Y4 Q2", "Y4 Q3", "Y4 Q4", "Y5 Q1", "Y5 Q2", + "Y5 Q3", "Y5 Q4") # Years and Quarters +sales <- c(125, 153, 106, 88, 118, 161, 133, 102, 138, 144, 113, 80, 109, 137, 125, 109, 130, 165, + 128, 96) + +DF <- data.frame(year_quart, sales) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year_quart,sales, group = 1)) + geom_line() + geom_point() + ylim(c(0,180)) + + labs(title = "Years/quart V/S Sales Time Series Plot", x = "Year/Quarter", y = "Sales") + + +q1 <- c(1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0) +q2 <- c(0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0) +q3 <- c(0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0) + +DF <- cbind(DF,q1,q2,q3) + +regressor <- lm(sales ~ q1 + q2 + q3, data = DF) +summary(regressor) + +b0 <- regressor$coefficients[1] +b1 <- regressor$coefficients[2] +b2 <- regressor$coefficients[3] +b3 <- regressor$coefficients[4] + +cat("Equation is sales = ",b0,"+",b1,"Qtr1 +",b2,"Qtr2 +",b3,"Qtr3") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.5b/Ex18_5b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.5b/Ex18_5b.R new file mode 100644 index 00000000..ab0e0032 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.5b/Ex18_5b.R @@ -0,0 +1,39 @@ + # Page no. : 823 - 824 + +# Seasonality and Trend + +year_quart <- c("Y1 Q1", "Y1 Q2", "Y1 Q3", "Y1 Q4", "Y2 Q1", "Y2 Q2", "Y2 Q3", "Y2 Q4", "Y3 Q1", + "Y3 Q2", "Y3 Q3", "Y3 Q4", "Y4 Q1", "Y4 Q2", "Y4 Q3", "Y4 Q4") +# Years and Quarters +sales <- c(4.8, 4.1, 6.0, 6.5, 5.8, 5.2, 6.8, 7.4, 6.0, 5.6, 7.5, 7.8, 6.3, 5.9, 8.0, 8.4) + +DF <- data.frame(year_quart, sales) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year_quart,sales, group = 1)) + geom_line() + geom_point() + ylim(c(0.0,9.0)) + + labs(title = "Years/quart V/S Sales Time Series Plot", x = "Year/Quarter", y = "Sales") + +q1 <- c(1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0) +q2 <- c(0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0) +q3 <- c(0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0) +period <- c(1:16) + +DF <- cbind(DF,q1,q2,q3,period) + +regressor <- lm(sales ~ q1 + q2 + q3 + period, data = DF) +summary(regressor) + +b0 <- regressor$coefficients[1] +b1 <- regressor$coefficients[2] +b2 <- regressor$coefficients[3] +b3 <- regressor$coefficients[4] +b4 <- regressor$coefficients[5] + +cat("Equation is sales = ",b0,"+",b1,"Qtr1 +",b2,"Qtr2 +",b3,"Qtr3 +",b4,"t") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.6a/Ex18_6a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.6a/Ex18_6a.R new file mode 100644 index 00000000..5166f3d6 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.6a/Ex18_6a.R @@ -0,0 +1,30 @@ + # Page no. : 832 - 833 + +# Time Series Decomposition + +year_quart <- c("Y1 Q1", "Y1 Q2", "Y1 Q3", "Y1 Q4", "Y2 Q1", "Y2 Q2", "Y2 Q3", "Y2 Q4", "Y3 Q1", + "Y3 Q2", "Y3 Q3", "Y3 Q4", "Y4 Q1", "Y4 Q2", "Y4 Q3", "Y4 Q4") +# Years and Quarters +sales <- c(4.8, 4.1, 6.0, 6.5, 5.8, 5.2, 6.8, 7.4, 6.0, 5.6, 7.5, 7.8, 6.3, 5.9, 8.0, 8.4) +moving_avg <- c(NA,5.350,5.600,5.875,6.075,6.300,6.350,6.450,6.625,6.725,6.800,6.875,7.000, + 7.15,NA,NA) +centered_avg <- c(NA,NA,5.475,5.738,5.975,6.188,6.325,6.400,6.538,6.675,6.763,6.838,6.938,7.075, + NA,NA) + +DF <- data.frame(year_quart, sales,moving_avg,centered_avg) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year_quart, group = 1)) + geom_line(aes(y = sales),color = "red") + + geom_point(aes(y = sales)) + geom_line(aes(y = centered_avg),color = "blue") + + geom_point(aes(y = centered_avg))+ + ylim(c(0.0,9.0)) + + labs(title = "Years/quart V/S Sales Time Series Plot", x = "Year/Quarter", y = "Sales") + + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.6b/Ex18_6b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.6b/Ex18_6b.R new file mode 100644 index 00000000..be924484 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH18/EX18.6b/Ex18_6b.R @@ -0,0 +1,36 @@ + # Page no. : 835 - 836 + +# Deseasonalizing the Time Series + +year_quart <- c("Y1 Q1", "Y1 Q2", "Y1 Q3", "Y1 Q4", "Y2 Q1", "Y2 Q2", "Y2 Q3", "Y2 Q4", "Y3 Q1", + "Y3 Q2", "Y3 Q3", "Y3 Q4", "Y4 Q1", "Y4 Q2", "Y4 Q3", "Y4 Q4") +# Years and Quarters +period <- c(1:16) +sales <- c(4.8, 4.1, 6.0, 6.5, 5.8, 5.2, 6.8, 7.4, 6.0, 5.6, 7.5, 7.8, 6.3, 5.9, 8.0, 8.4) +index <- c(0.93,0.84,1.09,1.14,0.93,0.84,1.09,1.14,0.93,0.84,1.09,1.14,0.93,0.84,1.09,1.14) +deseasonalized_sales <- c(5.16,4.88,5.50,5.70,6.24,6.19,6.24,6.49,6.45,6.67,6.88,6.84,6.77, + 7.02,7.34,7.37) + +DF <- data.frame(year_quart,period,sales,index,deseasonalized_sales) + +# Install Library if not installed + +# install.packages("gpplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF,aes(year_quart,deseasonalized_sales, group = 1)) + geom_line() + geom_point() + + ylim(c(0.0,9.0)) + + labs(title = "Years/quart V/S Deseasonalized Sales Time Series Plot", x = "Year/Quarter", + y = "Deseasonalized Sales") + +regressor <- lm(deseasonalized_sales ~ period, data = DF) +summary(regressor) +anova(regressor) + +b0 <- regressor$coefficients[1] +b1 <- regressor$coefficients[2] + +cat("Equation is deseasonalized sales = ",b0,"+",b1,"Period") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.1a/Ex19_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.1a/Ex19_1a.R new file mode 100644 index 00000000..1cc704b3 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.1a/Ex19_1a.R @@ -0,0 +1,43 @@ + # Page no. : 887 - 889 + +# Rank Correlation + +sales_person <- c('A','B','C','D','E','F','G','H','I','J') +x <- c(2,4,7,1,6,3,10,9,8,5) # Ranking of Potential +y <- c(400,360,300,295,280,350,200,260,220,385) # Two Years Sales +z <- c(1,3,5,6,7,4,10,8,9,2) # Ranking According to y + +DF <- data.frame(sales_person,x,y,z) + +d <- DF$x - DF$z +d_sq <- d**2 + +DF <- cbind(DF,d,d_sq) + +total_d_sq <- sum(DF$d_sq) + +n <- nrow(DF) + +r_s <- 1 - ((6 * total_d_sq)/(n * (n**2 + 1))) # Spearman Rank-Correlation Coefficient + +mean_rs <- 0 + +sigma_rs <- sqrt(1 / (n - 1)) + +z_val <- (r_s - mean_rs) / sigma_rs + +alpha <- 0.05 + +# Two Tail Test + +# P-value Approach + +pval <- 2 * pnorm(z_val,lower.tail = F) + +if(pval >= alpha) +{ + cat("Since pval",pval,"is greater than or equal to 0.05 therefore we cannot reject the Null Hypothesis") +} else{ + cat("Since pval",pval,"is less than 0.05 therefore we can reject the Null Hypothesis") +} + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.2a/Ex19_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.2a/Ex19_2a.R new file mode 100644 index 00000000..3bf1d0ec --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.2a/Ex19_2a.R @@ -0,0 +1,59 @@ + # Page no. : 858 - 861 + +# Sign Test + +store <- c(56, 19, 36, 128, 12, 63, 39, 84, 102, 44) +sales <- c(485, 562, 415, 860, 426, 474, 662, 380, 515, 721) + +DF <- data.frame(store, sales) + +median <- 450 +sign <- c() + +for (i in 1:nrow(DF)) { + if(DF$sales[i] >= median) + { + sign[i] = "+" + }else + { + sign[i] <- "-" + } +} + +DF <- cbind(DF,sign) +View(DF) + +positive <- table(DF$sign)[[2]] +n <- nrow(DF) + +test <- binom.test(positive, n) +test + +if(test$p.value >= 0.05) +{ + cat("We cannot reject null hypothesis") +} else +{ + cat("We can reject null hypothesis") +} + + +N <- 60 +n1 <- 22 # "+ sign +n2 <- 38 # "- sign +med <- 236000 + +mean <- 0.50 * N +sd <- sqrt(0.25 * N) + +CF <- 22.5 # Correction Factor + +p <- pnorm(CF, mean = mean, sd = sd) + +if(p >= 0.05) +{ + cat("We cannot reject null hypothesis") +} else +{ + cat("We can reject null hypothesis") +} diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.3a/Ex19_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.3a/Ex19_3a.R new file mode 100644 index 00000000..2b00ec97 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.3a/Ex19_3a.R @@ -0,0 +1,22 @@ + # Page no. : 866 - 868 + +# Wilcoxon Signed - Rank Test + +worker <- c(1:11) +A <- c(10.2, 9.6, 9.2, 10.6, 9.9, 10.2, 10.6, 10.0, 11.2, 10.7, 10.6) +B <- c(9.5, 9.8, 8.8, 10.1, 10.3, 9.3, 10.5, 10.0, 10.6, 10.2, 9.8) + +DF <- data.frame(worker, A, B) + +options(warn = -1) + +test <- wilcox.test(DF$A, DF$B, paired = T) +test + +if(test$p.value >= 0.05) +{ + cat("We cannot reject null hypothesis") +} else +{ + cat("We can reject null hypothesis") +} diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.4a/Ex19_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.4a/Ex19_4a.R new file mode 100644 index 00000000..f49476ff --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.4a/Ex19_4a.R @@ -0,0 +1,20 @@ + # Page no. : 873 - 875 + +# Mann - Whitney - Wilcoxon - Test + +college <- c(1:4) +m1 <- c(15,3,23,8) + +high <- c(1:5) +m2 <- c(18,20,32,9,25) + +test <- wilcox.test(m1, m2, correct = F) +test + +if(test$p.value >= 0.05) +{ + cat("We cannot reject null hypothesis") +} else +{ + cat("We can reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.4b/Ex19_4b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.4b/Ex19_4b.R new file mode 100644 index 00000000..bf442e33 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.4b/Ex19_4b.R @@ -0,0 +1,20 @@ + # Page no. : 876-878 + +# Mann - Whitney - Wilcoxon - Test Eg - 2 + +account1 <- c(1:12) +account2 <- c(1:10) + +balance1 <- c(1095, 955, 1200, 1195, 925, 950, 805, 945, 875, 1055, 1025, 975) +balance2 <- c(885, 850, 915, 950, 800, 750, 865, 1000, 1050, 935) + +test <- wilcox.test(balance1, balance2, correct = F) +test + +if(test$p.value >= 0.05) +{ + cat("We cannot reject null hypothesis") +} else +{ + cat("We can reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.5a/Ex19_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.5a/Ex19_5a.R new file mode 100644 index 00000000..5e411049 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH19/EX19.5a/Ex19_5a.R @@ -0,0 +1,20 @@ + # Page no. : 883 - 884 + +# Kruskal - Wallis Test + +A <- c(25, 70, 60, 85, 95, 90, 80) +B <- c(60, 20, 30, 15, 40, 35) +C <- c(50, 70, 60, 80, 90, 70, 75) + +x <- list(A,B,C) + +test <- kruskal.test(x) +test + +if(test$p.value >= 0.05) +{ + cat("We cannot reject null hypothesis") +} else +{ + cat("We can reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.1a/Ex2_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.1a/Ex2_1a.R new file mode 100644 index 00000000..3d3f25a9 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.1a/Ex2_1a.R @@ -0,0 +1,49 @@ + # Page no. : 33 + +# Frequency Distribution (Categorical Data) + +# Dataset + +soft_drink_names <- c("Coke Classic", "Diet Coke", "Pepsi", "Diet Coke", "Coke Classic","Coke Classic", + "Dr. Pepper", "Diet Coke", "Pepsi", "Pepsi" , "Coke Classic", "Dr. Pepper", + "Sprite", "Coke Classic", "Diet Coke", "Coke Classic", "Coke Classic", "Sprite", + "Coke Classic", "Diet Coke", "Coke Classic", "Diet Coke", "Coke Classic", "Sprite", + "Pepsi", "Coke Classic", "Coke Classic", "Coke Classic", "Pepsi", "Coke Classic", + "Sprite", "Dr. Pepper", "Pepsi", "Diet Coke", "Pepsi", "Coke Classic", + "Coke Classic", "Coke Classic", "Pepsi", "Dr. Pepper", "Coke Classic", "Diet Coke", + "Pepsi", "Pepsi", "Pepsi", "Pepsi", "Coke Classic", "Dr. Pepper", "Pepsi", "Sprite") + +soft_drink_table <- data.frame(table(soft_drink_names)) + + # Page no. : 34 + +FD <- data.frame(Soft_drinks = soft_drink_table$soft_drink_names, + Frequency = soft_drink_table$Freq) # Frequency Distribution + + +RF <- FD$Frequency / sum(FD$Frequency) # Relative Frequency + +FD <- cbind(FD,Relative_frequency = RF) + +PF <- FD$Relative_frequency * 100 # Percentage Frequency + +FD <- cbind(FD, Percentage_frequency = PF) + +View(FD) # Viewing the Frequency Distribution Table + +# Total values of Frequency Distribution + +total_freq <- sum(FD$Frequency) + +total_rel_freq <- sum(FD$Relative_frequency) + +total_per_freq <- sum(FD$Percentage_frequency) + +cat("Total value for frequency is", total_freq, "\n") +cat("Total value for relative frequency is", total_rel_freq, "\n") +cat("Total value for percentage frequency is", total_per_freq) + + + + + \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.1b/Ex2_1b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.1b/Ex2_1b.R new file mode 100644 index 00000000..168a50de --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.1b/Ex2_1b.R @@ -0,0 +1,42 @@ + # Page no. : 35 + +# Bar Charts and Pie Charts + +# Dataset + +soft_drink_names <- c("Coke Classic", "Diet Coke", "Pepsi", "Diet Coke", "Coke Classic","Coke Classic", + "Dr. Pepper", "Diet Coke", "Pepsi", "Pepsi" , "Coke Classic", "Dr. Pepper", + "Sprite", "Coke Classic", "Diet Coke", "Coke Classic", "Coke Classic", "Sprite", + "Coke Classic", "Diet Coke", "Coke Classic", "Diet Coke", "Coke Classic", "Sprite", + "Pepsi", "Coke Classic", "Coke Classic", "Coke Classic", "Pepsi", "Coke Classic", + "Sprite", "Dr. Pepper", "Pepsi", "Diet Coke", "Pepsi", "Coke Classic", + "Coke Classic", "Coke Classic", "Pepsi", "Dr. Pepper", "Coke Classic", "Diet Coke", + "Pepsi", "Pepsi", "Pepsi", "Pepsi", "Coke Classic", "Dr. Pepper", "Pepsi", "Sprite") + +soft_drink_table <- data.frame(table(soft_drink_names)) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +# Bar Chart + +ggplot(soft_drink_table,aes(soft_drink_names,Freq, fill = soft_drink_names))+geom_bar(stat = "identity")+ +labs(title="Bar chart" , x = "Soft Drink", y = "Frequency")+ylim(0,20) + +# Pie Chart + +soft_drink_purchase_slices <- soft_drink_table$Freq +soft_drink_names_labels <- soft_drink_table$soft_drink_names +soft_drink_purchase_pct <- (soft_drink_table$Freq/sum(soft_drink_table$Freq)) * 100 + +soft_drink_names_labels <- paste(soft_drink_names_labels,soft_drink_purchase_pct) +soft_drink_names_labels <- paste(soft_drink_names_labels, "%", sep = "") + +pie(soft_drink_purchase_slices, labels = soft_drink_names_labels, + col = rainbow(length(soft_drink_names_labels)), + main = "Pie Chart for Soft Drink Purchase") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.2a/Ex2_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.2a/Ex2_2a.R new file mode 100644 index 00000000..8cbdf6bc --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.2a/Ex2_2a.R @@ -0,0 +1,63 @@ + # Page no. : 39-40 + +# Frequency Distribution (Quantitative Data) + +audit_data <- c(12,15,20,22,14,14,15,27,21,18,19,18,22,33,16,18,17,23,28,13) + +no_of_classes <- 5 + +width <- (max(audit_data) - min(audit_data)) / no_of_classes + +width <- ceiling(width) # Rounding up of the value + +breaks <- seq(10,34,by = width) + +class_range <- cut(audit_data, breaks, right=T) + +frequency <- table(class_range) + +frequency_distribution <- data.frame(frequency) + +frequency_distribution <- data.frame(class_range = frequency_distribution$class_range, + frequency = frequency_distribution$Freq) + +# Note that :- Book answer will differ with my answer though number of classes and width of +# each class is same as in the book!!! + + # Page no. : 41 + +relative_frequency <- round(frequency_distribution$frequency / sum(frequency_distribution$frequency) + ,2) # Rounding of data to 2 digits + +percentage_frequency <- relative_frequency * 100 + +audit_data_FD <- cbind(frequency_distribution, + relative_frequency, percentage_frequency) + +View(audit_data_FD) + + # Page no. : 41-42 + +# Dot Plot and Histogram + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +# Dot Plot + +dotchart(audit_data, main = "Dot Plot for the Audit Time Data", xlab = "Audit Time (days)", + cex = 0.5) # cex is for scaling + +# Note that: Book dot plot is different from my dot plot. + +# Histogram + +ggplot(audit_data_FD, aes(class_range, frequency, fill = class_range))+ + geom_histogram(stat = "identity")+labs(title="Histogram for the Audit Time Data" , + x = "Audit Time (days)", y = "Frequency")+ylim(0,8) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.3a/Ex2_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.3a/Ex2_3a.R new file mode 100644 index 00000000..dedd0e8c --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.3a/Ex2_3a.R @@ -0,0 +1,23 @@ + # Page no. : 57-58 + +# Dataset + +week <- c(1,2,3,4,5,6,7,8,9,10) +x <- c(2,5,1,3,4,1,5,3,4,2) +y <- c(50,57,41,54,54,38,63,48,59,46) +data <- data.frame(week,x,y) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +# Scatter Plot + +ggplot(data, aes(x,y)) + geom_point() + geom_smooth(method = "lm", se = F) + +labs(title = "Scatter Plot and Tradeline for the Stereo and Sound Equipment Store", + x = "Number of Commercials", + y = "Sales ($100s)") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.4a/Ex2_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.4a/Ex2_4a.R new file mode 100644 index 00000000..8971d636 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.4a/Ex2_4a.R @@ -0,0 +1,34 @@ + # Page no. : 44 + +# Cumulative Distributions + +audit_time <- c("Less than or equal to 14", "Less than or equal to 19", "Less than or equal to 24", + "Less than or equal to 29", "Less than or equal to 34") +frequency <- c(4,8,5,2,1) # Refer to table no. 2.5 page no. 40 +cumulative_freq <- cumsum(frequency) + +DF <- data.frame(audit_time, frequency, cumulative_freq) + +CRF <- DF$cumulative_freq / sum(DF$frequency) # Cumulative Relative Frequency + +CPF <- CRF * 100 # Cumulative Percentage Frequency + +DF <- cbind(DF, CRF, CPF) +View(DF) + +breaks <- seq(9, 34, by = 5) +cumfreq0 <- c(0, DF$cumulative_freq) + +DF2 <- data.frame(breaks, cumfreq0) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF2, aes(breaks, cumfreq0, group = 1)) + geom_point() + geom_line() + + xlim(c(0,35)) + labs(title = "Ogive For the Audit Time Data", x ="Audit Time (Days)", + y ="Cumulative Frequency") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.5a/Ex2_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.5a/Ex2_5a.R new file mode 100644 index 00000000..71624534 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH2/EX2.5a/Ex2_5a.R @@ -0,0 +1,15 @@ + # Page no. : 49 + +# Exploratory Data Analysis : The Stem - and - Leaf Display + +data <- c(112, 72, 69, 97, 107, 73, 92, 76, 86, 73, 126, 128, 118, 127, 124, 82, 104, 132, 134, 83, + 92, 108, 96, 100, 92, 115, 76, 91, 102, 81, 95, 141, 81, 80, 106, 84, 119, 113, 98, 75, + 68, 98, 115, 106, 95, 100, 85, 94, 106, 119) + +stem(data) + + # Page no. : 51 + +data2 <- c(1565, 1852, 1644, 1766, 1888, 1912, 2044, 1812, 1790, 1679, 2008, 1852, 1967, 1954, + 1733) +stem(data2) # Answer is varing from the book \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH20/EX20.1a/Ex20_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH20/EX20.1a/Ex20_1a.R new file mode 100644 index 00000000..b35f4bf5 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH20/EX20.1a/Ex20_1a.R @@ -0,0 +1,71 @@ + # Page no. : 913 - 919 + +# Sample Mean Chart : Process Mean and SD Unknown + +o1 <- c(3.5056, 3.4882, 3.4897, 3.5153, 3.5059, 3.4977, 3.4910, 3.4991, 3.5099, 3.4880, 3.4881, + 3.5043, 3.5043, 3.5004, 3.4846, 3.5145, 3.5004, 3.4959, 3.4878, 3.4969) +o2 <- c(3.5086, 3.5085, 3.4898, 3.5120, 3.5113, 3.4961, 3.4913, 3.4853, 3.5162, 3.5015, 3.4887, + 3.4867, 3.4769, 3.5030, 3.4938, 3.4832, 3.5042, 3.4823, 3.4864, 3.5144) +o3 <- c(3.5144, 3.4884, 3.4995, 3.4989, 3.5011, 3.5050, 3.4976, 3.4830, 3.5228, 3.5094, 3.5141, + 3.4946, 3.4944, 3.5082, 3.5065, 3.5188, 3.4954, 3.4964, 3.4960, 3.5053) +o4 <- c(3.5009, 3.5250, 3.5130, 3.4900, 3.4773, 3.5014, 3.4831, 3.5083, 3.4958, 3.5102, 3.5175, + 3.5018, 3.5014, 3.5045, 3.5089, 3.4935, 3.5020, 3.5082, 3.5070, 3.4985) +o5 <- c(3.5030, 3.5031, 3.4969, 3.4837, 3.4801, 3.5060, 3.5044, 3.5094, 3.5004, 3.5146, 3.4863, + 3.4784, 3.4904, 3.5234, 3.5011, 3.4989, 3.4889, 3.4871, 3.4984, 3.4885) + +DF <- data.frame(o1, o2, o3, o4, o5) + +sample_mean <- rowMeans(DF) +sample_range <- c(0.0135, 0.0368, 0.0233, 0.0316, 0.0340, 0.0099, 0.0213, 0.0264, 0.0270, 0.0266, + 0.0312, 0.0259, 0.0274, 0.0230, 0.0243, 0.0356, 0.0153, 0.0259, 0.0206, 0.0259) + +DF <- cbind(DF, sample_mean, sample_range) +View(DF) + +AR <- mean(DF$sample_range) # Average Range +OM <- mean(DF$sample_mean) # Overall Mean +n <- 5 # Sample Observations +d2 <- 2.362 +A2 <- 3 / (d2 * sqrt(n)) + +UCL <- OM + (A2 * AR) # Upper Control Limit +LCL <- OM - (A2 * AR) # Lower Control Limit + +cat("UCL is ",UCL) +cat("LCL is",LCL) + +library(qicharts2) + +qic(DF$sample_mean, xlab = "Sample Number", ylab = "Sample Mean", title = "Sample Mean Chart") + +d3 <- 0.864 + +D1 <- 1 + (3 * (d3 / d2)) +D2 <- 1 - (3 * (d3 / d2)) + +UCL2 <- AR * D1 +LCL2 <- AR * D2 + +cat("UCL is ",UCL2) +cat("LCL is",LCL2) # Book answer is different + +qic(DF$sample_range, xlab = "Sample Number", ylab = "Sample Range", title = "R Chart") + +p <- 0.03 +n <- 200 + +sigma <- sqrt((p * (1 - p)) / n) + +UCL3 <- p + 3 * sigma +LCL3 <- p - 3 * sigma + +cat("UCL is ",UCL3) +cat("LCL is",LCL3) + +# Data for P chart is not available in Book + +UCL4 <- n * p + 3 * sqrt(n * p * (1 - p)) +LCL4 <- n * p - 3 * sqrt(n * p * (1 - p)) + +cat("UCL is ",UCL4) +cat("LCL is",LCL4) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH21/EX21.1a/Ex21_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH21/EX21.1a/Ex21_1a.R new file mode 100644 index 00000000..20fedddb --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH21/EX21.1a/Ex21_1a.R @@ -0,0 +1,26 @@ + # Page no. : 940 - 941 + +# Problem Formulation + +decision <- factor(c("Small Complex, d1", "Medium Complex, d2", "Large Complex, d3")) +demand1 <- c(8, 14, 20) +demand2 <- c(7, 5, -9) + +DF <- data.frame(decision, demand1, demand2) + +# Install Library if not install + +install.packages("rpart") +install.packages("rpart.plot") + +# Import Library + +library(rpart) +library(rpart.plot) + +ans <- rpart(decision ~ ., data = DF, method = "class" ) +rpart.plot(ans) + +# Decision Tree is Different from Book + + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1a/Ex3_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1a/Ex3_1a.R new file mode 100644 index 00000000..4c56e127 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1a/Ex3_1a.R @@ -0,0 +1,9 @@ + # Page no. : 87 + +# Mean + +x <- c(46, 54, 42, 46, 32) + +sample_mean <- mean(x) + +cat("Sample mean for x is ",sample_mean) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1b/Ex3_1b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1b/Ex3_1b.R new file mode 100644 index 00000000..045ed111 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1b/Ex3_1b.R @@ -0,0 +1,17 @@ + # Page no. : 88 + +# Dataset + +graduate <- c(1,2,3,4,5,6,7,8,9,10,11,12) +salary <- c(3450,3550,3650,3480,3355,3310,3490,3730,3540,3925,3520,3480) + + +dataset <- data.frame(graduate, salary) + +# Mean + +mean_salary <- mean(dataset$salary) + +cat("Mean monthly starting salary of 12 business school graduates is",mean_salary) + + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1c/Ex3_1c.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1c/Ex3_1c.R new file mode 100644 index 00000000..83a16e99 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1c/Ex3_1c.R @@ -0,0 +1,9 @@ + # Page no. : 89 + +# Median + +x <- c(32, 42, 46, 46, 54) + +median <- median(x) + +cat("Median value for x is ", median) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1d/Ex3_1d.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1d/Ex3_1d.R new file mode 100644 index 00000000..73f974ab --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1d/Ex3_1d.R @@ -0,0 +1,9 @@ + # Page no. : 89 + +salary <- c(3450,3550,3650,3480,3355,3310,3490,3730,3540,3925,3520,3480) + +# Median + +median <- median(salary) + +cat("The median of salary is ", median) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1e/Ex3_1e.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1e/Ex3_1e.R new file mode 100644 index 00000000..1d5c3ec4 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.1e/Ex3_1e.R @@ -0,0 +1,20 @@ + # Page no. : 90-91 + +salary <- c(3450,3550,3650,3480,3355,3310,3490,3730,3540,3925,3520,3480) + +# 85th and 50th Percentiles + +solution <- quantile(salary, probs = c(0.85, 0.5)) + +cat("Value for 85th and 50th percentile are ", solution[1], ",", solution[2]) + +# Note that: 85th percentile value is different from the book + + +# 25th, 50th, 75th Percentiles (First, Second, Third Quartiles) + +values <- quantile(salary, probs = c(0.25, 0.5, 0.75)) + +cat("Value for first, second, third quartiles are ", values[1], ",", values[2], ",", values[3] ) + +# Note that: First and Second Quartile values are different from the book diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2a/Ex3_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2a/Ex3_2a.R new file mode 100644 index 00000000..821e64bc --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2a/Ex3_2a.R @@ -0,0 +1,18 @@ + # Page no. : 96-97 + +salary <- c(3450,3550,3650,3480,3355,3310,3490,3730,3540,3925,3520,3480) + +# Range + +range <- range(salary) +diff <- range[2] - range[1] + +cat("Range is",diff) + +# Inter-Quartile Range + +IQR <- IQR(salary) + +cat("IQR is ",IQR) + +# Note that : IQR value of Book is different. \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2b/Ex3_2b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2b/Ex3_2b.R new file mode 100644 index 00000000..e3b7af4b --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2b/Ex3_2b.R @@ -0,0 +1,9 @@ + # Page no. : 97-98 + +students <- c(46, 54, 42, 46, 32) + +# Variance + +variance <- var(students) + +cat("Variance of students is ",variance) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2c/Ex3_2c.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2c/Ex3_2c.R new file mode 100644 index 00000000..87d1b68b --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.2c/Ex3_2c.R @@ -0,0 +1,15 @@ + # Page no. : 98-99 + +salary <- c(3450,3550,3650,3480,3355,3310,3490,3730,3540,3925,3520,3480) + +# Variance + +variance <- var(salary) + +# Standard Deviation + +sd <- sd(salary) + +cat("Variance of salary is ",variance) +cat("Standard Deviation is ",sd) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.3a/Ex3_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.3a/Ex3_3a.R new file mode 100644 index 00000000..ecc1efcf --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.3a/Ex3_3a.R @@ -0,0 +1,21 @@ + # Page no. : 104 + +# Z-score + +students <- c(46,54,42,46,32) + +deviation <- students - mean(students) + +sample_variance <- var(students) + +dataset <- data.frame(students,deviation) + +z <- c() + +for(i in 1:length(dataset$students)){ + z[i] <- deviation[i]/sqrt(sample_variance) +} + +dataset <- cbind(dataset, zScore = z) + +View(dataset) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.4a/Ex3_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.4a/Ex3_4a.R new file mode 100644 index 00000000..f588e647 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.4a/Ex3_4a.R @@ -0,0 +1,16 @@ + # Page no. : 110 + +salary <- c(3450,3550,3650,3480,3355,3310,3490,3730,3540,3925,3520,3480) + +# Install Library if not installed + +#install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +# Boxplot + +ggplot(data.frame(salary), aes(x = "", y = salary)) + geom_boxplot(fill = "purple")+ + ggtitle("Boxplot for Salary") + ylab("Salary") diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.5a/Ex3_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.5a/Ex3_5a.R new file mode 100644 index 00000000..7ccced15 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.5a/Ex3_5a.R @@ -0,0 +1,20 @@ + # Page no. : 115-116 and 119 + +# Dataset + +x <- c(2,5,1,3,4,1,5,3,4,2) +y <- c(50,57,41,54,54,38,63,48,59,46) + +dataset <- data.frame(x,y) + +# Coveriance + +coveriance <- cov(dataset$x,dataset$y) + +cat("Value of covariance is ",coveriance) + +# Correlation Coefficient + +correlation <- cor(dataset$x,dataset$y) + +cat("Value of correlation coefficient is ",correlation) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.5b/Ex3_5b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.5b/Ex3_5b.R new file mode 100644 index 00000000..63236e63 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.5b/Ex3_5b.R @@ -0,0 +1,12 @@ + # Page no. : 121 + +# Data + +x <- c(5,10,15) +y <- c(10,30,50) + +# Sample Correlation Coefficient + +corr <- cor(x, y) + +cat("Sample correlation coefficient of x and y is ", corr) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.6a/Ex3_6a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.6a/Ex3_6a.R new file mode 100644 index 00000000..b3212dd6 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.6a/Ex3_6a.R @@ -0,0 +1,15 @@ + # Page no. : 124 - 125 + +# Data + +purchase <- c(1,2,3,4,5) +cost <- c(3.00,3.40,2.80,2.90,3.25) +pound <- c(1200,500,2750,1000,800) + +dataset <- data.frame(purchase,cost,pound) + +# Weighted Mean + +mean <- weighted.mean(dataset$cost,dataset$pound) + +cat("Weigted mean for the dataset is",mean) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.6b/Ex3_6b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.6b/Ex3_6b.R new file mode 100644 index 00000000..3fcafa7d --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH3/EX3.6b/Ex3_6b.R @@ -0,0 +1,23 @@ + # Page no. : 126 - 127 + +# Data + +audit <- c("10-14", "15-19","20-24","25-29","30-34") +midpoint <- c(12,17,22,27,32) +frequency <- c(4,8,5,2,1) + +dataset <- data.frame(audit, midpoint, frequency) + +# Mean for Grouped Data + +mean <- weighted.mean(dataset$midpoint,dataset$frequency) + +cat("Mean for grouped data is",mean) + +# Sample Variance for Grouped Data + +var <- sum(dataset$frequency*((dataset$midpoint - mean)**2)) / (sum(dataset$frequency) - 1) + +# Note that : Grouped sample variance has no inbuild function + +cat("Sample variance for grouped data is",var) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1a/Ex4_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1a/Ex4_1a.R new file mode 100644 index 00000000..2f41aa69 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1a/Ex4_1a.R @@ -0,0 +1,21 @@ + # Page no. : 154 + +# Combinations + +# Eg. 1 + +N <- 5 +n <- 2 + +combinations <- choose(n = N, k = n) + +cat("The total combinations are",combinations) + +# Eg. 2 + +N <- 53 +n <- 6 + +combinations <- choose(n = N, k = n) + +cat("The total combinations are",combinations) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1b/Ex4_1b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1b/Ex4_1b.R new file mode 100644 index 00000000..1b495474 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1b/Ex4_1b.R @@ -0,0 +1,10 @@ + # Page no. : 155 + +# Permutations + +N <- 5 +n <- 2 + +permutations <- choose(n = N, k = n)*factorial(n) + +cat("The total permutations are",permutations) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1c/Ex4_1c.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1c/Ex4_1c.R new file mode 100644 index 00000000..009acdab --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1c/Ex4_1c.R @@ -0,0 +1,16 @@ + # Page no. : 155 - 156 + +# Assigning Probabilities + +x <- c(0,1,2,3,4) +y <- c(2,5,6,4,3) + +DF <- data.frame(x,y) + +y_sum <- sum(DF$y) + +prob <- DF$y / y_sum + +DF <- cbind(DF,prob) + +View(DF) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1d/Ex4_1d.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1d/Ex4_1d.R new file mode 100644 index 00000000..ba08853c --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.1d/Ex4_1d.R @@ -0,0 +1,29 @@ + # Page no. : 157 - 158 + +# Probabilities Assigning Example + +x <- c(2,2,2,3,3,3,4,4,4) +y <- c(6,7,8,6,7,8,6,7,8) + +z = list() + +for(i in 1:length(x)) +{ + z[i] <- list(c(x[i],y[i])) +} + +past_project <- c(6,6,2,4,8,2,2,4,6) + +DF <- data.frame(x,y,I(z),past_project) + +past_project_sum <- sum(DF$past_project) + +p <- DF$past_project / past_project_sum + +DF <- cbind(DF,p) + +total_probability <- sum(DF$p) + +cat("Total probability for the Sample Point is",total_probability) + +View(DF) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.2a/Ex4_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.2a/Ex4_2a.R new file mode 100644 index 00000000..83f5311e --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.2a/Ex4_2a.R @@ -0,0 +1,42 @@ + # Page no. : 161 + +# Probability of an Event + +# C denotes the event that is completed in 10 months or less + +C <- c(list(c(2,6)), list(c(2,7)), list(c(2,8)), list(c(3,7)), list(c(3,8)), list(c(4,6))) +prob <- c(0.15,0.15,0.05,0.10,0.20,0.05) + +dataset <- data.frame(I(C),prob) + +event <- sum(dataset$prob) + +# P(C) = P(2,6) + P(2,7) + P(2,8) + P(3,7) + P(3,8) + P(4,6) + +cat("Probability of an event P(C) is",event) + +# L denotes the event that is completed in less than 10 months + +L <- c(list(c(2,6)), list(c(2,7)), list(c(3,7))) +prob <- c(0.15,0.15,0.10) + +dataset <- data.frame(I(L),prob) + +# P(L) = P(2,6) + P(2,7) + P(3,7) + +event2 <- sum(dataset$prob) + +cat("Probability of an event P(L) is",event2) + +# M denotes the event that is completed in more than 10 months + +M <- c(list(c(3,8)), list(c(4,7)), list(c(4,8))) +prob <- c(0.05,0.10,0.15) + +dataset <- data.frame(I(M),prob) + +# P(M) = P(3,8) + P(4,7) + P(4,8) + +event3 <- sum(dataset$prob) + +cat("Probability of an event P(L) is",event3) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3a/Ex4_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3a/Ex4_3a.R new file mode 100644 index 00000000..480edd9b --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3a/Ex4_3a.R @@ -0,0 +1,9 @@ + # Page no. : 165 + +# Probability Computation using Complement + +p_comp_A <- 0.80 + +p_A <- 1 - p_comp_A + +cat("Probability for A is",p_A) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3b/Ex4_3b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3b/Ex4_3b.R new file mode 100644 index 00000000..35dc1e36 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3b/Ex4_3b.R @@ -0,0 +1,22 @@ + # Pahe no. : 167 + +# Intersection and Union of Events + +a <- 5 +n <- 50 +c <- 6 +d <- 2 + +p_L <- a / n + +p_D <- c / n + +p_L_and_D <- d / n + + +cat("Probability for L intersection D is",p_L_and_D) + +p_L_or_D <- p_L + p_D - p_L_and_D + +cat("Probability for L union D is",p_L_or_D) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3c/Ex4_3c.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3c/Ex4_3c.R new file mode 100644 index 00000000..33b28047 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.3c/Ex4_3c.R @@ -0,0 +1,11 @@ + # Page no. : 168 + +# Addition Law + +p_S <- 0.30 +p_W <- 0.20 +p_S_and_W <- 0.12 + +p_S_or_W <- p_S + p_W - p_S_and_W + +cat("Probability after applying addition law is ",p_S_or_W) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.4a/Ex4_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.4a/Ex4_4a.R new file mode 100644 index 00000000..0a93b691 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.4a/Ex4_4a.R @@ -0,0 +1,40 @@ + # Page no. : 171 - 174 + +# Conditional Probability + +position <- c("Promoted", "Not Promoted") +gender <- c("Men","Women") +number1 <- c(288, 36) # Promoted +number2 <- c(672, 204) # Not Promoted + +DF <- data.frame(position, gender, number1, number2) + +table <- round(prop.table(DF[,3:4]), 2) +table <- as.matrix(table) +table + +position <- c("Promoted", "Not Promoted") +men <- c(table[1,1][[1]], table[1,2][[1]]) +women <- c(table[2,1][[1]], table[2,2][[1]]) + +DF2 <- data.frame(position, men, women) +View(DF2) + +columnSums <- apply(DF2[,2:3],2, sum) +rowSums <- apply(DF2[,2:3], 1, sum) + +cat("Total Probability For having Men is", columnSums[1]) +cat("Total Probability For having Women is", columnSums[2]) +cat("Total Probability For Promotion", rowSums[1]) +cat("Total Probability For Not a Promotion", rowSums[2]) + +cond1 <- DF2$men[1] / columnSums[1] + +cat("Conditional Probability for Men and getting Promoted given the Probability + of Total Men is",cond1) + +cond2 <- DF2$women[1] / columnSums[2] + +cat("Conditional Probability for Women and getting Promoted given the Probability + of Total Women is",cond2) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.4b/Ex4_4b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.4b/Ex4_4b.R new file mode 100644 index 00000000..9810074a --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.4b/Ex4_4b.R @@ -0,0 +1,25 @@ + # Page no. : 174 - 175 + +# Multiplication Law + +# P(S | D) = 0.75 + +x <- 0.75 + +# Event S = 0.84 + +y <- 0.84 + +x_and_y <- x * y + +cat("After applying multiplication law we get", x_and_y) + +# Multiplication Law for Independent Events + +A <- 0.80 + +B <- 0.80 + +A_and_B <- A * B + +cat("After applying multiplication law for independent events A and B we get", A_and_B) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.5a/Ex4_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.5a/Ex4_5a.R new file mode 100644 index 00000000..9528a580 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH4/EX4.5a/Ex4_5a.R @@ -0,0 +1,21 @@ + # Page no. : 182 + +# Tabular Approach for Bayes' Theorem + +events <- c("A1","A2") +prior_probabilities <- c(0.65,0.35) + +conditional_probabilities <- c(0.02,0.05) + +joint_probabilities <- prior_probabilities * conditional_probabilities + +total_joint_probability <- sum(joint_probabilities) + +posterior_probabilities <- joint_probabilities / total_joint_probability + +DF <- data.frame(events,prior_probabilities,conditional_probabilities + ,joint_probabilities,posterior_probabilities) + +View(DF) + +cat("Total posterior probability is",sum(DF$posterior_probabilities)) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.1a/Ex5_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.1a/Ex5_1a.R new file mode 100644 index 00000000..e0e40298 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.1a/Ex5_1a.R @@ -0,0 +1,44 @@ + # Page no. : 198 - 199 + +# Discrete Probability Distribution: + +x <- c(0,1,2,3,4,5) +prob_of_x <- c(0.18,0.39,0.24,0.14,0.04,0.01) + +dataset <- data.frame(x, prob_of_x) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(dataset, aes(x = x, y = prob_of_x)) + geom_bar(stat = "identity", fill = "blue") + labs( + title = "Graphical representation of the Probability Distribution", + x = "Number of Automobiles", y = "Probability") + + # Page no. : 203 + +# Expected value + +exp_values <- dataset$x * dataset$prob_of_x + +dataset <- data.frame(cbind(dataset, exp_values)) + +expected_value <- sum(dataset$exp_values) +cat("Expected value for the given problem is", expected_value) + + # Page no. : 204 - 205 + +# Variance and Standard Deviation + +deviation_of_x <- (dataset$x - expected_value) + +deviation_square <- (deviation_of_x) ** 2 +variance <- sum(dataset$prob_of_x * deviation_square) +standard_deviation <- sqrt(variance) + +cat("Variance is",variance) +cat("Standard Deviation is",standard_deviation) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.2a/Ex5_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.2a/Ex5_2a.R new file mode 100644 index 00000000..b0cd63c8 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.2a/Ex5_2a.R @@ -0,0 +1,13 @@ + # Page no. : 211 + +# Binomial Probability Distribution + +no_of_trials <- 3 +no_of_successes <- 2 +BPD <- choose(n = no_of_trials, k = no_of_successes) + +cat("Answer is",BPD) + +no_of_successes <- 3 +BPD <- choose(n = no_of_trials, k = no_of_successes) +cat("Answer is",BPD) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.2b/Ex5_2b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.2b/Ex5_2b.R new file mode 100644 index 00000000..01c7c5f8 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.2b/Ex5_2b.R @@ -0,0 +1,98 @@ + # Page no. : 211 + +# Binomial Probability Distribution Eg-2 + +# Data +customer1 <- c("Purchase","Purchase","No Purchase") +customer2 <- c("Purchase","No Purchase","Purchase") +customer3 <- c("No Purchase","Purchase","Purchase") + +customer <- data.frame(customer1,customer2,customer3) + +len <- nrow(customer) # Trial + +x <- 1 # For purchase +y <- 0 # For no purchase + +p <- 0.30 +q <- 1 - p +outcome <- c() + +# Install Library if not installed + +install.packages("Rlab") + +# Import Library + +library(Rlab) # For dbern + +for(i in 1:len) +{ + if(customer1[i] == "Purchase" && customer2[i] == "Purchase" && customer3[i] == "Purchase") + { + outcome[i] = dbern(x,p) * dbern(x,p) * dbern(x,p) + } else if(customer1[i] == "Purchase" && customer2[i] == "Purchase" && customer3[i] == "No Purchase") + { + outcome[i] = dbern(x,p) * dbern(x,p) * dbern(y,p) + } else if(customer1[i] == "Purchase" && customer2[i] == "No Purchase" && customer3[i] == "Purchase") + { + outcome[i] = dbern(x,p) * dbern(y,p) * dbern(x,p) + } else if(customer1[i] == "Purchase" && customer2[i] == "No Purchase" && customer3[i] == "No Purchase") + { + outcome[i] = dbern(x,p) * dbern(y,p) * dbern(y,p) + } else if(customer1[i] == "No Purchase" && customer2[i] == "Purchase" && customer3[i] == "Purchase") + { + outcome[i] = dbern(y,p) * dbern(x,p) * dbern(x,p) + } else if(customer1[i] == "No Purchase" && customer2[i] == "Purchase" && customer3[i] == "No Purchase") + { + outcome[i] = dbern(y,p) * dbern(x,p) * dbern(y,p) + } else if(customer1[i] == "No Purchase" && customer2[i] == "No Purchase" && customer3[i] == "Purchase") + { + outcome[i] = dbern(y,p) * dbern(y,p) * dbern(x,p) + } else + { + outcome[i] = dbern(y,p) * dbern(y,p) * dbern(y,p) + } +} + +customer <- cbind(customer,outcome) + +View(customer) + + # Page no. : 212 - 213 + +# Binomial Probability Function + +x <- c(0,1,2,3) +fun <- c() + +for (i in 0:length(x)) { + fun[i] <- dbinom(x[i],len,p) +} + +dataset <- data.frame(x, fun) +View(dataset) + +# Install Library if not installed + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(dataset, aes(x = x, y = fun)) + geom_bar(stat = "identity", fill = "blue") + labs( + title = "Graphical representation of the Probability Distribution", + x = "Number of Customers", y = "Probability") + + # Page no. : 214 - 215 + +# Expected Value, Variance and Standard Deviation for Binomial Probability Distribution + +expected_value <- len * p +variance <- len * p * q +standard_deviation <- sqrt(variance) + +cat("Expected value is",expected_value) +cat("Variance is",variance) +cat("Standard deviation is",standard_deviation) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.3a/Ex5_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.3a/Ex5_3a.R new file mode 100644 index 00000000..819986a9 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.3a/Ex5_3a.R @@ -0,0 +1,12 @@ + # Page no. : 218 + +# Poisson Probability Distribution + +x = 5 +expected_value <- 10 +e <- 2.72 # Exponential value + +PPD <- dpois(x, expected_value) # Poisson Probability Distribution + +cat("Answer is",PPD) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.4a/Ex5_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.4a/Ex5_4a.R new file mode 100644 index 00000000..65794295 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.4a/Ex5_4a.R @@ -0,0 +1,31 @@ + # Page no. : 222 - 223 + +# Hypergeometric Probability Distribution + +# Probability for 1 defective item + +N <- 12 +n <- 3 +r <- 5 +x <- 1 + +HPD <- dhyper(x = x,m = r,n = N-r,k = n) + +cat("Answer is",HPD) + +# Probability for atleast one defective item + +HPD <- dhyper(x = 0,m = r,n = N-r,k = n) # Probability for no defective item + +cat("Answer is",1 - HPD) # Probability for atleast one defective item + +# Expected value, Variance and Standard Deviation + +expected_value <- n * (r / N) +variance <- expected_value * (1 -(r/N)) * ((N-n)/(N-1)) +standard_deviation <- sqrt(variance) + +cat("Expected value",expected_value) +cat("Variance",variance) +cat("standard deviation",standard_deviation) + \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.5a/Ex5_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.5a/Ex5_5a.R new file mode 100644 index 00000000..92b8df66 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH5/EX5.5a/Ex5_5a.R @@ -0,0 +1,28 @@ + # Page no. : 203 - 204 + +# Expected Value and Variance + +x <- c(0,1,2,3,4,5) +prob_of_x <- c(0.18,0.39,0.24,0.14,0.04,0.01) +expected_value <- x * prob_of_x + +DF <- data.frame(x, prob_of_x, expected_value) + +expected_mean <- sum(DF$expected_value) + +cat("Expected mean is",expected_mean) + +deviation <- DF$x - expected_mean +sq_deviation <- deviation ** 2 +expected_value2 <- DF$prob_of_x * sq_deviation + +DF <- cbind(DF, deviation, sq_deviation, expected_value2) +View(DF) + +expected_variance <- sum(DF$expected_value2) + +cat("Expected variance is", expected_variance) + +expected_SD <- sqrt(expected_variance) + +cat("Expected SD is", expected_SD) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.1a/Ex6_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.1a/Ex6_1a.R new file mode 100644 index 00000000..5dc93b50 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.1a/Ex6_1a.R @@ -0,0 +1,31 @@ + # Page no. : 234 - 236 + +# Uniform Probability Distribution + +a <- 120 +b <- 140 +fun_over_x <- 1/20 + +# Since uniform probability is symmetric we can split it into left and right parts which +# are symmetric in nature + +c <- 130 # (120+140)/2 = 130 + +# Probability of uniform probability distribution is the area of the figure (rectangle) + +# Area for the left symmetric part of the figure + +area <- punif(c,a,b) +area_full <- 2 * area + +cat("Probability is",area_full) + +# Expected value, Variance and standard Deviation + +expected_value <- (a + b) / 2 +variance <- (b - a) ** 2 / 12 +standard_deviation <- sqrt(variance) + +cat("Expected value is",expected_value) +cat("Variance is",variance) +cat("Standard deviation is",standard_deviation) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.2a/Ex6_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.2a/Ex6_2a.R new file mode 100644 index 00000000..111dbd90 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.2a/Ex6_2a.R @@ -0,0 +1,18 @@ + # Page no. : 246 - 247 + +# Normal Probability Distribution + +mean <- 36500 +sigma <- 5000 +x <- 40000 +probability <- pnorm(40000, mean=36500, sd=5000, lower.tail= F) + +cat("The probability of x exceed 40000 is",probability) + + # Page no. : 247 + +probability <- 0.10 +z_value <- round(qnorm(probability), 2) # Round it to 2 decimal place +x <- (sigma * z_value) + mean + +cat("Value of x for not more than 10% of area is selected is",x) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.3a/Ex6_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.3a/Ex6_3a.R new file mode 100644 index 00000000..82d5c16a --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.3a/Ex6_3a.R @@ -0,0 +1,32 @@ + # Page no. : 251 - 252 + +# Normal Approximation of Binomial Probabilities + +n <- 100 +p <- 0.1 +q <- 1 - p + +mu <- n * p +sigma <- sqrt(mu * q) + +# P(x = 12) ==> P(11.5 <= x <= 12.5) + +x1 <- 12.5 +x2 <- 11.5 +z_value1 <- (x1 - mu) / sigma +z_value2 <- (x2 - mu) / sigma + +area1 <- pnorm(z_value1) +area2 <- pnorm(z_value2) + +diff <- area1 - area2 + +cat("The normal approximation to the probability of 12 successes in 100 trials is ",diff) + +# Probability for 13 + +x <- 13.5 +z <- (x - mu) / sigma +ans <- pnorm(z) + +cat("Answer is", ans) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.4a/Ex6_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.4a/Ex6_4a.R new file mode 100644 index 00000000..a6e514a5 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH6/EX6.4a/Ex6_4a.R @@ -0,0 +1,24 @@ + # Page no. : 255 + +# Exponential Probability Distribution + +mu <- 15 +x1 <- 6 +x2 <- 18 + +# P(x <= 6) + +EPD <- pexp(x1,1/mu) + +# P(x <= 18) + +EPD2 <- pexp(x2, 1/mu) + +diff <- EPD2 - EPD + +cat("The probability that loading a truck will take between 6 and 18 minutes is ",diff) + +SD <- mu +sigma <- SD ** 2 + +cat("Variance is", sigma) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.1a/Ex7_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.1a/Ex7_1a.R new file mode 100644 index 00000000..95c3530b --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.1a/Ex7_1a.R @@ -0,0 +1,30 @@ + # Page no. : 274 + +# Sample Mean and Sample Standard Deviation + +annual_salary <- c(49094.30,53263.90,49643.50,49894.90,47621.60,55924.00,49092.30,51404.40,50957.70, + 55109.70,45922.60,57268.40,55688.80,51564.70,56188.20,51766.00,52541.30,44980.00, + 51932.60,52973.00,45120.90,51753.00,54391.80,50164.20,52973.60,50241.30,52793.90, + 50979.40,55860.90,57309.10) + +program <- c("Yes","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","Yes","No","Yes","No","No","Yes", + "No","Yes","Yes","Yes","Yes","Yes","No","No","No","No","No","Yes","Yes","No") + +dataset <- data.frame(annual_salary, program) + +sample_mean <- mean(dataset$annual_salary) +sample_sd <- sd(dataset$annual_salary) + +cat("Sample mean of the data is", sample_mean) +cat("Sample satndard deviation is", sample_sd) + +# Note that : Book SD is different from our SD + +# Sample Proportion + +n <- nrow(dataset) +x <- 19 + +sample_proportion <- x / n + +cat("Sample Proportion is",sample_proportion) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.2a/Ex7_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.2a/Ex7_2a.R new file mode 100644 index 00000000..396c2bb9 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.2a/Ex7_2a.R @@ -0,0 +1,17 @@ + # Page no. 277 - 278 + +# Sampling Distribution + +mean_annual_salary <- c("49500.00-49999.99","50000.00-50499.99","50500.00-50999.99","51000.00-51499.99", + "51500.00-51999.99","52000.00-52499.99","52500.00-52999.99","53000.00-53499.99", + "53500.00-53999.99") +frequency <- c(2,16,52,101,133,110,54,26,6) +relative_frequency <- c(.004,.032,.104,.202,.266,.220,.108,.052,.012) + +DF <- data.frame(mean_annual_salary,frequency,relative_frequency) + +library(ggplot2) + +ggplot(DF,aes(mean_annual_salary,relative_frequency)) + + geom_histogram(stat = "identity", fill = "purple") + labs(title = "Relative Frequency Histogram", + x = " Mean Salary", y = "frequency") \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.3a/Ex7_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.3a/Ex7_3a.R new file mode 100644 index 00000000..696c4ffb --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.3a/Ex7_3a.R @@ -0,0 +1,35 @@ + # Page no. : 281 + +# Sampling Distribution of xbar + +sigma <- 4000 +N <- 2500 +n <- 30 +x <- n / N + +if(x > 0.05) # Condition to include finite population factor or not (< 5%) +{ + standard_error <- sqrt((N-n)/(N-1)) * (sigma / sqrt(n)) +} else{ + standard_error <- sigma / sqrt(n) +} + +cat("Standard deviation of sample mean is",standard_error) + + # Page no. : 284 + +# To find probability that xbar is between 51300 and 52300 + +xbar1 <- 52300 +xbar2 <- 51300 +mu <- 51800 + +z1 <- (xbar1 - mu) / standard_error +z2 <- (xbar2 - mu) / standard_error + +p1 <- pnorm(z1, lower.tail = T) +p2 <- pnorm(z2, lower.tail = T) + +diff <- p1 - p2 + +cat("Probability that xbar is between 51300 and 52300 is", diff) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.3b/Ex7_3b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.3b/Ex7_3b.R new file mode 100644 index 00000000..0220b6a1 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.3b/Ex7_3b.R @@ -0,0 +1,22 @@ + # Page no. : 285 - 286 + +# Relationship between Sample Size and Sampling Distribution of xbar + +sigma <- 4000 +n <- 100 +population_mean <- 51800 + +standard_error <- sigma / sqrt(n) + +xbar1 <- 52300 +xbar2 <- 51300 + +z1 <- (xbar1 - population_mean) / standard_error +z2 <- (xbar2 - population_mean) / standard_error + +p1 <- pnorm(z1, lower.tail = T) +p2 <- pnorm(z2, lower.tail = T) + +diff <- p1 - p2 + +cat("Probability that xbar is between 51300 and 52300 with increased sample size is", diff) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4a/Ex7_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4a/Ex7_4a.R new file mode 100644 index 00000000..46bd63c7 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4a/Ex7_4a.R @@ -0,0 +1,19 @@ + # Page no. : 290 + +# Sampling Distribution of pbar + +population_proportion <- 0.60 +n <- 30 +N <- 2500 + +x <- n / N + +if(x > 0.05) # Condition to include finite population or not ( < 5%) +{ + standard_deviation <- sqrt((N-n)(N-1)) * sqrt((population_proportion * + (1 - population_proportion)) / n) +} else{ + standard_deviation <- sqrt((population_proportion * (1 - population_proportion)) / n) +} + +cat("Standard deviation for sample proportion is",standard_deviation) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4b/Ex7_4b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4b/Ex7_4b.R new file mode 100644 index 00000000..750b42bb --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4b/Ex7_4b.R @@ -0,0 +1,22 @@ + # Page no. : 291 + +# Practical value of the Sampling Distribution of pbar + +population_proportion <- 0.60 +standard_error <- 0.0894 +sample_proportion <- 0.65 + +z_value <- (sample_proportion - population_proportion) / standard_error + +prob1 <- pnorm(sample_proportion, population_proportion, standard_error, lower.tail =T) + +sample_proportion2 <- 0.55 + +z_value <- (sample_proportion2 - population_proportion) / standard_error + +prob2 <- pnorm(sample_proportion2, population_proportion, standard_error, lower.tail =T) + +final_prob <- prob1 - prob2 + +cat("The final probability is",final_prob) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4c/Ex7_4c.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4c/Ex7_4c.R new file mode 100644 index 00000000..a026dafb --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH7/EX7.4c/Ex7_4c.R @@ -0,0 +1,25 @@ + # Page no. : 292 - 293 + +# Practical value of the Sampling Distribution of pbar Eg-2 + +population_proportion <- 0.60 +n <- 100 + +standard_error <- sqrt(population_proportion*(1 - population_proportion)/(n)) + +sample_proportion <- 0.65 + +z_value <- (sample_proportion - population_proportion) / standard_error + +prob1 <- pnorm(sample_proportion, population_proportion, standard_error, lower.tail =T) + +sample_proportion2 <- 0.55 + +z_value <- (sample_proportion2 - population_proportion) / standard_error + +prob2 <- pnorm(sample_proportion2, population_proportion, standard_error, lower.tail =T) + +final_prob <- prob1 - prob2 + +cat("The final probability is",final_prob) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.1a/Ex8_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.1a/Ex8_1a.R new file mode 100644 index 00000000..fdb7a470 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.1a/Ex8_1a.R @@ -0,0 +1,35 @@ + # Page no. : 310 - 314 +# Population Mean Sigma known + +pop_sd <- 20 +sample_size <- 100 +sample_mean <- 82 + +standard_error <- pop_sd / sqrt(sample_size) + +# 95% confidence interval + +margin_of_error <- qnorm(0.975)*standard_error # 95% confidence interval --> 1 - 0.025 = 0.975 + +IE <- sample_mean + c(-margin_of_error, margin_of_error) + +cat("The margin of error is given by", margin_of_error) +cat("The 95% interval estimate is given by", IE) + +# 90% confidence interval + +margin_of_error <- qnorm(0.95)*standard_error # 90% confidence interval --> 1 - 0.05 = 0.95 + +IE <- sample_mean + c(-margin_of_error, margin_of_error) + +cat("The margin of error is given by", margin_of_error) +cat("The 90% interval estimate is given by", IE) + +# 99% confidence interval + +margin_of_error <- qnorm(0.995)*standard_error # 99% confidence interval --> 1 - 0.005 = 0.995 + +IE <- sample_mean + c(-margin_of_error, margin_of_error) + +cat("The margin of error is given by", margin_of_error) +cat("The 99% interval estimate is given by", IE) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.2a/Ex8_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.2a/Ex8_2a.R new file mode 100644 index 00000000..3650aeae --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.2a/Ex8_2a.R @@ -0,0 +1,17 @@ + # Page no. : 319 - 320 + + +# Population Mean Sigma Unknown + +cradit_card_balances <- c(9430,7535,4078,5604,5179,4416,10676,1627,10112,6567,13627,18719,14661,12195, + 10544,13659,7061,6245,13021,9719,2200,10746,12744,5742,7159,8137,9467,12595, + 7917,11346,12806,4972,11356,7117,9465,19263,9071,3603,16804,13479,14044,6817, + 6845,10493,615,13627,12557,6232,9691,11448,8279,5649,11298,4353,3467,6191, + 12851,5337,8372,7445,11032,6525,5239,6195,12584,15415,15917,12591,9743,10324) + +test <- t.test(cradit_card_balances) +IE1 <- test$conf.int[1] +IE2 <- test$conf.int[2] + +cat("The 95% interval estimate is given by", IE1, "to", IE2) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.2b/Ex8_2b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.2b/Ex8_2b.R new file mode 100644 index 00000000..af58cafb --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.2b/Ex8_2b.R @@ -0,0 +1,15 @@ + # Page no. : 321 - 322 + +# Population Mean Sigma Unknown Eg-2 + +data <- c(52,44,55,44,45,59,50,54,62,46,54,42,60,62,43,42,48,55,57,56) + + +hist(data, col = "blue", main = "Histogram of Training Times", xlab = "Traing Times (days)", + ylab = "Frequency") + +test <- t.test(data) +IE1 <- test$conf.int[1] +IE2 <- test$conf.int[2] + +cat("The 95% interval estimate is given by", IE1, "to", IE2) diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.3a/Ex8_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.3a/Ex8_3a.R new file mode 100644 index 00000000..02c33e7d --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.3a/Ex8_3a.R @@ -0,0 +1,13 @@ + # Page no. : 326 - 327 + +# Determining the Sample Size + +margin_of_error <- 2 +z_value <- 1.96 # 95% Level of Confidence Interval + +sample_standard_deviation <- 9.65 + +sample_size <- ((z_value)**2) * ((sample_standard_deviation)**2) / (margin_of_error)**2 + +cat("Sample size is",ceiling(sample_size)) +# If Sample Size is not integer then we round up to next higher integer \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.4a/Ex8_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.4a/Ex8_4a.R new file mode 100644 index 00000000..65724811 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.4a/Ex8_4a.R @@ -0,0 +1,20 @@ + # Page no. : 329 + +# Population Proportion + +N <- 900 +n <- 396 + +p <- n / N +q <- 1 - p + +# Confidence Interval is 95% + +z_value <- qnorm(0.975) # 95% confidence interval --> 1 - 0.025 = 0.975 + +margin_of_error <- z_value * sqrt((p*q)/N) +IE <- p + c(-margin_of_error, margin_of_error) + +cat("The margin of error is given by", margin_of_error) +cat("The 95% interval estimate is given by", IE) + diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.4b/Ex8_4b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.4b/Ex8_4b.R new file mode 100644 index 00000000..8f4874e9 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH8/EX8.4b/Ex8_4b.R @@ -0,0 +1,27 @@ + # Page no. : 330 + +# Determining the Sample Size + +margin_of_error <- 0.025 +z_value <- 1.96 # 95% Level of Confidence Interval + +p <- 0.44 +q <- 1 - p + +sample_size <- ((z_value)**2 * p * q) / (margin_of_error)**2 + +cat("Sample size is",ceiling(sample_size)) +# If Sample Size is not integer then we round up to next higher integer + + # Page no. : 331 + +margin_of_error <- 0.025 +z_value <- 1.96 # 95% Level of Confidence Interval + +p <- 0.50 +q <- 1 - p + +sample_size <- ((z_value)**2 * p * q) / (margin_of_error)**2 + +cat("Sample size is",ceiling(sample_size)) +# If Sample Size is not integer then we round up to next higher integer \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1a/Ex9_1a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1a/Ex9_1a.R new file mode 100644 index 00000000..88333719 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1a/Ex9_1a.R @@ -0,0 +1,38 @@ + # Page no. : 359 - 360 + +# Population Mean Sigma Known One Tailed Test + +sigma <- 0.18 +n <- 36 +xbar <- 2.92 +mu <- 3 + +z_value <- (xbar - mu) / (sigma / sqrt(n)) +z_value <- round(z_value,2) + +alpha <- 0.01 + +# P Value Approch (Lower-Tail Test) + +pval <- pnorm(z_value) + +if(pval > alpha) +{ + cat("Since p-value ",pval ,"is greater than 0.01, therefore we will accept null hypothesis") +} else { + cat("Since p-value ",pval ,"is less than 0.01, therefore we will reject null hypothesis and accept + alternative hypothesis.") +} + +# Critical Value Approch (Lower-Tail Test) + +z_alpha <- qnorm(1 - (alpha)) # Area of 0.01 to the left (1 - 0.01 = 0.99) +critical_approch <- -z_alpha + +if(z_value <= critical_approch) +{ + cat("Since z-value", z_value ,"is less then or equal to", critical_approch , "therefore we reject + the null hypothesis and accept the alternative hypothesis.") +} else{ + cat("Since z-value", z_value ,"is more than", critical_approch,"therefore we accept the null hypothesis.") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1b/Ex9_1b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1b/Ex9_1b.R new file mode 100644 index 00000000..facd6b1b --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1b/Ex9_1b.R @@ -0,0 +1,42 @@ + # Page no. : 362 - 364 + +# Population Mean Sigma Known Two Tailed Test + +sample_size <- 50 +sample_mean <- 297.6 +population_mean <- 295 +significance_level <- 0.05 # alpha +population_sd <- 12 + + # Page no. : 364 + +## Critical value approch + +z_value <- (sample_mean - population_mean) / (population_sd / sqrt(sample_size)) + +z_half_alpha <- qnorm(1 - (significance_level/2)) +critical_value_1 <- -z_half_alpha +critical_value_2 <- z_half_alpha + +if(z_value >= critical_value_2 || z_value <= critical_value_1) +{ + cat("Since z-value", z_value ,"does not lie in the range", critical_value_1 ,"and", critical_value_2 + ,"therefore we reject the null hypothesis and accept the alternative hypothesis.") +} else{ + cat("Since z-value", z_value ,"lies in the range", critical_value_1 ,"and", critical_value_2 + ,"therefore we accept the null hypothesis.") +} + + # Page no. : 363 - 364 + +## P-value approch + +area_under_curve <- 1 - pnorm(z_value) +pval <- 2 * area_under_curve # P-value +if(pval > 0.05) +{ + cat("Since p-value ",pval ,"is greater than 0.05, therefore we will accept null hypothesis") +} else { + cat("Since p-value ",pval ,"is less than 0.05, therefore we will reject null hypothesis and accept + alternative hypothesis.") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1c/Ex9_1c.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1c/Ex9_1c.R new file mode 100644 index 00000000..2ff51440 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.1c/Ex9_1c.R @@ -0,0 +1,26 @@ + # Page no. : 366 - 367 + +# Relationship between Interval Estimation and Hypothesis Testing + +mu <- 295 +alpha <- 0.05 +n <- 50 +xbar <- 297.6 +sigma <- 12 + +z_value <- 1.96 # alpha = 0.05 so alpha/2 = 0.05/2 = 0.025 (z-value is for 0.025) + +# 95% Confidence Interval + +margin_of_error <- z_value * (sigma / sqrt(n)) + +IE <- xbar + c(-margin_of_error, margin_of_error) # Interval Estimate + +cat("Interval estimate for 95% Confidence Interval is",IE) + +if(mu >= IE[2] || mu <= IE[1]) +{ + cat("Null Hypothesis is rejected..") +} else{ + cat("Null Hypothesis cannot be rejected..") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.2a/Ex9_2a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.2a/Ex9_2a.R new file mode 100644 index 00000000..1a15d1da --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.2a/Ex9_2a.R @@ -0,0 +1,25 @@ + # Page no. : 371 - 372 + +# Population Mean Sigma Unknown One Tailed Test + +mu0 <- 7 +alpha <- 0.05 +xbar <- 7.25 +s <- 1.052 +n <- 60 + +t_value <- (xbar - mu0) / (s / sqrt(n)) + +df <- n - 1 + +# Upper Tail Test + +pval <- pt(t_value,df = df,lower.tail = F) # Book answer is 0.354 + +if(pval > alpha) +{ + cat("Since p-value ",pval ,"is greater than 0.05, therefore we will accept null hypothesis") +} else { + cat("Since p-value ",pval ,"is less than 0.05, therefore we will reject null hypothesis and accept + alternative hypothesis.") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.2b/Ex9_2b.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.2b/Ex9_2b.R new file mode 100644 index 00000000..148fd992 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.2b/Ex9_2b.R @@ -0,0 +1,41 @@ + # Page no. : 372 - 373 + +# Population Mean Sigma Unknown Two Tailed Test + +mu0 <- 40 +alpha <- 0.05 +xbar <- 37.4 +s <- 11.79 +n <- 25 + +t_value <- (xbar - mu0) / (s / sqrt(n)) + +df <- n - 1 # Degree of Freedom + +# Two Tail Test +# P - value Approach + +pval <- 2 *(1 - pt(t_value,df = df,lower.tail = F)) # Book answer is 0.2822 + +if(pval > alpha) +{ + cat("Since p-value ",pval ,"is greater than 0.05, therefore we will accept null hypothesis") +} else { + cat("Since p-value ",pval ,"is less than 0.05, therefore we will reject null hypothesis and accept + alternative hypothesis.") +} + +# Critical Value Approach + +t_half_alpha <- qt(1 - (alpha/2),df) +critical_value_1 <- -t_half_alpha +critical_value_2 <- t_half_alpha + +if(t_value >= critical_value_2 || t_value <= critical_value_1) +{ + cat("Since t-value", t_value ,"does not lie in the range", critical_value_1 ,"and", critical_value_2 + ,"therefore we reject the null hypothesis and accept the alternative hypothesis.") +} else{ + cat("Since t-value", t_value ,"lies in the range", critical_value_1 ,"and", critical_value_2 + ,"therefore we accept the null hypothesis.") +} diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.3a/Ex9_3a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.3a/Ex9_3a.R new file mode 100644 index 00000000..edaf1328 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.3a/Ex9_3a.R @@ -0,0 +1,38 @@ + # Page no. : 377 - 378 + +# Population Proportion + +p0 <- 0.20 +alpha <- 0.05 +n <- 400 +x <- 100 + +p_bar <- x / n + +z_value <- (p_bar - p0) / sqrt((p0*(1 - p0)) / n) + +# Upper Tail Test + +# P-value Approach + +pval <- pnorm(z_value,lower.tail = F) +if(pval > alpha) +{ + cat("Since p-value ",pval ,"is greater than 0.05, therefore we will accept null hypothesis") +} else { + cat("Since p-value ",pval ,"is less than 0.05, therefore we will reject null hypothesis and accept + alternative hypothesis.") +} + +# Critical Value Approach + +z_alpha <- qnorm(1 - alpha) +critical_value <- z_alpha + +if(z_value >= critical_value) +{ + cat("Since z-value", z_value ,"is greater then or equal to", critical_value , "therefore we reject + the null hypothesis and accept the alternative hypothesis.") +} else{ + cat("Since z-value", z_value ,"is less than", critical_value,"therefore we accept the null hypothesis.") +} \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.4a/Ex9_4a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.4a/Ex9_4a.R new file mode 100644 index 00000000..288d81b6 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.4a/Ex9_4a.R @@ -0,0 +1,35 @@ + # Page no. : 382 - 383 + +# Calculating the Probability of Type Second Errors + +mu0 <- 120 +alpha <- 0.05 +z_value <- 1.645 +n <- 36 +sigma <- 12 + +xbar <- mu0 - z_value * (sigma / sqrt(n)) + +mu <- 112 +z <- (xbar - mu) / (sigma / sqrt(n)) + +# Upper Tail Test + +beta_value <- pnorm(z, lower.tail = F) + +cat("The type 2nd error is",beta_value) + + # Page no. : 384 + +xbar <- 116.71 +mu <- 115 +sigma <- 12 +n <- 36 + +z <- (xbar - mu) / (sigma / sqrt(n)) + +# Upper Tail Test + +beta_value <- pnorm(z, lower.tail = F) + +cat("The type 2nd error is",beta_value) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.5a/Ex9_5a.R b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.5a/Ex9_5a.R new file mode 100644 index 00000000..d58a7633 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/CH9/EX9.5a/Ex9_5a.R @@ -0,0 +1,15 @@ + # Page no. : 389 + +# Determining the Sample Size + +alpha <- 0.05 +beta <- 0.10 +z_alpha <- 1.645 +z_beta <- 1.28 +mu0 <- 120 +mua <- 115 +sigma <- 12 + +n <- ((z_alpha + z_beta)**2) * (sigma)**2 / (mu0 - mua)**2 # Sample Size +n <- ceiling(n) +cat("Sampling Size is",n) \ No newline at end of file diff --git a/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/README.txt b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/README.txt new file mode 100644 index 00000000..f7a745f4 --- /dev/null +++ b/Statistics_For_Business_And_Economics_by_Anderson,_Sweeney,_And_Williams/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Shivam Agrawal +Course: B.tech +Branch: Computer Science And Engineering +College/Institute/Organization: Techno India Njr Institute Of Technology + +About The Book + +Book: Statistics For Business And Economics +Author: Anderson, Sweeney, And Williams +Publisher: Cengage Learning, Usa +Year Of Publication: 2011 +ISBN: 9780538471886 +Edition: 11 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH10/EX10.1/Ex10_1.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH10/EX10.1/Ex10_1.R new file mode 100644 index 00000000..aad7d668 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH10/EX10.1/Ex10_1.R @@ -0,0 +1,22 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 10: Introduction to Estimation +# Example 10.1 on Pg 342 +# Doll Computer Company + +data1 <- c(235, 374, 309, 499, 253, 421, 361, 514, 462, 369, 394, 439, + 348, 344, 330, 261, 374, 302, 466, 535, 386, 316, 296, 332, 334) +data1 +mean1 <- mean(data1) +mean1 +alpha = 0.05 +library(stats) +std1 = 75 +std2 <- sd(data1) +std2 + +ll <- mean1 - 1.96*75/(sqrt(25)) +ul <- mean1 + 1.96*75/(sqrt(25)) + +cat("The 95% confidence interval is:","(",ll, ul,")") + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH11/EX11.1/Ex11_1.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH11/EX11.1/Ex11_1.zip new file mode 100644 index 00000000..74dbde4c Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH11/EX11.1/Ex11_1.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH11/EX11.2/Ex11_2.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH11/EX11.2/Ex11_2.zip new file mode 100644 index 00000000..e3c5b2ca Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH11/EX11.2/Ex11_2.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.1/Ex12_1.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.1/Ex12_1.zip new file mode 100644 index 00000000..b9e70434 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.1/Ex12_1.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.2/Ex12_2.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.2/Ex12_2.zip new file mode 100644 index 00000000..2d87867e Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.2/Ex12_2.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.3/Ex12_3.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.3/Ex12_3.R new file mode 100644 index 00000000..0f40f4a5 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.3/Ex12_3.R @@ -0,0 +1,51 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 12: INFERENCE ABOUT A POPULATION +# Example 12.3 on Pg 415 +# Consistency of a Container-Filling Machine, Part 1 + +data1 <- c(999.6, 1000.7, 999.3, 1000.1, 999.5, 1000.5, 999.7, 999.6, 999.1, 997.8, + 1001.3, 1000.7, 999.4, 1000.0, 998.3, 999.5, 1000.1, 998.3, 999.2, 999.2, + 1000.4, 1000.1, 1000.1, 999.6, 999.9) +data1 +mean1 <- mean(data1) +mean1 +popmean = 1 #Null Hypothesis: H0: population mean = 1 (sigma^2 =1) +n <- length(data1) +n #sample size = 25 +library(stats) +stdev1 <- sd(data1) +stdev1 #Answer: 0.7958 +stdev1^2 #Answer: 0.6333 + +chistat <- (n-1)*stdev1^2/popmean +chistat #Answer: Chi-square test statistic = 15.20 + +#One-Sample Chi-Squared Test On Variance, using varTest() +install.packages("EnvStats") +library(EnvStats) +result <- varTest(data1, alternative = "greater", conf.level = 0.95, sigma.squared = 1) + +#Answer: + +#Results of Hypothesis Test +#-------------------------- + +#Null Hypothesis: variance = 1 +#Alternative Hypothesis: True variance is greater than 1 +#Test Name: Chi-Squared Test on Variance +#Estimated Parameter(s): variance = 0.6333333 +#Data: data1 +#Test Statistic: Chi-Squared = 15.2 +#Test Statistic Parameter: df = 24 +#P-value: 0.9147699 +#95% Confidence Interval: LCL = 0.4174101 UCL = Inf + +if(result$p.value > 0.05) +{ + print("there is NOT enough evidence to infer that the claim of sigmasquared = 1 is true.") +} else +{ + print("there is enough evidence to infer that the claim of sigmasquared = 1 is true.") +} + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.4/Ex12_4.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.4/Ex12_4.R new file mode 100644 index 00000000..dd47bf49 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.4/Ex12_4.R @@ -0,0 +1,33 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 12: INFERENCE ABOUT A POPULATION +# Example 12.4 on Pg. 418 +# Consistency of a Container-Filling Machine, Part 2 + +data1 <- c(999.6, 1000.7, 999.3, 1000.1, 999.5, 1000.5, 999.7, 999.6, 999.1, 997.8, + 1001.3, 1000.7, 999.4, 1000.0, 998.3, 999.5, 1000.1, 998.3, 999.2, 999.2, + 1000.4, 1000.1, 1000.1, 999.6, 999.9) +data1 +mean1 <- mean(data1) +mean1 +popmean = 1 #Null Hypothesis: H0: population mean = 1 +n <- length(data1) +n +library(stats) +stdev1 <- sd(data1) +stdev1 + +chistat <- (n-1)*stdev1^2/popmean +chistat + +chisqalphaby2 <- qchisq(0.005, df=(n-1), lower.tail=FALSE) +chisq1minusalphaby2 <- qchisq(0.995, df=(n-1), lower.tail=FALSE) + +lcl <- (n-1)*stdev1^2 / chisqalphaby2 +lcl +ucl <- (n-1)*stdev1^2 / chisq1minusalphaby2 +ucl + +cat("The 99% confidence interval is:", "(", round(lcl,3), ",", round(ucl,3),")" ) +#Answer: (0.333, 1.537) + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.5/Ex12_5.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.5/Ex12_5.zip new file mode 100644 index 00000000..eca0b299 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.5/Ex12_5.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.6/Ex12_6.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.6/Ex12_6.zip new file mode 100644 index 00000000..1e9d34cf Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH12/EX12.6/Ex12_6.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.1/Ex13_1.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.1/Ex13_1.zip new file mode 100644 index 00000000..ea098df2 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.1/Ex13_1.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.10/Ex13_10.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.10/Ex13_10.zip new file mode 100644 index 00000000..0d9821cb Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.10/Ex13_10.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.11/Ex13_11.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.11/Ex13_11.zip new file mode 100644 index 00000000..38539ee5 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.11/Ex13_11.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.2/Ex13_2.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.2/Ex13_2.zip new file mode 100644 index 00000000..b3b8c575 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.2/Ex13_2.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.3/Ex13_3.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.3/Ex13_3.zip new file mode 100644 index 00000000..ceaaad74 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.3/Ex13_3.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.4/Ex13_4.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.4/Ex13_4.zip new file mode 100644 index 00000000..b500eed9 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.4/Ex13_4.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.5/Ex13_5.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.5/Ex13_5.zip new file mode 100644 index 00000000..156a1f10 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.5/Ex13_5.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.6/Ex13_6.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.6/Ex13_6.zip new file mode 100644 index 00000000..2acc0391 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.6/Ex13_6.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.7/Ex13_7.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.7/Ex13_7.zip new file mode 100644 index 00000000..a4f99bd5 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.7/Ex13_7.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.8/Ex13_8.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.8/Ex13_8.zip new file mode 100644 index 00000000..6b1dfce9 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.8/Ex13_8.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.9/Ex13_9.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.9/Ex13_9.zip new file mode 100644 index 00000000..1d21e924 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH13/EX13.9/Ex13_9.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.1/Ex14_1.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.1/Ex14_1.zip new file mode 100644 index 00000000..24ae8fe4 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.1/Ex14_1.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.2.a/Ex14_2a.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.2.a/Ex14_2a.zip new file mode 100644 index 00000000..b1ab1426 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.2.a/Ex14_2a.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.2b/Ex14_2b.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.2b/Ex14_2b.zip new file mode 100644 index 00000000..81aa1a70 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.2b/Ex14_2b.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.3/Ex14_3.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.3/Ex14_3.zip new file mode 100644 index 00000000..384a3ce9 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.3/Ex14_3.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.4/Ex14_4.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.4/Ex14_4.zip new file mode 100644 index 00000000..3f56ef01 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.4/Ex14_4.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.5/Ex14_5.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.5/Ex14_5.zip new file mode 100644 index 00000000..3e72b650 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH14/EX14.5/Ex14_5.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH15/EX15.1/Ex15_1.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH15/EX15.1/Ex15_1.R new file mode 100644 index 00000000..5dd6bd0b --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH15/EX15.1/Ex15_1.R @@ -0,0 +1,24 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 15: CHI-SQUARED TESTS +# Example 15.1 on Pg 598 +# Testing Market Shares + +#Null Hypothesis, Ho: p1 = .45, p2 = .40, p3 = .15 +#Alternative Hypothesis, H1: At least one pi is not equal to its specified value + +fabric <- c(102, 82, 16) +chi <- chisq.test(fabric, p = c(.45, .40, .15)) +chi$statistic +chi$p.value #its less than 0.05 implying one can reject the Null hypothesis + +tabchi <- qchisq(.95, df=2) + +if(chi$statistic > tabchi) +{ + print("Advertising campaigns do have an effect. NUll Hypothesis is rejected.") +} else +{ + print("Advertising campaigns do NOT have an effect.") +} + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH15/EX15.2/Ex15_2.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH15/EX15.2/Ex15_2.zip new file mode 100644 index 00000000..3d6b4bd9 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH15/EX15.2/Ex15_2.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.1/Ex16_1.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.1/Ex16_1.R new file mode 100644 index 00000000..e6e99c32 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.1/Ex16_1.R @@ -0,0 +1,25 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 16: SIMPLE LINEAR REGRESSION AND CORRELATION +# Example 16.1 on Pg 638 +# Annual Bonus and Years of Experience + + +years_of_exp <- c(1,2,3,4,5,6) #years of experience - Explanatory variable +annual_bonus <- c(6,1,9,5,17,12) #annual bonus in 1000s - Respone variable + +#determine the straight line relationship between years of experience and annual bonus using least squares + +regression_line <- lm(annual_bonus ~ years_of_exp) #gives regression line +summary(regression_line) #gives the Residuals, Std Error etc + +plot(years_of_exp, annual_bonus) #scatter plot +abline(lm(annual_bonus ~ years_of_exp)) + +cat("The least squares or regression line is Y =", + regression_line$coefficients[1], "+", regression_line$coefficients[2], "X", + "where Y is Annual Bonus and X is years of job experience") + +# The least squares line is Y = 0.934 + 2.114X + +#End + diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.2/Ex16_2.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.2/Ex16_2.zip new file mode 100644 index 00000000..ccc1b119 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.2/Ex16_2.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.3/Ex16_3.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.3/Ex16_3.zip new file mode 100644 index 00000000..2e622732 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.3/Ex16_3.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.4/Ex16_4.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.4/Ex16_4.zip new file mode 100644 index 00000000..318fcfb6 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.4/Ex16_4.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.5/Ex16_5.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.5/Ex16_5.zip new file mode 100644 index 00000000..e8159958 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.5/Ex16_5.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.6/Ex16_6.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.6/Ex16_6.zip new file mode 100644 index 00000000..7d867793 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.6/Ex16_6.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.7.a/Ex16_7a.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.7.a/Ex16_7a.zip new file mode 100644 index 00000000..c8bfaf8b Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.7.a/Ex16_7a.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.7.b/Ex16_7b.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.7.b/Ex16_7b.zip new file mode 100644 index 00000000..745a6aab Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH16/EX16.7.b/Ex16_7b.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH17/EX17.1/Ex17_1.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH17/EX17.1/Ex17_1.zip new file mode 100644 index 00000000..16cccda0 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH17/EX17.1/Ex17_1.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.1/Ex2_1.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.1/Ex2_1.R new file mode 100644 index 00000000..62cc7809 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.1/Ex2_1.R @@ -0,0 +1,38 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 2: Graphical Descriptive Techniques I +# Example 2.1 on Pg 18 +# Work Status in the GSS 2008 Survey + +# Complete dataset of 2021 observations could not be found on the +# website: https://www.cengage.com/cgi-wadsworth/course_products_wp.pl?fid=M20b&product_isbn_issn=9781285425450&template=nelson +# Partial data of 150 observations found in the book as given below: +data <- c(1, 1, 1, 1, 1, 7, 7, 1, 1, 5, 1, 5, 7, 1, 1, 5, 7, 1, 5, 2, 5, 1, 5, 8, 1, 5, 7, 1, 4, 2, 7, 1, 2, + 1, 1, 2, 1, 7, 1, 7, 1, 2, 1, 1, 1, 1, 1, 6, 5, 1, 1, 1, 1, 1, 2, 5, 2, 7, 2, 7, 8, 1, 8, 1, 7, 1, + 6, 7, 6, 1, 5, 1, 2, 2, 4, 1, 1, 1, 1, 1, 6, 5, 5, 3, 2, 1, 1, 8 ,1 ,5, 1, 1, 1, 1, 5, 5, 1, 5, 4, + 7, 1, 1, 1, 4, 5, 2, 5, 6, 7 ,7, 1, 4, 2, 1, 2, 6, 1, 1, 1, 1, 1, 1, 7, 4, 1, 1, 1, 7, 8, 1, 3, 1, + 1, 3, 1, 1, 1, 1, 1, 1, 2, 1, 5, 1, 1, 1, 1, 1, 2, 1) + +# factor() function divides the dataset into its levels +f <- factor(data) + +# levels() function used for renaming +levels(f) <- c('Working full-time', 'Working part-time', 'Temporary no work', 'laid off', + 'Retired', 'School', 'Keeping house', 'Other') + +# table() function displays the frequency table +c <- table(f) +print(c) #gives frequencies +rel_c <- paste(round(prop.table(c)*100,2), "%", sep="") #gives relative frequencies in % +cbind(c, rel_c) #Table showing both frequencies and relative frequencies + +# barplot() function plots the bar graph using the frequency table +barplot(c, main="Work Status", las=0) + +# for pie-chart +# pie() function plots the pie chart using the frequency table +pct <- round(c/sum(c)*100) #computing percentages +lbls <- paste(levels(f), pct) #add percents to labels +lbls <- paste(lbls, "%", sep="") #add % to labels +pie(c, labels = lbls, main ="Pie Chart of Work Status") + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.2/Ex2_2.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.2/Ex2_2.R new file mode 100644 index 00000000..ab32f139 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.2/Ex2_2.R @@ -0,0 +1,23 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 2: Graphical Descriptive Techniques I +# Example 2.2 on Pg 24 +# Energy Consumption in the United States in 2007 + + +data1_source <- c("Petroleum", "NaturalGas", "Coal", "Nuclear", "Hydroelec", + "Wood", "Biofuels", "Wind", "Waste", "Geotherm", "Solar") +data1_BTU <- c(39.77, 23.64, 22.8, 8.42, 2.45, 2.14, 1.02, 0.34, 0.43, 0.35, 0.08) + +dev.off() + +# the appropriate graphical technique, in describing the proportion of total energy consumption by all sources, +# is a pie-chart. +# pie-chart using pie() function +colors <- c("beige", "dodgerblue", "hotpink4", "navy", "lawngreen", "lightslategrey", "purple3", "red", "yellow", "black", "orange") +lbls <- paste(data1_BTU,"%", sep="") +pie_legend <- paste(data1_source, lbls) +pie(data1_BTU, main ="Pie Chart of Energy Consumption", cex=0.7, col=colors, labels = NA) +legend(x=0.75,y=0.75,legend =pie_legend, fill=colors, bty="n", cex=0.6) + + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.3/Ex2_3.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.3/Ex2_3.R new file mode 100644 index 00000000..6159e367 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.3/Ex2_3.R @@ -0,0 +1,21 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 2: Graphical Descriptive Techniques I +# Example 2.3 on Pg 26 +# Per Capita Beer Consumption (10 Selected Countries) + + +Country <- c("Australia","Austria","Belgium","Canada","Croatia","Czech Republic","Denmark","Finland","Germany", + "Hungary","Ireland","Luxembourg","Netherlands","New Zealand","Poland","Portugal","Slovakia","Spain", + "UK","USA") + +Beer_consumption <- c(119.2,106.3,93,68.3,81.2,138.1,89.9,85,147.8,75.3, 138.3,84.4, 79, 77, 69.1, 59.6, + 84.1, 83.8, 96.8, 81.6) + +#bar chart for beer consumption +barchart <- barplot(Beer_consumption, names.arg = Country, ylim=c(0,160),axisnames = FALSE, + main=" Per Capita Beer Consumption (10 Selected Countries)") +text(x = barchart, y = Beer_consumption, label = Beer_consumption, pos = 3, cex = 0.9, col = "red") +text(x = barchart, y = par()$usr[3], label = Country ,srt = 45, adj = c(1.1,1.1), xpd = TRUE) #rotated x-axisnames + +#End + diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.4/Ex2_4.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.4/Ex2_4.zip new file mode 100644 index 00000000..64595b36 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH2/EX2.4/Ex2_4.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.1/Ex3_1.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.1/Ex3_1.zip new file mode 100644 index 00000000..4f54f770 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.1/Ex3_1.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.2/Ex3_2.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.2/Ex3_2.zip new file mode 100644 index 00000000..4e0fba36 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.2/Ex3_2.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.3/Ex3_3.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.3/Ex3_3.zip new file mode 100644 index 00000000..8b03581b Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.3/Ex3_3.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.4/Ex3_4.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.4/Ex3_4.zip new file mode 100644 index 00000000..17f7cca8 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.4/Ex3_4.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.5/Ex3_5.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.5/Ex3_5.zip new file mode 100644 index 00000000..60fb0285 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.5/Ex3_5.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.6/Ex3_6.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.6/Ex3_6.zip new file mode 100644 index 00000000..c67e4ea8 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.6/Ex3_6.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.7/Ex3_7.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.7/Ex3_7.zip new file mode 100644 index 00000000..3632f816 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH3/EX3.7/Ex3_7.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.1/Ex4_1.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.1/Ex4_1.R new file mode 100644 index 00000000..79cc12fa --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.1/Ex4_1.R @@ -0,0 +1,16 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 4: Numerical Descriptive Techniques +# Example 4.1 on Pg 99 +# Mean Time Spent on the Internet + +Internet_hours <- c(0, 7, 12, 5, 33, 14, 8, 0, 9, 22) + +#manually computing the sample mean of Internet hours +mean1 <- sum(Internet_hours)/length(Internet_hours) + +#computing mean using function +mean2 <- mean(Internet_hours) + +#Answer: sample mean is 11 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.10/Ex4_10.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.10/Ex4_10.R new file mode 100644 index 00000000..bcd501fe --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.10/Ex4_10.R @@ -0,0 +1,33 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 4: NUMERICAL DESCRIPTIVE TECHNIQUES +# Example 4.10 on Pg. 114 +# Using Chebysheff's Theorem to Interpret Standard Deviation + + +population_mean <- 28000 +population_sd <- 3000 + +sd2 <- 2 #two standard deviations +sd3 <- 3 #three standard deviations +chebyshev_2 <- 1- 1/(sd2^2) +chebyshev_3 <- 1- 1/(sd3^2) + +lower_bound_two_SD <- population_mean - population_sd * sd2 #Answer: $22,000 +upper_bound_two_SD <- population_mean + population_sd * sd2 #Answer: $34,000 + +lower_bound_three_SD <- population_mean - population_sd * sd3 #Answer: $19,000 +upper_bound_three_SD <- population_mean + population_sd * sd3 #Answer: $34,000 + +cat("Given the histogram is NOT bell shaped, we can only apply the Chebyshev's Thoerem and say that:") + +cat("1. Atleast", paste(round(chebyshev_2*100,digits=0),"%",sep=""), + "of the returns on investment lie between", round(lower_bound_two_SD), + "and", + round(upper_bound_two_SD)) + +cat("2. Atleast", paste(round(chebyshev_3*100,digits=1),"%",sep=""), + "of the returns on investment lie between", round(lower_bound_three_SD), + "and", + round(upper_bound_three_SD)) + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.11/Ex4_11.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.11/Ex4_11.R new file mode 100644 index 00000000..c60f0b6f --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.11/Ex4_11.R @@ -0,0 +1,13 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 4: Numerical Descriptive Techniques +# Example 4.11 on Pg 118 +# Percentiles of Time Spent on Internet + +Internet_hours <- c(0, 7, 12, 5, 33, 14, 8, 0, 9, 22) + +quantile(Internet_hours, probs = c(.25, .50, .75), type=6) + +#Answer: 25% 50% 75% + #3.75 8.50 16.00 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.12/Ex4_12.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.12/Ex4_12.zip new file mode 100644 index 00000000..158cc480 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.12/Ex4_12.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.13/Ex4_13.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.13/Ex4_13.zip new file mode 100644 index 00000000..fa9bd6af Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.13/Ex4_13.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.14/Ex4_14.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.14/Ex4_14.zip new file mode 100644 index 00000000..7abd4c2e Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.14/Ex4_14.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.15/Ex4_15.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.15/Ex4_15.zip new file mode 100644 index 00000000..769856e1 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.15/Ex4_15.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.16/Ex4_16.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.16/Ex4_16.R new file mode 100644 index 00000000..7bb945cd --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.16/Ex4_16.R @@ -0,0 +1,24 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 4: Numerical Descriptive Techniques +# Example 4.16 on Pg 129 +# Calculating the Coefficient of Correlation + +#Set 1 +x1 <- c(2,6,7) +y1 <- c(13,20,27) +cor(x1,y1) +#Answer: Correlation coefficient for Set 1: 0.9449112 + +#Set 2 +x2 <- c(2,6,7) +y2 <- c(27,20,13) +cor(x2,y2) +#Answer: Correlation coefficient for Set 2: -0.9449112 + +#Set 3 +x3 <- c(2,6,7) +y3 <- c(20,27,13) +cor(x3,y3) +#Answer: Correlation coefficient for Set 3: -0.1889822 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.17/Ex4_17.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.17/Ex4_17.zip new file mode 100644 index 00000000..27a84ec8 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.17/Ex4_17.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.18/Ex4_18.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.18/Ex4_18.zip new file mode 100644 index 00000000..c28ad43c Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.18/Ex4_18.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.19/Ex4_19.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.19/Ex4_19.zip new file mode 100644 index 00000000..7d4eeb89 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.19/Ex4_19.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.2/Ex4_2.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.2/Ex4_2.zip new file mode 100644 index 00000000..b863df3e Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.2/Ex4_2.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.3/Ex4_3.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.3/Ex4_3.R new file mode 100644 index 00000000..fcd0b42b --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.3/Ex4_3.R @@ -0,0 +1,13 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 4: Numerical Descriptive Techniques +# Example 4.3 on Pg 100 +# Median Time Spent on Internet + +Internet_hours <- c(0, 7, 12, 5, 33, 14, 8, 0, 9, 22) + +#computing median using the function median() +median(Internet_hours) + +#Answer: sample median is 8.5 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.4/Ex4_4.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.4/Ex4_4.zip new file mode 100644 index 00000000..5322bb38 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.4/Ex4_4.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.5/Ex4_5.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.5/Ex4_5.R new file mode 100644 index 00000000..cf7b6ef4 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.5/Ex4_5.R @@ -0,0 +1,25 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 4: Numerical Descriptive Techniques +# Example 4.5 on Pg 102 +# Mode Time Spent on Internet + +Internet_hours <- c(0, 7, 12, 5, 33, 14, 8, 0, 9, 22) + +# there is no inbuilt function for calculating Mode +# So, a function is written to compute Mode. It works if the data is numeric. +# It creates a frequency table using the function table() and gives the index of the value occuring maximum +# times using the function which.max(). +Mode <- function(x) +{ + if (is.numeric(x)) + { + x_table <- table(x) + return(as.numeric(names(x_table)[which.max(x_table)])) + } +} + +Mode(Internet_hours) + +#Answer: sample mode is 0 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.6/Ex4_6.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.6/Ex4_6.zip new file mode 100644 index 00000000..a2a6d5ba Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.6/Ex4_6.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.7/Ex4_7.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.7/Ex4_7.R new file mode 100644 index 00000000..9b6eb73c --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.7/Ex4_7.R @@ -0,0 +1,18 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 4: Numerical Descriptive Techniques +# Example 4.7 on Pg 110 +# Summer Jobs + +summer_job <- c(17, 15, 23, 7, 9, 13) + +#Find the mean and variance of these data. + +#Sample Mean +mean(summer_job) + +#Sample Variance +var(summer_job) + +#Answer: Mean is 14 & Variance is 33.2 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.8/Ex4_8.zip b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.8/Ex4_8.zip new file mode 100644 index 00000000..936cabb3 Binary files /dev/null and b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.8/Ex4_8.zip differ diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.9/Ex4_9.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.9/Ex4_9.R new file mode 100644 index 00000000..2352bd2e --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH4/EX4.9/Ex4_9.R @@ -0,0 +1,44 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 4: NUMERICAL DESCRIPTIVE TECHNIQUES +# Example 4.9 on Pg. 113 +# Using the Empirical Rule to Interpret Standard Deviation + + +population_mean <- 0.1 +population_sd <- 0.08 +sd1 <- 1 +sd2 <- 2 +sd3 <- 3 + +lower_bound_one_SD <- population_mean - population_sd * sd1 #Answer: 2% +upper_bound_one_SD <- population_mean + population_sd * sd1 #Answer: 18% +probability_within_bounds1 <- pnorm(upper_bound_one_SD, population_mean, population_sd) - pnorm(lower_bound_one_SD, population_mean, population_sd) +#Answer: 68% + +lower_bound_two_SD <- population_mean - population_sd * sd2 #Answer: -6% +upper_bound_two_SD <- population_mean + population_sd * sd2 #Answer: 26% +probability_within_bounds2 <- pnorm(upper_bound_two_SD, population_mean, population_sd) - pnorm(lower_bound_two_SD, population_mean, population_sd) +#Answer: 95% + +lower_bound_three_SD <- population_mean - population_sd * sd3 #Answer: -14% +upper_bound_three_SD <- population_mean + population_sd * sd3 #Answer: 34% +probability_within_bounds3 <- pnorm(upper_bound_three_SD, population_mean, population_sd) - pnorm(lower_bound_three_SD, population_mean, population_sd) +#Answer: 99.7% + +cat("Given the histogram is bell shaped, we can apply the Empirical Rule and say that:") +cat("1. Approximately", paste(round((probability_within_bounds1)*100,digits=0),"%",sep=""), + "of the returns on investment lie between", paste(round((lower_bound_one_SD)*100,digits=0),"%",sep=""), + "and", + paste(round((upper_bound_one_SD)*100,digits=0),"%",sep="")) + +cat("2. Approximately", paste(round((probability_within_bounds2)*100,digits=0),"%",sep=""), + "of the returns on investment lie between", paste(round((lower_bound_two_SD)*100,digits=0),"%",sep=""), + "and", + paste(round((upper_bound_two_SD)*100,digits=0),"%",sep="")) + +cat("3. Approximately", paste(round((probability_within_bounds3)*100,digits=1),"%",sep=""), + "of the returns on investment lie between", paste(round((lower_bound_three_SD)*100,digits=0),"%",sep=""), + "and", + paste(round((upper_bound_three_SD)*100,digits=0),"%",sep="")) + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH5/EX5.1/Ex5_1.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH5/EX5.1/Ex5_1.R new file mode 100644 index 00000000..400d2c2a --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH5/EX5.1/Ex5_1.R @@ -0,0 +1,9 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 5: Data Collection and Sampling +# Example 5.1 on Pg. 168 +# Random Sample of Income Tax Returns + +sample(1:1000, 40, replace=TRUE) #random sample generation with replacement +sample(1:1000, 40, replace=FALSE) #random sample generation without replacement + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.1/Ex6_1.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.1/Ex6_1.R new file mode 100644 index 00000000..26695249 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.1/Ex6_1.R @@ -0,0 +1,41 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.1 on Pg. 182 +# Determinants of Success among Mutual Fund Managers-Part 1 + + +#Denote: +#A1 = Fund manager graduated from a top-20 MBA program +#A2 = Fund manager did not graduate from a top-20 MBA program +#B1 = Fund outperforms the market +#B2 = Fund does not outperform the market + +#Given: +#P(A1 and B1) = 0.11 +#P(A2 and B1) = 0.06 +#P(A1 and B2) = 0.29 +#P(A2 and B2) = 0.54 + +p_A1_B1 = 0.11 +p_A2_B1 = 0.06 +p_A1_B2 = 0.29 +p_A2_B2 = 0.54 + +#P(A1) = P(A1 and B1) + P(A1 and B2) +p_A1 = p_A1_B1 + p_A1_B2 +#Answer: P(A1) = 0.4 + +#P(A2) = P(A2 and B1) + P(A2 and B2) +p_A2 = p_A2_B1 + p_A2_B2 +#Answer: P(A2) = 0.6 + +#P(B1) = P(A2 and B1) + P(A1 and B1) +p_B1 = p_A2_B1 + p_A1_B1 +#Answer: P(B1) = 0.17 + +#P(B2) = P(A2 and B2) + P(A1 and B2) +p_B2 = p_A2_B2 + p_A1_B2 +#Answer: P(B2) = 0.83 + + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.10/Ex6_10.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.10/Ex6_10.R new file mode 100644 index 00000000..5d101788 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.10/Ex6_10.R @@ -0,0 +1,130 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.10 on Pg. 203 +# Probability of Prostate Cancer + +#Given: +#Prior: P(Has Prostrate Cancer) = .010 +#Given Likelihood probabilities +#True negative: P(Negative test GIVEN No Prostrate Cancer) = 1 - .135 = .865 +#False positive: P(Positive test GIVEN No Prostrate Cancer) = .135 +#True positive: P(Positive test GIVEN Prostrate Cancer) = 1 - .300 = .700 +#False negative: P(Negative test GIVEN Prostrate Cancer) = .300 + + +#Function 'bayes_probability_tree' that creates a Probability Tree using Bayes Theorem + +install.packages("DiagrammeR") +library(DiagrammeR) + +bayes_probability_tree <- function(prior, true_positive, true_negative) { + + if (!all(c(prior, true_positive, true_negative) > 0) && !all(c(prior, true_positive, true_negative) < 1)) { + stop("probabilities must be greater than 0 and less than 1.", + call. = FALSE) + } + c_prior <- 1 - prior + c_tp <- 1 - true_positive + c_tn <- 1 - true_negative + + round4 <- purrr::partial(round, digits = 4) + + b1 <- round4(prior * true_positive) + b2 <- round4(prior * c_tp) + b3 <- round4(c_prior * c_tn) + b4 <- round4(c_prior * true_negative) + + bp <- round4(b1/(b1 + b3)) + + labs <- c("Cancer", prior, c_prior, true_positive, c_tp, true_negative, c_tn, b1, b2, b4, b3) + + tree <- + create_graph() %>% + add_n_nodes( + n = 11, + type = "path", + label = labs, + node_aes = node_aes( + shape = "circle", + height = 1, + width = 1, + x = c(0, 3, 3, 6, 6, 6, 6, 8, 8, 8, 8), + y = c(0, 2, -2, 3, 1, -3, -1, 3, 1, -3, -1))) %>% + add_edge( + from = 1, + to = 2, + edge_aes = edge_aes( + label = "Has Prostrate Cancer" + ) + ) %>% + add_edge( + from = 1, + to = 3, + edge_aes = edge_aes( + label = "Does not have Prostrate Cancer" + ) + ) %>% + add_edge( + from = 2, + to = 4, + edge_aes = edge_aes( + label = "True Positive: Positive test GIVEN Cancer" + ) + ) %>% + add_edge( + from = 2, + to = 5, + edge_aes = edge_aes( + label = "False Negative: Negative test GIVEN Cancer" + ) + ) %>% + add_edge( + from = 3, + to = 7, + edge_aes = edge_aes( + label = "False Positive: Positive test GIVEN NO Cancer " + ) + ) %>% + add_edge( + from = 3, + to = 6, + edge_aes = edge_aes( + label = "True Negative: Negative test GIVEN NO Cancer" + ) + ) %>% + add_edge( + from = 4, + to = 8, + edge_aes = edge_aes( + label = "=" + ) + ) %>% + add_edge( + from = 5, + to = 9, + edge_aes = edge_aes( + label = "=" + ) + ) %>% + add_edge( + from = 7, + to = 11, + edge_aes = edge_aes( + label = "=" + ) + ) %>% + add_edge( + from = 6, + to = 10, + edge_aes = edge_aes( + label = "=" + ) + ) + message(glue::glue("The probability that the man has prostate cancer given a positive test result is {bp}")) + print(render_graph(tree)) + invisible(tree) +} + +bayes_probability_tree(prior = 0.01, true_positive = 0.7, true_negative = (1-0.135)) + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.2/Ex6_2.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.2/Ex6_2.R new file mode 100644 index 00000000..d49b0a99 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.2/Ex6_2.R @@ -0,0 +1,30 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.2 on Pg. 184 +# Determinants of Success among Mutual Fund Managers-Part 2 + +#Denote: +#A1 = Fund manager graduated from a top-20 MBA program +#A2 = Fund manager did not graduate from a top-20 MBA program +#B1 = Fund outperforms the market +#B2 = Fund does not outperform the market + +#Given: +#P(A1 and B1) = 0.11 +#P(A2 and B1) = 0.06 +#P(A1 and B2) = 0.29 +#P(A2 and B2) = 0.54 + +p_A1_B1 = 0.11 +p_A2_B1 = 0.06 +p_A1_B2 = 0.29 +p_A2_B2 = 0.54 + +#Find P(A1/B2) + +p_A1_given_B2 = p_A1_B2/ (p_A2_B2 + p_A1_B2) +#Answer: P(A1/B2) = 0.3494 + +cat("34.9% of all mutual funds that do not outperform the market are managed by top-20 MBA program graduates.") + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.3/Ex6_3.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.3/Ex6_3.R new file mode 100644 index 00000000..a9dad437 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.3/Ex6_3.R @@ -0,0 +1,36 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.3 on Pg. 185 +# Determinants of Success among Mutual Fund Managers-Part 3 + + +#Denote: +#A1 = Fund manager graduated from a top-20 MBA program +#A2 = Fund manager did not graduate from a top-20 MBA program +#B1 = Fund outperforms the market +#B2 = Fund does not outperform the market + +#Given: +#P(A1 and B1) = 0.11 +#P(A2 and B1) = 0.06 +#P(A1 and B2) = 0.29 +#P(A2 and B2) = 0.54 + +p_A1_B1 = 0.11 +p_A2_B1 = 0.06 +p_A1_B2 = 0.29 +p_A2_B2 = 0.54 + +#determine whether A1 and B1 are independent + +p_A1_given_B1 = p_A1_B1/ (p_A2_B1 + p_A1_B1) +p_A1 = p_A1_B1 + p_A1_B2 + +cat("P(A1/B1) =", p_A1_given_B1) +cat("P(A1) =", p_A1) + +if(p_A1 == p_A1_given_B1) +{cat("A1 and B1 are independent since P(A1/B1) and P(A1) have same value")}else + {cat("A1 and B1 are not independent since P(A1/B1) and P(A1) do not have same value")} + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.4/Ex6_4.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.4/Ex6_4.R new file mode 100644 index 00000000..dbc55098 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.4/Ex6_4.R @@ -0,0 +1,33 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.4 on Pg. 186 +# Determinants of Success among Mutual Fund Managers-Part 4 + + +#Denote: +#A1 = Fund manager graduated from a top-20 MBA program +#A2 = Fund manager did not graduate from a top-20 MBA program +#B1 = Fund outperforms the market +#B2 = Fund does not outperform the market + +#Given: +#P(A1 and B1) = 0.11 +#P(A2 and B1) = 0.06 +#P(A1 and B2) = 0.29 +#P(A2 and B2) = 0.54 + +p_A1_B1 = 0.11 +p_A2_B1 = 0.06 +p_A1_B2 = 0.29 +p_A2_B2 = 0.54 + +#Find P(A1 or B1) i.e., P(A1 union B1) +#P(A1 or B1) = 1 - P(A2 and B2) + +p_A1_or_B1 = 1 - p_A2_B2 +#Answer: 0.46 + +cat("Thus,", paste(round(p_A1_or_B1*100), "%", sep=""),"of mutual funds either outperform the market or are managed by a top-20 MBA program graduate + or have both characteristics. ") + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.5/Ex6_5.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.5/Ex6_5.R new file mode 100644 index 00000000..7dc10749 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.5/Ex6_5.R @@ -0,0 +1,23 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.5 on Pg. 192 +# Selecting Two Students without Replacement + +#A is the event that the first student chosen is female +#B is the event that the second student chosen is also female. + +#Find P(A and B) without replacement + +#Given: +number_of_males = 7 +number_of_females = 3 + +p_A = number_of_females/(number_of_females + number_of_males) +p_B_given_A = (number_of_females-1)/((number_of_females + number_of_males)-1) #without replacement + +p_A_and_B = p_A * p_B_given_A +#Answer: 0.06666667 + +cat("Probability that the two students chosen are female:", p_A_and_B) + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.6/Ex6_6.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.6/Ex6_6.R new file mode 100644 index 00000000..7023f75f --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.6/Ex6_6.R @@ -0,0 +1,23 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.6 on Pg. 193 +# Selecting Two Students with Replacement + +#A is the event that the first student chosen is female +#B is the event that the second student chosen is also female. + +#Find P(A and B) with replacement + +#Given: +number_of_males = 7 +number_of_females = 3 + +p_A = number_of_females/(number_of_females + number_of_males) +p_B = number_of_females/(number_of_females + number_of_males) #with replacement + +p_A_and_B = p_A * p_B +#Answer: 0.09 + +cat("Probability that the two students chosen are female:", p_A_and_B) + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.7/Ex6_7.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.7/Ex6_7.R new file mode 100644 index 00000000..5bbdba34 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.7/Ex6_7.R @@ -0,0 +1,22 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.7 on Pg. 194 +# Applying the Addition Rule + +#A = the household subscribes to the Sun +#B = the household subscribes to the Post + +#Given P(A) = 0.22, P(B) = 0.35 and P(A and B) = 0.06 +#Find P(A union B) i.e., P(A or B) + +p_A = 0.22 +p_B = 0.35 +p_A_and_B = 0.06 + +#Addition rule: P(A union B) = P(A) + P(B) - P(A and B) +p_A_or_B = p_A + p_B - p_A_and_B +#Answer: 0.51 + +cat("The probability that a randomly selected household subscribes to either newspaper is", p_A_or_B) + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.8/Ex6_8.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.8/Ex6_8.R new file mode 100644 index 00000000..a4841020 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.8/Ex6_8.R @@ -0,0 +1,26 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.8 on Pg. 196 +# Probability of Passing the Bar Exam + +#Given: +#P(pass rate for first-time Bar Exam takers) = 0.72 +#P(pass rate for second-time Bar Exam takers who failed first time) = 0.88 + +pass_1 = 0.72 +fail_1 = 1-pass_1 + +pass2_Given_fail1 = 0.88 +#fail_and_pass = P(Fail [on first exam] and Pass [on second exam]) + +fail1_and_pass2 = pass2_Given_fail1 * fail_1 +#Answer: P(Fail [on first exam] and Pass [on second exam]) = 0.2464 + +#We need probability that a randomly selected law school graduate becomes a lawyer i.e., +#we need to find probability of passing the first or second exam. + +pass = pass_1 + fail1_and_pass2 + +cat("probability that a randomly selected law school graduate becomes a lawyer:", pass) + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.9/Ex6_9.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.9/Ex6_9.R new file mode 100644 index 00000000..0cbb2963 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH6/EX6.9/Ex6_9.R @@ -0,0 +1,28 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 6: PROBABILITY +# Example 6.9 on Pg. 199 +# Should an MBA Applicant Take a Preparatory Course? + +#A1 = GMAT score is 650 or more +#A2 = GMAT score less than 650 +#B = Take preparatory course + +#Given: +#P(B given A1) = .52 +#P(A1) = p_A1 = 0.1 +#P(B given A2) = .23 + +#Find P(A1/B) + +p_A1 = 0.1 +p_A2 = 1 - p_A1 +p_B_given_A1 = 0.52 +p_B_given_A2 = 0.23 + +#BAYE'S Rule: +#P(A1 given B) = P(A1)*P(B given A1) / (P(A1)*P(B given A1) + P(A2)*P(B given A2)) + +p_A1_given_B = (p_A1*p_B_given_A1) / (p_A1*p_B_given_A1 + p_A2*p_B_given_A2) +#Answer: 0.2007722 + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.1/Ex7_1.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.1/Ex7_1.R new file mode 100644 index 00000000..33961ae1 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.1/Ex7_1.R @@ -0,0 +1,18 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.1 on Pg. 220 +# Probability Distribution of Persons per Household + +#X is used to denote the random variable, the number of persons per household. +#Develop the probability distribution of X. + +Number_of_Persons <- c(1,2,3,4,5,6,7) +Number_of_Households <- c(31.1, 38.6, 18.8, 16.2, 7.2, 2.7, 1.4) + +#we need Probability of X i.e., the relative frequency. Let it be denoted by P_X + +P_X <- round(Number_of_Households/sum(Number_of_Households), digits=3) + +#Answer: P(X): 0.268 0.333 0.162 0.140 0.062 0.023 0.012 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.10/Ex7_10.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.10/Ex7_10.R new file mode 100644 index 00000000..aca191df --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.10/Ex7_10.R @@ -0,0 +1,21 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.10 on Pg. 247 +# Will Pat Fail the Quiz? + + +# Find the probability that Pat fails the quiz. A mark is considered a failure if it is less than 50% +# n=10 iid trials. probability of each success is 1/5. Binomial distribution is apt. + +#dbinom() function for Binomial +p0 <- dbinom(0, 10, 0.2) #x=0, n=10, p=0.2 +p1 <- dbinom(1, 10, 0.2) #x=1, n=10, p=0.2 +p2 <- dbinom(2, 10, 0.2) #x=2, n=10, p=0.2 +p3 <- dbinom(3, 10, 0.2) #x=3, n=10, p=0.2 +p4 <- dbinom(4, 10, 0.2) #x=4, n=10, p=0.2 + +cat("P(Pat fails the quiz) =", sum(p0,p1,p2,p3,p4)) + +#Answer: 0.96721 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.11/Ex7_11.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.11/Ex7_11.R new file mode 100644 index 00000000..8c599e5f --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.11/Ex7_11.R @@ -0,0 +1,27 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.11 on Pg. 249 +# Pat Statsdud Has Been Cloned! + +#mean n sd of a class with students like Pat?! + +mean.function <- function(n,p) +{ + return(n*p) +} + +sd.function <- function(n,p) +{ + return(sqrt(n*p*(1-p))) +} + +#mean of binomial i.e., nxp +mean.function(10,0.2) + +#variance of binomial i.e., nxpxq +sd.function(10,0.2) + +#Answer: mean is 2 +# sd is 1.264911 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.12/Ex7_12.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.12/Ex7_12.R new file mode 100644 index 00000000..cee18b8e --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.12/Ex7_12.R @@ -0,0 +1,17 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.12 on Pg. 252 +# Probability of the Number of Typographical Errors in Textbooks + + +# Given the number of errors per 100 pages follows Poisson (1.5) + +# P(there are no typographical errors in a sample of 100 pages) is given as: + +v <- dpois(0, 1.5) + +cat("P(there are no typographical errors in a sample of 100 pages) =", v ) + +#Answer: 0.22313 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.13.a/Ex7_13a.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.13.a/Ex7_13a.R new file mode 100644 index 00000000..0d2c0e69 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.13.a/Ex7_13a.R @@ -0,0 +1,18 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.13a on Pg. 253 +# Probability of the Number of Typographical Errors in 400 Pages + + +# Given the number of errors per 100 pages follows Poisson (1.5). +# Probability of the Number of Typographical Errors in 400 Pages. Now, mean is 6 typos per 400 pages. + +# P(there are no typographical errors in a sample of 400 pages) is given as: + +v <- dpois(0, 4*1.5) + +#Answer: 0.0024788 + +cat("P(there are no typographical errors in a sample of 400 pages) =", v ) + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.13.b/Ex7_13b.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.13.b/Ex7_13b.R new file mode 100644 index 00000000..0dbc3d7d --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.13.b/Ex7_13b.R @@ -0,0 +1,23 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.13b on Pg. 253 +# Probability of the Number of Typographical Errors in 400 Pages + + +# Given the number of errors per 100 pages follows Poisson (1.5). +# Probability of the Number of Typographical Errors in 400 Pages. Now, mean is 6 typos per 400 pages. + +# P(there are five or fewer typos) is given as: + +p0 <- dpois(0, 4*1.5) +p1 <- dpois(1, 4*1.5) +p2 <- dpois(2, 4*1.5) +p3 <- dpois(3, 4*1.5) +p4 <- dpois(4, 4*1.5) +p5 <- dpois(5, 4*1.5) + +cat("P(X <= 5) = P(0) + P(1) + P(2) + P(3) + P(4) + P(5) =", sum(p0,p1,p2,p3,p4,p5)) + +#Answer: 0.44568 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.2/Ex7_2.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.2/Ex7_2.R new file mode 100644 index 00000000..3e4917e7 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.2/Ex7_2.R @@ -0,0 +1,33 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.2 on Pg. 221 +# Probability Distribution of the Number of Sales + +# Denote: +# X = the number of sales +# prob = P(success) = 0.2 +# q = P(failure) = 0.8 +# three trials + +ProbofSales <- function(q) +{ + p = pbinom(q, size = 3, prob = 0.2, lower.tail = TRUE) + return(p) +} + +#p_0 = P(X=0) +p_0 = ProbofSales(0) +#p_1 = P(X=1) +p_1 = ProbofSales(1) - p_0 +#p_2 = P(X=2) +p_2 = ProbofSales(2) - ProbofSales(1) +#p_3 = P(X=3) +p_3 = ProbofSales(3) - ProbofSales(2) + +cat("The Probability Distribution of number of Sales:") +cat("P(Number of Sales is 0):", p_0) #Answer: 0.512 +cat("P(Number of Sales is 1):", p_1) #Answer: 0.384 +cat("P(Number of Sales is 2):", p_2) #Answer: 0.096 +cat("P(Number of Sales is 3):", p_3) #Answer: 0.008 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.3/Ex7_3.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.3/Ex7_3.R new file mode 100644 index 00000000..41dc1054 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.3/Ex7_3.R @@ -0,0 +1,25 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.3 on Pg. 224 +# Describing the Population of the Number of Persons per Household + + +#X is used to denote the random variable, the number of persons per household. +#Find the mean, variance, and standard deviation for the population of the number of persons per household + +Number_of_Persons <- c(1,2,3,4,5,6,7) +Number_of_Households <- c(31.1, 38.6, 18.8, 16.2, 7.2, 2.7, 1.4) + +#we need Probability of X i.e., the relative frequency. Let it be denoted by P_X +P_X <- round(Number_of_Households/sum(Number_of_Households), digits=3) + +E_X <- sum(P_X*Number_of_Persons) +V_X <- sum(((Number_of_Persons-E_X)^2)*P_X) +STDEV <- sqrt(V_X) + +#Answer: E(X) = 2.512 + #Var(X) = 1.9539 + #Std deviation (X) = 1.3978 + + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.4/Ex7_4.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.4/Ex7_4.R new file mode 100644 index 00000000..b6a7acb6 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.4/Ex7_4.R @@ -0,0 +1,26 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.4 on Pg. 225 +# Describing the Population of Monthly Profits + +#Given: +mean_sales = 25000 #mean of monthly sales at a computer store +stdev_sales = 4000 #standard deviation of monthly sales at a computer store + +#Given fixed cost: +fc = 6000 + +#Laws of Expected Value: E(c) = c; E(X + c) = E(X) + c; E(cX) = c*E(X) +#Laws of Variance: V(X + c) = V(X); V(cX) = c^2*V(X); V(c)=0 + +#Given: Profit = 0.3*Sales - fixed cost. + +#Applying the laws of expected value, E(Profit) = 0.3*E(Sales) - 6000 +#Applying the laws of variance, V(Profit) = V(0.30(Sales) - 6,000) = 0.09V(Sales) + +expected_profit = 0.3*mean_sales - fc +#Answer: 1500 +stdev_profit = sqrt(0.09*stdev_sales^2) +#Answer: 1200 + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.5/Ex7_5.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.5/Ex7_5.R new file mode 100644 index 00000000..502b2e9c --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.5/Ex7_5.R @@ -0,0 +1,64 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.5 on Pg. 230 +# Bivariate Distribution of the Number of House Sales + + +# X = number of houses that Xavier will sell in a month +# Y = number of houses Yvette will sell in a month. + +# bivariate probability distribution of X & Y +matr=matrix(c(0.12, 0.21, 0.07, 0.42, 0.06, 0.02, 0.06, 0.03, 0.01),3,3) + +#Marginal probabilities of Y +Y_marginal <- margin.table(matr, 1) +Y_marginaltable <- matrix(c(0,1,2, Y_marginal),3,2) +colnames(Y_marginaltable) <- c('Y', 'P(Y)') +rownames(Y_marginaltable) <- c('', '', '') +Y_marginaltable + +#Expected value of Y, E(Y): +Expected_Y = X_marginaltable[1]*Y_marginaltable[4] + Y_marginaltable[2]*Y_marginaltable[5] + + Y_marginaltable[3]*Y_marginaltable[6] +Expected_Y +#Answer: 0.5 + +#Variance(Y): +Var_Y = (Y_marginaltable[1]-Expected_Y)^2*Y_marginaltable[4] + + (Y_marginaltable[2]-Expected_Y)^2*Y_marginaltable[5] + + (Y_marginaltable[3]-Expected_Y)^2*Y_marginaltable[6] +Var_Y +#Answer: 0.45 + +#Standard Deviation of Y +Std_Y = sqrt(Var_Y) +#Answer: 0.6708204 + +################################### + +#Marginal probabilities of X +X_marginal <- margin.table(matr, 2) +X_marginaltable <- matrix(c(0,1,2, X_marginal),3,2) +colnames(X_marginaltable) <- c('X', 'P(X)') +rownames(X_marginaltable) <- c('', '', '') +X_marginaltable + +#Expected value of X, E(X): +Expected_X = X_marginaltable[1]*X_marginaltable[4] + X_marginaltable[2]*X_marginaltable[5] + + X_marginaltable[3]*X_marginaltable[6] +Expected_X +#Answer: 0.7 + +#Variance(X): +Var_X = (X_marginaltable[1]-Expected_X)^2*X_marginaltable[4] + + (X_marginaltable[2]-Expected_X)^2*X_marginaltable[5] + + (X_marginaltable[3]-Expected_X)^2*X_marginaltable[6] +Var_X +#Answer: 0.41 + +#Standard Deviation of X +Std_X = sqrt(Var_X) +#Answer: 0.6403124 + + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.6/Ex7_6.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.6/Ex7_6.R new file mode 100644 index 00000000..794ced19 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.6/Ex7_6.R @@ -0,0 +1,78 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.6 on Pg. 232 +# Describing the Bivariate Distribution + + +# X = number of houses that Xavier will sell in a month +# Y = number of houses Yvette will sell in a month. + +# bivariate probability distribution of X & Y +matr=matrix(c(0.12, 0.21, 0.07, 0.42, 0.06, 0.02, 0.06, 0.03, 0.01),3,3) + +#Marginal probabilities of Y +Y_marginal <- margin.table(matr, 1) +Y_marginaltable <- matrix(c(0,1,2, Y_marginal),3,2) +colnames(Y_marginaltable) <- c('Y', 'P(Y)') +rownames(Y_marginaltable) <- c('', '', '') +Y_marginaltable + +#Expected value of Y, E(Y): +Expected_Y = X_marginaltable[1]*Y_marginaltable[4] + Y_marginaltable[2]*Y_marginaltable[5] + + Y_marginaltable[3]*Y_marginaltable[6] +Expected_Y +#Answer: 0.5 + +#Variance(Y): +Var_Y = (Y_marginaltable[1]-Expected_Y)^2*Y_marginaltable[4] + + (Y_marginaltable[2]-Expected_Y)^2*Y_marginaltable[5] + + (Y_marginaltable[3]-Expected_Y)^2*Y_marginaltable[6] +Var_Y +#Answer: 0.45 + +#Standard Deviation of Y +Std_Y = sqrt(Var_Y) +#Answer: 0.6708204 + +################################### + +#Marginal probabilities of X +X_marginal <- margin.table(matr, 2) +X_marginaltable <- matrix(c(0,1,2, X_marginal),3,2) +colnames(X_marginaltable) <- c('X', 'P(X)') +rownames(X_marginaltable) <- c('', '', '') +X_marginaltable + +#Expected value of X, E(X): +Expected_X = X_marginaltable[1]*X_marginaltable[4] + X_marginaltable[2]*X_marginaltable[5] + + X_marginaltable[3]*X_marginaltable[6] +Expected_X +#Answer: 0.7 + +#Variance(X): +Var_X = (X_marginaltable[1]-Expected_X)^2*X_marginaltable[4] + + (X_marginaltable[2]-Expected_X)^2*X_marginaltable[5] + + (X_marginaltable[3]-Expected_X)^2*X_marginaltable[6] +Var_X +#Answer: 0.41 + +#Standard Deviation of X +Std_X = sqrt(Var_X) +#Answer: 0.6403124 + + +#################### + +#Covariance(X,Y): +cov_x_y = (Y_marginaltable[1]-Expected_Y)*(X_marginaltable[1]-Expected_X)*0.12+(Y_marginaltable[1]-Expected_Y)*(X_marginaltable[2]-Expected_X)*0.42+(Y_marginaltable[1]-Expected_Y)*(X_marginaltable[3]-Expected_X)*0.06+(Y_marginaltable[2]-Expected_Y)*(X_marginaltable[1]-Expected_X)*0.21+(Y_marginaltable[2]-Expected_Y)*(X_marginaltable[2]-Expected_X)*0.06+(Y_marginaltable[2]-Expected_Y)*(X_marginaltable[3]-Expected_X)*0.03+(Y_marginaltable[3]-Expected_Y)*(X_marginaltable[1]-Expected_X)*0.07+(Y_marginaltable[3]-Expected_Y)*(X_marginaltable[2]-Expected_X)*0.02+(Y_marginaltable[3]-Expected_Y)*(X_marginaltable[3]-Expected_X)*0.01 +cov_x_y +#Answer: -0.15 + + +#Correlation(X,Y) +corr_x_y = cov_x_y/(Std_X*Std_Y) +corr_x_y +#Answer: -0.3492151 + + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.7/Ex7_7.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.7/Ex7_7.R new file mode 100644 index 00000000..1ca7fd6f --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.7/Ex7_7.R @@ -0,0 +1,82 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.7 on Pg. 234 +# Describing the Population of the Total Number of House Sales + + +# X = number of houses that Xavier will sell in a month +# Y = number of houses Yvette will sell in a month. + +# bivariate probability distribution of X & Y +matr=matrix(c(0.12, 0.21, 0.07, 0.42, 0.06, 0.02, 0.06, 0.03, 0.01),3,3) + +#Marginal probabilities of Y +Y_marginal <- margin.table(matr, 1) +Y_marginaltable <- matrix(c(0,1,2, Y_marginal),3,2) +colnames(Y_marginaltable) <- c('Y', 'P(Y)') +rownames(Y_marginaltable) <- c('', '', '') +Y_marginaltable + +#Expected value of Y, E(Y): +Expected_Y = X_marginaltable[1]*Y_marginaltable[4] + Y_marginaltable[2]*Y_marginaltable[5] + + Y_marginaltable[3]*Y_marginaltable[6] +Expected_Y +#Answer: 0.5 + +#Variance(Y): +Var_Y = (Y_marginaltable[1]-Expected_Y)^2*Y_marginaltable[4] + + (Y_marginaltable[2]-Expected_Y)^2*Y_marginaltable[5] + + (Y_marginaltable[3]-Expected_Y)^2*Y_marginaltable[6] +Var_Y +#Answer: 0.45 + +#Standard Deviation of Y +Std_Y = sqrt(Var_Y) +#Answer: 0.6708204 + + +#Marginal probabilities of X +X_marginal <- margin.table(matr, 2) +X_marginaltable <- matrix(c(0,1,2, X_marginal),3,2) +colnames(X_marginaltable) <- c('X', 'P(X)') +rownames(X_marginaltable) <- c('', '', '') +X_marginaltable + +#Expected value of X, E(X): +Expected_X = X_marginaltable[1]*X_marginaltable[4] + X_marginaltable[2]*X_marginaltable[5] + + X_marginaltable[3]*X_marginaltable[6] +Expected_X +#Answer: 0.7 + +#Variance(X): +Var_X = (X_marginaltable[1]-Expected_X)^2*X_marginaltable[4] + + (X_marginaltable[2]-Expected_X)^2*X_marginaltable[5] + + (X_marginaltable[3]-Expected_X)^2*X_marginaltable[6] +Var_X +#Answer: 0.41 + +#Standard Deviation of X +Std_X = sqrt(Var_X) +#Answer: 0.6403124 + +#Covariance(X,Y): +cov_x_y = (Y_marginaltable[1]-Expected_Y)*(X_marginaltable[1]-Expected_X)*0.12+(Y_marginaltable[1]-Expected_Y)*(X_marginaltable[2]-Expected_X)*0.42+(Y_marginaltable[1]-Expected_Y)*(X_marginaltable[3]-Expected_X)*0.06+(Y_marginaltable[2]-Expected_Y)*(X_marginaltable[1]-Expected_X)*0.21+(Y_marginaltable[2]-Expected_Y)*(X_marginaltable[2]-Expected_X)*0.06+(Y_marginaltable[2]-Expected_Y)*(X_marginaltable[3]-Expected_X)*0.03+(Y_marginaltable[3]-Expected_Y)*(X_marginaltable[1]-Expected_X)*0.07+(Y_marginaltable[3]-Expected_Y)*(X_marginaltable[2]-Expected_X)*0.02+(Y_marginaltable[3]-Expected_Y)*(X_marginaltable[3]-Expected_X)*0.01 +cov_x_y +#Answer: -0.15 + +############################################### +# Describing the Population of the Total Number of House Sales + +# Laws of Expected Value: E(X + Y) = E(X) + E(Y) +# Laws of Variance: V(X + Y) = V(X) + V(Y) +2*Cov(X,Y) + +#E(X+Y) +Exp_X_Y = Expected_X + Expected_Y +#Answer: 1.2 + +#Var(X+Y) +V_X_Y = Var_X + Var_Y + 2*cov_x_y +#Answer: 0.56 + + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.8.a/Ex7_8a.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.8.a/Ex7_8a.R new file mode 100644 index 00000000..1d7aac74 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.8.a/Ex7_8a.R @@ -0,0 +1,15 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.8a on Pg. 239 +# Describing the Population of the Returns on a Portfolio + +#Given w1, w2 +w1 = .25 +w2 = .75 + +E_R1 = .08 #Expected value of McDonalds stock given +E_R2 = .15 #Expected value of Cisco stock +E_Rp = w1*E_R1 + w2*E_R2 #Expected return of the Portfolio +#Answer: 0.1325 + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.8b/Ex7_8b.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.8b/Ex7_8b.R new file mode 100644 index 00000000..2c3080c2 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.8b/Ex7_8b.R @@ -0,0 +1,30 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.8b on Pg. 239 +# Describing the Population of the Returns on a Portfolio + +#Given: + +w1 = 0.25 +w2 = 0.75 +s1 = 0.12 #Standard Deviation of stock McD +s2 = 0.22 #Standard Deviation of stock Cisco + +StandardDev <- function(Rho) +{ + return(sqrt(w1^2*s1^2 + w2^2*s2^2 + 2*w1*w2*Rho*s1*s2)) +} + +cat ("standard deviation of the returns on the portfolio, when the two stocks' returns are perfectly positively correlated, is:", + StandardDev(1)) +#Answer: 0.195 + +cat ("standard deviation of the returns on the portfolio, when the coefficient of correlation is 0.5, is:", + StandardDev(0.5)) +#Answer: 0.1819 + +cat ("standard deviation of the returns on the portfolio, when the two stocks' returns are uncorrelated, is:", + StandardDev(0)) +#Answer: 0.1677 + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.9.a/Ex7_9a.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.9.a/Ex7_9a.R new file mode 100644 index 00000000..fb69fdc0 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.9.a/Ex7_9a.R @@ -0,0 +1,18 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.9a on Pg. 246 +# Pat Statsdud and the Statistics Quiz + + +# What is the probability that Pat gets no answers correct? +# n=10 iid trials. probability of each success is 1/5. Binomial distribution is apt. + +#dbinom() function for Binomial +ans <- dbinom(0, 10, 0.2) #x=0, n=10, p=0.2 + +cat("P(Pat gets no answers correct) =", ans) + +#Answer: 0.10737 + +#End + diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.9.b/Ex7_9b.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.9.b/Ex7_9b.R new file mode 100644 index 00000000..843b6770 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH7/EX7.9.b/Ex7_9b.R @@ -0,0 +1,17 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 7: RANDOM VARIABLES AND DISCRETE PROBABILITY DISTRIBUTIONS +# Example 7.9a on Pg. 246 +# Pat Statsdud and the Statistics Quiz + + +# What is the probability that Pat gets two answers correct? +# n=10 iid trials. probability of each success is 1/5. Binomial distribution is apt. + +#dbinom() function for Binomial +ans <- dbinom(2, 10, 0.2) #x=2, n=10, p=0.2 + +cat("P(Pat gets two answers correct) =", ans) + +#Answer: 0.30199 + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.a/Ex8_1a.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.a/Ex8_1a.R new file mode 100644 index 00000000..6e11fe8a --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.a/Ex8_1a.R @@ -0,0 +1,20 @@ +# Statistics for Management and Economics by Gerald Keller +# CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.1a on Pg 267 +# Uniformly Distributed Gasoline Sales + +#Uniformly Distributed Gasoline Sales ~ U(2000,5000) + +#U(2000,5000) graph +curve(dunif(x, min = 2000, max = 5000), from = 0, to = 6000, ylab = "f(x)", main = "Uniform Density f(x)") + +#a. Find the probability that daily sales will fall between 2,500 and 3,000 gallons +#denote p1 = P(2500 <= X <= 3000) = P(X <= 3000) - P(X < 2500) +# punif() fives the probability of Uniform dist below a specified number + +p1 <- punif(3000, min=2000, max=5000) - punif(2500, min=2000, max=5000) + +#Answer: 0.16667 + +#End + \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.b/Ex8_1b.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.b/Ex8_1b.R new file mode 100644 index 00000000..768f34f3 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.b/Ex8_1b.R @@ -0,0 +1,17 @@ +# Statistics for Management and Economics by Gerald Keller +# CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.1b on Pg 267 +# Uniformly Distributed Gasoline Sales + + +#Uniformly Distributed Gasoline Sales ~ U(2000,5000) + +# What is the probability that the service station will sell at least 4,000 gallons? +# denote p2 = P(X >= 4000) = 1 - P(X<4000) +# punif() fives the probability of Uniform dist below a specified number + +p2 <- 1-punif(4000, min=2000, max=5000) + +#Answer: 0.33333 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.c/Ex8_1c.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.c/Ex8_1c.R new file mode 100644 index 00000000..8017191c --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.1.c/Ex8_1c.R @@ -0,0 +1,15 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.1c on Pg 267 +# Uniformly Distributed Gasoline Sales + + +#Uniformly Distributed Gasoline Sales ~ U(2000,5000) + +#c. What is the probability that the station will sell exactly 2,500 gallons? +# punif() fives the probability of Uniform dist below a specified number + +p3 <- punif(2500, min=2000, max=5000) - punif(2499.999999999999999999999, min=2000, max=5000) +#Answer: 0 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.2/Ex8_2.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.2/Ex8_2.R new file mode 100644 index 00000000..c00b7dfd --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.2/Ex8_2.R @@ -0,0 +1,17 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.2 on Pg 272 +# Normally Distributed Gasoline Sales + + +curve(dnorm(x,mean = 1000,sd=100), -1100, 2000) + +#Given daily demand for regular gasoline at another gas station ~ N(1000,100) +#Given mean=1000, sd=100 + +#Find P(X <= 1100). Let 'p' denote this required probability + +p <- pnorm(1100, mean=1000, sd=100) +#Answer: 0.8413 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.3.a/Ex8_3a.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.3.a/Ex8_3a.R new file mode 100644 index 00000000..e61443dd --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.3.a/Ex8_3a.R @@ -0,0 +1,15 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.3a on Pg 277 +# Probability of a Negative Return on Investment + +#an ROI variable ~ N(10,5) + +#Probability of losing money. Denote it by 'p' + +p <- pnorm(0, mean=10, sd=5) +cat("The probability of losing money:", p) + +#Answer: 0.02275 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.3.b/Ex8_3b.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.3.b/Ex8_3b.R new file mode 100644 index 00000000..f69e2e77 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.3.b/Ex8_3b.R @@ -0,0 +1,15 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.3b on Pg 277 +# Probability of a Negative Return on Investment + + +# Find the probability of losing money when the standard deviation is equal to 10%. + + +p <- pnorm(0, mean=10, sd=10) +cat("The probability of losing money when the standard deviation is equal to 10%:", p) + +#Answer: 0.1586553 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.4/Ex8_4.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.4/Ex8_4.R new file mode 100644 index 00000000..2e2e7f7f --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.4/Ex8_4.R @@ -0,0 +1,15 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.4 on Pg 279 +# Finding Z .05 + + +# Find the value of a standard normal random variable such that the +# probability that the random variable is greater than it is 5%. + +p <- qnorm(0.95) +cat("Z:", p) + +#Answer: 1.644854 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.5/Ex8_5.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.5/Ex8_5.R new file mode 100644 index 00000000..5785a40b --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.5/Ex8_5.R @@ -0,0 +1,15 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.5 on Pg 280 +# Finding Z -.05 + + +# Find the value of a standard normal random variable such that the +# probability that the random variable is less than it is 5%. + +p <- qnorm(0.05) +cat("Z:", p) + +#Answer: -1.644854 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.6/Ex8_6.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.6/Ex8_6.R new file mode 100644 index 00000000..c3d72514 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.6/Ex8_6.R @@ -0,0 +1,14 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.6 on Pg 283 +# Determining the Reorder Point + +mu = 200 +sd = 50 +Z_0.05 = qnorm(0.95) + +reorderpoint = sd*Z_0.05 + mu +#Answer: 282.2427 + +#End + diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.a/Ex8_7a.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.a/Ex8_7a.R new file mode 100644 index 00000000..3898eb4e --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.a/Ex8_7a.R @@ -0,0 +1,15 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.7a on Pg 288 +# Lifetimes of Alkaline Batteries + +#The lifetime of an alkaline battery is exp(0.05) distributed. +lambda = 0.05 +#a.What is the mean and standard deviation of the battery's lifetime? + +cat("Mean of battery's lifetime in hours:", 1/lambda) +cat("Standard Deviation of battery's lifetime in hours:", 1/lambda) + +#Answer: 20 hours + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.b/Ex8_7b.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.b/Ex8_7b.R new file mode 100644 index 00000000..53f94cb8 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.b/Ex8_7b.R @@ -0,0 +1,15 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.7b on Pg 288 +# Lifetimes of Alkaline Batteries + +#The lifetime of an alkaline battery is exp(0.05) distributed. +lambda = 0.05 +#b. Find the probability that a battery will last between 10 and 15 hours. + +p = pexp(15, rate=lambda) - pexp(10, rate=lambda) +cat("P(10 < battery lifetime < 15):",p) + +#Answer: 0.1341641 + +#End diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.c/Ex8_7c.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.c/Ex8_7c.R new file mode 100644 index 00000000..e7e7e793 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.7.c/Ex8_7c.R @@ -0,0 +1,19 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.7c on Pg 288 +# Lifetimes of Alkaline Batteries + + +#The lifetime of an alkaline battery is exp(0.05) distributed. +lambda = 0.05 + +#c. What is the probability that a battery will last for more than 20 hours? + +p = 1- pexp(20, rate=lambda) +cat("P(battery lifetime > 20):",p) + +#Answer: 0.3678794 + +#End + + diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.a/Ex8_8a.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.a/Ex8_8a.R new file mode 100644 index 00000000..7b319f95 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.a/Ex8_8a.R @@ -0,0 +1,18 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.8a on Pg 290 +# Supermarket Checkout Counter + + +#a.Find the probability of service is completed in fewer than 5 minutes +#the random variable, service process, X ~ exp(6/hour) i.e., X ~ exp(0.1/minute) +lambda = 0.1 #lambda = 0.1/minute + +p = pexp(5, rate=lambda) + +cat("P(X < 5):",p) + +#Answer:0.3934693 + +#End + diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.b/Ex8_8b.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.b/Ex8_8b.R new file mode 100644 index 00000000..93b0e5ec --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.b/Ex8_8b.R @@ -0,0 +1,19 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.8b on Pg 290 +# Supermarket Checkout Counter + + +#b.Find the probability of customer leaving checkout counter more than 10 minutes after arriving + +#the random variable, service process, X ~ exp(6/hour) i.e., X ~ exp(0.1/minute) +lambda = 0.1 #lambda = 0.1/minute + +p = 1 - pexp(10, rate=lambda) #P(X > 10) = 1 - P(X < 10) + +cat("P(X > 10):",p) + +#Answer:0.367879 + +#End + diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.c/Ex8_8c.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.c/Ex8_8c.R new file mode 100644 index 00000000..6838a026 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH8/EX8.8.c/Ex8_8c.R @@ -0,0 +1,19 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 8: CONTINUOUS PROBABILITY DISTRIBUTIONS +# Example 8.8b on Pg 290 +# Supermarket Checkout Counter + + +#c.Find the probability of the service being completed in a time between 5 and 8 minutes + +#the random variable, service process, X ~ exp(6/hour) i.e., X ~ exp(0.1/minute) +lambda = 0.1 #lambda = 0.1/minute + +p = pexp(8, rate=lambda) - pexp(5, rate=lambda) #P(5 < X < 8) = P(X < 8) - P(X < 5) + +cat("P(5 < X < 8):",p) + +#Answer: 0.1572017 + +#End + diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.1.a/Ex9_1a.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.1.a/Ex9_1a.R new file mode 100644 index 00000000..247ed016 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.1.a/Ex9_1a.R @@ -0,0 +1,21 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 9: Sampling Distributions +# Example 9.1a on Pg 316 +# Contents of a 32-Ounce Bottle + +# random variable is amount of soda in each 32-ounce bottle denoted by X. X ~ N(32.2, 0.3) + +#Given: +mu = 32.2 +sd = 0.3 + +# probability that one bottle will contain more than 32 ounces. P(X > 32). Lets denote by 'p' +# pnorm() gives P(X < x) when X ~ Normal +p = 1- pnorm(32, mean=32.2, sd=0.3) +cat("P(X > 32):", p) + +#Answer: 0.7475075 + +#Book's answer slightly different: 0.7486 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.1.b/Ex9_1b.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.1.b/Ex9_1b.R new file mode 100644 index 00000000..f287fbd1 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.1.b/Ex9_1b.R @@ -0,0 +1,24 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 9: Sampling Distributions +# Example 9.1b on Pg 316 +# Contents of a 32-Ounce Bottle + + +# random variable is amount of soda in each 32-ounce bottle denoted by X. X ~ N(32.2, 0.3) + +#Given: +mu = 32.2 +sd = 0.3 + +# what is the probability that the mean amount of the four bottles > 32 ounces. +# (X_bar > 32). Lets denote by 'p' +# pnorm() gives P(X < x) when X ~ Normal + +p = 1 - pnorm(32, mean=32.2, sd=0.3/sqrt(4)) +cat("P(X_bar > 32):", p) + +#Answer: 0.9087888 + +#Book's answer slightly different: 0.9082 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.2/Ex9_2.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.2/Ex9_2.R new file mode 100644 index 00000000..1d5a5f50 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.2/Ex9_2.R @@ -0,0 +1,24 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 9: Sampling Distributions +# Example 9.2 on Pg 326 +# Political Survey + + +# Given number of respondents who would vote ~ Binomial(300,0.52) +n = 300 +p = 0.52 + +# what is the probability that the sample proportion is greater than 50% i.e., P(p^ > 0.5) +# We know that sample proportion ~ Normal(p, sd) where p = 0.52 and sd = sqrt(p*(1-p)/n) + +sigma = sqrt(p*(1-p)/n) +#Answer: Sigma = 0.02884441 + +p1 = 1 - pnorm(0.5, mean=0.52, sd=sigma) +cat("P(p^ > 0.5):", p1) + +#Answer: 0.755963 + +#Book's answer slightly different: 0.7549 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.3/Ex9_3.R b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.3/Ex9_3.R new file mode 100644 index 00000000..9a38c36e --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/CH9/EX9.3/Ex9_3.R @@ -0,0 +1,26 @@ +# Statistics for Management and Economics by Gerald Keller +# Chapter 9: Sampling Distributions +# Example 9.3 on Pg 328 +# Starting Salaries of MBAs + +# Given starting salaries of MBAs at WLU, X1 ~ Normal(62000,14500) +mu1 = 62000 +sd1 = 14500 +v1 = sd1^2 +n1 = 50 + +# Given starting salaries of MBAs at UWO, X2 ~ Normal(60000,18300) +mu2 = 60000 +sd2 = 18300 +v2 = sd2^2 +n2 = 60 + +# find probability that the sample mean starting salary of WLU graduates will exceed that of the UWO graduates +# i.e., find P (X1 - X2 > 0) denoted by 'p' +#we know X1-X2 ~ N(mu1-mu2, sqrt(v1/n1 + v2/n2)) +p = 1 - pnorm(0, mean=mu1-mu2, sd=sqrt((v1/n1)+(v2/n2))) +cat("P(X1 - X2 > 0):", p) + +#Answer: 0.7386917 + +#End \ No newline at end of file diff --git a/Statistics_For_Management_And_Economics_by_Gerald_Keller/README.txt b/Statistics_For_Management_And_Economics_by_Gerald_Keller/README.txt new file mode 100644 index 00000000..9fb3d309 --- /dev/null +++ b/Statistics_For_Management_And_Economics_by_Gerald_Keller/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Sheeba Sekharan +Course: M.sc. (applied Statistics & Informatics) +Branch: Mathematics +College/Institute/Organization: Iit Bombay + +About The Book + +Book: Statistics For Management And Economics +Author: Gerald Keller +Publisher: Cengage Learning Usa +Year Of Publication: 2012 +ISBN: ISBN-13: 9788131528426 +Edition: 9 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1a/Ex1_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1a/Ex1_1a.R new file mode 100644 index 00000000..24e891e1 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1a/Ex1_1a.R @@ -0,0 +1,16 @@ + # Page no. : 7 + +# Frequency Tables : An Example + +stress_rating <- c(8, 7, 4, 10, 8, 6, 8, 9, 9, 7, 3, 7, 6, 5, 0, 9, 10, 7, 7, 3, 6, 7, + 5, 2, 1, 6, 7, 10, 8, 8) + +frequency_table <- data.frame(table(stress_rating)) + +percent <- round((prop.table(frequency_table$Freq) * 100), 1) + +frequency_table <- cbind(frequency_table, percent) + +View(frequency_table) + + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1c/Ex1_1c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1c/Ex1_1c.R new file mode 100644 index 00000000..be5b7b06 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1c/Ex1_1c.R @@ -0,0 +1,21 @@ + # Page no. : 8 - 9 + +# Frequency Tables : Another Example + +# Data on page no. 8 (bottom) + +social_interaction <- c(48, 15, 33, 3, 21, 19, 17, 16, 44, 25, 30, 3, 5, 9, 35, 32, 26, 13, 14, + 14, 47, 47, 18, 11, 5, 19, 24, 17, 6, 25, 8, 18, 29, 1, 18, 22, 3, 22, + 29, 2, 6, 10, 29, 10, 29, 21, 38, 41, 16, 17, 8, 40, 8, 10, 18, 7, 4, 4, + 8, 11, 3, 23, 10, 19, 21, 13, 12, 10, 4, 17, 11, 21, 9, 8, 7, 5, 3, 22, + 14, 25, 4, 11, 10, 18, 1, 28, 27, 19, 24, 35, 9, 30, 8, 26) + +breaks <- seq(0, 49, by = 1) + +social.interaction <- cut(social_interaction, breaks, right = F) + +frequency_table <- data.frame(table(social.interaction)) + +View(frequency_table) # table no. 1-5 (page no. 9) + +# Note that answer is different from book for eg. [0,1) is similar to 0 and so on... diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1d/Ex1_1d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1d/Ex1_1d.R new file mode 100644 index 00000000..3846d185 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1d/Ex1_1d.R @@ -0,0 +1,18 @@ + # Page no. : 9 + +# Grouped Frequency Tables + +stress_rating <- c(8, 7, 4, 10, 8, 6, 8, 9, 9, 7, 3, 7, 6, 5, 0, 9, 10, 7, 7, 3, 6, 7, + 5, 2, 1, 6, 7, 10, 8, 8) + +breaks <- seq(-1, 11, by = 2) + +stress.rating <- cut(stress_rating, breaks, right = T) + +grouped_frequency_table <- data.frame(table(stress.rating)) + +percent <- round((prop.table(grouped_frequency_table$Freq) * 100), 1) + +grouped_frequency_table <- cbind(grouped_frequency_table, percent) + +View(grouped_frequency_table) # First column is different but answer is correct diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1e/Ex1_1e.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1e/Ex1_1e.R new file mode 100644 index 00000000..5015399a --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.1e/Ex1_1e.R @@ -0,0 +1,22 @@ + # Page no. : 10 + +# Grouped Frequency Tables : Another Example + +social_interaction <- c(48, 15, 33, 3, 21, 19, 17, 16, 44, 25, 30, 3, 5, 9, 35, 32, 26, 13, 14, + 14, 47, 47, 18, 11, 5, 19, 24, 17, 6, 25, 8, 18, 29, 1, 18, 22, 3, 22, + 29, 2, 6, 10, 29, 10, 29, 21, 38, 41, 16, 17, 8, 40, 8, 10, 18, 7, 4, 4, + 8, 11, 3, 23, 10, 19, 21, 13, 12, 10, 4, 17, 11, 21, 9, 8, 7, 5, 3, 22, + 14, 25, 4, 11, 10, 18, 1, 28, 27, 19, 24, 35, 9, 30, 8, 26) + +breaks <- seq(0, 50, by = 5) + +social.interaction <- cut(social_interaction, breaks, right = F) + +grouped_frequency_table <- data.frame(table(social.interaction)) + +percent <- round((prop.table(grouped_frequency_table$Freq) * 100), 1) + +grouped_frequency_table <- cbind(grouped_frequency_table, percent) + +View(grouped_frequency_table) # First column is different but answer is correct + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2a/Ex1_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2a/Ex1_2a.R new file mode 100644 index 00000000..d6c0b0f8 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2a/Ex1_2a.R @@ -0,0 +1,21 @@ + # Page no. : 11 + +# Histogram for Frequency Table + +stress_rating <- c(8, 7, 4, 10, 8, 6, 8, 9, 9, 7, 3, 7, 6, 5, 0, 9, 10, 7, 7, 3, 6, 7, + 5, 2, 1, 6, 7, 10, 8, 8) + +frequency_table <- data.frame(table(stress_rating)) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(data = frequency_table, aes(x = stress_rating, y = Freq)) + + geom_bar(stat = "identity", fill = "violet") + + labs(title = "Histogram for frequency table", x = "Stress Rating", y = "Frequency") + + theme_bw() \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2b/Ex1_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2b/Ex1_2b.R new file mode 100644 index 00000000..0cdae0ce --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2b/Ex1_2b.R @@ -0,0 +1,24 @@ + # Page no. : 11 + +# Histogram for Grouped Frequency Table + +stress_rating <- c(8, 7, 4, 10, 8, 6, 8, 9, 9, 7, 3, 7, 6, 5, 0, 9, 10, 7, 7, 3, 6, 7, + 5, 2, 1, 6, 7, 10, 8, 8) + +frequency_table <- data.frame(table(stress_rating)) + +View(frequency_table) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(data = frequency_table, aes(x = stress_rating, y = Freq)) + + geom_bar(stat = "identity", fill = "violet") + + labs(title = "Histogram for grouped frequency table", x = "Stress Rating", y = "Frequency") + + theme_bw() + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2c/Ex1_2c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2c/Ex1_2c.R new file mode 100644 index 00000000..2ebb10bc --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2c/Ex1_2c.R @@ -0,0 +1,35 @@ + # Page no. : 11 + +# Histogram for Grouped Frequency Table Example 2 + +social_interaction <- c(48, 15, 33, 3, 21, 19, 17, 16, 44, 25, 30, 3, 5, 9, 35, 32, 26, 13, 14, + 14, 47, 47, 18, 11, 5, 19, 24, 17, 6, 25, 8, 18, 29, 1, 18, 22, 3, 22, + 29, 2, 6, 10, 29, 10, 29, 21, 38, 41, 16, 17, 8, 40, 8, 10, 18, 7, 4, 4, + 8, 11, 3, 23, 10, 19, 21, 13, 12, 10, 4, 17, 11, 21, 9, 8, 7, 5, 3, 22, + 14, 25, 4, 11, 10, 18, 1, 28, 27, 19, 24, 35, 9, 30, 8, 26) + +breaks <- seq(0, 50, by = 5) + +mid_values <- seq(0+5/2,50-5/2, 5) + +social.interaction <- cut(social_interaction, breaks, right = F) + +grouped_frequency_table <- data.frame(table(social.interaction)) +grouped_frequency_table$social_interacton_mid <- mid_values + +View(grouped_frequency_table) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(data = grouped_frequency_table, aes(x = factor(social_interacton_mid), y = Freq)) + + geom_bar(stat = "identity", fill = "violet") + + labs(title = "Histogram for grouped frequency table", x = "Social Interaction Mid Values", + y = "Frequency") + + theme_bw() + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2d/Ex1_2d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2d/Ex1_2d.R new file mode 100644 index 00000000..a6a633c6 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2d/Ex1_2d.R @@ -0,0 +1,23 @@ + # Page no. : 14 + +# Histogram for Nominal Variables + +closest_person <- c("Family member", "Nonromantic friend", "Romantic friend", "Other") + +frequency <- c(33, 76, 92, 7) + +frequency_table <- data.frame(closest_person, frequency) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(data = frequency_table, aes(x = closest_person, y = frequency)) + + geom_bar(stat = "identity", fill = "violet") + + labs(title = "Histogram for nominal variables", x = "Closest Person", y = "Frequency") + + theme_bw() + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2e/Ex1_2e.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2e/Ex1_2e.R new file mode 100644 index 00000000..72a38731 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.2e/Ex1_2e.R @@ -0,0 +1,26 @@ + # Page no. : 15 + +# How are you doing? + +# 3rd Question + +value <- c(1, 2, 3, 4, 5) + +frequency <- c(3, 4, 8, 5, 2) + +frequency_table <- data.frame(value, frequency) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(data = frequency_table, aes(x = value, y = frequency)) + + geom_bar(stat = "identity", fill = "violet") + + labs(title = "Histogram", x = "Value", y = "Frequency") + + theme_bw() + + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.4a/Ex1_4a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.4a/Ex1_4a.R new file mode 100644 index 00000000..952d9830 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH1/EX1.4a/Ex1_4a.R @@ -0,0 +1,25 @@ + # Page no. : 25 + +# Worked - out Exapmles + +Interest <- c(2, 4, 5, 5, 1, 3, 6, 3, 6, 6) + +frequency_table <- data.frame(table(Interest)) + +Percent <- round((prop.table(frequency_table$Freq) * 100), 0) + +frequency_table <- cbind(frequency_table, Percent) + +View(frequency_table) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(data = frequency_table, aes(x = Interest, y = Freq)) + + geom_bar(stat = "identity", fill = "violet") + + labs(title = "Histogram", x = "Interest", y = "Frequency") \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.1a/Ex10_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.1a/Ex10_1a.R new file mode 100644 index 00000000..02e282e8 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.1a/Ex10_1a.R @@ -0,0 +1,76 @@ + # Page no. : 406 - 407 + +# Table for a Two-way Analysis of Variance + +DF <- data.frame(Sensitivity = c(rep("Not High", 10), rep("High", 10)), + Test_Difficulty = c(rep(c("Easy", "Hard"), 10)), + Value = c(2.63, 2.69, 2.53, 2.31, 2.25, 2.45, 2.22, 2.80, 2.52, 2.55, 2.06, + 3.21, 2.32, 3.21, 2.04, 2.77, 2.31, 2.83, 2.22, 3.03) + ) + +View(DF) # Table no. 10-10 (Table is different as compared to book) + +res <- aov(Value ~ Test_Difficulty*Sensitivity, data = DF) +result <- round(anova(res), 2) + +# Table no. 10-11 + +result # Values differ with book's values (table values) + +# Below results are in table no. 10-10 + +ss_total <- round(sum(result$`Sum Sq`), 2) # Total sum of squared deviation + +cat("Total sum of squared deviation is \n", ss_total) + +ss_within <- round(result$`Sum Sq`[4], 2) # Sum of squared deviation within-groups + +cat("Sum of squared deviation within-groups is \n", ss_within) + +ss_interaction <- round(result$`Sum Sq`[3], 2) # Sum of squared deviation of interaction + +cat("Sum of squared deviation of interaction is \n", ss_interaction) + +ss_rows <- round(result$`Sum Sq`[2], 2) # Sum of squared deviation of rows + +cat("Sum of squared deviation of rows is \n", ss_rows) + +ss_columns <- round(result$`Sum Sq`[1], 2) # Sum of squared deviation of columns + +cat("Sum of squared deviation of columns is \n", ss_columns) + +alpha <- 0.05 # 5% significance level +df_numerator <- 1 # 2 - 1 = 1 (2 groups) +df_denomenator <- result$Df[4] + +fval <- qf(0.95, df_numerator, df_denomenator) +fval <- round(fval, 2) + +# Note that fval is same for sensitivity, test difficulty and for interaction effect + +cat("F value is \n", fval) + +f1 <- result$`F value`[1] # F value for test difficulty +f2 <- result$`F value`[2] # F value for sensitivity +f3 <- result$`F value`[3] # F value for test difficulty : sensitivity + +if(f1 >= fval) +{ + cat("Reject null hypothesis for test difficulty") +} else { + cat("Cannot reject null hypothesis for test difficulty") +} + +if(f2 >= fval) +{ + cat("Reject null hypothesis for sensitivity") +} else { + cat("Cannot reject null hypothesis for sensitivity") +} + +if(f3 >= fval) +{ + cat("Reject null hypothesis for test difficulty : sensitivity") +} else { + cat("Cannot reject null hypothesis for test difficulty : sensitivity") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.1b/Ex10_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.1b/Ex10_1b.R new file mode 100644 index 00000000..9b62a513 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.1b/Ex10_1b.R @@ -0,0 +1,69 @@ + # Page no. : 411 - 413 + +# How are you doing? + +# 5th Question + +DF <- data.frame(Participant = LETTERS[1:8], + Length_condition = c(rep("Short", 4), rep("Long", 4)), + Vividness_condition = c(rep(c("Low", "High"), 4)), + Number_recalled = c(6, 9, 4, 5, 2, 1, 4, 1) + ) + +View(DF) # Book's table is little bit different + +res <- aov(Number_recalled ~ Vividness_condition*Length_condition, data = DF) +result <- anova(res) +result + +ss_total <- round(sum(result$`Sum Sq`), 2) # Total sum of squared deviation + +cat("Total sum of squared deviation is", ss_total) + +ss_within <- round(result$`Sum Sq`[4], 2) # Sum of squared deviation within-groups + +cat("Sum of squared deviation within-groups is", ss_within) + +ss_interaction <- round(result$`Sum Sq`[3], 2) # Sum of squared deviation of interaction + +cat("Sum of squared deviation of interaction is", ss_interaction) + +ss_rows <- round(result$`Sum Sq`[2], 2) # Sum of squared deviation of rows + +cat("Sum of squared deviation of rows is", ss_rows) + +ss_columns <- round(result$`Sum Sq`[1], 2) # Sum of squared deviation of columns + +cat("Sum of squared deviation of columns is", ss_columns) + +alpha <- 0.05 # 5% significance level +df_numerator <- 1 # 2 - 1 = 1 (2 groups) +df_denomenator <- result$Df[4] + +fval <- qf(0.95, df_numerator, df_denomenator) +fval <- round(fval, 2) + +f1 <- result$`F value`[1] # F value for vividness condition +f2 <- result$`F value`[2] # F value for length condition +f3 <- result$`F value`[3] # F value for vividness condition : length condition + +if(f1 >= fval) +{ + cat("Reject null hypothesis") +} else { + cat("Cannot reject null hypothesis") +} + +if(f2 >= fval) +{ + cat("Reject null hypothesis") +} else { + cat("Cannot reject null hypothesis") +} + +if(f3 >= fval) +{ + cat("Reject null hypothesis") +} else { + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.2a/Ex10_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.2a/Ex10_2a.R new file mode 100644 index 00000000..8095711c --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.2a/Ex10_2a.R @@ -0,0 +1,33 @@ + # Page no. : 413 - 414 + +# Advanced Topic : Effect Size in the Factorial Analysis of Variance + +var_col <- 1.20 # Variance (columns) +df_col <- 1 # Degree of freedom (columns) + +var_within <- 0.03 # Variance within-groups +df_within <- 16 # Degree of freedom within-groups + +r_sq1 <- round((var_col * df_col) / ((var_col * df_col) + (var_within * df_within)), 2) + # The proportion of Variance announced for (test difficulty) + +cat("The proportion of Variance announced for (test difficulty) is", r_sq1) + +var_rows <- 0.00 # Variance (rows) +df_rows <- 1 # Degree of freedom (rows) + +r_sq2 <- round((var_rows * df_rows) / ((var_rows * df_rows) + (var_within * df_within)), 2) +# The proportion of Variance announced for (sensitivity) + +cat("The proportion of Variance announced for (sensitivity) is", r_sq2) + +var_int <- 0.60 # Variance (iteraction) +df_int <- 1 # Degree of freedom (interaction) + +var_within <- 0.03 # Variance within-groups +df_within <- 16 # Degree of freedom within-groups + +r_sq3 <- round((var_int * df_int) / ((var_int * df_int) + (var_within * df_within)), 2) +# The proportion of Variance announced for (test difficulty) + +cat("The proportion of Variance announced for (test difficulty) is", r_sq3) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.2b/Ex10_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.2b/Ex10_2b.R new file mode 100644 index 00000000..a4901927 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.2b/Ex10_2b.R @@ -0,0 +1,16 @@ + # Page no. : 416 - 417 + +# How are you doing? + +# 1st Question (c) part + +var_rows <- 9.45 # Variance (rows) +df_rows <- 1 # Degree of freedom (rows) + +var_within <- 3.67 # Variance within-groups +df_within <- 36 # Degree of freedom within-groups + +r_sq2 <- round((var_rows * df_rows) / ((var_rows * df_rows) + (var_within * df_within)), 2) +# The proportion of Variance announced for + +cat("The proportion of Variance announced for is", r_sq2) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.3a/Ex10_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.3a/Ex10_3a.R new file mode 100644 index 00000000..460ed20f --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH10/EX10.3a/Ex10_3a.R @@ -0,0 +1,76 @@ + # Page no. : 419 - 421 + +# worked out examples 1 + +# Only (b) and (c) part + +DF <- data.frame(Variable_A = c(rep("Level1", 8), rep("Level2", 8), rep("Level3", 8)), + Variable_B = c(rep(c("Level1", "Level2"), 12)), + Values = c(25, 19, 20, 24, 23, 21, 24, 20, 22, 24, 19, 18, 22, 22, 21, 20, + 16, 18, 19, 21, 13, 16, 16, 17) +) + +View(DF) # Book's table is little bit different + +# install.packages(ggplot2) +library(ggplot2) + +ggplot(DF, aes(x = Variable_A, y = Values, fill = Variable_B)) + geom_bar(position = "dodge", + stat = "identity") +# Litte bit different barplot as compare with book's barplot + +res <- aov(Values ~ Variable_B*Variable_A, data = DF) +result <- anova(res) +result + +ss_total <- round(sum(result$`Sum Sq`), 2) # Total sum of squared deviation + +cat("Total sum of squared deviation is", ss_total) + +ss_within <- round(result$`Sum Sq`[4], 2) # Sum of squared deviation within-groups + +cat("Sum of squared deviation within-groups is", ss_within) + +ss_interaction <- round(result$`Sum Sq`[3], 2) # Sum of squared deviation of interaction + +cat("Sum of squared deviation of interaction is", ss_interaction) + +ss_rows <- round(result$`Sum Sq`[2], 2) # Sum of squared deviation of rows + +cat("Sum of squared deviation of rows is", ss_rows) + +ss_columns <- round(result$`Sum Sq`[1], 2) # Sum of squared deviation of columns + +cat("Sum of squared deviation of columns is", ss_columns) + +alpha <- 0.05 # 5% significance level +df_numerator <- 2 # 3 - 1 = 1 (2 groups) +df_denomenator <- result$Df[4] + +fval <- qf(0.95, df_numerator, df_denomenator) +fval <- round(fval, 2) + +f1 <- result$`F value`[1] # F value for variable B +f2 <- result$`F value`[2] # F value for variable A +f3 <- result$`F value`[3] # F value for variable B : variable A + +if(f1 >= fval) +{ + cat("Reject null hypothesis") +} else { + cat("Cannot reject null hypothesis") +} + +if(f2 >= fval) +{ + cat("Reject null hypothesis") +} else { + cat("Cannot reject null hypothesis") +} + +if(f3 >= fval) +{ + cat("Reject null hypothesis") +} else { + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.1a/Ex11_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.1a/Ex11_1a.R new file mode 100644 index 00000000..33d98aa2 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.1a/Ex11_1a.R @@ -0,0 +1,22 @@ + # Page no. : 441 - 442 + +# Graphing Correlations : The Scatter Diagram An example + +Hours_slept <- c(5, 7, 8, 6, 6, 10) +Happy_mood <- c(2, 4, 7, 2, 3, 6) + +DF <- data.frame(Hours_slept, Happy_mood) +View(DF) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF, aes(x = Hours_slept, y = Happy_mood)) + geom_point() + labs(title = + "Scatter plot", x = "Hours slept last night", y = "Happy mood") + theme_bw() + + scale_x_continuous(limits=c(1, 12), breaks = c(1:12)) + + scale_y_continuous(limits=c(1, 8), breaks = c(1:8)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.1b/Ex11_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.1b/Ex11_1b.R new file mode 100644 index 00000000..3add1327 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.1b/Ex11_1b.R @@ -0,0 +1,24 @@ + # Page no. : 443 + +# How are you doing? + +# 3rd Question + +person <- LETTERS[1:4] +x <- c(3, 6, 1, 4) +y <- c(4, 7, 2, 6) + +DF <- data.frame(person, x, y) +View(DF) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF, aes(x = x, y = y)) + geom_point() + labs(title = "Scatter plot", x = "X", y = "Y") + + theme_bw() + scale_x_continuous(limits=c(0, 6), breaks = c(0:6)) + + scale_y_continuous(limits=c(0, 7), breaks = c(0:7)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2a/Ex11_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2a/Ex11_2a.R new file mode 100644 index 00000000..e00b2be4 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2a/Ex11_2a.R @@ -0,0 +1,38 @@ + # Page no. : 455 - 456 + +# Figuring the correlation coefficient an example + +Hours_slept <- c(5, 7, 8, 6, 6, 10) +Happy_mood <- c(2, 4, 7, 2, 3, 6) + +# Book Method + +m1 <- mean(Hours_slept) # Mean +m2 <- mean(Happy_mood) # Mean + +deviation1 <- Hours_slept - m1 +sq_dev1 <- deviation1 ** 2 # Squared deviation +sd1 <- round(sqrt(sum(sq_dev1) / 6), 2) # Standard deviation + +z_score1 <- round(deviation1 / sd1, 2) + +deviation2 <- Happy_mood - m2 +sq_dev2 <- deviation2 ** 2 # Squared deviation +sd2 <- round(sqrt(sum(sq_dev2) / 6), 2) # Standard deviation + +z_score2 <- round(deviation2 / sd2, 2) + +c_p <- round(z_score1 * z_score2, 2) # Cross Product + +DF <- data.frame(Hours_slept, deviation1, sq_dev1, z_score1, Happy_mood, deviation2, sq_dev2, + z_score2, c_p) +View(DF) + +r <- round(sum(DF$c_p) / nrow(DF), 2) # Correlation Coefficient + +cat("Correlation coefficient is", r) + +# Direct method + +r2 <- round(cor(Happy_mood,Hours_slept), 2) +cat("Correlation coefficient is", r2) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2b/Ex11_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2b/Ex11_2b.R new file mode 100644 index 00000000..ba1278f7 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2b/Ex11_2b.R @@ -0,0 +1,11 @@ + # Page no. : 456 - 457 + +# Figuring the correlation coefficient a second example + +No_of_exposures <- c(1:8) +No_of_words_recalled <- c(3, 2, 6, 4, 5, 5, 6, 9) + +# Direct method + +r <- round(cor(No_of_exposures,No_of_words_recalled), 2) # Correlation Coefficient +cat("Correlation coefficient is", r) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2c/Ex11_2c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2c/Ex11_2c.R new file mode 100644 index 00000000..07cdcd73 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.2c/Ex11_2c.R @@ -0,0 +1,15 @@ + # Page no. : 457 - 458 + +# How are you doing? + +# 4th Question + +person <- c("K", "L", "M") +z_score1 <- c(0.5, -1.4, 0.9) +z_score2 <- c(-0.7, -0.8, 1.5) + +c_p <- round(z_score1 * z_score2, 2) # Cross product + +r <- round(sum(c_p) / 3, 2) # Correlation coefficien + +cat("Correlation coefficient is", r) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3a/Ex11_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3a/Ex11_3a.R new file mode 100644 index 00000000..2edc72a5 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3a/Ex11_3a.R @@ -0,0 +1,10 @@ + # Page no. : 458 - 459 + +# Significance of a correlation coefficient + +N <- 3 # No. of perons +r <- 0.24 # Correlation coefficient + +t <- round(r / sqrt((1 - (r ** 2)) / (N - 2)), 2) # t value + +cat("t value is", t) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3b/Ex11_3b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3b/Ex11_3b.R new file mode 100644 index 00000000..babc9dba --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3b/Ex11_3b.R @@ -0,0 +1,26 @@ + # Page no. : 459 + +# Significance of a correlation coefficient an example + +N <- 6 # Sample size +r <- 0.85 # Correlation coefficient +alpha <- 0.05 # 5% significance level + +df <- N - 2 # Degree of freedom + +# Two - tailed + +tval <- qt(1-alpha/2, df) +tval <- c(tval, -tval) + +t <- round(r / sqrt((1 - (r ** 2)) / (N - 2)), 2) # t value + +cat("t value is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3c/Ex11_3c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3c/Ex11_3c.R new file mode 100644 index 00000000..1077b922 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.3c/Ex11_3c.R @@ -0,0 +1,28 @@ + # Page no. : 461 - 462 + +# How are you doing? + +# 3rd Question + +N <- 60 # Sample size +r <- -0.31 # Correlation coefficient +alpha <- 0.05 # 5% significance level + +df <- N - 2 # Degree of freedom + +# Two - tailed + +tval <- qt(1-alpha/2, df) +tval <- c(tval, -tval) + +t <- round(r / sqrt((1 - (r ** 2)) / (N - 2)), 2) # t value + +cat("t value is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4a/Ex11_4a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4a/Ex11_4a.R new file mode 100644 index 00000000..65c50505 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4a/Ex11_4a.R @@ -0,0 +1,22 @@ + # Page no. : 477 - 478 + +# Worked out examples 1 + +Elementry_School <- c("Main Street", "Casat", "Lakeland", "Shady Grove", "Jefferson") +Class_size <- c(25, 14, 33, 28, 20) +Achievement <- c(80, 98, 50, 82, 90) + +DF <- data.frame(Elementry_School, Class_size, Achievement) +View(DF) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF, aes(x = Class_size, y = Achievement)) + geom_point() + + labs(title = "Scatter plot", x = "Class size", y = "Achievement test score") + + theme_bw() \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4b/Ex11_4b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4b/Ex11_4b.R new file mode 100644 index 00000000..dac926dd --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4b/Ex11_4b.R @@ -0,0 +1,12 @@ + # Page no. : 478 - 479 + +# Worked out examples 2 + +Elementry_School <- c("Main Street", "Casat", "Lakeland", "Shady Grove", "Jefferson") +Class_size <- c(25, 14, 33, 28, 20) +Achievement <- c(80, 98, 50, 82, 90) + +# Direct method + +r <- round(cor(Class_size,Achievement), 2) # Correlation Coefficient +cat("Correlation coefficient is", r) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4c/Ex11_4c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4c/Ex11_4c.R new file mode 100644 index 00000000..6f497d0f --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH11/EX11.4c/Ex11_4c.R @@ -0,0 +1,26 @@ + # Page no. : 479 - 480 + +# Worked out examples 3 + +N <- 5 # Sample size +r <- -0.90 # Correlation coefficient +alpha <- 0.05 # 5% significance level + +df <- N - 2 # Degree of freedom + +# Two - tailed + +tval <- qt(1-alpha/2, df) +tval <- c(tval, -tval) + +t <- round(r / sqrt((1 - (r ** 2)) / (N - 2)), 2) # t value + +cat("t value is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.1a/Ex12_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.1a/Ex12_1a.R new file mode 100644 index 00000000..715beb03 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.1a/Ex12_1a.R @@ -0,0 +1,21 @@ + # Page no. : 494 - 496 + +# The linear prediction rule an example + +a <- 0.3 # Regression constant +b <- 0.004 # Regression coefficient +x <- 700 # SAT score + +y_cap <- a + (b * x) # Predicted GPA (Linear predictor) + +cat("Predicted GPA (Linear predictor) is", y_cap) + +# Another example + +a <- -3 # Regression constant +b <- 1 # Regression coefficient +x <- 9 # Hours of sleep + +y_cap <- a + (b * x) # Predicted mood (Linear predictor) + +cat("Predicted mood (Linear predictor) is", y_cap) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.1b/Ex12_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.1b/Ex12_1b.R new file mode 100644 index 00000000..a13d7d78 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.1b/Ex12_1b.R @@ -0,0 +1,32 @@ + # Page no. : 497 + +# How are you doing? + +# 4th Question + +a <- -1.23 # Regression constant +b <- 6.11 # Regression coefficient + +# (a) + +x <- 2.00 # Predictor variable + +y_cap <- a + (b * x) # Predicted score (Linear predictor) + +cat("Predicted score (Linear predictor) is", y_cap) + +# (b) + +x <- 4.87 # Predictor variable + +y_cap <- a + (b * x) # Predicted score (Linear predictor) + +cat("Predicted score (Linear predictor) is", round(y_cap, 2)) + +# (a) + +x <- -1.92 # Predictor variable + +y_cap <- a + (b * x) # Predicted score (Linear predictor) + +cat("Predicted score (Linear predictor) is", round(y_cap, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.2a/Ex12_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.2a/Ex12_2a.R new file mode 100644 index 00000000..a4948142 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.2a/Ex12_2a.R @@ -0,0 +1,25 @@ + # Page no. : 501 + +# Another example of drawing the regression line + +# Data on page no. : 442 + +Hours_slept <- c(5, 7, 8, 6, 6, 10) +Happy_mood <- c(2, 4, 7, 2, 3, 6) + +DF <- data.frame(Hours_slept, Happy_mood) +View(DF) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF, aes(x = Hours_slept, y = Happy_mood)) + geom_point() + + labs(title = "Scatter plot", x = "Hours slept last night", y = "Happy mood") + theme_bw() + + scale_x_continuous(limits=c(1, 12), breaks = c(1:12)) + + scale_y_continuous(limits=c(1, 8), breaks = c(1:8)) + + geom_smooth(method='lm', se = F) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3a/Ex12_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3a/Ex12_3a.R new file mode 100644 index 00000000..0f8fe141 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3a/Ex12_3a.R @@ -0,0 +1,30 @@ + # Page no. : 502 - 504 + +# Finding the best linear prediction rule + +# Rule 1 ==> y_cap <- 8 - (.18)*X +# Rule 2 ==> y_cap <- 4 + (0)*X +# Rule 3 ==> y_cap <- -2.5 + (1)*X +# Rule 4 ==> y_cap <- -3 + (1)*X + +Hours_slept <- c(5, 6, 6, 7, 8, 10) +Actual_mood <- c(2, 2, 3, 4, 7, 6) + +# Rule 1 + +y_cap1 <- 8 - (.18) * Hours_slept # Predicted mood + +# Rule 2 + +y_cap2 <- 4 + (0) * Hours_slept # Predicted mood + +# Rule 3 + +y_cap3 <- -2.5 + (1) * Hours_slept # Predicted mood + +# Rule 4 + +y_cap4 <- -3 + (1) * Hours_slept # Predicted mood + +DF <- data.frame(Hours_slept, Actual_mood, y_cap1, y_cap2, y_cap3, y_cap4) +View(DF) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3b/Ex12_3b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3b/Ex12_3b.R new file mode 100644 index 00000000..6bd0b477 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3b/Ex12_3b.R @@ -0,0 +1,62 @@ + # Page no. : 504 - 505 + +# The least squared error principle + +# Rule 1 ==> y_cap <- 8 - (.18)*X +# Rule 2 ==> y_cap <- 4 + (0)*X +# Rule 3 ==> y_cap <- -2.5 + (1)*X +# Rule 4 ==> y_cap <- -3 + (1)*X + +Hours_slept <- c(5, 6, 6, 7, 8, 10) +Actual_mood <- c(2, 2, 3, 4, 7, 6) + +# Rule 1 + +y_cap1 <- 8 - (.18) * Hours_slept # Predicted mood + +error1 <- Actual_mood - y_cap1 + +error1_sq <- round(error1 ** 2, 2) # Error squared + +# Rule 2 + +y_cap2 <- 4 + (0) * Hours_slept # Predicted mood + +error2 <- Actual_mood - y_cap2 + +error2_sq <- error2 ** 2 # Error squared + +# Rule 3 + +y_cap3 <- -2.5 + (1) * Hours_slept # Predicted mood + +error3 <- Actual_mood - y_cap3 + +error3_sq <- error3 ** 2 # Error squared + +# Rule 4 + +y_cap4 <- -3 + (1) * Hours_slept # Predicted mood + +error4 <- Actual_mood - y_cap4 + +error4_sq <- error4 ** 2 # Error squared + +DF <- data.frame(Hours_slept, Actual_mood, y_cap1, error1, error1_sq, y_cap4, error4, error4_sq) +View(DF) + +s1 <- sum(DF$error1_sq) + +cat("Rule 1 sum of squared errors is", s1) + +s2 <- sum(error2_sq) + +cat("Rule 2 sum of squared errors is", s2) + +s3 <- sum(error3_sq) + +cat("Rule 3 sum of squared errors is", s3) + +s4 <- sum(DF$error4_sq) + +cat("Rule 4 sum of squared errors is", s4) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3c/Ex12_3c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3c/Ex12_3c.R new file mode 100644 index 00000000..eb0d31d0 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3c/Ex12_3c.R @@ -0,0 +1,22 @@ + # Page no. : 505 - 507 + +# Finding a and b for the least squares linear prediction rule + +Hours_slept <- c(5, 7, 8, 6, 6, 10) +Happy_mood <- c(2, 4, 7, 2, 3, 6) + +DF <- data.frame(Hours_slept, Happy_mood) +View(DF) + +# Direct method + +regressor <- lm(Happy_mood ~ Hours_slept, data = DF) +res <- summary(regressor) + +res + +b <- res$coefficients[[2]] + +a <- res$coefficients[[1]] + +cat("Linear Prediction Rule is y_cap =",a,"+",b,"x") \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3d/Ex12_3d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3d/Ex12_3d.R new file mode 100644 index 00000000..dfc319a1 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.3d/Ex12_3d.R @@ -0,0 +1,50 @@ + # Page no. : 507 - 508 + +# How are you doing? + +# 4th Question + +x <- c(4, 6, 7, 3) +y <- c(6, 8, 3, 7) + +DF <- data.frame(x, y) +View(DF) + +# (a) part + +# Direct method + +regressor <- lm(y ~ x, data = DF) +res <- summary(regressor) + +res + +b <- res$coefficients[[2]] + +a <- res$coefficients[[1]] + +cat("Linear Prediction Rule is y_cap =",a,"+",b,"x") + +# (b) part + +y_cap1 <- a + b * x # Predicted score + +error1 <- y - y_cap1 + +error1_sq <- round(error1 ** 2, 2) # Error squared + +s1 <- sum(error1_sq) + +cat("Sum of squared errors is", s1) + +# (c) part + +y_cap2 <- 9 - (0.7) * x # Predicted score + +error2 <- y - y_cap2 + +error2_sq <- round(error2 ** 2, 2) # Error squared + +s2 <- sum(error2_sq) + +cat("Sum of squared errors is", s2) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.4a/Ex12_4a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.4a/Ex12_4a.R new file mode 100644 index 00000000..400d364b --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.4a/Ex12_4a.R @@ -0,0 +1,11 @@ + # Page no. : 509 - 510 + +# The standardized regression coefficient + +ss_x <- 16 +ss_y <- 22 +b <- 1 + +beta <- round(b * (sqrt(ss_x) / sqrt(ss_y)), 2) # Standardized regression coefficient + +cat("Standardized regression coefficient is", beta) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.4b/Ex12_4b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.4b/Ex12_4b.R new file mode 100644 index 00000000..626659d5 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.4b/Ex12_4b.R @@ -0,0 +1,13 @@ + # Page no. : 511 - 512 + +# How are you doing? + +# 2nd Question (b) part + +ss_x <- 2.57 +ss_y <- 7.21 +b <- -1.21 + +beta <- round(b * (sqrt(ss_x) / sqrt(ss_y)), 2) # Standardized regression coefficient + +cat("Standardized regression coefficient is", beta) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.5a/Ex12_5a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.5a/Ex12_5a.R new file mode 100644 index 00000000..a50f1854 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.5a/Ex12_5a.R @@ -0,0 +1,18 @@ + # Page no. : 512 - 513 + +# Multiple regression + +a <- -3.78 + +b1 <- 0.87 +x1 <- 7 + +b2 <- 0.33 +x2 <- 3 + +b3 <- 0.20 +x3 <- 1 + +y_cap <- round(a + (b1 * x1) + (b2 * x2) + (b3 * x3), 2) # Predicted mood (multiple regression) + +cat("Predicted mood (multiple regression) is", y_cap) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.5b/Ex12_5b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.5b/Ex12_5b.R new file mode 100644 index 00000000..83682299 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.5b/Ex12_5b.R @@ -0,0 +1,29 @@ + # Page no. : 514 - 515 + +# How are you doing? + +# 3rd Question + +a <- 2.19 + +b1 <- -3.16 + +b2 <- 0.99 + +# (a) part + +x1 <- 0.40 +x2 <- 10.50 + +y_cap1 <- round(a + (b1 * x1) + (b2 * x2), 2) # Predicted score (multiple regression) + +cat("Predicted score (multiple regression) is", y_cap1) + +# (b) part + +x1 <- 0.15 +x2 <- 5.50 + +y_cap2 <- round(a + (b1 * x1) + (b2 * x2), 2) # Predicted score (multiple regression) + +cat("Predicted score (multiple regression) is", y_cap2) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.6a/Ex12_6a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.6a/Ex12_6a.R new file mode 100644 index 00000000..a60e51a9 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.6a/Ex12_6a.R @@ -0,0 +1,20 @@ + # Page no. : 520 - 522 + +# Proportionate reduction in error + +Hours_slept <- c(5, 6, 6, 7, 8, 10) +Actual_mood <- c(2, 2, 3, 4, 7, 6) + +DF <- data.frame(Hours_slept, Actual_mood) +View(DF) + +# Direct method + +regressor <- lm(Actual_mood ~ Hours_slept, data = DF) +res <- summary(regressor) + +res + +p_r <- round(res$r.squared, 2) # Proportionate reduction in error + +cat("Proportionate reduction in error is", p_r) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.6b/Ex12_6b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.6b/Ex12_6b.R new file mode 100644 index 00000000..1b4bc079 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.6b/Ex12_6b.R @@ -0,0 +1,31 @@ + # Page no. : 523 - 524 + +# How are you doing? + +# 4th Question + +score <- c(6, 4, 2, 8) +predicted_score <- c(5.7, 4.3, 2.9, 7.1) + +m <- mean(score) # mean + +error <- score - m +error_sq <- error ** 2 # Error square + +error2 <- score - predicted_score +error2_sq <- error2 ** 2 # Error square + +DF <- data.frame(score, error, error_sq, predicted_score, error2, error2_sq) +View(DF) + +ss_total <- sum(DF$error_sq) + +ss_error <- sum(DF$error2_sq) + +p_r <- round((ss_total - ss_error) / ss_total, 2) # Proportionate reduction in error + +cat("Proportionate reduction in error is", p_r) + +r <- round(sqrt(p_r), 2) # Correlation coefficient + +cat("Correlation coefficient is", r) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7a/Ex12_7a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7a/Ex12_7a.R new file mode 100644 index 00000000..fcf2906f --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7a/Ex12_7a.R @@ -0,0 +1,41 @@ + # Page no. : 526 + +# Worked out examples 1 + +# This example includes solution of worked out examples 3 + +Elementry_School <- c("Main Street", "Casat", "Lakeland", "Shady Grove", "Jefferson") +Class_size <- c(25, 14, 33, 28, 20) +Achievement <- c(80, 98, 50, 82, 90) + +DF <- data.frame(Elementry_School, Class_size, Achievement) +View(DF) + +# Direct method + +regressor <- lm(Achievement ~ Class_size, data = DF) +res <- summary(regressor) + +res + +b <- round(res$coefficients[[2]], 2) + +a <- round(res$coefficients[[1]], 2) + +cat("Linear Prediction Rule is y_cap =",a,"+",b,"x") + +# (a) part + +x <- 23 # Class size + +y_cap <- a + (b * x) # Predicted achievement + +cat("Predicted achievement is", y_cap) + +# (b) part + +x <- 14 # Class size + +y_cap <- a + (b * x) # Predicted achievement + +cat("Predicted achievement is", y_cap) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7b/Ex12_7b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7b/Ex12_7b.R new file mode 100644 index 00000000..25b03368 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7b/Ex12_7b.R @@ -0,0 +1,24 @@ + # Page no. : 526 + +# Worked out examples 2 + +Elementry_School <- c("Main Street", "Casat", "Lakeland", "Shady Grove", "Jefferson") +Class_size <- c(25, 14, 33, 28, 20) +Achievement <- c(80, 98, 50, 82, 90) + +DF <- data.frame(Elementry_School, Class_size, Achievement) +View(DF) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +ggplot(DF, aes(x = Class_size, y = Achievement)) + geom_point() + + labs(title = "Scatter plot", x = "Class size", y = "Achievement test score") + + theme_bw() + geom_smooth(method = "lm", se = F) + +# Book's figure is in page 527 \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7c/Ex12_7c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7c/Ex12_7c.R new file mode 100644 index 00000000..25f5178a --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7c/Ex12_7c.R @@ -0,0 +1,11 @@ + # Page no. : 528 + +# Worked out examples 4 + +ss_x <- 214 +ss_y <- 1328 +b <- -2.25 + +beta <- round(b * (sqrt(ss_x) / sqrt(ss_y)), 2) # Standardized regression coefficient + +cat("Standardized regression coefficient is", beta) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7d/Ex12_7d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7d/Ex12_7d.R new file mode 100644 index 00000000..a4ed8d8e --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7d/Ex12_7d.R @@ -0,0 +1,18 @@ + # Page no. : 528 - 529 + +# Worked out examples 5 + +a <- 2.13 + +b1 <- 1.32 +x1 <- 4 + +b2 <- 1.21 +x2 <- 5 + +b3 <- 1.41 +x3 <- 3 + +y_cap <- round(a + (b1 * x1) + (b2 * x2) + (b3 * x3), 2) # Predicted talkativeness + +cat("Predicted talkativeness is", y_cap) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7e/Ex12_7e.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7e/Ex12_7e.R new file mode 100644 index 00000000..74edf3d2 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH12/EX12.7e/Ex12_7e.R @@ -0,0 +1,21 @@ + # Page no. : 529 - 530 + +# Worked out examples 6 + +Elementry_School <- c("Main Street", "Casat", "Lakeland", "Shady Grove", "Jefferson") +Class_size <- c(25, 14, 33, 28, 20) +Achievement <- c(80, 98, 50, 82, 90) + +DF <- data.frame(Elementry_School, Class_size, Achievement) +View(DF) + +# Direct method + +regressor <- lm(Achievement ~ Class_size, data = DF) +res <- summary(regressor) + +res + +p_r <- round(res$r.squared, 2) # Proportionate reduction in error + +cat("Proportionate reduction in error is", p_r) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1a/Ex13_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1a/Ex13_1a.R new file mode 100644 index 00000000..b9c9782e --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1a/Ex13_1a.R @@ -0,0 +1,15 @@ + # Page no. : 543 -544 + +# An example + +gender <- c("Male", "Female") +o <- c(996, 390) # Observed frequency +e <- c(693, 693) # Expected frequency + +diff <- o - e # Difference +diff_sq <- diff ** 2 # Difference squared + +ans <- round(diff_sq / e, 2) # Difference squared weighted by expected frequency + +DF <- data.frame(gender, o, e, diff, diff_sq, ans) +View(DF) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1b/Ex13_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1b/Ex13_1b.R new file mode 100644 index 00000000..9194f46c --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1b/Ex13_1b.R @@ -0,0 +1,14 @@ + # Page no. : 545 -546 + +# The chi - square statistic and the chi - square test for goodness of fit + +o <- c(996, 390) # Observed frequency +e <- c(693, 693) # Expected frequency + +diff <- o - e # Difference +diff_sq <- diff ** 2 # Difference squared +ans <- round(diff_sq / e, 2) # Difference squared weighted by expected frequency + +chi_sq <- sum(ans) # Chi-square + +cat("Value of chi-square is", chi_sq) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1c/Ex13_1c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1c/Ex13_1c.R new file mode 100644 index 00000000..204bbc0f --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1c/Ex13_1c.R @@ -0,0 +1,34 @@ + # Page no. : 549 -550 + +# Another example + +condition <- c("Anxiety disorder", "Alcohol or drug abuse", "Mood disorder", + "Impulse - control disorder", "None of these conditions") + +observed <- c(138, 99, 123, 111, 529) + +expected <- c(146, 80, 110, 128, 536) + +DF <- data.frame(condition, observed, expected) +View(DF) + +alpha <- 0.05 # 5% significance level +df <- nrow(DF) - 1 # Degree of freedom + +chi_sq_val <- round(qchisq(alpha,df,lower.tail = F), 2) # Chi-square value + +diff <- DF$observed - DF$expected # Difference +diff_sq <- diff ** 2 # Difference squared +ans <- round(diff_sq / DF$expected, 2) # Difference squared weighted by expected frequency + +chi_sq <- sum(ans) # Chi-square + +cat("Value of chi-square is", chi_sq) + +if(chi_sq > chi_sq_val) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1d/Ex13_1d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1d/Ex13_1d.R new file mode 100644 index 00000000..489cc8cc --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.1d/Ex13_1d.R @@ -0,0 +1,32 @@ + # Page no. : 551 - 553 + +# How are you doing? + +# 5th Question (a) part + +alpha <- 0.05 # 5% significance level +categories <- 2 + +observed <- c(15, 35) +N <- sum(observed) # total +expected <- c(0.6 * N, 0.4 * N) + +df <- categories - 1 # Degree of freedom + +chi_sq_val <- round(qchisq(alpha,df,lower.tail = F), 2) # Chi-square value + +diff <- observed - expected # Difference +diff_sq <- diff ** 2 # Difference squared +ans <- round(diff_sq / expected, 2) # Difference squared weighted by expected frequency + +chi_sq <- sum(ans) # Chi-square + +cat("Value of chi-square is", chi_sq) + +if(chi_sq > chi_sq_val) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2a/Ex13_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2a/Ex13_2a.R new file mode 100644 index 00000000..2f430333 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2a/Ex13_2a.R @@ -0,0 +1,48 @@ + # Page no. : 553 - 557 + +# The chi - square test for independence + +# Contingency Table + +gender <- c(rep("Male", 28), rep("Female", 30), rep("Male", 125), rep("Female", 39)) +age <- c(rep("Child", 58), rep("Adult", 164)) + +c_t <- table(age, gender) # Contingency table + +c_t + +# Direct method + +result <- chisq.test(c_t) +result + +# Expected values + +expected <- round(result$expected, 2) +expected # Book's table 13-5 + +# Figuring chi - square + +chi_sq <- round(result$statistic, 2) + +cat("Chi-square value is", chi_sq) # Answer is different from book + +# Degrees of freedom + +df <- result$parameter + +cat("Degrees of freedom is", df) + +# Hypothesis testing + +alpha <- 0.05 # 5% significance level + +chi_sq_val <- round(qchisq(alpha,df,lower.tail = F), 2) # Chi-square value + +if(chi_sq > chi_sq_val) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2b/Ex13_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2b/Ex13_2b.R new file mode 100644 index 00000000..5373db31 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2b/Ex13_2b.R @@ -0,0 +1,49 @@ + # Page no. : 558 - 559 + +# Another example + +# Contingency Table + +generation <- c(rep("First", 73), rep("Other", 89), rep("First", 657), rep("Other", 1226)) +drop <- c(rep("Dropped out", 162), rep("Did not drop out", 1883)) + +c_t <- table(drop, generation) # Contingency table + +c_t + +# Direct method + +result <- chisq.test(c_t) +result + +# Expected values + +expected <- round(result$expected, 2) +expected # Book's table 13-7 + +# Figuring chi - square + +chi_sq <- round(result$statistic, 2) + +cat("Chi-square value is", chi_sq) # Answer is different from book + +# Degrees of freedom + +df <- result$parameter + +cat("Degrees of freedom is", df) + +# Hypothesis testing + +alpha <- 0.01 # 1% significance level + +chi_sq_val <- round(qchisq(alpha,df,lower.tail = F), 2) # Chi-square value + +if(chi_sq > chi_sq_val) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} +# Book's answer differ with our answer \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2c/Ex13_2c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2c/Ex13_2c.R new file mode 100644 index 00000000..31a9aacb --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.2c/Ex13_2c.R @@ -0,0 +1,49 @@ + # Page no. : 560 - 561 + +# How are you doing? + +# 4th Question (a) part + +nominal_variable_A <- c(rep("Category1", 10), rep("Category2", 10), rep("Category1", 50), + rep("Category2", 10), rep("Category1", 10), rep("Category2", 10)) +nominal_variable_B <- c(rep("Category1", 20), rep("Category2", 60), rep("Category3", 20)) + +c_t <- table(nominal_variable_B, nominal_variable_A) # Contingency table + +c_t + +# Direct method + +result <- chisq.test(c_t) +result + +# Expected values + +expected <- round(result$expected, 2) +expected + +# Figuring chi - square + +chi_sq <- round(result$statistic, 2) + +cat("Chi-square value is", chi_sq) + +# Degrees of freedom + +df <- result$parameter + +cat("Degrees of freedom is", df) + +# Hypothesis testing + +alpha <- 0.10 # 10% significance level + +chi_sq_val <- round(qchisq(alpha,df,lower.tail = F), 2) # Chi-square value + +if(chi_sq > chi_sq_val) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.3a/Ex13_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.3a/Ex13_3a.R new file mode 100644 index 00000000..f80bc0aa --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.3a/Ex13_3a.R @@ -0,0 +1,20 @@ + # Page no. : 562 - 563 + +# Effect Size for Chi-Square Tests for Independence + +chi_sq <- 6.73 # Chi-square value +N <- 2045 # No. of people + +phi_coeff <- round(sqrt(chi_sq / N), 2) # Phi coefficient + +cat("Phi coefficient is", phi_coeff) + + +chi_sq <- 12.70 # Chi-square value +N <- 100 # No. of people +df_smaller <- 1 # Degree of freedom on smaller side + +c_phi_coeff <- round(sqrt(chi_sq / (N * df_smaller)), 2) # Cramer's phi coefficient + +cat("Cramer's phi coefficient is", c_phi_coeff) # Book's answer is wrong + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.3b/Ex13_3b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.3b/Ex13_3b.R new file mode 100644 index 00000000..c5d92617 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.3b/Ex13_3b.R @@ -0,0 +1,22 @@ + # Page no. : 565 - 566 + +# How are you doing? + +# 2nd Question (d) part + +chi_sq <- 12 # Chi-square value +N <- 100 # No. of people + +phi_coeff <- round(sqrt(chi_sq / N), 2) # Phi coefficient + +cat("Phi coefficient is", phi_coeff) + +# 3rd Question (d) part + +chi_sq <- 20 # Chi-square value +N <- 200 # No. of people +df_smaller <- 4 - 1 # Degree of freedom on smaller side (4 x 6 contingency table) + +c_phi_coeff <- round(sqrt(chi_sq / (N * df_smaller)), 2) # Cramer's phi coefficient + +cat("Cramer's phi coefficient is", c_phi_coeff) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4a/Ex13_4a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4a/Ex13_4a.R new file mode 100644 index 00000000..f7efd000 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4a/Ex13_4a.R @@ -0,0 +1,31 @@ + # Page no. : 569 - 570 + +# Worked out examples 1 + +grade <- LETTERS[1:5] +observed <- c(10, 34, 140, 10, 6) +expected <- c(5, 28, 134, 28, 5) + +DF <- data.frame(grade, observed, expected) +View(DF) + +alpha <- 0.01 # 1% significance level +df <- nrow(DF) - 1 # Degree of freedom + +chi_sq_val <- round(qchisq(alpha,df,lower.tail = F), 2) # Chi-square value + +diff <- DF$observed - DF$expected # Difference +diff_sq <- diff ** 2 # Difference squared +ans <- round(diff_sq / DF$expected, 2) # Difference squared weighted by expected frequency + +chi_sq <- sum(ans) # Chi-square + +cat("Value of chi-square is", chi_sq) + +if(chi_sq > chi_sq_val) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4b/Ex13_4b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4b/Ex13_4b.R new file mode 100644 index 00000000..213ef545 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4b/Ex13_4b.R @@ -0,0 +1,49 @@ + # Page no. : 571 - 572 + +# Worked out examples 2 + +# Contingency Table + +participant_gender <- c(rep("Men", 29), rep("Women", 17), rep("Men", 4), rep("Women", 14), + rep("Men", 26), rep("Women", 28)) +comparision <- c(rep("Same sex", 46), rep("Opposite sex", 18), rep("Both sexes", 54)) + +c_t <- table(comparision, participant_gender) # Contingency table + +c_t + +# Direct method + +result <- chisq.test(c_t) +result + +# Expected values + +expected <- round(result$expected, 2) +expected # Book's table 13-12 + +# Figuring chi - square + +chi_sq <- round(result$statistic, 2) + +cat("Chi-square value is", chi_sq) + +# Degrees of freedom + +df <- result$parameter + +cat("Degrees of freedom is", df) + +# Hypothesis testing + +alpha <- 0.05 # 5% significance level + +chi_sq_val <- round(qchisq(alpha,df,lower.tail = F), 2) # Chi-square value + +if(chi_sq > chi_sq_val) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4c/Ex13_4c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4c/Ex13_4c.R new file mode 100644 index 00000000..eb0685d7 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH13/EX13.4c/Ex13_4c.R @@ -0,0 +1,18 @@ + # Page no. : 572 + +# Worked out examples 3 and 4 + +chi_sq <- 14.41 # Chi-square value +N <- 85 # No. of people + +phi_coeff <- round(sqrt(chi_sq / N), 2) # Phi coefficient + +cat("Phi coefficient is", phi_coeff) + +chi_sq <- 8.78 # Chi-square value +N <- 118 # No. of people +df_smaller <- 2 - 1 # Degree of freedom on smaller side (2 x 2 contingency table) + +c_phi_coeff <- round(sqrt(chi_sq / (N * df_smaller)), 2) # Cramer's phi coefficient + +cat("Cramer's phi coefficient is", c_phi_coeff) # Book's answer is wrong diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.1a/Ex14_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.1a/Ex14_1a.R new file mode 100644 index 00000000..ea89c582 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.1a/Ex14_1a.R @@ -0,0 +1,54 @@ + # Page no. : 592 - 593 + +# An example of a data transformation + +highly_sensitive_no <- c(0, 3, 10, 22) +highly_sensitive_yes <- c(17, 36, 45, 75) + +m1 <- mean(highly_sensitive_no) # Mean +var1 <- round(var(highly_sensitive_no), 2) # Variance + +m2 <- mean(highly_sensitive_yes) # Mean +var2 <- round(var(highly_sensitive_yes), 2) # Variance + +sq_root1 <- round(sqrt(highly_sensitive_no), 2) # Square root of highly_sensitive_no +sq_root2 <- round(sqrt(highly_sensitive_yes), 2) # Square root of highly_sensitive_yes + +DF <- data.frame(highly_sensitive_no, sq_root1, highly_sensitive_yes, sq_root2) +View(DF) + +alpha <- 0.05 # 5% signigicance level + +df1 <- length(highly_sensitive_no) - 1 # Degree of freedom of highly_sensitive_no +df2 <- length(highly_sensitive_yes) - 1 # Degree of freedom of highly_sensitive_yes + +df_total <- df1 + df2 # Total degrees of freedom + +# One - tailed + +tval <- round(qt(alpha, df_total, lower.tail = T), 2) + +result <-t.test(DF$sq_root1, DF$sq_root2) +result + +mean1 <- round(result$estimate[1], 2) # Mean of transformed highly_sensitive_no +var_1 <- round(var(DF$sq_root1), 2) # Variance of transformed highly_sensitive_no + +mean2 <- round(result$estimate[2], 2) # Mean of transformed highly_sensitive_yes +var_2 <- round(var(DF$sq_root2), 2) # Variance of transformed highly_sensitive_yes + +p_var <- round(((df1 / df_total) * var_1) + ((df2 / df_total) * var_2), 2) # Pooled variance + +cat("Pooled variance is", p_var) + +t <- round(result$statistic[[1]], 2) # t value + +cat("t value is", t) + +if(t < tval) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2a/Ex14_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2a/Ex14_2a.R new file mode 100644 index 00000000..f4115b4f --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2a/Ex14_2a.R @@ -0,0 +1,31 @@ + # Page no. : 595 - 596 + +# An example of a rank - order test + +highly_sensitive_no <- c(0, 3, 10, 22) +highly_sensitive_yes <- c(17, 36, 45, 75) + +DF <- data.frame( highly_sensitive = rep(c("No", "Yes"), each = 4), + Values = c(highly_sensitive_no, highly_sensitive_yes) + ) + +Rank <- rank(DF$Values) +DF <- cbind(DF, Rank) + +View(DF) + +alpha <- 0.05 # 5% significance level + +result <- wilcox.test(highly_sensitive_no, highly_sensitive_yes, paired = T) + +result + +p_value <- result$p.value + +if(p_value > alpha) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2b/Ex14_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2b/Ex14_2b.R new file mode 100644 index 00000000..fe76a5d7 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2b/Ex14_2b.R @@ -0,0 +1,42 @@ + # Page no. : 596 - 597 + +# Using parametric tests with rank - transformed data + +highly_sensitive_no <- c(1, 2, 3, 5) +highly_sensitive_yes <- c(4, 6, 7, 8) + +m1 <- mean(highly_sensitive_no) # Mean +var1 <- round(var(highly_sensitive_no), 2) # Variance + +m2 <- mean(highly_sensitive_yes) # Mean +var2 <- round(var(highly_sensitive_yes), 2) # Variance + +df1 <- length(highly_sensitive_no) - 1 # Degree of freedom of highly_sensitive_no +df2 <- length(highly_sensitive_yes) - 1 # Degree of freedom of highly_sensitive_yes + +df_total <- df1 + df2 # Total degrees of freedom + +# One - tailed + +alpha <- 0.05 # 5% significance level + +tval <- round(qt(alpha, df_total, lower.tail = T), 2) + +p_var <- round(((df1 / df_total) * var1) + ((df2 / df_total) * var2), 2) # Pooled variance + +cat("Pooled variance is", p_var) + +result <-t.test(highly_sensitive_no, highly_sensitive_yes) +result + +t <- round(result$statistic[[1]], 2) # t value + +cat("t value is", t) + +if(t < tval) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2c/Ex14_2c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2c/Ex14_2c.R new file mode 100644 index 00000000..a6385ffd --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.2c/Ex14_2c.R @@ -0,0 +1,13 @@ + # Page no. : 598 - 599 + +# How are you doing? + +# 2nd Question + +scores <- c(5, 18, 3, 9, 2) + +rank <- rank(scores) # Rank of scores + +DF <- data.frame(scores, rank) + +View(DF) # Our answer is in data frame formate \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.3a/Ex14_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.3a/Ex14_3a.R new file mode 100644 index 00000000..db236ff4 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH14/EX14.3a/Ex14_3a.R @@ -0,0 +1,23 @@ + # Page no. : 605 + +# Worked out examples 1 and 2 + +group_A <- c(15, 4, 12, 14) +group_B <- c(21, 16, 49, 17) +group_C <- c(18, 19, 11, 22) + +sq_root1 <- round(sqrt(group_A), 2) # Square root of group A +sq_root2 <- round(sqrt(group_B), 2) # Square root of group B +sq_root3 <- round(sqrt(group_C), 2) # Square root of group C + +DF <- data.frame(sq_root1, sq_root2, sq_root3) +View(DF) + +DF2 <- data.frame( Groups = rep(c("Group A", "Group B", "Group C"), each = 4), + Values = c(group_A, group_B, group_C) + ) + +Rank <- rank(DF2$Values) +DF2 <- cbind(DF2, Rank) + +View(DF2) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1a/Ex2_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1a/Ex2_1a.R new file mode 100644 index 00000000..6a16d053 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1a/Ex2_1a.R @@ -0,0 +1,9 @@ + # Page no. : 36 - 37 + +# Mean Example 1 + +x <- c(7, 8, 8, 7, 3, 1, 6, 9, 3, 8) + +value <- mean(x) + +cat("Mean of x is", value) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1b/Ex2_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1b/Ex2_1b.R new file mode 100644 index 00000000..afda1d39 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1b/Ex2_1b.R @@ -0,0 +1,26 @@ + # Page no. : 37 + +# Mean Example 2 + +x <- c(8, 7, 4, 10, 8, 6, 8, 9, 9, 7, 3, 7, 6, 5, 0, 9, 10, 7, 7, 3, 6, 7, 5, 2, 1, 6, 7, 10, + 8, 8) + +value <- mean(x) + +cat("Mean of x is", round(value,2)) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +# Showing mean value on histogram + +ggplot(data = data.frame(x), aes(x = x)) + + geom_bar(stat = "count", fill = "violet") + + geom_vline(xintercept = mean(x), col = "red", lwd = 0.8) + + labs(title = "Histogram with mean value", x = "Stress Rating", y = "Frequency") + + theme_bw() \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1c/Ex2_1c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1c/Ex2_1c.R new file mode 100644 index 00000000..bbdf206a --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1c/Ex2_1c.R @@ -0,0 +1,28 @@ + # Page no. : 38 + +# Mean Example 3 + +x <- c(48, 15, 33, 3, 21, 19, 17, 16, 44, 25, 30, 3, 5, 9, 35, 32, 26, 13, 14, 14, 47, 47, 18, + 11, 5, 19, 24, 17, 6, 25, 8, 18, 29, 1, 18, 22, 3, 22, 29, 2, 6, 10, 29, 10, 29, 21, 38, + 41, 16, 17, 8, 40, 8, 10, 18, 7, 4, 4, 8, 11, 3, 23, 10, 19, 21, 13, 12, 10, 4, 17, 11, + 21, 9, 8, 7, 5, 3, 22, 14, 25, 4, 11, 10, 18, 1, 28, 27, 19, 24, 35, 9, 30, 8, 26) + +value <- mean(x) + +cat("Mean of x is", round(value, 2)) + +# Install Library if not install + +# install.packages("ggplot2") + +# Import Library + +library(ggplot2) + +# Showing mean value on histogram + +ggplot(data = data.frame(table(x)), aes(x = x, y = Freq)) + + geom_bar(stat = "identity", fill = "violet") + + geom_vline(xintercept = mean(x), col = "red", lwd = 0.8) + + labs(title = "Histogram with mean value", x = "Social Interaction", y = "Frequency") + + theme_bw() \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1d/Ex2_1d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1d/Ex2_1d.R new file mode 100644 index 00000000..02a55ed4 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.1d/Ex2_1d.R @@ -0,0 +1,38 @@ + # Page no. : 43 + +# How are you doing? + +# 3rd Question + +scores <- c(2, 3, 3, 6, 6) + +value <- mean(scores) + +cat("Mean value of scores is", value) + +# 4th Question (Only a, b, c parts) + +scores <- c(5, 3, 2, 13, 2) + +# a) Mean + +value <- mean(scores) + +cat("Mean value of scores is", value) + +# b) Mode + +mode <- function(v) { + x <- unique(v) + x[which.max(tabulate(match(v, x)))] +} + +value <- mode(scores) + +cat("Mode of scores is", value) + +# c) Median + +value <- median(scores) + +cat("Median of scores is", value) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2a/Ex2_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2a/Ex2_2a.R new file mode 100644 index 00000000..9c4dc70c --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2a/Ex2_2a.R @@ -0,0 +1,21 @@ + # Page no. : 48 + +# Variance and Standard Deviation Example 1 + +scores <- c(7, 8, 8, 7, 3, 1, 6, 9, 3, 8) + +# Install Library if not install + +install.packages("rafalib") + +# Import Library + +library(rafalib) + +variance <- popvar(scores) + +standard_deviation <- popsd(scores) + +cat("Variance of scores are", round(variance, 2), "and Standard Deviation of scores are", + round(standard_deviation, 2)) + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2b/Ex2_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2b/Ex2_2b.R new file mode 100644 index 00000000..0cde6a4c --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2b/Ex2_2b.R @@ -0,0 +1,24 @@ + # Page no. : 49 + +# Variance and Standard Deviation Example 2 + +interactions <- c(48, 15, 33, 3, 21, 19, 17, 16, 44, 25, 30, 3, 5, 9, 35, 32, 26, 13, 14, + 14, 47, 47, 18, 11, 5, 19, 24, 17, 6, 25, 8, 18, 29, 1, 18, 22, 3, 22, + 29, 2, 6, 10, 29, 10, 29, 21, 38, 41, 16, 17, 8, 40, 8, 10, 18, 7, 4, 4, + 8, 11, 3, 23, 10, 19, 21, 13, 12, 10, 4, 17, 11, 21, 9, 8, 7, 5, 3, 22, + 14, 25, 4, 11, 10, 18, 1, 28, 27, 19, 24, 35, 9, 30, 8, 26) + +# Install Library if not install + +install.packages("rafalib") + +# Import Library + +library(rafalib) + +variance <- popvar(interactions) + +standard_deviation <- popsd(interactions) + +cat("Variance of scores are", round(variance, 2), "and Standard Deviation of scores are", + round(standard_deviation, 2)) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2c/Ex2_2c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2c/Ex2_2c.R new file mode 100644 index 00000000..47ed5b5e --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.2c/Ex2_2c.R @@ -0,0 +1,22 @@ + # Page no. : 51 - 52 + +# How are you doing? + +# 4th Question + +scores <- c(2, 4, 3, 7) + +# Install Library if not install + +install.packages("rafalib") + +# Import Library + +library(rafalib) + +variance <- popvar(scores) + +standard_deviation <- popsd(scores) + +cat("Variance of scores are", round(variance, 2), "and Standard Deviation of scores are", + round(standard_deviation, 2)) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.3a/Ex2_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.3a/Ex2_3a.R new file mode 100644 index 00000000..81593723 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH2/EX2.3a/Ex2_3a.R @@ -0,0 +1,43 @@ + # Page no. : 58 - 60 + +# Worked - out Exapmles + +# a) Mean + +scores <- c(8, 6, 6, 9, 6, 5, 6, 2) + +value <- mean(scores) + +cat("Mean of scores is", value) + +# b) Median + +scores <- c(1, 7, 4, 2, 3, 6, 2, 9, 7) + +value <- median(scores) + +cat("Median of value is", value) + +# c) Sum of Squares, Variance and Standard Deviation + +scores <- c(8, 6, 6, 9, 6, 5, 6, 2) + +value <- sum((scores - mean(scores))**2) + +cat("Sum of Squares of scores is", value) + +# Install Library if not install + +install.packages("rafalib") + +# Import Library + +library(rafalib) + +variance <- popvar(scores) + +cat("Variance of scores is", variance) + +standard_deviation <- popsd(scores) + +cat("Standard Deviation of scores is", round(standard_deviation, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1a/Ex3_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1a/Ex3_1a.R new file mode 100644 index 00000000..96a8ceb9 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1a/Ex3_1a.R @@ -0,0 +1,21 @@ + # Page no. : 71 + +# Formula to change Raw Score to Z Score + +x <- 8 # Raw Score +m <- 12 # Mean +sd <- 4 # Standard Deviation + +Z <- (x - m) / sd + +cat("Z Score is", Z) + +# Formula to change Z Score to Raw Score + +Z <- 1.5 # Z Score +sd <- 4 # Standard Deviation +m <- 12 # Mean + +X <- (Z * sd) + m + +cat("Raw Score is", X) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1b/Ex3_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1b/Ex3_1b.R new file mode 100644 index 00000000..cba9b598 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1b/Ex3_1b.R @@ -0,0 +1,21 @@ + # Page no. : 72 + +# Additional Example (1) to change Raw Score to Z Score and Vice Versa + +# a) Raw Score to Z Score + +m <- 3.40 # Mean +sd <- 1.47 # Standard Deviation +x <- 6 # Raw Score + +Z <- (x - m) / sd + +cat("Z Score is", round(Z, 2)) + +# b) Z Score to Raw Score + +Z <- -1.63 # Z Score + +X <- (Z * sd) + m + +cat("Raw Score is", round(X, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1c/Ex3_1c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1c/Ex3_1c.R new file mode 100644 index 00000000..ea108c75 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1c/Ex3_1c.R @@ -0,0 +1,21 @@ + # Page no. : 72 - 73 + +# Additional Example (2) to change Raw Score to Z Score and Vice Versa + +# a) Raw Score to Z Score + +m <- 6.43 # Mean +sd <- 2.56 # Standard Deviation +x <- 10 # Raw Score + +Z <- (x - m) / sd + +cat("Z Score is", round(Z, 2)) + +# b) Z Score to Raw Score + +Z <- -1.73 # Z Score + +X <- (Z * sd) + m + +cat("Raw Score is", round(X, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1d/Ex3_1d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1d/Ex3_1d.R new file mode 100644 index 00000000..2d97cef1 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1d/Ex3_1d.R @@ -0,0 +1,40 @@ + # Page no. : 73 + +# How are you doing? + +# 3rd Question + +m <- 20 # Mean +sd <- 5 # Standard Deviation + +# a) + +x1 <- 30 + +z1 <- (x1 - m) / sd + +cat("Z Score is", round(z1, 2)) + +# b) + +x2 <- 15 + +z2 <- (x2 - m) / sd + +cat("Z Score is", round(z2, 2)) + +# c) + +x3 <- 20 + +z3 <- (x3 - m) / sd + +cat("Z Score is", round(z3, 2)) + +# d) + +x4 <- 22.5 + +z4 <- (x4 - m) / sd + +cat("Z Score is", round(z4, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1e/Ex3_1e.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1e/Ex3_1e.R new file mode 100644 index 00000000..c75a8253 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.1e/Ex3_1e.R @@ -0,0 +1,41 @@ + # Page no. : 73 + +# How are you doing? + +# 5th Question + +m <- 10 # Mean +sd <- 2 # Standard Deviation + +# a) + +z1 <- 2 + +x1 <- (z1 * sd) + m + +cat("Raw Score is", round(x1, 2)) + +# b) + +z2 <- 0.5 + +x2 <- (z2 * sd) + m + +cat("Raw Score is", round(x2, 2)) + +# c) + +z3 <- 0 + +x3 <- (z3 * sd) + m + +cat("Raw Score is", round(x3, 2)) + +# d) + +z4 <- -3 + +x4 <- (z4 * sd) + m + +cat("Raw Score is", round(x4, 2)) + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.2a/Ex3_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.2a/Ex3_2a.R new file mode 100644 index 00000000..da6879fa --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.2a/Ex3_2a.R @@ -0,0 +1,34 @@ + # Page no. : 79 - 81 + +# Examples for finding Percentage from Z Scores and Raw Scores using Normal Curve Table + +m <- 100 # Mean +sd <- 15 # Standard Deviation + +# a) + +IQ1 <- 125 + +Z1 <- (IQ1 - m) / sd + +cat("Z Score is", round(Z1, 2)) + +percent <- pnorm(Z1, lower.tail = F) * 100 + +cat("Percentage of IQ level is", round(percent, 2)) + +# Book's answer is slightly different due to rounding off the values. + +# b) + +IQ2 <- 95 + +Z2 <- (IQ2 - m) / sd + +cat("Z Score is", round(Z2, 2)) + +percent <- pnorm(Z2, lower.tail = F) * 100 + +cat("Percentage of IQ level is", round(percent, 2)) + +# Book's answer is slightly different due to rounding off the values. \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.2b/Ex3_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.2b/Ex3_2b.R new file mode 100644 index 00000000..9fe491d2 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.2b/Ex3_2b.R @@ -0,0 +1,42 @@ + # Page no. : 81 - 84 + +# Examples for finding Z Scores and Raw Scores from Percentage using Normal Curve Table + +m <- 100 # Mean +sd <- 15 # Standard Deviation + +# a) + +percent <- 0.05 # 5% + +Z1 <- qnorm(percent, lower.tail = F) + +cat("Z Score is", round(Z1, 2)) + +IQ1 <- (sd * Z1) + m + +cat("Raw Score is", round(IQ1, 2)) + +# b) + +percent <- 0.55 # 55% + +Z2 <- qnorm(percent, lower.tail = F) + +cat("Z Score is", round(Z2, 2)) + +IQ2 <- (sd * Z2) + m + +cat("Raw Score is", round(IQ2, 2)) + +# c) + +percent <- 0.95 # 95% + +Z3 <- qnorm(0.975, lower.tail = T) # 0.95 + 0.025 since curve is symmetric + +cat("Z Score is", round(Z3, 2)) + +IQ3 <- (sd * Z3) + m + +cat("Raw Score is", round(IQ3, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3a/Ex3_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3a/Ex3_3a.R new file mode 100644 index 00000000..e53bdcfd --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3a/Ex3_3a.R @@ -0,0 +1,23 @@ + # Page no. : 100 + +# Worked - out Examples + +# Changing a Raw Score to a Z Score + +m <- 80 # Mean +sd <- 20 # Standard Deviation +x <- 65 # Raw Score + +Z <- (x - m) / sd + +cat("Z Score is", Z) + +# Changing a Z Score to a Raw Score + +m <- 200 # Mean +sd <- 50 # Standard Deviation +z <- 1.26 # Z Score + +X <- (z * sd) + m + +cat("Raw Score is", X) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3b/Ex3_3b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3b/Ex3_3b.R new file mode 100644 index 00000000..41a2ce1d --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3b/Ex3_3b.R @@ -0,0 +1,36 @@ + # Page no. : 100 - 102 + +# Worked - out Examples + +# Figuring the Percentage Above or Below a Particular Raw Score or Z Score + +m <- 20 # Mean +sd <- 3 # Standard Deviation +x <- 24 # Raw Score + +Z <- (x - m) / sd + +cat("Z Score is", round(Z,2)) + +percent <- pnorm(Z, lower.tail = F) * 100 + +cat("Percentage of people have scores above 24 is", round(percent, 2)) + +# Book answer is slightly different + + +# Figuring Z Scores and Raw Scores From Percentages + +m <- 20 # Mean +sd <- 3 # Standard Deviation +percent <- 0.75 # 75% + +Z <- qnorm(percent, lower.tail = F) + +cat("Z Score is", round(Z, 2)) + +X <- (sd * Z) + m + +cat("Raw Score is", round(X, 2)) + +# Book answer is slightly different (differ by 0.01) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3c/Ex3_3c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3c/Ex3_3c.R new file mode 100644 index 00000000..77a1d30f --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH3/EX3.3c/Ex3_3c.R @@ -0,0 +1,19 @@ + # Page no. : 102 - 103 + +# Worked - out Examples + +# Finding a Probability + +apple <- 20 +strawberry <- 20 +cherry <- 5 +grape <- 5 + +total <- apple + strawberry + cherry + grape + +case <- cherry + grape + +probability <- case / total + +cat("Probability of picking one piece of candy at random which will be either cherry or grape + is", probability) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1a/Ex4_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1a/Ex4_1a.R new file mode 100644 index 00000000..eda6ea85 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1a/Ex4_1a.R @@ -0,0 +1,25 @@ + # Page no. : 111 - 115 + +# The Hypothesis - Testing Process + +m <- 14 # Mean +sd <- 3 # Standard Deviation +x <- 6 # Raw Score +alpha <- 0.01 # 1% Significance level + +# Bottom 1% + +cutoff <- qnorm(alpha) # Cutoff Z Score +cutoff <- round(cutoff, 2) + +z <- (x - m) / sd # Actual Z Score + +cat("Cutoff Sample Z Score is ", cutoff) +cat("Actual Sample Z Score is", round(z, 2)) + +if(z < cutoff) +{ + cat("We reject null hypothesis since actual z score is less than cutoff z score.") +}else{ + cat("We cannot reject null hypothesis.") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1b/Ex4_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1b/Ex4_1b.R new file mode 100644 index 00000000..d7c9d7e5 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1b/Ex4_1b.R @@ -0,0 +1,22 @@ + # Page no. : 116 - 118 + +# The Second Example + +m <- 70 # Mean +sd <- 10 # Standard Deviation +x <- 80 # Raw Score +alpha <- 0.05 # 5% Significance level + +# Top 5% + +cutoff <- qnorm(1 - alpha) # Cutoff Z Score +cutoff <- round(cutoff, 2) + +z <- (x - m) / sd # Actual Z Score + +if(z > cutoff) +{ + cat("We reject null hypothesis since actual z score is greater than cutoff z score.") +}else{ + cat("We cannot reject null hypothesis.") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1c/Ex4_1c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1c/Ex4_1c.R new file mode 100644 index 00000000..b15409f6 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.1c/Ex4_1c.R @@ -0,0 +1,28 @@ + # Page no. : 119 - 120 + +# How are you doing? + +# 6th Question + +m <- 30 # Mean +sd <- 4 # Standard Deviation +x <- 40 # Raw Score +alpha <- 0.05 # 5% Significance level + +# Top 5% + +cutoff <- qnorm(1 - alpha) # Cutoff Sample Z Score +cutoff <- round(cutoff, 2) + +z <- (x - m) / sd # Actual Sample Z Score + +cat("Cutoff Sample Z Score is ", cutoff) +cat("Actual Sample Z Score is", z) + +if(z > cutoff) +{ + cat("We reject null hypothesis since actual sample z score is greater than cutoff sample z + score.") +}else{ + cat("We cannot reject null hypothesis.") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.2a/Ex4_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.2a/Ex4_2a.R new file mode 100644 index 00000000..9f1ab544 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.2a/Ex4_2a.R @@ -0,0 +1,28 @@ + # Page no. : 123 - 124 + +# Example of Hypothesis Testing with a Two - Tailed Test + +m <- 69.5 # Mean +sd <- 14.1 # Standard Deviation +x <- 41 # Raw Score +alpha <- 0.05 # 5% Significance level + +# Two - Tailed Test + +cutoff1 <- qnorm(0.025) # 0.05 / 2 = 0.025 (Cutoff Z Score 1) +cutoff1 <- round(cutoff1, 2) + +cutoff2 <- qnorm(0.975) # 1 - 0.025 = 0.975 (Cutoff Z Score 2) +cutoff2 <- round(cutoff2, 2) + +z <- (x - m) / sd # Actual Z Score + +cat("Cutoff Z scores are", cutoff1, "and", cutoff2) +cat("Actual Z score is", round(z, 2)) + +if(z > cutoff1 & z < cutoff2) +{ + cat("We cannot reject null hypothesis as z is lying between the cutoffs.") +}else{ + cat("We can reject null hypothesis as z does'nt lying between the cutoffs.") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.2b/Ex4_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.2b/Ex4_2b.R new file mode 100644 index 00000000..312c698f --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.2b/Ex4_2b.R @@ -0,0 +1,30 @@ + # Page no. : 125 + +# How are you doing? + +# 6th Question + +m <- 500 # Mean +sd <- 40 # Standard Deviation +x <- 400 # Raw Score +alpha <- 0.01 # 5% Significance level + +# Two - Tailed Test + +cutoff1 <- qnorm(0.005) # 0.01 / 2 = 0.005 (Cutoff Z Score 1) +cutoff1 <- round(cutoff1, 2) + +cutoff2 <- qnorm(0.995) # 1 - 0.005 = 0.995 (Cutoff Z Score 2) +cutoff2 <- round(cutoff2, 2) + +z <- (x - m) / sd # Actual Z Score + +cat("Cutoff Z scores are", cutoff1, "and", cutoff2) +cat("Actual Z score is", round(z, 2)) + +if(z > cutoff1 & z < cutoff2) +{ + cat("We cannot reject null hypothesis as z is lying between the cutoffs.") +}else{ + cat("We can reject null hypothesis as z does'nt lying between the cutoffs.") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.3a/Ex4_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.3a/Ex4_3a.R new file mode 100644 index 00000000..653bfe41 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH4/EX4.3a/Ex4_3a.R @@ -0,0 +1,28 @@ + # Page no. : 131 - 132 + +# Worked - out Examples + +m <- 19 # Mean +sd <- 4 # Standard Deviation +x <- 27 # Raw Score +alpha <- 0.05 # 5% Significance level + +# Two - Tailed Test + +cutoff1 <- qnorm(0.025) # 0.05 / 2 = 0.025 (Cutoff Z Score 1) +cutoff1 <- round(cutoff1, 2) + +cutoff2 <- qnorm(0.975) # 1 - 0.025 = 0.975 (Cutoff Z Score 2) +cutoff2 <- round(cutoff2, 2) + +z <- (x - m) / sd # Actual Z Score + +cat("Cutoff Z scores are", cutoff1, "and", cutoff2) +cat("Actual Z score is", round(z, 2)) + +if(z > cutoff1 & z < cutoff2) +{ + cat("We cannot reject null hypothesis as z is lying between the cutoffs.") +}else{ + cat("We can reject null hypothesis as z does'nt lying between the cutoffs.") +} diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1a/Ex5_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1a/Ex5_1a.R new file mode 100644 index 00000000..52a428bb --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1a/Ex5_1a.R @@ -0,0 +1,21 @@ + # Page no. : 144 + +# Determining the Characteristics of a Distribution of Means + +grade <- 6.67 # Population Variance +N <- 2 # Number of individuals + +ans <- grade / N # Variance of a distribution of means + +cat("Answer is", round(ans,2)) + + +pv <- 400 # Population Variance +N <- 25 # Number of individuals + +ans <- pv / N # Variance of a distribution of means + +cat("Answer is", round(ans, 2)) + + + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1b/Ex5_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1b/Ex5_1b.R new file mode 100644 index 00000000..6fe07dba --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1b/Ex5_1b.R @@ -0,0 +1,17 @@ + # Page no. : 146 - 147 + +# Example of Determining the Characteristics of a Distribution of Means + +mean <- 200 # Population Mean +sd <- 48 # Standard Deviation +N <- 64 # Sample + +var <- sd ** 2 # Variance +ans <- var / N # Variance of a distribution of means + +cat("Answer is",ans) + + +sd2 <- sqrt(ans) # Standard Deviation of a distribution of means + +cat("Answer is",sd2) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1c/Ex5_1c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1c/Ex5_1c.R new file mode 100644 index 00000000..14177392 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.1c/Ex5_1c.R @@ -0,0 +1,17 @@ + # Page no. : 148 + +# How are you doing? +# Q-6 + +mean <- 60 +sd <- 10 # Standard Deviation +N <- 4 # Sample + +var <- sd ** 2 +ans <- var / N + +cat("Answer is",ans) + +var2 <- sqrt(ans) + +cat("Answer is",var2) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2a/Ex5_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2a/Ex5_2a.R new file mode 100644 index 00000000..7a256277 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2a/Ex5_2a.R @@ -0,0 +1,11 @@ + # Page no. : 148 - 149 + +# Hypothesis testing with a distribution of means: The Z Test + +mean <- 18 # Sample Mean +d_mean <- 10 # Distribution of means +sd <- 4 # Standard deviation + +z <- (mean - d_mean) / sd + +cat("The value of z-score is", z) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2b/Ex5_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2b/Ex5_2b.R new file mode 100644 index 00000000..60621aa2 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2b/Ex5_2b.R @@ -0,0 +1,25 @@ + # Page no. : 150 - 152 + +# Example 1 for Hypothesis testing with a distribution of means: The Z Test + +n <- 64 # No. of students +mean <- 220 # Sample Mean +d_mean <- 200 # Distribution of means +sd <- 48 # Population standard deviation +var <- sd ** 2 # Population variance +d_var <- var / n # Variance for the distribution of means +d_sd <- sqrt(d_var) # standard deviation for the distribution of means +alpha <- 0.05 # Significance level +zval <- qnorm(alpha, lower.tail = F) # Z value at 5% significance level + +z <- (mean - d_mean) / d_sd + +cat("The value of z-score is", z) + +if(z > zval) +{ + cat("Reject null hypothesis") +} else +{ + cat("We cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2c/Ex5_2c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2c/Ex5_2c.R new file mode 100644 index 00000000..3c20337a --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2c/Ex5_2c.R @@ -0,0 +1,29 @@ + # Page no. : 152 - 154 + +# Example 2 for Hypothesis testing with a distribution of means: The Z Test + +n <- 25 # No. of students +mean <- 48 # Sample Mean +d_mean <- 53 # Distribution of means +sd <- 7 # Population standard deviation +var <- sd ** 2 # Population variance +d_var <- var / n # Variance for the distribution of means +d_sd <- sqrt(d_var) # standard deviation for the distribution of means +alpha <- 0.01 # Significance level + +# Two-Tailed Test + +zval <- qnorm(1 - alpha/2) # Z value at 1% significance level +zval <- round(c(zval, -zval),2) + +z <- (mean - d_mean) / d_sd + +cat("The value of z-score is", z) + +if(z > zval[1] || z < zval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("We cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2d/Ex5_2d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2d/Ex5_2d.R new file mode 100644 index 00000000..0bb40557 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.2d/Ex5_2d.R @@ -0,0 +1,31 @@ + # Page no. : 154 - 155 + +# How are you doing? + +# 3rd Question + +n <- 36 # No. of people +mean <- 70 # Sample Mean +d_mean <- 75 # Distribution of means +sd <- 12 # Population standard deviation +var <- sd ** 2 # Population variance +d_var <- var / n # Variance for the distribution of means +d_sd <- sqrt(d_var) # standard deviation for the distribution of means +alpha <- 0.05 # Significance level + +# Two-Tailed Test + +zval <- qnorm(1 - alpha/2) # Z value at 1% significance level +zval <- round(c(zval, -zval),2) + +z <- (mean - d_mean) / d_sd + +cat("The value of z-score is", z) + +if(z > zval[1] || z < zval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("We cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.3a/Ex5_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.3a/Ex5_3a.R new file mode 100644 index 00000000..c1e86f64 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.3a/Ex5_3a.R @@ -0,0 +1,26 @@ + # Page no. : 161 + +# Confidence interval + +c_i <- 0.995 # 99% confidence interval --> 1 - 0.005 = 0.995 +n <- 25 # No. of students +d_mean <- 53 # Distribution of means +mean <- 48 # Sample mean +sd <- 7 # Standard deviation +var <- sd ** 2 # Variance + +se <- sqrt(var/n) # Standard error + +cat("Standard error is", se) + +r_s <- round(qnorm(c_i), 2) # Raw score + +x <- se * r_s # How far is the confidence limit is from mean (margin of error) + +y <- mean + c(-x, x) + +cat("The margin of error is given by", x) +cat("The 99% confidence interval is given by", y) + + + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.3b/Ex5_3b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.3b/Ex5_3b.R new file mode 100644 index 00000000..1da6d7e1 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.3b/Ex5_3b.R @@ -0,0 +1,25 @@ + # Page no. : 163 + +# How are you doing? + +# 4th Question (b part) + +n <- 36 # No. of people +mean <- 70 # Sample mean +d_mean <- 75 # Distribution of means +sd <- 12 # Standard deviation +var <- sd ** 2 # Variance +c_i <- 0.975 # 95% confidence interval --> 1 - 0.025 = 0.975 + +se <- sqrt(var/n) # Standard error + +cat("Standard error is", se) + +r_s <- round(qnorm(c_i), 2) # Raw score + +x <- se * r_s # How far is the confidence limit is from mean (margin of error) + +y <- mean + c(-x, x) + +cat("The margin of error is given by", x) +cat("The 99% confidence interval is given by", y) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4a/Ex5_4a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4a/Ex5_4a.R new file mode 100644 index 00000000..ecb3d2aa --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4a/Ex5_4a.R @@ -0,0 +1,11 @@ + # Page no. : 167 + +# Worked out examples 1 + +sd <- 13 # Standard deviation +var <- sd ** 2 # Variance +n <- 20 # Sample size + +d_sd <- sqrt(var/n) # Standard deviation for distribution of means + +cat("Standard deviation for distribution of means is", round(d_sd, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4b/Ex5_4b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4b/Ex5_4b.R new file mode 100644 index 00000000..ac71ca70 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4b/Ex5_4b.R @@ -0,0 +1,29 @@ + # Page no. : 167 - 168 + +# Worked out examples 2 + +n <- 75 # No. of people +mean <- 16 # Sample Mean +d_mean <- 15 # Distribution of means +sd <- 5 # Population standard deviation +var <- sd ** 2 # Population variance +d_var <- var / n # Variance for the distribution of means +d_sd <- sqrt(d_var) # standard deviation for the distribution of means +alpha <- 0.05 # Significance level + +# Two-Tailed Test + +zval <- qnorm(1 - alpha/2) # Z value at 1% significance level +zval <- round(c(zval, -zval),2) + +z <- (mean - d_mean) / d_sd + +cat("The value of z-score is", z) + +if(z > zval[1] || z < zval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("We cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4c/Ex5_4c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4c/Ex5_4c.R new file mode 100644 index 00000000..d4d5a6fd --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH5/EX5.4c/Ex5_4c.R @@ -0,0 +1,26 @@ + # Page no. : 169 + +# Worked out examples 3 + +n <- 75 # No. of people +mean <- 16 # Sample Mean +d_mean <- 15 # Distribution of means +sd <- 5 # Population standard deviation +var <- sd ** 2 # Population variance +d_var <- var / n # Variance for the distribution of means +d_sd <- sqrt(d_var) # standard deviation for the distribution of means +c_i <- 0.995 # 99% confidence interval --> 1 - 0.005 = 0.995 + +se <- d_sd # Standard error + +cat("Standard error is", se) + +r_s <- round(qnorm(c_i), 2) # Raw score + +x <- se * r_s # How far is the confidence limit is from mean (margin of error) + +y <- mean + c(-x, x) + +cat("The margin of error is given by", x) +cat("The 99% confidence interval is given by", y) + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.1a/Ex6_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.1a/Ex6_1a.R new file mode 100644 index 00000000..2e4eb8e0 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.1a/Ex6_1a.R @@ -0,0 +1,23 @@ + # Page no. : 184 - 185 + +# Figuring effect size + +m1 <- 220 # Mean of population 1 +m2 <- 200 # Mean of population 2 +sd <- 48 # Standard deviation + +d1 <- (m1 - m2) / sd # Estimated effect size + +cat("Estimated effect size is", round(d1, 2)) + +m1 <- 210 # Mean of population 1 + +d2 <- (m1 - m2) / sd # Estimated effect size + +cat("Estimated effect size is", round(d2, 2)) + +m1 <- 170 # Mean of population 1 + +d3 <- (m1 - m2) / sd # Estimated effect size + +cat("Estimated effect size is", round(d3, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.1b/Ex6_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.1b/Ex6_1b.R new file mode 100644 index 00000000..eb3ea614 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.1b/Ex6_1b.R @@ -0,0 +1,13 @@ + # Page no. : 188 - 189 + +# How are you doing? + +# 4th Question + +m1 <- 540 # Mean of population 1 +m2 <- 500 # Mean of population 2 +sd <- 100 # Standard deviation + +d1 <- (m1 - m2) / sd # Estimated effect size + +cat("Estimated effect size is", round(d1, 2)) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.2a/Ex6_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.2a/Ex6_2a.R new file mode 100644 index 00000000..82e01c90 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.2a/Ex6_2a.R @@ -0,0 +1,17 @@ + # Page no. : 197 + +# Determining power from predicted effect size + +m2 <- 200 # Mean of population 2 +d <- .20 # Predicted effect size +sd <- 48 # Standard deviation + +m <- m2 + (d * sd) # Predicted mean + +cat("Predicted effect size is", round(m, 2)) + +d <- .50 # Predicted effect size + +m <- m2 + (d * sd) # Predicted mean + +cat("Predicted effect size is", round(m, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.2b/Ex6_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.2b/Ex6_2b.R new file mode 100644 index 00000000..f6e1c5e0 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.2b/Ex6_2b.R @@ -0,0 +1,13 @@ + # Page no. : 204 + +# How are you doing? + +# 2nd Question + +m2 <- 500 # Mean of population 2 +d <- .80 # Predicted effect size +sd <- 100 # Standard deviation + +m <- m2 + (d * sd) # Predicted mean + +cat("Predicted effect size is", round(m, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.3a/Ex6_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.3a/Ex6_3a.R new file mode 100644 index 00000000..a99077ae --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.3a/Ex6_3a.R @@ -0,0 +1,25 @@ + # Page no. : 214 - 215 + +# Advanced topic : Figuring Statistical Power + +m <- 200 # Mean +sd <- 48 # Standard deviation +var <- sd ** 2 # Variance +n <- 64 # No. of students + +d_sd <- sqrt(var/n) # Standard deviation of distribution of means + +m2 <- 208 + +# Reference to page no. 189 + +alpha <- 0.05 # 5% significance level +zval <- qnorm(alpha, lower.tail = F) # Z value at 5% significance level + +r_s <- round((zval * d_sd) + m, 2) # Raw score + +# Reference over + +z <- (r_s - m2) / d_sd + +cat("Value of z is", round(z, 2)) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.3b/Ex6_3b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.3b/Ex6_3b.R new file mode 100644 index 00000000..c8886987 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.3b/Ex6_3b.R @@ -0,0 +1,23 @@ + # Page no. : 216 - 217 + +# How are you doing? + +# 1st Question (a) part + +m <- 500 # Mean +sd <- 100 # Standard deviation +var <- sd ** 2 # Variance +n <- 60 # No. of people + +d_sd <- sqrt(var/n) # Standard deviation of distribution of means + +m2 <- 540 + +alpha <- 0.05 # 5% significance level +zval <- qnorm(alpha, lower.tail = F) # Z value at 5% significance level + +r_s <- round((zval * d_sd) + m, 2) # Raw score + +z <- (r_s - m2) / d_sd + +cat("Value of z is", round(z, 2)) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4a/Ex6_4a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4a/Ex6_4a.R new file mode 100644 index 00000000..f347a8c0 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4a/Ex6_4a.R @@ -0,0 +1,11 @@ + # Page no. : 218 + +# Worked out examples 1 + +m1 <- 37 # Mean of population 1 +m2 <- 40 # Mean of population 2 +sd <- 10 # Standard deviation + +d1 <- (m1 - m2) / sd # Estimated effect size + +cat("Estimated effect size is", round(d1, 2)) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4b/Ex6_4b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4b/Ex6_4b.R new file mode 100644 index 00000000..40c5b50b --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4b/Ex6_4b.R @@ -0,0 +1,11 @@ + # Page no. : 218 - 219 + +# Worked out examples 2 + +m2 <- 40 # Mean of population 2 +d <- -0.20 # Small predicted effect size +sd <- 10 # Standard deviation + +m <- m2 + (d * sd) # Predicted mean + +cat("Predicted effect size is", round(m, 2)) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4c/Ex6_4c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4c/Ex6_4c.R new file mode 100644 index 00000000..37eabcdd --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH6/EX6.4c/Ex6_4c.R @@ -0,0 +1,21 @@ + # Page no. : 219 + +# Worked out examples 3 + +m <- 40 # Mean +sd <- 10 # Standard deviation +var <- sd ** 2 # Variance +n <- 25 # Sample size + +d_sd <- sqrt(var/n) # Standard deviation of distribution of means + +m2 <- 49 + +alpha <- 0.01 # 1% significance level +zval <- qnorm(alpha, lower.tail = F) # Z value at 1% significance level + +r_s <- round((zval * d_sd) + m, 2) # Raw score + +z <- (r_s - m2) / d_sd + +cat("Value of z is", round(z, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1a/Ex7_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1a/Ex7_1a.R new file mode 100644 index 00000000..421c32d6 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1a/Ex7_1a.R @@ -0,0 +1,10 @@ + # Page no. : 229 - 230 + +# Basic Principle of the t Test : Estimating the Population Variance from the Sample Scores + +n <- 16 # Sample +ss <- 694 # Sum of squared deviation + +var <- (ss) / (n - 1) # Estimated population variance + +cat("Etimated population variance is", round(var, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1b/Ex7_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1b/Ex7_1b.R new file mode 100644 index 00000000..ac3cc2dd --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1b/Ex7_1b.R @@ -0,0 +1,14 @@ + # Page no. : 231 + +# The Standard Deviation of the Distribution of Means + +s <- 16 # Sample size +var <- 46.27 # Estimated population variance + +d_var <- var / s # Variance of the distribution of means + +cat("Variance of the distribution of means is", round(d_var, 2)) + +d_sd <- sqrt(d_var) # Standard deviation of the distribution of means + +cat("Standard deviation of the distribution of means is", round(d_sd, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1c/Ex7_1c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1c/Ex7_1c.R new file mode 100644 index 00000000..04b2b713 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1c/Ex7_1c.R @@ -0,0 +1,11 @@ + # Page no. : 234 + +# The Sample mean's score on the comparison distribution : the t score + +m1 <- 21 # Mean +m2 <- 17 # Distribution of means +sd <- 1.70 # Standard deviation + +t <- (m1 - m2) / sd # t score + +cat("The t score is", round(t, 2)) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1d/Ex7_1d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1d/Ex7_1d.R new file mode 100644 index 00000000..ef3df1ed --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1d/Ex7_1d.R @@ -0,0 +1,51 @@ + # Page no. : 235 - 236 + +# Another example of a t test for a single sample + +rating <- c(5, 3, 6, 2, 7, 6, 7, 4, 2, 5) +n <- 10 + +mean <- mean(rating) # Rating mean + +diff <- rating - mean # Difference from the sample's mean + +sq_diff <- diff ** 2 # Squared differenc from the sample's mean + +data_frame <- data.frame(rating, diff, sq_diff) + +View(data_frame) + +df <- n - 1 # Degree of freedom + +mu <- 4 # Distribution of means + +var <- sum(data_frame$sq_diff) / df # Variance + +d_var <- var / n # Variance of the distribution of means + +d_sd <- sqrt(d_var) # Standar deviation of the distribution of means + +alpha <- 0.01 # 1% significance level + +# Two - Tailed + +tval <- round(qt(1 - alpha/2, df), 2) +tval <- c(tval, -tval) + +t <- (mean - mu) / d_sd # Actual t value + +cat("Value of t is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} + + + + + + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1e/Ex7_1e.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1e/Ex7_1e.R new file mode 100644 index 00000000..bdeb77d8 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.1e/Ex7_1e.R @@ -0,0 +1,44 @@ + # Page no. : 238 - 240 + +# How are you doing? + +# 6th Question (a) part + +n <- 4 # Sample size +df <- n - 1 # Degree of freedom + +m1 <- 23 # Population mean + +scores <- c(20, 22, 22, 20) + +mean <- mean(scores) # Sample mean + +diff <- scores - mean # Difference from the sample's mean + +sq_diff <- diff ** 2 # Squared differenc from the sample's mean + +alpha <- 0.05 # 5% significance level + +var <- sum(sq_diff) / df # Variance + +d_var <- var / n # Variance of the distribution of means + +d_sd <- sqrt(d_var) # Standar deviation of the distribution of means + +# One - tailed + +tval <- round(qt(alpha, df, lower.tail = T), 2) + +t <- (mean - m1) / d_sd # Actual t value + +cat("Value of t is", t) + +if(t < tval) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} + + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2a/Ex7_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2a/Ex7_2a.R new file mode 100644 index 00000000..e6e4004d --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2a/Ex7_2a.R @@ -0,0 +1,55 @@ + # Page no. : 241 - 242 + +# Example of a t test for dependent means + +husbands <- LETTERS[1:19] # Upper case letters + +n <- 19 # Sample size + +df <- n - 1 # Degree of freedom + +# Communication Quality + +before <- c(126, 133, 126, 115, 108, 109, 124, 98, 95, 120, 118, 126, 121, 116, 94, 105, 123, + 125, 128) +after <- c(115, 125, 96, 115, 119, 82, 93, 109, 72, 104, 107, 118, 102, 115, 83, 87, 121, 100, + 118) + +diff <- after - before # Difference +mean <- mean(diff) + +deviation <- round(diff - mean, 2) + +sq_dev <- round(deviation ** 2, 2) # Squared deviation + +data_frame <- data.frame(husbands, before, after, diff, deviation, sq_dev) + +View(data_frame) + +mu <- 0 # Assumed mean + +var <- sum(data_frame$sq_dev) / df # Variance + +d_var <- var / n # Variance of the distribution of means + +d_sd <- sqrt(d_var) # Standar deviation of the distribution of means + +alpha <- 0.05 # 5% significance level + +# Two - Tailed + +tval <- round(qt(1 - alpha/2, df), 2) +tval <- c(tval, -tval) + +t <- (mean - mu) / d_sd # Actual t value + +cat("Value of t is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2b/Ex7_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2b/Ex7_2b.R new file mode 100644 index 00000000..5a10e93a --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2b/Ex7_2b.R @@ -0,0 +1,53 @@ + # Page no. : 245 - 246 + +# A second example of a t test for dependent means + +student <- c(1:10) + +n <- 10 # Sample size + +df <- n - 1 # Degree of freedom + +# Brain Activation + +b_p <- c(1487.8, 1329.4, 1407.9, 1236.1, 1299.8, 1447.2, 1354.1, 1204.6, + 1322.3, 1388.5) # Beloved's photo +c_p <- c(1487.2, 1328.1, 1405.9, 1234.0, 1298.2, 1444.7, 1354.3, 1203.7, + 1320.8, 1386.8) # Control photo + +diff <- b_p - c_p # Difference +mean <- mean(diff) + +deviation <- round(diff - mean, 2) + +sq_dev <- round(deviation ** 2, 2) # Squared deviation + +data_frame <- data.frame(student, b_p, c_p, diff, deviation, sq_dev) + +View(data_frame) + +mu <- 0 # Assumed mean + +var <- sum(data_frame$sq_dev) / df # Variance + +d_var <- var / n # Variance of the distribution of means + +d_sd <- sqrt(d_var) # Standar deviation of the distribution of means + +alpha <- 0.05 # 5% significance level + +# OOne - Tailed + +tval <- round(qt(alpha, df, lower.tail = F), 2) + +t <- (mean - mu) / d_sd # Actual t value + +cat("Value of t is", t) + +if(t > tval) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2c/Ex7_2c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2c/Ex7_2c.R new file mode 100644 index 00000000..8d3c0959 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.2c/Ex7_2c.R @@ -0,0 +1,51 @@ + # Page no. : 249 - 250 + +# How are you doing? + +# 4th Question (a) part + +person <- c(1:5) +n <- 5 # Sample size +df <- n - 1 # Degree of freedom + +before <- c(20, 30, 20, 40, 30) +after <- c(30, 50, 10, 30, 40) + +diff <- after - before # Difference +mean <- mean(diff) + +deviation <- round(diff - mean, 2) + +sq_dev <- round(deviation ** 2, 2) # Squared deviation + +data_frame <- data.frame(person, before, after, diff, deviation, sq_dev) + +View(data_frame) + +mu <- 0 # Assumed mean + +var <- sum(data_frame$sq_dev) / df # Variance + +d_var <- var / n # Variance of the distribution of means + +d_sd <- sqrt(d_var) # Standar deviation of the distribution of means + +alpha <- 0.05 # 5% significance level + +# Two - Tailed + +tval <- round(qt(1 - alpha/2, df), 2) +tval <- c(tval, -tval) + +t <- (mean - mu) / d_sd # Actual t value + +cat("Value of t is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} + diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.3a/Ex7_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.3a/Ex7_3a.R new file mode 100644 index 00000000..56c3ff02 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.3a/Ex7_3a.R @@ -0,0 +1,19 @@ + # Page no. : 252 + +# Effect size for the t test for dependent means + +mu1 <- 4 # Mean 1 +mu2 <- 0 # Mean 2 +sd <- 8 # Standard deviation + +d <- (mu1 - mu2) / sd # Effect size + +cat("Effect size is", d) + +m_d <- -12.05 # Mean of the difference scores +var <- 153.49 # Variance +sd <- round(sqrt(var), 2) # Standard deviation + +d <- round((m_d - mu2) / sd, 2) # Effect size + +cat("Effect size is", d) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.3b/Ex7_3b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.3b/Ex7_3b.R new file mode 100644 index 00000000..c561a5aa --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.3b/Ex7_3b.R @@ -0,0 +1,14 @@ + # Page no. : 254 + +# How are you doing? + +# 4th Question (a) part + +mu1 <- 40 # Mean of the difference scores +mu2 <- 0 # Mean 2 +sd <- 80 # Standard deviation +alpha <- 0.05 # 5% significance level + +d <- round((mu1 - mu2) / sd, 2) # Effect size + +cat("Effect size is", d) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.4a/Ex7_4a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.4a/Ex7_4a.R new file mode 100644 index 00000000..53e57e39 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.4a/Ex7_4a.R @@ -0,0 +1,38 @@ + # Page no. : 259 + +# Worked out examples 1 + +scores <- c(14, 8, 6, 5, 13, 10, 10, 6) +n <- length(scores) # Sample size +df <- n - 1 # Degree of freedom +mean <- 6 # Given mean +alpha <- 0.05 # 5% significance level + +m <- mean(scores) # Scores mean + +diff <- scores - m # Difference + +sq_diff <- diff ** 2 # Squared difference from the sample's mean + +var <- sum(sq_diff) / df # Variance + +d_var <- var / n # Variance of the distribution of means + +d_sd <- sqrt(d_var) # Standar deviation of the distribution of means + +# Two - tailed + +tval <- round(qt(1 - alpha/2, df), 2) +tval <- c(tval, -tval) + +t <- (m - mean) / d_sd # Actual t value + +cat("Value of t is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.4b/Ex7_4b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.4b/Ex7_4b.R new file mode 100644 index 00000000..ea817664 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH7/EX7.4b/Ex7_4b.R @@ -0,0 +1,48 @@ + # Page no. : 259 - 261 + +# Worked out examples 2 + +participant <- c(1:10) +n <- 10 # Sample size +df <- n - 1 # Degree of freedom + +before <- c(10.4, 12.6, 11.2, 10.9, 14.3, 13.2, 9.7, 11.5, 10.8, 13.1) +after <- c(10.8, 12.1, 12.1, 11.4, 13.9, 13.5, 10.9, 11.5, 10.4, 12.5) + +diff <- after - before # Difference +mean <- mean(diff) + +deviation <- round(diff - mean, 2) + +sq_dev <- round(deviation ** 2, 2) # Squared deviation + +data_frame <- data.frame(participant, before, after, diff, deviation, sq_dev) + +View(data_frame) + +mu <- 0 # Assumed mean + +var <- sum(data_frame$sq_dev) / df # Variance + +d_var <- var / n # Variance of the distribution of means + +d_sd <- sqrt(d_var) # Standar deviation of the distribution of means + +alpha <- 0.05 # 5% significance level + +# Two - Tailed + +tval <- round(qt(1 - alpha/2, df), 2) +tval <- c(tval, -tval) + +t <- (mean - mu) / d_sd # Actual t value + +cat("Value of t is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1a/Ex8_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1a/Ex8_1a.R new file mode 100644 index 00000000..ae15212a --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1a/Ex8_1a.R @@ -0,0 +1,17 @@ + # Page no. : 278 - 279 + +# Estimating the population variance + +n1 <- 11 # Group 1 participants +df1 <- n1 - 1 # Degree of freedom for group 1 +var1 <- 60 # Variance + +n2 <- 31 # Group 2 participants +df2 <- n2 - 1 # Degree of freedom for group 2 +var2 <- 80 # Variance + +df <- df1 + df2 # Total degrees of freedom + +p_var <- ((df1 / df) * var1) + ((df2 / df) * var2) # Pooled variance + +cat("Pooled variance is", p_var) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1b/Ex8_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1b/Ex8_1b.R new file mode 100644 index 00000000..fa929a37 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1b/Ex8_1b.R @@ -0,0 +1,15 @@ + # Page no. : 279 - 280 + +# Figuring the variance of each of the two distributions of means + +n1 <- 11 # Group 1 participants +n2 <- 31 # Group 2 participants +p_var <- 75 # Pooled variance + +var1 <- p_var / n1 # Variance for group 1 + +cat("Variance for group 1 is", round(var1, 2)) + +var2 <- p_var / n2 # Variance for group 1 + +cat("Variance for group 2 is", round(var2, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1c/Ex8_1c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1c/Ex8_1c.R new file mode 100644 index 00000000..9dd44044 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1c/Ex8_1c.R @@ -0,0 +1,14 @@ + # Page no. : 280 + +# The variance and standard deviation of the distribution of differences between means + +var1 <- 6.82 # Variance of the distribution of means of group 1 +var2 <- 2.42 # Variance of the distribution of means of group 2 + +diff_var <- var1 + var2 # Variance difference + +cat("Variance difference is", diff_var) + +diff_sd <- sqrt(diff_var) # Standard deviation difference + +cat("Standard deviation difference is", round(diff_sd, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1d/Ex8_1d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1d/Ex8_1d.R new file mode 100644 index 00000000..d639646f --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1d/Ex8_1d.R @@ -0,0 +1,12 @@ + # Page no. : 281 - 282 + +# The t score for the difference between the two actual means + +m1 <- 198 # Mean of the first sample +m2 <- 190 # Mean of the second sample + +diff_sd <- 3.04 # Standard deviation difference + +t <- (m1 - m2) / diff_sd # t score + +cat("t score is", round(t, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1e/Ex8_1e.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1e/Ex8_1e.R new file mode 100644 index 00000000..1cbcc33b --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.1e/Ex8_1e.R @@ -0,0 +1,35 @@ + # Page no. : 282 - 283 + +# How are you doing? + +# 5th Question (a) part + +n1 <- 21 # Sample 1 participants +df1 <- n1 - 1 # Degree of freedom 1 +var1 <- 100 # Variance + +n2 <- 31 # Sample 1 participants +df2 <- n2 - 1 # Degree of freedom 1 +var2 <- 200 # Variance + +df <- df1 + df2 # Total degrees of freedom + +p_var <- ((df1 / df) * var1) + ((df2 / df) * var2) # Pooled variance + +cat("Pooled variance is", p_var) + +d_var1 <- p_var / n1 # Variance of the distribution of means of sample 1 + +cat("Variance of the distribution of means of sample 1 is", round(d_var1, 2)) + +d_var2 <- p_var / n2 # Variance of the distribution of means of sample 2 + +cat("Variance of the distribution of means of sample 2 is", round(d_var2, 2)) + +diff_var <- d_var1 + d_var2 # Variance difference + +cat("Variance difference is", round(diff_var, 2)) + +diff_sd <- sqrt(diff_var) # Standard deviation difference + +cat("Standard deviation difference is", round(diff_sd, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2a/Ex8_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2a/Ex8_2a.R new file mode 100644 index 00000000..2f3d484d --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2a/Ex8_2a.R @@ -0,0 +1,71 @@ +# # Page no. : 284 +# +# # Example of a T test for independent means + +# Expressive Writing Group + +score1 <- c(77, 88, 77, 90, 68, 74, 62, 93, 82, 79) +n1 <- length(score1) # Sample size 1 +df1 <- n1 - 1 # Degree of freedom +m1 <- mean(score1) # Mean +deviation1 <- score1 - m1 +sq_dev1 <- deviation1 ** 2 # Squared deviation + +data_frame1 <- data.frame(score1, deviation1, sq_dev1) +View(data_frame1) + +# Control Writing Group + +score2 <- c(87, 77, 71, 70, 63, 50, 58, 63, 76, 65) +n2 <- length(score2) # Sample size 2 +df2 <- n2 - 1 # Degree of freedom +m2 <- mean(score2) # Mean +deviation2 <- score2 - m2 +sq_dev2 <- deviation2 ** 2 # Squared deviation + +data_frame2 <- data.frame(score2, deviation2, sq_dev2) +View(data_frame2) + +var1 <- sum(data_frame1$sq_dev1) / df1 # Variance 1 +var2 <- sum(data_frame2$sq_dev2) / df2 # Variance 2 + +df <- df1 + df2 # Total degrees of freedom + +p_var <- ((df1 / df) * var1) + ((df2 / df) * var2) # Pooled variance + +cat("Pooled variance is", round(p_var, 2)) + +d_var1 <- p_var / n1 # Variance of the distribution of means of sample 1 + +cat("# Variance of the distribution of means of sample 1 is", round(d_var1, 2)) + +d_var2 <- p_var / n2 # Variance of the distribution of means of sample 2 + +cat("# Variance of the distribution of means of sample 2 is", round(d_var2, 2)) + +diff_var <- d_var1 + d_var2 # Variance difference + +cat("Variance difference is", diff_var) + +diff_sd <- sqrt(diff_var) # Standard deviation difference + +cat("Standard deviation difference is", round(diff_sd, 2)) + +# Two - Tailed + +alpha <- 0.05 # 5% significance level + +tval <- qt(1-alpha/2, df) +tval <- c(tval, -tval) + +t <- round((m1 - m2) / diff_sd, 2) # t score + +cat("t score is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2b/Ex8_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2b/Ex8_2b.R new file mode 100644 index 00000000..679404e4 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2b/Ex8_2b.R @@ -0,0 +1,71 @@ + # Page no. : 286 - 287 + +# A second example of a T test for independent means + +# Experimental Group (Receiving Special Program) + +score1 <- c(6, 4, 9, 7, 7, 3) +n1 <- length(score1) # Sample size 1 +df1 <- n1 - 1 # Degree of freedom +m1 <- mean(score1) # Mean +deviation1 <- score1 - m1 +sq_dev1 <- deviation1 ** 2 # Squared deviation + +data_frame1 <- data.frame(score1, deviation1, sq_dev1) +View(data_frame1) + +# Control Group (Receiving Ordinary Program) + +score2 <- c(6, 1, 5, 3, 1, 1, 4, 3) +n2 <- length(score2) # Sample size 2 +df2 <- n2 - 1 # Degree of freedom +m2 <- mean(score2) # Mean +deviation2 <- score2 - m2 +sq_dev2 <- deviation2 ** 2 # Squared deviation + +data_frame2 <- data.frame(score2, deviation2, sq_dev2) +View(data_frame2) + +var1 <- sum(data_frame1$sq_dev1) / df1 # Variance 1 +var2 <- sum(data_frame2$sq_dev2) / df2 # Variance 2 + +df <- df1 + df2 # Total degrees of freedom + +p_var <- ((df1 / df) * var1) + ((df2 / df) * var2) # Pooled variance + +cat("Pooled variance is", round(p_var, 2)) + +d_var1 <- p_var / n1 # Variance of the distribution of means of sample 1 + +cat("# Variance of the distribution of means of sample 1 is", round(d_var1, 2)) + +d_var2 <- p_var / n2 # Variance of the distribution of means of sample 2 + +cat("# Variance of the distribution of means of sample 2 is", round(d_var2, 2)) + +diff_var <- d_var1 + d_var2 # Variance difference + +cat("Variance difference is", diff_var) + +diff_sd <- sqrt(diff_var) # Standard deviation difference + +cat("Standard deviation difference is", round(diff_sd, 2)) + +# Two - Tailed + +alpha <- 0.05 # 5% significance level + +tval <- qt(1-alpha/2, df) +tval <- c(tval, -tval) + +t <- round((m1 - m2) / diff_sd, 2) # t score + +cat("t score is", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2c/Ex8_2c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2c/Ex8_2c.R new file mode 100644 index 00000000..92c30cb6 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.2c/Ex8_2c.R @@ -0,0 +1,55 @@ + # Page no. : 289 - 291 + +# How are you doing? + +# 2nd Question (a) part + +alpha <- 0.05 # 5% significance level + +n1 <- 26 # Sample size 1 +df1 <- n1 - 1 # Degree of freedom +m1 <- 5 # Mean 1 +var1 <- 10 # Variance 1 + +n2 <- 36 # Sample size 2 +df2 <- n2 - 1 # Degree of freedom +m2 <- 8 # Mean 2 +var2 <- 12 # Variance 2 + +df <- df1 + df2 # Total degrees of freedom + +p_var <- ((df1 / df) * var1) + ((df2 / df) * var2) # Pooled variance + +cat("Pooled variance is \n", round(p_var, 2)) + +d_var1 <- p_var / n1 # Variance of the distribution of means of sample 1 + +cat("Variance of the distribution of means of sample 1 is \n", round(d_var1, 2)) + +d_var2 <- p_var / n2 # Variance of the distribution of means of sample 2 + +cat("Variance of the distribution of means of sample 2 is \n", round(d_var2, 2)) + +diff_var <- d_var1 + d_var2 # Variance difference + +cat("Variance difference is \n", round(diff_var, 2)) + +diff_sd <- sqrt(diff_var) # Standard deviation difference + +cat("Standard deviation difference is \n", round(diff_sd, 2)) + +# One - Tailed + +tval <- qt(alpha, df) + +t <- round((m1 - m2) / diff_sd, 2) # t score + +cat("t score is \n", t) + +if(t < tval) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.3a/Ex8_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.3a/Ex8_3a.R new file mode 100644 index 00000000..2efae457 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.3a/Ex8_3a.R @@ -0,0 +1,19 @@ + # Page no. : 293 - 294 + +# Effect size for the t test for independent means + +mu1 <- 29 # Mean 1 +mu2 <- 21 # Mean 2 +sd <- 10 # Standard deviation + +d <- (mu1 - mu2) / sd # Effect size + +cat("Effect size is \n", d) + +m1 <- 33.10 # Mean 1 +m2 <- 27.00 # Mean 2 +p_sd <- 12.99 # Pooled standard deviation + +e_d <- round((m1 - m2) / p_sd, 2) # Estimated effect size + +cat("Estimated effect size is \n", e_d) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.4a/Ex8_4a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.4a/Ex8_4a.R new file mode 100644 index 00000000..88e429e4 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.4a/Ex8_4a.R @@ -0,0 +1,25 @@ + # Page no. : 300 + +# Harmonic mean + +n1 <- 11 # Sample 1 +n2 <- 31 # Sample 2 + +total <- n1 + n2 + +h_m <- round((2 * n1 * n2) / total, 2) # Harmonic mean + +cat("Harmonic mean is \n", h_m) + +# How are you doing? + +# 1st Question (Only harmonic mean) + +n1 <- 6 # Sample 1 +n2 <- 34 # Sample 2 + +total <- n1 + n2 + +h_m <- round((2 * n1 * n2) / total, 2) # Harmonic mean + +cat("Harmonic mean is \n", h_m) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5a/Ex8_5a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5a/Ex8_5a.R new file mode 100644 index 00000000..9cdcfe06 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5a/Ex8_5a.R @@ -0,0 +1,33 @@ + # Page no. : 301 - 302 + +# Worked out examples 1 + +n1 <- 40 # Sample 1 +df1 <- n1 - 1 # Degree of freedom +var1 <- 15 # Variance 1 + +n2 <- 60 # Sample 2 +df2 <- n2 - 1 # Degree of freedom +var2 <- 12 # Variance 2 + +df <- df1 + df2 # Total degrees of freedom + +p_var <- ((df1 / df) * var1) + ((df2 / df) * var2) # Pooled variance + +cat("Pooled variance is \n", round(p_var, 2)) + +d_var1 <- p_var / n1 # Variance of the distribution of means of sample 1 + +cat("Variance of the distribution of means of sample 1 is \n", round(d_var1, 2)) + +d_var2 <- p_var / n2 # Variance of the distribution of means of sample 2 + +cat("Variance of the distribution of means of sample 2 is \n", round(d_var2, 2)) + +diff_var <- d_var1 + d_var2 # Variance difference + +cat("Variance difference is \n", round(diff_var, 2)) + +diff_sd <- sqrt(diff_var) # Standard deviation difference + +cat("Standard deviation difference is \n", round(diff_sd, 2)) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5b/Ex8_5b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5b/Ex8_5b.R new file mode 100644 index 00000000..05bb88ce --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5b/Ex8_5b.R @@ -0,0 +1,67 @@ + # Page no. : 302 - 303 + +# Worked out examples 2 + +score1 <- c(7, 6, 9, 7, 6) +n1 <- length(score1) # Sample size 1 +df1 <- n1 - 1 # Degree of freedom +m1 <- mean(score1) # Mean +deviation1 <- score1 - m1 +sq_dev1 <- deviation1 ** 2 # Squared deviation + +data_frame1 <- data.frame(score1, deviation1, sq_dev1) +View(data_frame1) + +score2 <- c(5, 2, 4, 3, 6) +n2 <- length(score2) # Sample size 2 +df2 <- n2 - 1 # Degree of freedom +m2 <- mean(score2) # Mean +deviation2 <- score2 - m2 +sq_dev2 <- deviation2 ** 2 # Squared deviation + +data_frame2 <- data.frame(score2, deviation2, sq_dev2) +View(data_frame2) + +var1 <- sum(data_frame1$sq_dev1) / df1 # Variance 1 +var2 <- sum(data_frame2$sq_dev2) / df2 # Variance 2 + +df <- df1 + df2 # Total degrees of freedom + +p_var <- ((df1 / df) * var1) + ((df2 / df) * var2) # Pooled variance + +cat("Pooled variance is \n", round(p_var, 2)) + +d_var1 <- p_var / n1 # Variance of the distribution of means of sample 1 + +cat("Variance of the distribution of means of sample 1 is \n", round(d_var1, 2)) + +d_var2 <- p_var / n2 # Variance of the distribution of means of sample 2 + +cat("Variance of the distribution of means of sample 2 is \n", round(d_var2, 2)) + +diff_var <- d_var1 + d_var2 # Variance difference + +cat("Variance difference is \n", diff_var) + +diff_sd <- sqrt(diff_var) # Standard deviation difference + +cat("Standard deviation difference is \n", round(diff_sd, 2)) + +# Two - Tailed + +alpha <- 0.05 # 5% significance level + +tval <- qt(1-alpha/2, df) +tval <- c(tval, -tval) + +t <- round((m1 - m2) / diff_sd, 2) # t score + +cat("t score is \n", t) + +if(t > tval[1] || t < tval[2]) +{ + cat("Reject null hypothesis") +} else +{ + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5c/Ex8_5c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5c/Ex8_5c.R new file mode 100644 index 00000000..126155bd --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH8/EX8.5c/Ex8_5c.R @@ -0,0 +1,12 @@ + # Page no. : 304 + +# Worked out examples 3 + +n1 <- 22 # Sample 1 +n2 <- 51 # Sample 2 + +total <- n1 + n2 + +h_m <- round((2 * n1 * n2) / total, 2) # Harmonic mean + +cat("Harmonic mean is", h_m) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1a/Ex9_1a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1a/Ex9_1a.R new file mode 100644 index 00000000..9792939e --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1a/Ex9_1a.R @@ -0,0 +1,112 @@ + # Page no. : 325 - 331 + +# Carrying out an Analysis of Variance + +# Page no. : 325 - 326 + +# Criminal Record Group + +rating1 <- c(10, 7, 5, 10, 8) +n1 <- length(rating1) # Sample 1 size +df1 <- n1 - 1 # Degree of freedom +m1 <- mean(rating1) # Mean of rating 1 +deviation1 <- rating1 - m1 # Deviation from mean 1 +sq_dev1 <- deviation1 ** 2 # Squared deviation from mean 1 + +data_frame1 <- data.frame(rating1, deviation1, sq_dev1) +View(data_frame1) + +# Clean Record Group + +rating2 <- c(5, 1, 3, 7, 4) +n2 <- length(rating2) # Sample 2 size +df2 <- n2 - 1 # Degree of freedom +m2 <- mean(rating2) # Mean of rating 2 +deviation2 <- rating2 - m2 # Deviation from mean 2 +sq_dev2 <- deviation2 ** 2 # Squared deviation from mean 2 + +data_frame2 <- data.frame(rating2, deviation2, sq_dev2) +View(data_frame2) + +# No Information Group + +rating3 <- c(4, 6, 9, 3, 3) +n3 <- length(rating1) # Sample 3 size +df3 <- n3 - 1 # Degree of freedom +m3 <- mean(rating3) # Mean of rating 3 +deviation3 <- rating3 - m3 # Deviation from mean 3 +sq_dev3 <- deviation3 ** 2 # Squared deviation from mean 3 + +data_frame3 <- data.frame(rating3, deviation3, sq_dev3) +View(data_frame3) + +var1 <- var(data_frame1$rating1) # Variance for rating 1 +var2 <- var(data_frame2$rating2) # Variance for rating 2 +var3 <- var(data_frame3$rating3) # Variance for rating 3 + +cat("Variance for rating 1 is", var1) +cat("Variance for rating 2 is", var2) +cat("Variance for rating 3 is", var3) + +# Figuring the within - groups estimate of the population variance + +# Page no. : 326 - 327 + +n_g <- 3 # Number of groups +df_within <- (n1 + n2 + n3) - n_g # Degree of freedom within-groups + +var_within <- round((var1 + var2 + var3) / n_g, 2) # Variance within-groups + +cat("Variance within-groups is", var_within) + +# Figuring the between - groups estimate of the population variance + +# Page no. : 327 - 329 + +df_between <- n_g - 1 # Degree of freedom between-groups +gm <- round((m1 + m2 + m3) / n_g, 2) # Grand mean + +gm_dev <- c((m1 - gm), (m2 - gm), (m3 - gm)) # Deviation from the grand mean +sq_gm_dev <- round(gm_dev ** 2, 2) # Squared deviation from the grand mean + +d_var <- round(sum(sq_gm_dev) / df_between, 2) # Variance for the distribution of means + +cat("Variance for the distribution of means is", d_var) + +N <- 5 # 5 elements in each rating +var_between <- d_var * N # Variance between-groups + +cat("Variance between-groups is", var_between) + +# Figuring the F ratio + +# Page no. : 329 + +fvalue <- round(var_between / var_within, 2) # F ratio +cat("F ratio is", fvalue) + +# Direct method to find F ratio + +DF <- data.frame(rating1, rating2, rating3) +x <- c(t(as.matrix(DF))) +f <- c("r_1", "r_2", "r_3") +tm <- gl(3, 1, 5*3, factor(f)) +result <- anova(lm(x ~ tm)) # Similar to aov(x ~ tm) + +cat("F ratio is", round(result$`F value`[1], 2)) + +# F value + +# Page no. : 331 + +alpha <- 0.05 # 5% Sgnificance level + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +if(fvalue >= fval) +{ + cat("Reject Null Hypothesis") +} else { + cat("Cannot reject Null Hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1b/Ex9_1b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1b/Ex9_1b.R new file mode 100644 index 00000000..964160f4 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1b/Ex9_1b.R @@ -0,0 +1,62 @@ +# Page no. : 331 - 333 + +# How are you doing? + +# Data given + +scores_A <- c(5, 7) +m1 <- 6 # Mean 1 +n1 <- 2 # Sample size + +scores_B <- c(6, 9) +m2 <- 7.5 # Mean 2 +n2 <- 2 # Sample size + +scores_c <- c(8, 9) +m3 <- 8.5 # Mean 3 +n3 <- 2 # Sample size + +# 1st Question (c) part + +n_s <- 3 # Number of samples +df_within <- (n1 + n2 + n3) - n_s # Degree of freedom within-groups + +var_within <- round((var(scores_A) + var(scores_B) + var(scores_c)) / n_s, 2) +# Variance within-groups + + +cat("Variance within-groups is", var_within) + +# 2nd and 3rd Question (c) parts + +df_between <- n_s - 1 # Degree of freedom between-groups +gm <- round((m1 + m2 + m3) / n_s, 2) # Grand mean + +gm_dev <- c((m1 - gm), (m2 - gm), (m3 - gm)) # Deviation from the grand mean +sq_gm_dev <- round(gm_dev ** 2, 2) # Squared deviation from the grand mean + +d_var <- round(sum(sq_gm_dev) / df_between, 2) # Variance for the distribution of means + +cat("Variance for the distribution of means is", d_var) + +N <- 2 # 2 elements in each rating +var_between <- d_var * N # Variance between-groups + +cat("Variance between-groups is", var_between) + +# 4th Question (c) part + +fvalue <- round(var_between / var_within, 2) # F ratio +cat("F ratio is", fvalue) + +# 5th and 6th Question (c) parts + +cat("Between-groups degree of freedom is", df_between) +cat("Within-groups degree of freedom is", df_within) + +alpha <- 0.05 # 5% Sgnificance level + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1c/Ex9_1c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1c/Ex9_1c.R new file mode 100644 index 00000000..293dad43 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1c/Ex9_1c.R @@ -0,0 +1,66 @@ + # Page no. : 334 - 335 + +# Another example + +# Attachment Styl - Secure + +n1 <- 10 # Sample size +df1 <- n1 - 1 # Degree of freedom +m1 <- 2.10 # Mean +sd1 <- 1.66 # Standard deviation +var1 <- 2.76 # Variance + +# Attachment Styl - Avoidant + +n2 <- 10 # Sample size +df2 <- n2 - 1 # Degree of freedom +m2 <- 3.70 # Mean +sd2 <- 1.89 # Standard deviation +var2 <- 3.57 # Variance + +# Attachment Styl - Anxious-Ambivalent + +n3 <- 10 # Sample size +df3 <- n3 - 1 # Degree of freedom +m3 <- 4.20 # Mean +sd3 <- 1.93 # Standard deviation +var3 <- 3.72 # Variance + +n_s <- 3 # Number of samples +df_within <- (n1 + n2 + n3) - n_s # Degree of freedom within-groups +df_between <- n_s - 1 # Degree of freedom between-groups + +alpha <- 0.05 # 5% Sgnificance level + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) + +var_within <- round((var1 + var2 + var3) / n_s, 2) # Variance within-groups + +cat("Variance within-groups is", var_within) + +gm <- round((m1 + m2 + m3) / n_s, 2) # Grand mean + +gm_dev <- c((m1 - gm), (m2 - gm), (m3 - gm)) # Deviation from the grand mean +sq_gm_dev <- round(gm_dev ** 2, 2) # Squared deviation from the grand mean + +d_var <- round(sum(sq_gm_dev) / df_between, 2) # Variance for the distribution of means + +cat("Variance for the distribution of means is", d_var) + +N <- 10 # 10 elements in each rating +var_between <- d_var * N # Variance between-groups + +cat("Variance between-groups is", var_between) + +fvalue <- round(var_between / var_within, 2) # F ratio +cat("F ratio is", fvalue) + +if(fvalue >= fval) +{ + cat("Reject Null Hypothesis") +} else { + cat("Cannot reject Null Hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1d/Ex9_1d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1d/Ex9_1d.R new file mode 100644 index 00000000..82126d4d --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.1d/Ex9_1d.R @@ -0,0 +1,62 @@ + # Page no. : 338 - 339 + +# How are you doing? + +# 1st Question (a) part + +N <- 16 # Participants in each group +df <- N - 1 # Degree of freedom + +# Group 1 + +m1 <- 20 # Mean +var1 <- 8 # Variance + +# Group 2 + +m2 <- 22 # Mean +var2 <- 9 # Variance + +# Group 3 + +m3 <- 18 # Mean +var3 <- 7 # Variance + +alpha <- 0.01 # 1% Sgnificance level + +n_s <- 3 # Number of samples +df_within <- (3 * N) - n_s # Degree of freedom within-groups +df_between <- n_s - 1 # Degree of freedom between-groups + + +fval <- qf(0.99,df_between, df_within) # 1 - alpha = 1 - 0.01 = 0.99 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) + +var_within <- round((var1 + var2 + var3) / n_s, 2) # Variance within-groups + +cat("Variance within-groups is", var_within) + +gm <- round((m1 + m2 + m3) / n_s, 2) # Grand mean + +gm_dev <- c((m1 - gm), (m2 - gm), (m3 - gm)) # Deviation from the grand mean +sq_gm_dev <- round(gm_dev ** 2, 2) # Squared deviation from the grand mean + +d_var <- round(sum(sq_gm_dev) / df_between, 2) # Variance for the distribution of means + +cat("Variance for the distribution of means is", d_var) + +var_between <- d_var * N # Variance between-groups + +cat("Variance between-groups is", var_between) + +fvalue <- round(var_between / var_within, 2) # F ratio +cat("F ratio is", fvalue) + +if(fvalue >= fval) +{ + cat("Reject Null Hypothesis") +} else { + cat("Cannot reject Null Hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2a/Ex9_2a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2a/Ex9_2a.R new file mode 100644 index 00000000..5af32685 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2a/Ex9_2a.R @@ -0,0 +1,41 @@ + # Page no. : 340 - 341 + +# Planned contrast an example + +m1 <- 8 # Mean 1 +m2 <- 5 # Mean 2 +n_s <- 2 # Number of samples for contrast +N <- 5 # 5 elements in each sample + +var_within <- 5.33 # Variance within-groups + +gm <- (m1 + m2) / n_s # Grand mean +gm_dev <- c((m1 - gm), (m2 - gm)) # Deviation from the grand mean +sq_gm_dev <- round(gm_dev ** 2, 2) # Squared deviation from the grand mean +df_between <- n_s - 1 # Degree of freedom between-groups (2 samples) +df_within <- (3 * N) - (n_s + 1) # Degree of freedom within-groups (3 samples) + +d_var <- round(sum(sq_gm_dev) / df_between, 2) # Variance for the distribution of means + +cat("Variance for the distribution of means is", d_var) + +var_between <- d_var * N # Variance between-groups + +cat("Variance between-groups is", var_between) + +fvalue <- round(var_between / var_within, 2) # F ratio +cat("F ratio is", fvalue) + +alpha <- 0.05 # 5% Sgnificance level + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) + +if(fvalue >= fval) +{ + cat("Reject null hypothesis (Significant)") +} else { + cat("Cannot reject null hypothesis (not significant)") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2b/Ex9_2b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2b/Ex9_2b.R new file mode 100644 index 00000000..52fd225e --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2b/Ex9_2b.R @@ -0,0 +1,41 @@ + # Page no. : 341 + +# Planned contrast a second example + +m1 <- 8 # Mean 1 +m2 <- 4 # Mean 2 +n_s <- 2 # Number of samples for contrast +N <- 5 # 5 elements in each sample + +var_within <- 5.33 # Variance within-groups + +gm <- (m1 + m2) / n_s # Grand mean +gm_dev <- c((m1 - gm), (m2 - gm)) # Deviation from the grand mean +sq_gm_dev <- round(gm_dev ** 2, 2) # Squared deviation from the grand mean +df_between <- n_s - 1 # Degree of freedom between-groups (2 samples) +df_within <- (3 * N) - (n_s + 1) # Degree of freedom within-groups (3 samples) + +d_var <- round(sum(sq_gm_dev) / df_between, 2) # Variance for the distribution of means + +cat("Variance for the distribution of means is", d_var) + +var_between <- d_var * N # Variance between-groups + +cat("Variance between-groups is", var_between) + +fvalue <- round(var_between / var_within, 2) # F ratio +cat("F ratio is", fvalue) + +alpha <- 0.05 # 5% Sgnificance level + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) + +if(fvalue >= fval) +{ + cat("Reject null hypothesis (Significant)") +} else { + cat("Cannot reject null hypothesis (not significant)") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2c/Ex9_2c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2c/Ex9_2c.R new file mode 100644 index 00000000..913dc591 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.2c/Ex9_2c.R @@ -0,0 +1,44 @@ + # Page no. : 342 - 343 + +# How are you doing? + +# 3rd Question + +N <- 25 # 25 elements in each sample +var_within <- 100 # Variance within-groups + +m1 <- 10 # Mean 1 +m2 <- 16 # Mean 2 + +n_s <- 2 # Number of samples for contrast + +gm <- (m1 + m2) / n_s # Grand mean +gm_dev <- c((m1 - gm), (m2 - gm)) # Deviation from the grand mean +sq_gm_dev <- round(gm_dev ** 2, 2) # Squared deviation from the grand mean +df_between <- n_s - 1 # Degree of freedom between-groups (2 samples) +df_within <- (3 * N) - (n_s + 1) # Degree of freedom within-groups (3 samples) + +d_var <- round(sum(sq_gm_dev) / df_between, 2) # Variance for the distribution of means + +cat("Variance for the distribution of means is", d_var) + +var_between <- d_var * N # Variance between-groups + +cat("Variance between-groups is", var_between) + +fvalue <- round(var_between / var_within, 2) # F ratio +cat("F ratio is", fvalue) + +alpha <- 0.05 # 5% Sgnificance level + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) + +if(fvalue >= fval) +{ + cat("Reject null hypothesis (Significant)") +} else { + cat("Cannot reject null hypothesis (not significant)") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.3a/Ex9_3a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.3a/Ex9_3a.R new file mode 100644 index 00000000..858f7644 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.3a/Ex9_3a.R @@ -0,0 +1,52 @@ + # Page no. : 344 - 345 + +# Scheffe Test + +N <- 5 # 5 elements in each sample +f <- 4.22 # F value (overall) + +df_between <- 2 # Degree of freedom between-groups +df_within <- (3 * N) - (df_between + 1) # Degree of freedom within-groups (3 samples) +fvalue <- f / df_between # F value (conrast) + +cat("F value (contrast) is", fvalue) + +alpha <- 0.05 # 5% Sgnificance level + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) + +if(fvalue >= fval) +{ + cat("Reject null hypothesis (Significant)") +} else { + cat("Cannot reject null hypothesis (not significant)") +} +# How are you doing? + +# 5th Question + +N <- 50 # 50 elements in each sample +f <- 12.60 # F value (overall) + +df_between <- 3 # Degree of freedom between-groups +df_within <- (4 * N) - (df_between + 1) # Degree of freedom within-groups (4 samples) +fvalue <- f / df_between # F value (conrast) + +cat("F value (contrast) is", fvalue) + +alpha <- 0.05 # 5% Sgnificance level + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) + +if(fvalue >= fval) +{ + cat("Reject null hypothesis (Significant)") +} else { + cat("Cannot reject null hypothesis (not significant)") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.4a/Ex9_4a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.4a/Ex9_4a.R new file mode 100644 index 00000000..18e26207 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.4a/Ex9_4a.R @@ -0,0 +1,23 @@ + # Page no. : 345 - 346 + +# Effect size for the analysis of variance + +var_within <- 5.33 # Variance within-groups +var_between <- 21.70 # Variance within-groups + +df_between <- 2 # Degree of freedom between-groups +df_within <- 12 # Degree of freedom within-groups + +r_sq <- round((var_between * df_between)/((var_between * df_between)+(var_within * df_within)),2) + # Proportion of variance accounted for + +cat("Proportion of variance accounted for is", r_sq) + +# Another approach + +f <- 4.07 # F value (Ratio) + +r_sq <- round((f * df_between)/((f * df_between) + (df_within)),2) + # Proportion of variance accounted for + +cat("Proportion of variance accounted for is", r_sq) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.4b/Ex9_4b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.4b/Ex9_4b.R new file mode 100644 index 00000000..6cd8c535 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.4b/Ex9_4b.R @@ -0,0 +1,30 @@ + # Page no. : 348 + +# How are you doing? + +# 2nd Question (d) part + +var_within <- 7.20 # Variance within-groups +var_between <- 12.22 # Variance within-groups + +df_between <- 2 # Degree of freedom between-groups +df_within <- 8 # Degree of freedom within-groups + +r_sq <- round((var_between * df_between)/((var_between * df_between)+(var_within * df_within)),2) + # Proportion of variance accounted for + +cat("Proportion of variance accounted for is", r_sq) + +# 3rd Question (c) part + +N <- 18 # 18 participants in each group +t_g <- 3 # Total groups +f <- 4.50 # F value (Ratio) + +df_between <- t_g - 1 # Degree of freedom between-groups +df_within <- (t_g * N) - t_g # Degree of freedom within-groups + +r_sq <- round((f * df_between)/((f * df_between) + (df_within)),2) + # Proportion of variance accounted for + +cat("Proportion of variance accounted for is", r_sq) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.5a/Ex9_5a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.5a/Ex9_5a.R new file mode 100644 index 00000000..82400eab --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.5a/Ex9_5a.R @@ -0,0 +1,66 @@ + # Page no. : 351 - 354 + +# Advanced Topic: The Structural Model in the Analysis of Variance an example + +# Criminal Record Group + +rating1 <- c(10, 7, 5, 10, 8) + +# Clean Record Group + +rating2 <- c(5, 1, 3, 7, 4) + +# No Information Group + +rating3 <- c(4, 6, 9, 3, 3) + +DF <- data.frame(rating1, rating2, rating3) + +# Direct Method + +k <- ncol(DF) # Number of Treatments +n <- nrow(DF) # Number of Observations for each Treatment +N <- n * k # Total Observations + +x <- c(t(as.matrix(DF))) +f <- c("r_1", "r_2", "r_3") +tm <- gl(k, 1, n*k, factor(f)) +result <- anova(lm(x ~ tm)) # Similar to aov(x ~ tm) + +result + +ss_total <- round(sum(result$`Sum Sq`), 2) # Total sum of squared deviation + +cat("Total sum of squared deviation is", ss_total) + +ss_within <- round(result$`Sum Sq`[2], 2) # Sum of squared deviation within-groups + +cat("Sum of squared deviation within-groups is", ss_within) + +ss_between <- round(result$`Sum Sq`[1], 2) # Sum of squared deviation between-groups + +cat("Sum of squared deviation between-groups is", ss_between) + +df_total <- sum(result$Df) # Total degrees of freedom + +cat("Total degrees of freedom is", df_total) + +df_within <- result$Df[2] # Degree of freedom within-groups + +cat("Degree of freedom within-groups is", df_within) + +df_between <- result$Df[1] # Degree of freedom between-groups + +cat("Degree of freedom between-groups is", df_between) + +var_within <- round(result$`Mean Sq`[2], 2) # Variance within-groups + +cat("Variance within-groups is", var_within) + +var_between <- round(result$`Mean Sq`[1], 2) # Variance between-groups + +cat("Variance between-groups is", var_between) + +f <- round(result$`F value`[1], 2) # F value (Ratio) + +cat("F value (Ratio) is", f) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6a/Ex9_6a.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6a/Ex9_6a.R new file mode 100644 index 00000000..ec586714 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6a/Ex9_6a.R @@ -0,0 +1,51 @@ + # Page no. : 359 - 360 + +# Worked out examples 1 + +N <- 20 # 20 participants in each group +n_g <- 4 # Numbr of groups + +m1 <- 15 # Mean 1 +var1 <- 20 # Variance 1 + +m2 <- 12 # Mean 2 +var2 <- 25 # Variance 2 + +m3 <- 18 # Mean 3 +var3 <- 14 # Variance 3 + +m4 <- 15 # Mean 4 +var4 <- 27 # Variance 4 + +alpha <- 0.05 # 5% significant level + +df_between <- n_g - 1 # Degree of freedom between-groups +df_within <- (4 * N) - (n_g) # Degree of freedom within-groups + +var_within <- round((var1 + var2 + var3 + var4) / n_g, 2) # Variance within-groups +cat("Variance within-groups is", var_within) + +gm <- (m1 + m2 + m3 + m4) / n_g # Grand mean +gm_dev <- c((m1 - gm), (m2 - gm), (m3 - gm), (m4 - gm)) # Deviation from the grand mean +sq_gm_dev <- round(gm_dev ** 2, 2) # Squared deviation from the grand mean + +d_var <- round(sum(sq_gm_dev) / df_between, 2) # Variance for the distribution of means + +cat("Variance for the distribution of means is", d_var) + +var_between <- d_var * N # Variance between-groups + +cat("Variance between-groups is", var_between) + +fvalue <- round(var_between / var_within, 2) # F ratio +cat("F ratio is", fvalue) + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +if(fvalue >= fval) +{ + cat("Reject Null Hypothesis") +} else { + cat("Cannot reject Null Hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6b/Ex9_6b.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6b/Ex9_6b.R new file mode 100644 index 00000000..8a4f0385 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6b/Ex9_6b.R @@ -0,0 +1,45 @@ + # Page no. : 360 - 361 + +# Worked out examples 2 + +m1 <- 12 # Mean 1 +var1 <- 25 # Variance 1 + +m2 <- 18 # Mean 2 +var2 <- 14 # Variance 2 + +alpha <- 0.01 # 1% significant level +n_s <- 2 # Number of samples for contrast +N <- 20 # 20 elements in each sample + +var_within <- 21.5 # Variance within-groups (overall) + +df_between <- n_s - 1 # Degree of freedom between-groups (2 samples) +df_within <- (4 * N) - (n_s + 2) # Degree of freedom within-groups (4 samples) + +gm <- (m1 + m2) / n_s # Grand mean +gm_dev <- c((m1 - gm), (m2 - gm)) # Deviation from the grand mean +sq_gm_dev <- round(gm_dev ** 2, 2) # Squared deviation from the grand mean + +d_var <- round(sum(sq_gm_dev) / df_between, 2) # Variance for the distribution of means + +cat("Variance for the distribution of means is", d_var) + +var_between <- d_var * N # Variance between-groups + +cat("Variance between-groups is", var_between) + +fvalue <- round(var_between / var_within, 2) # F ratio +cat("F ratio is", fvalue) + +fval <- qf(0.95,df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) + +if(fvalue >= fval) +{ + cat("Reject null hypothesis (Significant)") +} else { + cat("Cannot reject null hypothesis (not significant)") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6c/Ex9_6c.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6c/Ex9_6c.R new file mode 100644 index 00000000..19ef8444 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6c/Ex9_6c.R @@ -0,0 +1,35 @@ + # Page no. : 361 + +# Worked out examples 3 + +n <- 6 # Six planned contrasts +alpha <- 0.05 # 5% significance level + +b_c_s <- round(alpha / n, 4) # Bonferroni corrected signficance level + +cat("Bonferroni corrected signficance level is", b_c_s) + + # Page no. : 342 + +# The Bonferroni Procedure + +n <- 2 # Two planned contrasts +alpha <- 0.05 # 5% significance level + +b_c_s <- round(alpha / n, 4) # Bonferroni corrected signficance level + +cat("Bonferroni corrected signficance level is", b_c_s) + +n <- 3 # Two planned contrasts +alpha <- 0.05 # 5% significance level + +b_c_s <- round(alpha / n, 4) # Bonferroni corrected signficance level + +cat("Bonferroni corrected signficance level is", b_c_s) + +n <- 3 # Two planned contrasts +alpha <- 0.01 # 1% significance level + +b_c_s <- round(alpha / n, 4) # Bonferroni corrected signficance level + +cat("Bonferroni corrected signficance level is", b_c_s) diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6d/Ex9_6d.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6d/Ex9_6d.R new file mode 100644 index 00000000..dda3081d --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6d/Ex9_6d.R @@ -0,0 +1,27 @@ + # Page no. : 361 + +# Worked out examples 4 + +N <- 10 # 10 elements in each sample +f <- 11.21 # F value (overall) +n_g <- 5 # Number of groups + +df_between <- n_g - 1 # Degree of freedom between-groups +df_within <- (5 * N) - (n_g) # Degree of freedom within-groups (5 samples) +fvalue <- f / df_between # F value (conrast) + +cat("F value (contrast) is", fvalue) + +alpha <- 0.01 # 1% Sgnificance level + +fval <- qf(0.99,df_between, df_within) # 1 - alpha = 1 - 0.01 = 0.99 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.01 significance level is", fval) + +if(fvalue >= fval) +{ + cat("Reject null hypothesis (Significant)") +} else { + cat("Cannot reject null hypothesis (not significant)") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6e/Ex9_6e.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6e/Ex9_6e.R new file mode 100644 index 00000000..6cbcd942 --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6e/Ex9_6e.R @@ -0,0 +1,17 @@ + # Page no. : 361 + +# Worked out examples 5 + +N <- 20 # 20 participants in each group +n_g <- 4 # Number of groups + +df_between <- n_g - 1 # Degree of freedom between-groups +df_within <- (4 * N) - (n_g) # Degree of freedom within-groups + +var_between <- 120 # Variance between-groups +var_within <- 21.5 # Variance within-groups + +r_sq <- round((var_between * df_between)/((var_between * df_between)+(var_within * df_within)),2) + # Proportion of variance accounted for + +cat("Proportion of variance accounted for is", r_sq) \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6f/Ex9_6f.R b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6f/Ex9_6f.R new file mode 100644 index 00000000..27e8140e --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/CH9/EX9.6f/Ex9_6f.R @@ -0,0 +1,66 @@ + # Page no. : 362 + +# Worked out examples 6 + +# Treatment A + +x1 <- c(8, 13, 10, 9) + +# Treatment B + +x2 <- c(7, 3, 8) + +# Treatment C + +x3 <- c(6, 4, 2) + +DF <- data.frame( Y=c(x1, x2, x3), Treatment =factor(rep(c("x1", "x2", "x3"), + times=c(length(x1), length(x2), length(x3))))) + +View(DF) + +res <- aov(Y~Treatment, data=DF) +result <- anova(res) +result + +df_total <- sum(result$Df) # Total degree of freeodom + +cat("Total degrees of freedom is", df_total) + +df_within <- result$Df[2] # Degree of freedom within-groups + +cat("Degree of freedom within-groups is", df_within) + +df_between <- result$Df[1] # Degree of freedom between-groups + +cat("Degree of freedom between-groups is", df_between) + +alpha <- 0.05 # 5% significance level + +f <- round(result$`F value`[1], 2) # F value (Ratio) + +cat("F value (Ratio) is", f) + +ss_total <- round(sum(result$`Sum Sq`), 2) # Total sum of squared deviation + +cat("Total sum of squared deviation is", ss_total) + +ss_within <- round(result$`Sum Sq`[2], 2) # Sum of squared deviation within-groups + +cat("Sum of squared deviation within-groups is", ss_within) + +ss_between <- round(result$`Sum Sq`[1], 2) # Sum of squared deviation between-groups + +cat("Sum of squared deviation between-groups is", ss_between) + +fval <- qf(0.95, df_between, df_within) # 1 - alpha = 1 - 0.05 = 0.95 +fval <- round(fval, 2) + +cat("Cutoff F for the 0.05 significance level is", fval) + +if(f >= fval) +{ + cat("Reject null hypothesis") +} else { + cat("Cannot reject null hypothesis") +} \ No newline at end of file diff --git a/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/README.txt b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/README.txt new file mode 100644 index 00000000..31d7071b --- /dev/null +++ b/Statistics_For_Psychology_by_Arthur_Aron,_Elliot_J._Coups,_And_Elaine_N._Aron/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Shivam Agrawal +Course: B. Tech +Branch: Computer Science And Engineering +College/Institute/Organization: Techno India Njr Institute Of Technology + +About The Book + +Book: Statistics For Psychology +Author: Arthur Aron, Elliot J. Coups, And Elaine N. Aron +Publisher: Pearson, Usa +Year Of Publication: 2013 +ISBN: 9780205923922 +Edition: 6 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.1/Ex10.5_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.1/Ex10.5_1.R new file mode 100644 index 00000000..4be73114 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.1/Ex10.5_1.R @@ -0,0 +1,9 @@ +#Page.No 10.5 + +x<-50 #Marks +M<-60 # Mean +S.D<-10 # Std deviation + +z<-scale(x,center = M,scale = S.D) + +cat("Rama's score is ",z[1,]," i.e 1-sigma distance below the mean") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.2/Ex10.5_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.2/Ex10.5_2.R new file mode 100644 index 00000000..d1602ba8 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.2/Ex10.5_2.R @@ -0,0 +1,9 @@ +#Page.No 10.5 + +x<-50 #Marks +M<-40 # Mean +S.D<-10 # Std deviation + +z<-scale(x,center = M,scale = S.D) + +cat("Hari's score is ",z[1,],"i.e 1sigma distance above the mean") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.3/Ex10.5_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.3/Ex10.5_3.R new file mode 100644 index 00000000..b0a5f82e --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.5.3/Ex10.5_3.R @@ -0,0 +1,15 @@ +#Page.No 10.6 + +#Rama In english +z<-scale(60,center = 40,scale = 10) +cat("Rama secures ",z[1,],"in mothertougue") +"Rama's Z-score is +2sigma" + +#Hari in english +z<-scale(60,center = 70,scale = 10) +cat("Hari secures ",z[1,],"in mothertougue") +"Hari's Z-score is -1sigma" + +"Rama remains +2 sigma distance from mean + Hari remains -1 sigma distance below from mean + So Rama's performance is better" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.6.1/Ex10.6_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.6.1/Ex10.6_1.R new file mode 100644 index 00000000..56a644da --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.6.1/Ex10.6_1.R @@ -0,0 +1,15 @@ +#Page.No 10.6 - 10.7 + +# In english +z<-scale(60,center = 40,scale = 8) +z<-z[1,] +T_score_E<-10*z+50 +cat("Rama T_score in english is ",T_score_E) + +#In mother tongue +z<-scale(50,center = 50,scale = 6) +z<-z[1,] +T_score_M<-10*z+50 +cat("Rama T_score in mother tongue is ",T_score_M) + +"Rama performance better in English than mother tongue" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.7.1/Ex10.7_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.7.1/Ex10.7_1.R new file mode 100644 index 00000000..09ad50b6 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH10/EX10.7.1/Ex10.7_1.R @@ -0,0 +1,13 @@ +#Page.no 10.7 - 10.8 + +x<-50 #Marks +M<-40 # Mean +S.D<-6 # Std deviation + +z<-scale(x,center = M,scale = S.D) + +z<-z[1,] + +H_score<-50+14*z + +cat("Rama H_score is ",H_score) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.1/Ex11.4_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.1/Ex11.4_1.R new file mode 100644 index 00000000..45f3c138 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.1/Ex11.4_1.R @@ -0,0 +1,32 @@ +# Page no. : 11.5 - 11.6 + +condition <- c("Favourable","Unfavourable","Undecided") +observed <- c(20,40,21) +expected <- c(27,27,27) + +DF <- data.frame(condition, observed, expected) +View(DF) + +alpha5 <- 0.05 # 5% significance level +alpha1<-0.01 #1% significance level +df <- nrow(DF) - 1 # Degree of freedom + +chi_sq_val_5 <- round(qchisq(alpha5,df,lower.tail = F), 2) # Chi-square value +chi_sq_val_1<- round(qchisq(alpha1,df,lower.tail = F), 2) + +diff <- DF$observed - DF$expected # Difference +diff_sq <- diff ** 2 # Difference squared +ans <- round(diff_sq / DF$expected, 2) # Difference squared weighted by expected frequency + +chi_sq <- sum(ans) # Chi-square + +cat("Value of chi-square is", chi_sq) + +if(chi_sq > chi_sq_val_5) + if(chi_sq > chi_sq_val_1) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and no significance") +} diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.2/Ex11.4_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.2/Ex11.4_2.R new file mode 100644 index 00000000..2c7b114e --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.2/Ex11.4_2.R @@ -0,0 +1,34 @@ +# Page.No: 11.6 - 11.7 + +condition <- c("Heads","Tails") +observed <- c(50,130) +expected <- c(90,90) + +DF <- data.frame(condition, observed, expected) +View(DF) + +alpha5 <- 0.05 # 5% significance level +alpha1<-0.01 #1% significance level +df <- nrow(DF) - 1 # Degree of freedom + +chi_sq_val_5 <- round(qchisq(alpha5,df,lower.tail = F), 2) # Chi-square value +chi_sq_val_1<- round(qchisq(alpha1,df,lower.tail = F), 2) + +diff <- DF$observed - DF$expected # Difference +diff_sq <- diff ** 2 # Difference squared +ans <- round(diff_sq / DF$expected, 2) # Difference squared weighted by expected frequency + +chi_sq <- sum(ans) # Chi-square + +cat("Value of chi-square is", chi_sq) + +if(chi_sq > chi_sq_val_5) + if(chi_sq > chi_sq_val_1) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and no significance") +} + +"The answer provided in the text book is wrong" \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.3/Ex11.4_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.3/Ex11.4_3.R new file mode 100644 index 00000000..325d5f78 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.3/Ex11.4_3.R @@ -0,0 +1,33 @@ +# Page no. : 11.7 - 11.8 + +condition <- c("Good","Average","Poor") +observed <- c(20,24,6) +expected <- c(8,34,8) + +DF <- data.frame(condition, observed, expected) +View(DF) + +alpha5 <- 0.05 # 5% significance level +alpha1<-0.01 #1% significance level +df <- nrow(DF) - 1 # Degree of freedom + +chi_sq_val_5 <- round(qchisq(alpha5,df,lower.tail = F), 2) # Chi-square value +chi_sq_val_1<- round(qchisq(alpha1,df,lower.tail = F), 2) + +diff <- DF$observed - DF$expected # Difference +diff_sq <- diff ** 2 # Difference squared +ans <- round(diff_sq / DF$expected, 2) # Difference squared weighted by expected frequency + +chi_sq <- sum(ans) # Chi-square + +cat("Value of chi-square is", chi_sq) + +if(chi_sq > chi_sq_val_5) + if(chi_sq > chi_sq_val_1) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and no significance") +} + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.4/Ex11.4_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.4/Ex11.4_4.R new file mode 100644 index 00000000..5bdfc77e --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.4/Ex11.4_4.R @@ -0,0 +1,33 @@ +# Page no. : 11.7 - 11.8 + +condition <- c("Good","Average","Bad") +observed <- c(25,60,35) +expected <- c(40,40,40) + +DF <- data.frame(condition, observed, expected) +View(DF) + +alpha5 <- 0.05 # 5% significance level +alpha1<-0.01 #1% significance level +df <- nrow(DF) - 1 # Degree of freedom + +chi_sq_val_5 <- round(qchisq(alpha5,df,lower.tail = F), 2) # Chi-square value +chi_sq_val_1<- round(qchisq(alpha1,df,lower.tail = F), 2) + +diff <- DF$observed - DF$expected # Difference +diff_sq <- diff ** 2 # Difference squared +ans <- round(diff_sq / DF$expected, 2) # Difference squared weighted by expected frequency + +chi_sq <- sum(ans) # Chi-square + +cat("Value of chi-square is", chi_sq) + +if(chi_sq > chi_sq_val_5) + if(chi_sq > chi_sq_val_1) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and no significance") +} + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.7/Ex11.4_7.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.7/Ex11.4_7.R new file mode 100644 index 00000000..716c94dc --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.7/Ex11.4_7.R @@ -0,0 +1,35 @@ +# Page no. : 11.10 - 11.11 + +condition <- c("First","Second","Third") +matrix <- matrix(c(15,25,10,20,25,5),2,3,byrow = TRUE) +expected<-c((sum(matrix[,1])*50)/100,(sum(matrix[,2])*50)/100, + (sum(matrix[,3])*50)/100,(sum(matrix[,1])*50)/100, + (sum(matrix[,2])*50)/100,(sum(matrix[,3])*50)/100) +expected +observed<-c(15,25,10,20,25,5) +DF <- data.frame(condition, observed, expected) +View(DF) + +alpha <- 0.05 # 5% significance level +df <- nrow(DF) - 1 # Degree of freedom + +chi_sq_val <- round(qchisq(alpha,df,lower.tail = F), 2) # Chi-square value + +diff <- DF$observed - DF$expected # Difference +diff_sq <- diff ** 2 # Difference squared +ans <- round(diff_sq / DF$expected, 2) # Difference squared weighted by expected frequency + +chi_sq <- sum(ans) # Chi-square + +cat("Value of chi-square is", chi_sq) + + +if(chi_sq > chi_sq_val) + { + cat("Reject null hypothesis and it is significant") + } else + { + cat("Cannot reject null hypothesis and no significance") + } + +"Opinion of rural and Urban population differ significantly" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.8/Ex11.4_8.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.8/Ex11.4_8.R new file mode 100644 index 00000000..ed8d0bab --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH11/EX11.4.8/Ex11.4_8.R @@ -0,0 +1,37 @@ +#Page.no 11.11 - 11.12 + +R1 = c(20,10) +R2 = c(5,15) +rows = 2 + +#2*2 contingency table +table = matrix(c(R1, R2), + nrow=rows, + byrow=TRUE) + +rownames(table) = c("Good Achievement", "Bad achievement")# Naming the rows and +colnames(table) = c("High", "Low") # columns is optional. +table + +chi_sq<-chisq.test(table,correct=FALSE) + +chi_sq<-chi_sq$statistic + +## Chi-squared table value @ 5% +alpha <- 0.05 # 5% significance level +df <- nrow(table) - 1 # Degree of freedom + +chi_sq_val <- round(qchisq(alpha,df,lower.tail = F), 2) # Chi-square table value + + +cat("The calculated chi square value is ",chi_sq) + +if(chi_sq > chi_sq_val) +{ + cat("Reject null hypothesis and observed Chi-square is significant") +} else +{ + cat("Cannot reject null hypothesis and there is no significance") +} + +"so Interest has significantly affect the performance level of children" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.1/Ex12.9.3_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.1/Ex12.9.3_1.R new file mode 100644 index 00000000..6a67aaf6 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.1/Ex12.9.3_1.R @@ -0,0 +1,33 @@ +#Page.No 12.9- 12.11 + +# A function created to find t-ratio +t.test <- function(m1,m2,s1,s2,n1,n2,r,equal.variance=FALSE) +{ + { + se1 <-s1/sqrt(n1-1) + se2<-s2/sqrt(n2-1) + df <- n1-1 + seD<-sqrt((se1^2)+(se2^2)-2*r*se1*se2) + } + t <- (m1-m2)/seD + dat <- c(m1-m2, seD, t, 2*pt(-abs(t),df)) + names(dat) <- c("Difference of means", "Std Error", "t", "p-value") + return(dat) +} + +Mn.P<-70 # Mean of Pre- test +Mn.E<-67 # Mean Of end - test +SD.P<-6 # Sd of pre- test +SD.E<-5.8 # sd of end- test +N.P<-30 # No.of.Observations of Pre- test +N.E<-30 # No.of.Observations of end- test +r<-.82 # correlation coefficient + +t.test(Mn.P,Mn.E,SD.E,SD.P,N.P,N.E,r) + +critical_t<-abs(qt(0.01/2,29)) + +cat("The p-value <0.01 and the table value of t @ 0.01 level of significance is ",critical_t,"which is less than the obtained t-ratio") + +"Therefore the mean difference is significant @ 0.01 level of significance" + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.2/Ex12.9.3_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.2/Ex12.9.3_2.R new file mode 100644 index 00000000..85dc67d0 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.2/Ex12.9.3_2.R @@ -0,0 +1,33 @@ +# Page.No 12.11 - 12.13 + +# A function created to find t-ratio +t.test <- function(m1,m2,s1,s2,n1,n2,r,equal.variance=FALSE) +{ + { + se1 <-s1/sqrt(n1-1) + se2<-s2/sqrt(n2-1) + df <- n1-1 + seD<-sqrt((se1^2)+(se2^2)-2*r*se1*se2) + } + t <- (m1-m2)/seD + dat <- c(m1-m2, seD, t, 2*pt(-abs(t),df)) + names(dat) <- c("Difference of means", "Std Error", "t", "p-value") + return(dat) +} + + +Mn.P<-88 # Mean of Pre- test +Mn.E<-85 # Mean Of end - test +SD.P<-16 # Sd of pre- test +SD.E<-12 # sd of end- test +N.P<-64 # No.of.Observations of Pre- test +N.E<-64 # No.of.Observations of end- test +r<-.5 # correlation coefficient + +t.test(Mn.P,Mn.E,SD.E,SD.P,N.P,N.E,r) + +ct<-abs(qt(0.05/2,63)) + +cat("The p-value > 0.05 and the table value of t @ 0.05 level of significance is ",ct,"which is greater than the obtained t-ratio") +"The mean difference is significant" + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.3/Ex12.9.3_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.3/Ex12.9.3_3.R new file mode 100644 index 00000000..2fbabb5d --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.3/Ex12.9.3_3.R @@ -0,0 +1,27 @@ +#Page.no 12.13 + +x<-c(40,36,35,34,40,28,31,34,37,25) +y<-c(50,42,51,46,35,52,68,51,84,63) + +t<-t.test(x, y, paired = TRUE, alternative = "two.sided",conf.level = 0.99) + +degrees_of_freedom<-t$parameter # Degrees of freedom + +t_ratio<-abs(t$statistic) # t calculated value + +critical_t<-abs(qt(0.01/2,degrees_of_freedom)) # t table value + +p<-t$p.value # P value + +cat("The p value is",p,"which is less than 0.01") + +if(t_ratio > critical_t) + { + cat("Reject null hypothesis and it is significant") + } else + { + cat("Cannot reject null hypothesis and no significance") + } + +"Therefore, the gain from trial 1 to 5 is significance at 0.01 level of significance" + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.4/Ex12.9.3_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.4/Ex12.9.3_4.R new file mode 100644 index 00000000..433d101e --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.4/Ex12.9.3_4.R @@ -0,0 +1,26 @@ +#Page.no 12.15-12.16 + +x<-c(16,18,20,24,24,22,20,18,10,8,20) +y<-c(24,20,24,28,30,20,24,22,18,18,24) + +t<-t.test(x, y, paired = TRUE, alternative = "two.sided",conf.level = 0.99) + +degrees_of_freedom<-t$parameter # Degrees of freedom + +t_ratio<-t$statistic # t calculated value + +critical_t<-abs(qt(0.01/2,degrees_of_freedom)) # t table value + +p<-t$p.value # P value + +cat("The calculated t value is",t_ratio) + +if(t_ratio > critical_t) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and insignificant") +} + +"Therefore, the gain from viewing the film is insignificant" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.5/Ex12.9.3_5.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.5/Ex12.9.3_5.R new file mode 100644 index 00000000..f32b4caa --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.5/Ex12.9.3_5.R @@ -0,0 +1,43 @@ +#Page.No 12.16- 12.18 + +# A function created to find t-ratio +t.test <- function(m1,m2,s1,s2,n1,n2,equal.variance=FALSE) +{ + { + se1 <-s1/sqrt(n1-1) + se2<-s2/sqrt(n2-1) + df <- n1+n2-1 + seD<-sqrt((se1^2)+(se2^2)) + } + t <- (m1-m2)/seD + dat <- c(m1-m2, seD, t, 2*pt(-abs(t),df)) + names(dat) <- c("Difference of means", "Std Error", "t", "p-value") + return(dat) +} + +t.test(62,57,9.7,6.8,30,25) + +ct<-abs(qt(0.05/2,53)) +cat("Since the p-value <0.05 and the table value of t @ 0.05 level of significance is ",ct,"which is less than the obtained t-ratio",2.199) +"Therefore the mean difference is statistically significant @ 0.05 level of significance" + +#### Another Method by using the library function + +library(BSDA) +result<-tsum.test(mean.x = 62,s.x = 9.7,n.x = 30, + mean.y = 57,s.y = 6.8,n.y = 25) + +t_ratio<-result$statistic + +cat("The calculated t value is",t_ratio) + +critical_t<-abs(qt(0.05/2,53)) + +if(t_ratio > critical_t) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.6/Ex12.9.3_6.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.6/Ex12.9.3_6.R new file mode 100644 index 00000000..a2d19dfb --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.6/Ex12.9.3_6.R @@ -0,0 +1,46 @@ +#Page.No 12.18- 12.20 + +# A function created to find t-ratio +t.test <- function(m1,m2,s1,s2,n1,n2,equal.variance=FALSE) +{ + { + se1 <-s1/sqrt(n1-1) + se2<-s2/sqrt(n2-1) + df <- n1+n2-1 + seD<-sqrt((se1^2)+(se2^2)) + } + t <- (m1-m2)/seD + dat <- c(m1-m2, seD, t, 2*pt(-abs(t),df)) + names(dat) <- c("Difference of means", "Std Error", "t", "p-value") + return(dat) +} + +t.test(100,105,10,10,50,50) +n1<-50 +n2<-50 +df<-n1+n2-1 + +ct<-abs(qt(0.05/2,df)) + +cat("Since the p-value <0.05 and the table value of t @ 0.05 level of significance is ",ct,"which is less than the obtained t-ratio",2.199) +"Therefore the mean difference is statistically significant @ 0.05 level of significance" + +#### Another Method by using the library function + +library(BSDA) +result<-tsum.test(mean.x = 100,s.x = 10,n.x = 50, + mean.y = 105,s.y = 10,n.y = 50) + +t_ratio<-abs(result$statistic) + +critical_t<-abs(qt(0.05/2,53)) + +if(t_ratio > critical_t) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.7/Ex12.9.3_7.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.7/Ex12.9.3_7.R new file mode 100644 index 00000000..1a3cba13 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.7/Ex12.9.3_7.R @@ -0,0 +1,32 @@ +# Page.No 12.20-12.23 + + +boys<-c(59,43,37,25,31,36,33,41,20,18) +girls<-c(57,43,44,39,21,18,15,55,40,30) + +library(BSDA) +result<-tsum.test(mean.x = mean(boys),s.x = sd(boys),n.x = length(boys), + mean.y = mean(girls),s.y = sd(girls),n.y = length(girls)) + +t_ratio<-abs(result$statistic) # T calculated value + +cat("The calculated t value is",t_ratio) + +df<-length(girls)+length(boys)-2 # degrees of freedom + +p_value<-result$p.value #P value + +critical_t<-abs(qt(0.05/2,df)) # t table value + +if(t_ratio > critical_t) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + +"Thus their is no significant difference between the mean intelligence scores of boys and girls" + +cat("p value is greater than 0.05 i.e ",p_value,"null hypothesis retained") + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.8/Ex12.9.3_8.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.8/Ex12.9.3_8.R new file mode 100644 index 00000000..07131909 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.8/Ex12.9.3_8.R @@ -0,0 +1,29 @@ +#Page.No 12.23- 12.26 + +control_group<-c(11,11,10,12,8,15,10,8,10,8) +experimental_group<-c(4,4,8,9,12,15,3,13,9,9) + +library(BSDA) +result<-tsum.test(mean.x = mean(control_group),s.x = sd(control_group),n.x = length(control_group), + mean.y = mean(experimental_group),s.y = sd(experimental_group),n.y = length(experimental_group)) + +t_ratio<-result$statistic # T calculated value + +cat("The calculated tvalue is ",t_ratio) + +df<-length(control_group)-1 # degrees of freedom + +p_value<-result$p.value #P value + +critical_t<-abs(qt(0.05/2,df)) # t table value + +if(t_ratio > critical_t) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + +"Thus their is no significant difference between the mean score of control group and experimental group" +cat("p value is greater than 0.05 i.e",p_value,"null hypothesis retained") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.9/Ex12.9.3_9.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.9/Ex12.9.3_9.R new file mode 100644 index 00000000..7ba68c47 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH12/EX12.9.3.9/Ex12.9.3_9.R @@ -0,0 +1,29 @@ +# Page.No 12.26 - 12.29 + +GroupX<-c(26,24,18,17,18,20,18) +GroupY<-c(38,26,24,24,30,22) + +library(BSDA) +result<-tsum.test(mean.x = mean(GroupX),s.x = sd(GroupX),n.x = length(GroupX), + mean.y = mean(GroupY),s.y = sd(GroupY),n.y = length(GroupY)) + +t_ratio<-abs(result$statistic) # T calculated value + +cat("The calculated t value is",t_ratio) + +df<-length(GroupX)+length(GroupY)-1 # degrees of freedom + +p_value<-result$p.value #P value + +critical_t<-abs(qt(0.05/2,df)) # t table value + +if(t_ratio > critical_t) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + +"Thus their is significant difference between Group X and Group Y" +cat("p value is less than 0.05 i.e",p_value,"null hypothesis is rejected") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.1/Ex13.8_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.1/Ex13.8_1.R new file mode 100644 index 00000000..a852e7c7 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.1/Ex13.8_1.R @@ -0,0 +1,12 @@ +#Page.No 13.7 - 13.9 + +lecture<-c(10,12,13,13,14) +seminar<-c(13,15,15,17,18) +discussion<-c(7,7,10,11,12) + +combined_groups<-data.frame(cbind(lecture,seminar,discussion)) +stackedgroup<-stack(combined_groups) +anova_results<-aov(values~ind,data = stackedgroup) +summary(anova_results) + +"The ANOVA shows that there is significant differences among the three methods of instructions" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.2/Ex13.8_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.2/Ex13.8_2.R new file mode 100644 index 00000000..1f2858b1 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.2/Ex13.8_2.R @@ -0,0 +1,12 @@ +#Page.No 13.10 - 13.12 + +lecture<-c(10,12,13,13,14) +seminar<-c(13,15,15,17,18) +discussion<-c(7,7,10,11,12) + +combined_groups<-data.frame(cbind(lecture,seminar,discussion)) +stackedgroup<-stack(combined_groups) +anova_results<-aov(values~ind,data = stackedgroup) +summary(anova_results) + +"The ANOVA shows that there is significant differences among the three methods of instructions" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.3/Ex13.8_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.3/Ex13.8_3.R new file mode 100644 index 00000000..16a89f09 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.3/Ex13.8_3.R @@ -0,0 +1,22 @@ +#Page.No 13.7 - 13.9 + +Group1<-c(6,7,9,10,8) +Group2<-c(11,10,8,12,9) + +combined_groups<-data.frame(cbind(Group1,Group2)) +stackedgroup<-stack(combined_groups) +anova_results<-aov(values~ind,data = stackedgroup) +summary(anova_results) + +"The ANOVA shows that there is significant differences among the three methods of instructions" + +# To find the t-value +library(BSDA) + +result<-tsum.test(mean.x = mean(Group1),s.x = sd(Group1),n.x = length(Group1), + mean.y = mean(Group2),s.y = sd(Group2),n.y = length(Group2)) + +t<-abs(result$statistic) + +t^2 ->F # From the anova_results F= 4 + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.4/Ex13.8_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.4/Ex13.8_4.R new file mode 100644 index 00000000..b511904e --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH13/EX13.8.4/Ex13.8_4.R @@ -0,0 +1,88 @@ +#Page.No 13.14 - 13.17 + +specialist<-c(1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2) +performance<-c(5,4,3,2,1,3,4,8,5,6,4,5,5,6,5,4,6,8,5,6,8,9,10,6,7,6,8,5,9,8) +activity<-c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3) +activity<-as.factor(activity) +specialist<-as.factor(specialist) +combined_groups<-data.frame(cbind(activity,specialist,performance)) + +# Two- way anova +anova_results<-aov(performance~ specialist+activity+specialist*activity) # anova model specification +summary(anova_results) + +# Interpretation from anova table p_value + +" It can attributed that the co-curricular activities have differ significantly in their relation with selection of the specialist" + +# Using F value +# Interpretation on Specialist + +Fcalculated<-1.716 + +# at 0.05 level of significance + +Ftable_0.05<-qf(.95, df1=1, df2=24) + +if(Fcalculated > Ftable_0.05) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + +# At 0.01 level of significance + +Ftable_0.01<-qf(.99, df1=2, df2=24) + +if(Fcalculated > Ftable_0.01) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + +### interpretation on activities + +Fcalculated<-13.319 + +Ftable_0.05<-qf(.95, df1=2, df2=24) + +if(Fcalculated > Ftable_0.05) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + +## Interpretation on interaction effect + +# at 0.05 level of significance + +Fcalculated<-2.397 + +Ftable_0.05<-qf(.95, df1=2, df2=24) + +if(Fcalculated > Ftable_0.05) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + +# at 0.01 level of significance + +Ftable_0.01<-qf(.99, df1=2, df2=24) + +if(Fcalculated > Ftable_0.01) +{ + cat("Reject null hypothesis and it is significant") +} else +{ + cat("Cannot reject null hypothesis and their is No significance") +} + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH14/EX14.4.1/Ex14.4_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH14/EX14.4.1/Ex14.4_1.R new file mode 100644 index 00000000..f356596b --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH14/EX14.4.1/Ex14.4_1.R @@ -0,0 +1,142 @@ +# Page.No 14.6 - 14.12 + +X<-c(5,6,3,2,4,4,8,5,6,2,6,5,6,2,1) + +Y<-c(6,7,5,4,3,8,7,6,5,4,4,6,5,2,3) + +#ANOVA table for X +X1<-c(5,6,3,2,4) +X2<-c(4,8,5,6,2) +X3<-c(6,5,6,2,1) +combined_groups<-data.frame(cbind(X1,X2,X3)) +stackedgroup<-stack(combined_groups) +anova_results_X<-aov(values~ind,data = stackedgroup) +summary(anova_results_X) + +# ANOVA table for Y +Y1<-c(6,7,5,4,3) +Y2<-c(8,7,6,5,4) +Y3<-c(4,6,5,2,3) +combined_groups<-data.frame(cbind(Y1,Y2,Y3)) +stackedgroup<-stack(combined_groups) +anova_results_Y<-aov(values~ind,data = stackedgroup) +summary(anova_results_Y) + +table_value_1<-qf(.99,2,12) +table_value_5<-qf(.95,2,12) + +## From the calculated F value and critical value @ 0.05 and 0.01 +## There is no difference among covariates of X + +##### calculation of anova table by another method + + +sum(X) +sum(Y) +sum(X^2) +sum(Y^2) +sum(X*Y) + +N<-length(X1) +sum_of_N<-length(X) + +#Step 1 correction +Cx<-(sum(X))^2/sum_of_N +Cy<-(sum(Y)^2)/sum_of_N +Cxy<-sum(X)*sum(Y)/sum_of_N + +#Step 2 TotalSS +TSSx<-sum(X^2)-Cx +TSSy<-sum(Y^2)-Cy +TSSxy<-sum(X*Y)-Cxy # Cx<-(sum(X))^2/N + +#step 3 Between means +Bet_Mn_X<-(sum(X1)^2+sum(X2)^2+sum(X3)^2)/N-Cx +Bet_Mn_Y<-(sum(Y1)^2+sum(Y2)^2+sum(Y3)^2)/N-Cy +Bet_Mn_XY<-(sum(X1)*sum(Y1)+sum(X2)*sum(Y2)+sum(X3)*sum(Y3))/N-Cxy + +# step 4 +# Within Group SS +WSS_x<-TSSx-Bet_Mn_X +WSS_Y<-TSSy-Bet_Mn_Y +WSS_XY<-TSSxy-Bet_Mn_XY + +# Degrees of freedom +Bdf<-3-1 # 3 groups +Tdf<-length(X)-1 +Wdf<-Tdf-Bdf +df<-c(Bdf,Wdf,Tdf) + +#sum of squares +SSx<-c(Bet_Mn_X,WSS_x,TSSx) +SSy<-c(Bet_Mn_Y,WSS_Y,TSSy) + +# Mean sum of squares +MSx<-SSx/df +MSy<-SSy/df + +Anova_table<-matrix(c(df,SSx,SSy,MSx,MSy),3,5) + +# step 6 computing adjusted sum of squares for Y + +TSSy.x<-TSSy-(TSSxy^2)/TSSx +WSSy.x<-WSS_Y-(WSS_XY^2)/WSS_x +BSSy.x<-TSSy.x-WSSy.x + +SSy.x<-c(BSSy.x,WSSy.x,TSSy.x) +SSx.y<-c(BSSy.x,WSS_XY,TSSxy) + +df<-c(Bdf,Wdf-1,Tdf-1) +MSy.x<-SSy.x/df + +#Step 7 ANCOVA + +matrix(c(df,SSx,SSy,SSx.y,SSy.x,MSy.x),3,6) # Ancova table + +Fy.x<-2.94/1.72 # from the ANCOVA table + +Ftable<-qf(.95,2,13) + +# Since F calculated value less than F table value Accept null hypothesis +# The computation of adjusted SS for y is not significant @ 0.05 + +SDy.x<-sqrt(WSSy.x/11) +#From comparison both are not significant at 0.05 level + +## Step 8 Adjusted y means + +Mx<-c(mean(X1),mean(X2),mean(X3)) +My<-c(mean(Y1),mean(Y2),mean(Y3)) +GMx<-mean(Mx) +r_total<-cor(X,Y) +r_between<-Bet_Mn_XY/sqrt(Bet_Mn_X*Bet_Mn_Y) +r_within<-WSS_XY/sqrt(WSS_x*WSS_Y) +bx<-WSS_XY/WSS_x + +M1<-mean(Y1)-bx*(mean(X1)-GMx) +M2<-mean(Y2)-bx*(mean(X2)-GMx) +M3<-mean(Y3)-bx*(mean(X3)-GMx) + +My.x<-c(M1,M2,M3) + +Table<- matrix(c(Mx,My,My.x),3,3) +print(Table) + +# Step 9 Comparison of Adjusted Means + +SDy.x +SEmd<-SDy.x*sqrt(1/length(X1)+1/length(X2)) + +# t_value + +(M1-M2)/SEmd + +(M1-M3)/SEmd + +(M2-M3)/SEmd + +# All pairs are not significant +cat("There is high correlation",r_between,r_within,r_total) + +"hence Group 1 , Group 2 , Group 3 not differ significantly " + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH2/EX2.6.1/Ex2.6_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH2/EX2.6.1/Ex2.6_1.R new file mode 100644 index 00000000..3b30ba6a --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH2/EX2.6.1/Ex2.6_1.R @@ -0,0 +1,16 @@ +# Page.No 2.5 + +#(a) class limit +lower_limit<-10 +upper_limit<-20 + +lower_value<-lower_limit-0.5 +upper_value<-upper_limit+0.5 + +cat("The lower and upper values of the class interval 10-20 is",lower_value,upper_value) + +#(b) class midpoint + +midpoint<-lower_limit+(upper_limit-lower_limit)/2 + +cat("mid point of a class interval 10-20 is", midpoint) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH3/EX3.3.1/Ex3.3_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH3/EX3.3.1/Ex3.3_1.R new file mode 100644 index 00000000..e5ce004f --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH3/EX3.3.1/Ex3.3_1.R @@ -0,0 +1,31 @@ +# Page.No 3.4 + +#(i) Determining Range +scores<-c(10,15,16,17,18,20,22,25,30,35,40,42,45,46,47,48,49,47,48,49,50,15,20,28,33) +HS<-max(scores) +LS<-min(scores) +range<-HS-LS + +cat("The range of the frequency distribution is ",range) + +#(ii) Determining size of class interval + +no.of.classes<-8 +size<-range/no.of.classes + +cat("The size of the class intervals is ",size) + +#(vii) frequency table + +low_value<-9.5 +high_value<-54.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +c<-cut(scores,breaks = X_breaks) +table<-table(c) +data<-data.frame(table) +print(data) + +N<-sum(data$Freq) +cat("Total no of frequencies is",N) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.10.1/Ex4.10_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.10.1/Ex4.10_1.R new file mode 100644 index 00000000..31c212ef --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.10.1/Ex4.10_1.R @@ -0,0 +1,6 @@ +# Page.No 4.12 + +numeric<-c(50,25,20,5) +degree<-numeric*360/100 + +pie(degree,main = "pie-diagram",col = c("gray30","gray80","black","white"),labels = c(degree)) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.7.1/Ex4.7_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.7.1/Ex4.7_1.R new file mode 100644 index 00000000..831a8e66 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.7.1/Ex4.7_1.R @@ -0,0 +1,19 @@ +# Page.No 4.8 + +# Given data +low_value<-9.5 +high_value<-34.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(5,4,6,4,2) +data<-rep(X_mid,f) + +# Histogram +hist(data,main="Histogram", + xlab="class_limits", + border="black", + col="Steelblue3", + xlim=c(0,40), + las=1, + breaks=5) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.8.1/Ex4.8_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.8.1/Ex4.8_1.R new file mode 100644 index 00000000..0d8c0bbf --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.8.1/Ex4.8_1.R @@ -0,0 +1,20 @@ +# Page.No 4.9 + +# Given data table +low_value<-4.5 +high_value<-39.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_breaks +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +X_mid +f<-c(0,2,3,6,4,5,0) +data<-rep(X_mid,f) + +# Plottinf the frequency polugon +plot(X_mid,f,type = "line",main = "title",xlab = "Mid Points",ylab = "Frequencies",col = "red") + +## Another method +hist<-(hist(data,main ="Histogram",xlab="class_limits",border="black",col="Steelblue3",xlim=c(0,50),las=1,breaks=5)) +library("agricolae") +polygon.freq(hist,f=1,col="red") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.9.1/Ex4.9_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.9.1/Ex4.9_1.R new file mode 100644 index 00000000..9e2d628b --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH4/EX4.9.1/Ex4.9_1.R @@ -0,0 +1,7 @@ +# Page.No 4.11 + +x<-seq(9.5,34.5,5) # class interval +f<-c(0,5,4,6,3,2) # frequency +cf<-cumsum(f) # cumulative frequency +percent<-cf/sum(f)*100 +plot(x,percent,type = "o",main="OGIVE",xlim = c(9.5,50),ylim=c(0,100),xlab = "Upper limits",ylab = "Cumulative Percentage Frequency") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.1/Ex5.3_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.1/Ex5.3_1.R new file mode 100644 index 00000000..ee5e1489 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.1/Ex5.3_1.R @@ -0,0 +1,7 @@ +#Page.No 5.5 + +marks<-c(70,30,20,90,40) # Marks in history + +avg<-mean(marks) # Mean of history marks + +cat("The average marks of the students is",avg) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.10/Ex5.3_10.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.10/Ex5.3_10.R new file mode 100644 index 00000000..5efe25b5 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.10/Ex5.3_10.R @@ -0,0 +1,5 @@ +#Page.No 5.16 + +X<-c(8,5,6,4,7) +d<-X-mean(X) +cat("The sum of deviations is",sum(d)) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.11/Ex5.3_11.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.11/Ex5.3_11.R new file mode 100644 index 00000000..859880b1 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.11/Ex5.3_11.R @@ -0,0 +1,8 @@ +#Page.No 5.17 + +X<-c(10,12,18,16,14) +d<-X-mean(X) +sum_of_deviations<-sum(d) +sum_of_dsquares<-sum(d^2) +cat("The Sum of squares of deviations is",sum_of_dsquares)# which is greater than sum of squares +mean(X) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.12/Ex5.3_12.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.12/Ex5.3_12.R new file mode 100644 index 00000000..1d7250f4 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.12/Ex5.3_12.R @@ -0,0 +1,17 @@ +#Page.No 5.17 + +#If each score is added or subtracted by a constant quantity +#The mean will increased by same quantity +X<-c(1,2,3,4,5,6,7) +mean(X) + +# Addition of constant 5 +X_add<-X+5 +mean(X_add) +mean(X)+5 # the same constant addition + +# subtrction of constant 5 +X_sub<-X-5 +mean(X_sub) +mean(X)-5 # the same constant subtraction + \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.2/Ex5.3_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.2/Ex5.3_2.R new file mode 100644 index 00000000..5be36a40 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.2/Ex5.3_2.R @@ -0,0 +1,5 @@ +#Page.No 5.5 + +marks<-c(10,20,30,40,50,60,70,80,90) # marks in English +avg<-mean(marks) # average of marks +cat("The average marks of the students is",avg) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.3/Ex5.3_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.3/Ex5.3_3.R new file mode 100644 index 00000000..60fd49a5 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.3/Ex5.3_3.R @@ -0,0 +1,5 @@ +#Page.No 5.6 + +scores<-c(80,90,95,96,85,84,82) # marks in mathematics +avg<-mean(scores) # average of marks +cat("The average marks of the students is",avg) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.4/Ex5.3_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.4/Ex5.3_4.R new file mode 100644 index 00000000..41964d17 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.4/Ex5.3_4.R @@ -0,0 +1,18 @@ +#Page.No 5.7 + +# Given data table +low_value<-9.5 +high_value<-34.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(5,4,6,3,2) # frequency of the distribution +data<-rep(X_mid,f) +mean(data) + +# to create a table from raw data +x<-cut(data, breaks=X_breaks) +datatable<-table(x) +df<-data.frame(datatable) +df$midpnt<-X_mid +df diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.5/Ex5.3_5.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.5/Ex5.3_5.R new file mode 100644 index 00000000..e40287f6 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.5/Ex5.3_5.R @@ -0,0 +1,8 @@ +#Page.No 5.9 + +Lower_limits<-c(5,11,17,23,29) +Upper_limits<-c(10,15,22,28,35) +frequency<-c(1,4,3,7,5) +library("gds") # function for Descriptive statistics of grouped data +results<-gds(Lower_limits,Upper_limits,frequency) +cat("the mean of the distribution is",results$mean) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.6/Ex5.3_6.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.6/Ex5.3_6.R new file mode 100644 index 00000000..9ea421bc --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.6/Ex5.3_6.R @@ -0,0 +1,8 @@ +#Page.No 5.12 -5.14 + +Lower_limits<-c(10,15,20,25,30) +Upper_limits<-c(14,19,24,29,35) +frequency<-c(5,10,7,2,1) +library("gds") # Function for Descriptive statistics of grouped data +results<-gds(Lower_limits,Upper_limits,frequency) +cat("the mean of the distribution is",results$mean) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.7/Ex5.3_7.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.7/Ex5.3_7.R new file mode 100644 index 00000000..bd5b1722 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.7/Ex5.3_7.R @@ -0,0 +1,6 @@ +#Page.No 5.14 + +mean<-c(50,45,40,45) # mean scores in history +no.of.students<-c(20,20,15,30) # no.of students in section +wm<-weighted.mean(mean,no.of.students) +cat("Combined mean is",wm) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.8/Ex5.3_8.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.8/Ex5.3_8.R new file mode 100644 index 00000000..db76466c --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.8/Ex5.3_8.R @@ -0,0 +1,5 @@ +#Page.No 5.15 + +No.of.students<-c(12,8,10,15,7) +Mean<-c(50,70,30,45,48) # Mean in English test +weighted.mean(Mean,No.of.students) \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.9/Ex5.3_9.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.9/Ex5.3_9.R new file mode 100644 index 00000000..eb09ff73 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.3.9/Ex5.3_9.R @@ -0,0 +1,6 @@ +#Page.No 5.15 + +no.of.students<-c(8,12,10,14,9) +Mean_of_achievement_test<-c(55,78,80,50,87) +M_comb<-weighted.mean(Mean_of_achievement_test,no.of.students) +cat("combined mean of the achievement test of students of 5 classes is",M_comb) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.1/Ex5.4_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.1/Ex5.4_1.R new file mode 100644 index 00000000..f88ad28e --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.1/Ex5.4_1.R @@ -0,0 +1,5 @@ +# Page.No 5.24 + +scores<-c(10,15,16,14,17,20,21) +md<-median(scores) +cat("The median is",md) \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.2/EX5.4_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.2/EX5.4_2.R new file mode 100644 index 00000000..5c5e62f6 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.2/EX5.4_2.R @@ -0,0 +1,5 @@ +#Page.No 5.25 + +scores<-c(15,10,14,16) +Md<-median(scores) +cat("The median of the scores is",Md) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.3/Ex5.4_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.3/Ex5.4_3.R new file mode 100644 index 00000000..18fd987c --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.3/Ex5.4_3.R @@ -0,0 +1,17 @@ +#Page.No 5.25 + +# (i) +scores<-c(10,8,25,24,30,45) +median(scores) + +#(ii) +Scores<-c(40,48,43,42,41) +median(Scores) + +#(iii) +score<-c(11,13,15,15,15,18,21) +median(score) + +lower_value<-median(score)-0.5 # from the lower limit +corrected_median<-lower_value+2/3 +cat("median is ",corrected_median) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.7/Ex5.4_7.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.7/Ex5.4_7.R new file mode 100644 index 00000000..9444d794 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.7/Ex5.4_7.R @@ -0,0 +1,8 @@ +#Page.No 5.30 + +Lower_limits<-c(10,15,20,25,30) +Upper_limits<-c(14,19,24,29,34) +frequency<-c(5,4,6,3,2) +library("gds") +results<-gds(Lower_limits,Upper_limits,frequency) +cat("the median of the distribution is",results$median) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.8/Ex5.4_8.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.8/Ex5.4_8.R new file mode 100644 index 00000000..89b3a852 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.8/Ex5.4_8.R @@ -0,0 +1,8 @@ +#Page.No 5.32 - 5.33 + +library("gds") #function for Descriptive statistics of grouped data +lower_limits<-c(10,15,20,25,30) +upper_limits<-c(14,19,24,29,34) +frequency<-c(5,4,6,3,2) +md<-gds(lower_limits,upper_limits,frequency) +cat("The median is",md$median) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.9/Ex5.4_9.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.9/Ex5.4_9.R new file mode 100644 index 00000000..db0e5682 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.4.9/Ex5.4_9.R @@ -0,0 +1,11 @@ +#Page.No 5.33 + +#(i) and (ii) +Lower_limits<-c(40,50,60,70,80,90) +Upper_limits<-c(49,59,69,79,89,99) +frequency<-c(14,12,15,10,15,14) + +library("gds") # Function to find Descriptive statistics of grouped data +results<-gds(Lower_limits,Upper_limits,frequency) +cat("the median of the distribution is",results$median) +#The answer may slightly vary due to rounding off values diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.1/Ex5.5_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.1/Ex5.5_1.R new file mode 100644 index 00000000..69c3f16c --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.1/Ex5.5_1.R @@ -0,0 +1,23 @@ +#Page.No 5.42 + +# Create the function. +mode <- function(x) { + unique_val <- unique(x) + counts <- vector() + for (i in 1:length(unique_val)) { + counts[i] <- length(which(x==unique_val[i])) + } + position <- c(which(counts==max(counts))) + if (mean(counts)==max(counts)) + mode_x <- 'Mode does not exist' + else + mode_x <- unique_val[position] + return(mode_x) +} + +# Create the vector with numbers. +v <- c(10,20,10,25,10,20,10,22,28) + +# Calculate the mode using the user function. +result <- mode(v) +cat("The mode is",result) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.10/Ex5.5_10.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.10/Ex5.5_10.R new file mode 100644 index 00000000..b999579b --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.10/Ex5.5_10.R @@ -0,0 +1,57 @@ +#Page.No 5.45 + +# A function created to find the median of a grouped data +GroupedMedian <- function(frequencies, intervals, sep = NULL, trim = NULL) { + # If "sep" is specified, the function will try to create the + # required "intervals" matrix. "trim" removes any unwanted + # characters before attempting to convert the ranges to numeric. + if (!is.null(sep)) { + if (is.null(trim)) pattern <- "" + else if (trim == "cut") pattern <- "\\[|\\]|\\(|\\)" + else pattern <- trim + intervals <- sapply(strsplit(gsub(pattern, "", intervals), sep), as.numeric) + } + + Midpoints <- rowMeans(intervals) + cf <- cumsum(frequencies) + Midrow <- findInterval(max(cf)/2, cf) + 1 + L <- intervals[1, Midrow] # lower class boundary of median class + h <- diff(intervals[, Midrow]) # size of median class + f <- frequencies[Midrow] # frequency of median class + cf2 <- cf[Midrow - 1] # cumulative frequency class before median class + n_2 <- max(cf)/2 # total observations divided by 2 + + unname(L + (n_2 - cf2)/f * h) +} + +# The Problem +frequency<-c(5,4,6,3,2) +colnames<-c("numbers") +rownames<-c("[9.5,14.5]"," (14.5,19.5]"," (19.5,24.5]","(24.5,29.5]"," (29.5,34.5]") +#The class intevals are changed to exclusive one by adding 0.5 to the upper limits and deducing 0.5 from the lower limits +y<-matrix(frequency,nrow=length(frequency),dimnames=list(rownames,colnames)) +md<-GroupedMedian(y[, "numbers"], rownames(y), sep=",", trim="cut") + + +### find the mean for grouped data +low_value<-9.5 +high_value<-34.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(5,4,6,3,2) +data<-rep(X_mid,f) +Mn<-mean(data) + +## to find mode from mean and median +Mode<-3*md-2*Mn +cat ("The mode is",Mode) + +# Page.No 5.47 +###(ii)Another method +Lower_limits<-c(10,15,20,25,30) +Upper_limits<-c(14,19,24,29,34) +frequency<-c(5,4,6,3,2) +library("gds") # Package for grouped statistics +results<-gds(Lower_limits,Upper_limits,frequency) +cat("the mode of the distribution is",results$mode) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.11/Ex5.5_11.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.11/Ex5.5_11.R new file mode 100644 index 00000000..f1d152fe --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.11/Ex5.5_11.R @@ -0,0 +1,50 @@ +# Page.No 5.48 + +# A function created to find the median of a grouped data +GroupedMedian <- function(frequencies, intervals, sep = NULL, trim = NULL) { + # If "sep" is specified, the function will try to create the + # required "intervals" matrix. "trim" removes any unwanted + # characters before attempting to convert the ranges to numeric. + if (!is.null(sep)) { + if (is.null(trim)) pattern <- "" + else if (trim == "cut") pattern <- "\\[|\\]|\\(|\\)" + else pattern <- trim + intervals <- sapply(strsplit(gsub(pattern, "", intervals), sep), as.numeric) + } + + Midpoints <- rowMeans(intervals) + cf <- cumsum(frequencies) + Midrow <- findInterval(max(cf)/2, cf) + 1 + L <- intervals[1, Midrow] # lower class boundary of median class + h <- diff(intervals[, Midrow]) # size of median class + f <- frequencies[Midrow] # frequency of median class + cf2 <- cf[Midrow - 1] # cumulative frequency class before median class + n_2 <- max(cf)/2 # total observations divided by 2 + + unname(L + (n_2 - cf2)/f * h) +} + +# The Problem +frequency<-c(2,3,1,4,2,1,2,4,3,2,7,4) +colnames<-c("numbers") +rownames<-c("[1.5,8.5]"," (8.5,15.5]"," (15.5,22.5]","(22.5,29.5]"," (29.5,36.5]","(36.5,43.5]", + "(43.5,50.5]","(50.5,57.5]","(57.5,64.5]","(64.5,71.5]","(71.5,78.5]","(78.5,85.5]") +#The class intevals are changed to exclusive one by adding 0.5 to the upper limits and deducing 0.5 from the lower limits +y<-matrix(frequency,nrow=length(frequency),dimnames=list(rownames,colnames)) +md<-GroupedMedian(y[, "numbers"], rownames(y), sep=",", trim="cut") + + +### find the mean for grouped data +low_value<-1.5 +high_value<-85.5 +step_value<-7 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(2,3,1,4,2,1,2,4,3,2,7,4) +data<-rep(X_mid,f) +Mn<-mean(data) + +## to find mode from mean and median +Mode<-3*md-2*Mn +cat ("The mode is",Mode) + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.2/Ex5.5_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.2/Ex5.5_2.R new file mode 100644 index 00000000..d9bd5e1d --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.2/Ex5.5_2.R @@ -0,0 +1,16 @@ +#Page.No 5.43 + +x<-c(30,31,32,33,34,35)#size of the garments +f<-c(20,30,40,60,25,10) # no of persons wearing +data<-rep(x,f) + +# Creating function to find mode +## Or u can use the previous functions too +Mode <- function(x) { + ux <- unique(x) + ux[which.max(tabulate(match(x, ux)))] +} + +md<-Mode(data) + +cat ("size of the dress most frequently used in season is",md) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.3/Ex5.5_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.3/Ex5.5_3.R new file mode 100644 index 00000000..eae3cbb0 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.3/Ex5.5_3.R @@ -0,0 +1,14 @@ +#Page.No 5.43 + +# Create the function. +getmode <- function(v) { + uniqv <- unique(v) + uniqv[which.max(tabulate(match(v, uniqv)))] +} + +# Create the vector with numbers. +Scores <- c(20,20,30,20,25,20,38,37,38) + +# Calculate the mode using the user function. +result <- getmode(Scores) +cat("The mode is",result) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.4/Ex5.5_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.4/Ex5.5_4.R new file mode 100644 index 00000000..bb21ca9f --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.4/Ex5.5_4.R @@ -0,0 +1,14 @@ +#Page.No 5.43 + +# Create the function. +getmode <- function(v) { + uniqv <- unique(v) + uniqv[which.max(tabulate(match(v, uniqv)))] +} + +# Create the vector with numbers. +scores <- c(20,25,20,15,19,22,20,22) + +# Calculate the mode using the user function. +result <- getmode(scores) +cat("The mode is",result) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.6/Ex5.5_6.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.6/Ex5.5_6.R new file mode 100644 index 00000000..f984a98a --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.6/Ex5.5_6.R @@ -0,0 +1,21 @@ +#Page.No 5.43 + +Scores <- c(20,25,20,28,29,28,30,32) + +#Creating a function +mode <- function(x) { + unique_val <- unique(x) + counts <- vector() + for (i in 1:length(unique_val)) { + counts[i] <- length(which(x==unique_val[i])) + } + position <- c(which(counts==max(counts))) + if (mean(counts)==max(counts)) + mode_x <- 'Mode does not exist' + else + mode_x <- unique_val[position] + return(mode_x) +} + +mode(Scores) +# the series is Bi-modal diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.7/Ex5.5_7.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.7/Ex5.5_7.R new file mode 100644 index 00000000..63519d28 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.7/Ex5.5_7.R @@ -0,0 +1,24 @@ +# Page.no 5.44 + +##Creating a function +mode <- function(x) { + unique_val <- unique(x) + counts <- vector() + for (i in 1:length(unique_val)) { + counts[i] <- length(which(x==unique_val[i])) + } + position <- c(which(counts==max(counts))) + if (mean(counts)==max(counts)) + mode_x <- 'Mode does not exist' + else + mode_x <- unique_val[position] + return(mode_x) +} + +y<-c(11,11,12,12,12,13,13,13,13,14,14,14,14,15,15,16,17,18) +Md<-mode(y) + +## Since 13 and 14 are adjacent numbers their mean can be considered as the mode +Mode<-mean(Md) +cat("The mode will be", Mode) + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.8/Ex5.5_8.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.8/Ex5.5_8.R new file mode 100644 index 00000000..e3d706d4 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.8/Ex5.5_8.R @@ -0,0 +1,26 @@ +# Page.no 5.44 + +##Creating a function +mode <- function(x) { + unique_val <- unique(x) + counts <- vector() + for (i in 1:length(unique_val)) { + counts[i] <- length(which(x==unique_val[i])) + } + position <- c(which(counts==max(counts))) + if (mean(counts)==max(counts)) + mode_x <- 'Mode does not exist' + else + mode_x <- unique_val[position] + return(mode_x) +} + +y<-c(11,11,12,12,12,13,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,17,17,18) +Md<-mode(y) + +# value 13 occurs 5 times which is greater than the frequency of the adjacent values +# Also 15 occurs 4 times which is also greater than the frequency of the adjacent values + +# hence this is Bi-modal +cat("The mode values are",13 ,15) + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.9/Ex5.5_9.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.9/Ex5.5_9.R new file mode 100644 index 00000000..1930620f --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.5.9/Ex5.5_9.R @@ -0,0 +1,19 @@ +#Page.No 5.45 + +# Given frequency distribution data +low_value<-9.5 +high_value<-39.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_breaks +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +X_mid +f<-c(2,3,2,8,3,2) +data<-rep(X_mid,f) + +# creating function to find mode +Mode <- function(x) { + ux <- unique(x) + ux[which.max(tabulate(match(x, ux)))] +} +Mode(data) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.7.1/Ex5.7_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.7.1/Ex5.7_1.R new file mode 100644 index 00000000..5b546799 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.7.1/Ex5.7_1.R @@ -0,0 +1,65 @@ +#Page.No 5.51 - 5.53 + +Lower_limits<-c(10,15,20,25,30,35,40,45) +Upper_limits<-c(14,19,24,29,34,39,44,49) +frequency<-c(3,6,5,9,8,8,2,8) +library("gds") # Package for grouped statistics +results<-gds(Lower_limits,Upper_limits,frequency) +cat("The mean is ",results$mean) +cat("The median is ",results$median) +cat("The mode is ",results$mode) +# The answers may slightly vary due to roundingoff values + + + +#### To get the Precise answers you can try the following method +# A function created to find the median of a grouped data +GroupedMedian <- function(frequencies, intervals, sep = NULL, trim = NULL) { + # If "sep" is specified, the function will try to create the + # required "intervals" matrix. "trim" removes any unwanted + # characters before attempting to convert the ranges to numeric. + if (!is.null(sep)) { + if (is.null(trim)) pattern <- "" + else if (trim == "cut") pattern <- "\\[|\\]|\\(|\\)" + else pattern <- trim + intervals <- sapply(strsplit(gsub(pattern, "", intervals), sep), as.numeric) + } + + Midpoints <- rowMeans(intervals) + cf <- cumsum(frequencies) + Midrow <- findInterval(max(cf)/2, cf) + 1 + L <- intervals[1, Midrow] # lower class boundary of median class + h <- diff(intervals[, Midrow]) # size of median class + f <- frequencies[Midrow] # frequency of median class + cf2 <- cf[Midrow - 1] # cumulative frequency class before median class + n_2 <- max(cf)/2 # total observations divided by 2 + + unname(L + (n_2 - cf2)/f * h) +} + +# The Problem +frequency<-c(3,6,5,9,8,8,2,8) +colnames<-c("numbers") +rownames<-c("[9.5,14.5]"," (14.5,19.5]"," (19.5,24.5]","(24.5,29.5]", + "(29.5,34.5]","(34.5,39.5]","(39.5,44.5]","(44.5,49.5]") +#The class intevals are changed to exclusive one by adding 0.5 to the upper limits and deducing 0.5 from the lower limits +y<-matrix(frequency,nrow=length(frequency),dimnames=list(rownames,colnames)) +md<-GroupedMedian(y[, "numbers"], rownames(y), sep=",", trim="cut") + + +### find the mean for grouped data +low_value<-9.5 +high_value<-49.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(3,6,5,9,8,8,2,8) +data<-rep(X_mid,f) +Mn<-mean(data) +Mn + +## to find mode from mean and median +Mode<-3*md-2*Mn +cat ("The mode is",Mode) +cat("The median is",md) +cat("The mean is",Mn) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.7.2/Ex5.7_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.7.2/Ex5.7_2.R new file mode 100644 index 00000000..ff055117 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH5/EX5.7.2/Ex5.7_2.R @@ -0,0 +1,45 @@ +# Page.No 5.53 + +Lower_limits<-c(100,110,120,130,140,150,160) +Upper_limits<-c(109,119,129,139,149,159,169) +frequency<-c(10,12,13,18,6,7,4) +library("gds") # Package for grouped statistics +results<-gds(Lower_limits,Upper_limits,frequency) +cat("The mean is ",results$mean) +cat("The median is ",results$median) + +GroupedMedian <- function(frequencies, intervals, sep = NULL, trim = NULL) { + # If "sep" is specified, the function will try to create the + # required "intervals" matrix. "trim" removes any unwanted + # characters before attempting to convert the ranges to numeric. + if (!is.null(sep)) { + if (is.null(trim)) pattern <- "" + else if (trim == "cut") pattern <- "\\[|\\]|\\(|\\)" + else pattern <- trim + intervals <- sapply(strsplit(gsub(pattern, "", intervals), sep), as.numeric) + } + + Midpoints <- rowMeans(intervals) + cf <- cumsum(frequencies) + Midrow <- findInterval(max(cf)/2, cf) + 1 + L <- intervals[1, Midrow] # lower class boundary of median class + h <- diff(intervals[, Midrow]) # size of median class + f <- frequencies[Midrow] # frequency of median class + cf2 <- cf[Midrow - 1] # cumulative frequency class before median class + n_2 <- max(cf)/2 # total observations divided by 2 + + unname(L + (n_2 - cf2)/f * h) +} + +# The Problem +frequency<-c(10,12,13,18,06,07,04) +colnames<-c("numbers") +rownames<-c("[99.5,109.5]"," (109.5,119.5]"," (119.5,129.5]","(129.5,139.5]", + "(139.5,149.5]","(149.5,159.5]","(159.5,169.5]") +#The class intevals are changed to exclusive one by adding 0.5 to the upper limits and deducing 0.5 from the lower limits +y<-matrix(frequency,nrow=length(frequency),dimnames=list(rownames,colnames)) +md<-GroupedMedian(y[, "numbers"], rownames(y), sep=",", trim="cut") + + +Mode <- 3*md-2*results$mean +cat("The mode is",Mode) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.2.1/Ex6.2_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.2.1/Ex6.2_1.R new file mode 100644 index 00000000..51cf8879 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.2.1/Ex6.2_1.R @@ -0,0 +1,40 @@ +# Page.No 6.5 - 6.8 + +## Function to find percentile +percentile <- function(frequencies, intervals, sep = NULL, trim = NULL,p) { + # If "sep" is specified, the function will try to create the + # required "intervals" matrix. "trim" removes any unwanted + # characters before attempting to convert the ranges to numeric. + if (!is.null(sep)) { + if (is.null(trim)) pattern <- "" + else if (trim == "cut") pattern <- "\\[|\\]|\\(|\\)" + else pattern <- trim + intervals <- sapply(strsplit(gsub(pattern, "", intervals), sep), as.numeric) + } + Midpoints <- rowMeans(intervals) + cf <- cumsum(frequencies) + row <- findInterval(max(cf)*p, cf) + 1 + L <- intervals[1, row] # lower class boundary of percentile class + h <- diff(intervals[, row]) # size of percentile class + f <- frequencies[row] # frequency of percentile class + cf2 <- cf[row - 1] # cumulative frequency class before percentile class + n_2 <- max(cf)*p # total observations multiplied with percentile + + unname(L + (n_2 - cf2)/f * h) +} + +# The given Problem +frequency<-c(2,3,4,5,3,2,2,3) +colnames<-c("numbers") +rownames<-c("[9.5,14.5]"," (14.5,19.5]"," (19.5,24.5]","(24.5,29.5]"," (29.5,34.5]","(34.5,39.5]","(39.5,44.5]","(44.5,49.5]") +#The class intevals are changed to exclusive one by adding 0.5 to the upper limits and deducing 0.5 from the lower limits + +y<-matrix(frequency,nrow=length(frequency),dimnames=list(rownames,colnames)) + +p=c(0.15,0.25,0.50,0.65,0.75,0.80,0.85) + +Percentile_value <-percentile(y[, "numbers"], rownames(y), sep=",", trim="cut",p) + +Result<- round(rbind(p*100,Percentile_value),digits = 3) + +print(Result) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.1/Ex6.3_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.1/Ex6.3_1.R new file mode 100644 index 00000000..8cd33e0d --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.1/Ex6.3_1.R @@ -0,0 +1,18 @@ +#Page.No 6.11 +#Page.No 6.11 + +data<-as.vector(c(10,8,7,15,18,19,20,28,16,13,17,29,30,6,5,4,26,24,14,21)) +N<-length(data) + +# ranking of scores +r<-rank(-data) # negative for rank the data in descending order +rank_matrix<-cbind(r,data) + + +# Rank of score 18 +rank_matrix[5,] +R<-rank_matrix[5,1] + +percentile_rank<-round(100-((100*R-50))/N,digits = 0) +cat("The percentile rank of 18 is approximately ",percentile_rank) + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.2/Ex6.3_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.2/Ex6.3_2.R new file mode 100644 index 00000000..c45220db --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.2/Ex6.3_2.R @@ -0,0 +1,16 @@ +# Page No.6.12 + +data<-as.vector(c(65,59,46,32,25,15,14,10,9,7,5,3)) +N<-length(data) + +# ranking of scores +r<-rank(-data) # negative for rank the data in descending order +rank_matrix<-cbind(r,data) + + +# Rank of score 18 +rank_matrix[5,] +R<-rank_matrix[5,1] + +percentile_rank<-100-((100*R-50))/N +cat("The percentile rank of 18 is approximately ",percentile_rank) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.3/Ex6.3_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.3/Ex6.3_3.R new file mode 100644 index 00000000..b3b30f69 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.3/Ex6.3_3.R @@ -0,0 +1,38 @@ +#Page.No 6.13 + +# Function to find percentile rank of grouped data +percentilerank<-function(class_interval,lower_limit,x){ + L<-lower_limit + row<-which(data$c==class_interval) + f<-data$Freq[row] + cf<-data.frame(cumsum(data$Freq)) + cf1<-cf$cumsum.data.Freq.[row] + cf2<-cf$cumsum.data.Freq.[row-1] + F<-if(row - 1<= 0) { + cf1 + }else { cf2 } + N<-sum(data$Freq) + i<-step_value + unname((100/N)*(F+(x-L)/i*f)) +} + +# Given data +low_value<-9.5 +high_value<-69.5 +step_value<-10 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +frequency<-c(4,8,2,2,3,1) +data<-rep(X_mid,frequency) +c<-cut(data,breaks = X_breaks) +table<-table(c) +data<-data.frame(table) +print(data) + +# percentile rank of 24 + +PR22<-percentilerank("(19.5,29.5]",19.5,22) + +cat("The percentile rank of 22 is ",PR22) + + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.4/Ex6.3_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.4/Ex6.3_4.R new file mode 100644 index 00000000..5bef6694 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.3.4/Ex6.3_4.R @@ -0,0 +1,45 @@ +#Page.No 6.13 + +# Function to find percentile rank of grouped data +percentilerank<-function(class_interval,lower_limit,x){ + L<-lower_limit + row<-which(data$c==class_interval) + f<-data$Freq[row] + cf<-data.frame(cumsum(data$Freq)) + cf1<-cf$cumsum.data.Freq.[row] + cf2<-cf$cumsum.data.Freq.[row-1] + F<-if(row - 1<= 0) { + cf1 + }else { cf2 } + N<-sum(data$Freq) + i<-step_value + unname((100/N)*(F+(x-L)/i*f)) +} + +# Given data +low_value<-9.5 +high_value<-89.5 +step_value<-10 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +frequency<-c(2,3,4,5,2,1,1,2) +data<-rep(X_mid,frequency) +c<-cut(data,breaks = X_breaks) +table<-table(c) +data<-data.frame(table) +print(data) + +# percentile rank of 24 + +PR24<-percentilerank("(19.5,29.5]",19.5,24) +PR36<-percentilerank("(29.5,39.5]",29.5,36) +PR52<-percentilerank("(49.5,59.5]",49.5,52) +PR55<-percentilerank("(49.5,59.5]",49.5,55) +PR67<-percentilerank("(59.5,69.5]",59.5,67) + +results<-c(PR24,PR36,PR52,PR55,PR67) +Q<-c("PR24","PR36","PR52","PR55","PR67") + +percentile_ranks<-data.frame(Q,results) +print(percentile_ranks) + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.4.1/Ex6.4_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.4.1/Ex6.4_1.R new file mode 100644 index 00000000..fc6e5d50 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.4.1/Ex6.4_1.R @@ -0,0 +1,50 @@ +# Page.No 6.18 - 6.23 + +percentile <- function(frequencies, intervals, sep = NULL, trim = NULL,p) { + # If "sep" is specified, the function will try to create the + # required "intervals" matrix. "trim" removes any unwanted + # characters before attempting to convert the ranges to numeric. + if (!is.null(sep)) { + if (is.null(trim)) pattern <- "" + else if (trim == "cut") pattern <- "\\[|\\]|\\(|\\)" + else pattern <- trim + intervals <- sapply(strsplit(gsub(pattern, "", intervals), sep), as.numeric) + } + Midpoints <- rowMeans(intervals) + cf <- cumsum(frequencies) + row <- findInterval(max(cf)*p, cf) + 1 + L <- intervals[1, row] # lower class boundary of percentile class + h <- diff(intervals[, row]) # size of percentile class + f <- frequencies[row] # frequency of percentile class + c <- cf[row - 1] + cf2 <- if(row - 1<= 0 ) {0} + else { cf[row - 1] } # cumulative frequency class before percentile class + n_2 <- max(cf)*p # total observations multiplied with percentile + + unname(L + (n_2 - cf2)/f * h) +} + + +# The Problem +frequency<-c(9,5,7,8,8,6,2,3,2) +colnames<-c("numbers") +rownames<-c("[9.5,14.5]"," (14.5,19.5]"," (19.5,24.5]","(24.5,29.5]"," (29.5,34.5]","(34.5,39.5]","(39.5,44.5]","(44.5,49.5]","(49.5,54.5]") +#The class intevals are changed to exclusive one by adding 0.5 to the upper limits and deducing 0.5 from the lower limits +y<-matrix(frequency,nrow=length(frequency),dimnames=list(rownames,colnames)) + + +p1=c(0.90,0.80,0.75,0.70,0.60,0.50,0.48,0.40,0.30,0.20) + +p2=c(0.17,0.10) + +Percentile_value1<-percentile(y[, "numbers"], rownames(y), sep=",", trim="cut",p1) + +Percentile_value2<-percentile(y[, "numbers"], rownames(y), sep=",", trim="cut",p2) + +Result1<- round(rbind(p1*100,Percentile_value1),digits = 3) # percentile values of above 20 + +Result2<- round(rbind(p2*100,Percentile_value2),digits = 3) # percentile values of below 20 + +print(Result1) + +print(Result2) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.5.1/Ex6.5_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.5.1/Ex6.5_1.R new file mode 100644 index 00000000..5f319c17 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH6/EX6.5.1/Ex6.5_1.R @@ -0,0 +1,19 @@ +# Page.No 6.23-6.24 + +low_value<-19.5 +high_value<-64.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +frequency<-c(1,2,2,7,10,8,5,3,2) +scores<-rep(X_mid,frequency) +cf<-cumsum(frequency) +cpf<-cf/sum(frequency)*100 +plot(X_mid,cpf,xlim=c(10,70),ylim = c(0,100),type = "o",xlab = "scores",ylab = "Cumulative percentage frequency",main = "Graphic Representation of percentiles") +abline(h=c(17,25,50,63,75),untf = FALSE) + +## Or to make the clear visualization +abline(h=c(17,25,50,63,75),v=c(33.3,35.5,41,44,47)) + +## to give colours +abline(h=c(17,25,50,63,75),v=c(33.3,35.5,41,44,47),col=c("red","green","blue","orange","yellow")) \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.1/Ex7.5_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.1/Ex7.5_1.R new file mode 100644 index 00000000..f685c23b --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.1/Ex7.5_1.R @@ -0,0 +1,5 @@ +#Page. No 7.5 + +scores<-c(5,7,9,15,17,19) +range<-max(scores)-min(scores) +cat("the range of the scores is",range) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.2/Ex7.5_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.2/Ex7.5_2.R new file mode 100644 index 00000000..15ca97a7 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.2/Ex7.5_2.R @@ -0,0 +1,5 @@ +# Page.No 7.5 + +scores<-c(19,22,90,100,150,190) +range<-max(scores)-min(scores) +cat("the range of the scores is",range) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.3/Ex7.5_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.3/Ex7.5_3.R new file mode 100644 index 00000000..ff3ef41c --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.3/Ex7.5_3.R @@ -0,0 +1,7 @@ +#Page.No 7.6 + +scores<-c(10,20,30,40,50,60,65,66,70,80) +hs<-max(scores) +ls<-min(scores) +Coef.R<-(hs-ls)/(hs+ls) +cat("The coefficient of Range is",Coef.R) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.4/Ex7.5_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.4/Ex7.5_4.R new file mode 100644 index 00000000..8900bab2 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.4/Ex7.5_4.R @@ -0,0 +1,10 @@ +#Page.No 7.6 + +class_intervals <-c(10,14,15,19,20,24,25,29,30,34) +frequency<-c(2,8,6,2,2) +HS<-max(class_intervals) # highest score +LS<-min(class_intervals) #Lowest score + +Coef.R<-(HS-LS)/(HS+LS) + +cat("The coefficient of Range is",Coef.R) \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.5/Ex7.5_5.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.5/Ex7.5_5.R new file mode 100644 index 00000000..13a2a760 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.5/Ex7.5_5.R @@ -0,0 +1,10 @@ +#Page.No 7.7 + +class_intervals <-c(5,9,10,14,15,19,20,24,25,29) +frequency<-c(2,4,5,7,2) +HS<-max(class_intervals) #Highest score +LS<-min(class_intervals) # Lowest score + +Coef.R<-(HS-LS)/(HS+LS) + +cat("The coefficient of Range is",Coef.R) \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.6/Ex7.5_6.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.6/Ex7.5_6.R new file mode 100644 index 00000000..e1c21f98 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.5.6/Ex7.5_6.R @@ -0,0 +1,10 @@ +#Page.No 7.7 + +frequency<-c(2,2,3,3) +scores<-c(10,14,15,19,20,24,25,29) +HS<-max(scores) #Highest score +LS<-min(scores) #Lowest score + +Coef.R<-(HS-LS)/(HS+LS) + +cat("The coefficient of Range is",Coef.R) \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.1/Ex7.6_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.1/Ex7.6_1.R new file mode 100644 index 00000000..6da4aa0c --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.1/Ex7.6_1.R @@ -0,0 +1,20 @@ +#Page.No 7.10 -7.13 + +library("gds") # function to find descriptive statistics of Grouped data + +f<-c(2,8,10,6,5,9) # frequency + +Lower_limits<-c(9.5,14.5,19.5,24.5,29.5,34.5) +Upper_limits<-c(14.5,19.5,24.5,29.5,34.5,39.5) + +results<-gds(Lower_limits,Upper_limits,f) + +cat("The first quartile is",results$quartile1) # 1st Quartile + +cat("The third quartile is",results$quartile3) # 3rd Quartile + +#Quartile deviation +Q<-(results$quartile3-results$quartile1)/2 + +cat("The quartile deviation is ",Q) + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.2/Ex7.6_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.2/Ex7.6_2.R new file mode 100644 index 00000000..56702573 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.2/Ex7.6_2.R @@ -0,0 +1,18 @@ +#Page.No 7.13-7.15 + +library("gds") # function to find descriptive statistics of Grouped data + +# Given data +f<-c(2,8,10,12,8,10) +Lower_limits<-c(39.5,49.5,59.5,69.5,79.5,89.5) +Upper_limits<-c(49.5,59.5,69.5,79.5,89.5,99.5) +results<-gds(Lower_limits,Upper_limits,f) + +cat("The first quartile is",results$quartile1) + +cat("The third quartile is",results$quartile3) + +# Quartile deviation +Q<-(results$quartile3-results$quartile1)/2 +cat("The quartile deviation is ",Q) + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.3/Ex7.6_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.3/Ex7.6_3.R new file mode 100644 index 00000000..3bd9b64a --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.6.3/Ex7.6_3.R @@ -0,0 +1,17 @@ +#Page.No 7.15 -7.17 + +library("gds") # function to find descriptive statistics of Grouped data + +f<-c(6,4,6,4,8,7,5) +Lower_limits<-c(39.5,44.5,49.5,54.5,59.5,64.5,69.5) +Upper_limits<-c(44.5,49.5,54.5,59.5,64.5,69.5,74.5) +results<-gds(Lower_limits,Upper_limits,f) + +cat("The first quartile is",results$quartile1) + +cat("The third quartile is",results$quartile3) + +# Quartile deviation +Q<-(results$quartile3-results$quartile1)/2 +cat("The quartile deviation of the distibution is ",Q) + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.2/Ex7.7_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.2/Ex7.7_2.R new file mode 100644 index 00000000..b5cdb4e8 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.2/Ex7.7_2.R @@ -0,0 +1,9 @@ +#Page.No 7.19 -7.20 + +scores<-c(20,18,42,46,50,64,75) +A.D<-mean(abs(scores-mean(scores))) + +cat("Average Deviation of the scores is ",A.D) + +"The answer provided in the textbook is wrong" +### The first value 20 - mean(scores) is 25 not 15 diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.3/Ex7.7_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.3/Ex7.7_3.R new file mode 100644 index 00000000..f248935f --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.3/Ex7.7_3.R @@ -0,0 +1,6 @@ +#Page.No 7.20 + +x<-c(25,45,15,16,84) # Scores +A.D<-mean(abs(x-mean(x))) + +cat("Average Deviation of the distribution is ",A.D) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.5/Ex7.7_5.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.5/Ex7.7_5.R new file mode 100644 index 00000000..94e9abdc --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.5/Ex7.7_5.R @@ -0,0 +1,15 @@ +#Page.No 7.22 + +# Given distribution table +low_value<-99.5 +high_value<-169.5 +step_value<-10 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(10,8,7,6,12,9,8) +data<-rep(X_mid,f) + +# Average deviation +A.D<-mean(abs(data-mean(data))) + +cat("Average Deviation of the distribution is ",A.D) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.6/Ex7.7_6.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.6/Ex7.7_6.R new file mode 100644 index 00000000..e79d4a02 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.6/Ex7.7_6.R @@ -0,0 +1,15 @@ +#Page.No 7.23 + +# Given distribution table +low_value<-69.5 +high_value<-81.5 +step_value<-2 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(3,3,4,1,4,5) +data<-rep(X_mid,f) + +# Average deviation +A.D<-mean(abs(data-mean(data))) + +cat("Average Deviation of the distribution is ",A.D) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.7/Ex7.7_7.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.7/Ex7.7_7.R new file mode 100644 index 00000000..9df5dfa6 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.7.7/Ex7.7_7.R @@ -0,0 +1,15 @@ +#Page.No 7.24 + +# Given distribution table +low_value<-103.5 +high_value<-128.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(4,3,2,6,5) +data<-rep(X_mid,f) + +# Average deviation +A.D<-mean(abs(data-mean(data))) + +cat("Average Deviation of the distribution is ",A.D) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.1/Ex7.8_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.1/Ex7.8_1.R new file mode 100644 index 00000000..ea7b95f2 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.1/Ex7.8_1.R @@ -0,0 +1,13 @@ +#Page.No 7.27 - 7.28 + +scores<-c(8,9,10,11,12,13,14,15) + +n <- length(scores) # number of values + +std <- sd(scores) # sample standard deviation + +S.D<-sqrt((std ^ 2) * ((n - 1) / n)) # Population std deveiation + +cat("The standard deviation of the scores is",S.D) + +"The Answer given in the book is wrong" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.10/Ex7.8_10.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.10/Ex7.8_10.R new file mode 100644 index 00000000..62e71026 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.10/Ex7.8_10.R @@ -0,0 +1,17 @@ +#Page.No 7.40 - 7.41 + +M<-c(40,30) # Mean values +N<-c(20,30) # No.of students in a class +S.D<-c(8,4) # Std deviation of students + +M.comb<-weighted.mean(M,N) + +# Difference between the mean of the 1st and 2nd distribution and combined mean +d1sqr<-(40-M.comb)^2 +d2sqr<-(30-M.comb)^2 + +sigma.comb<-sqrt(((20*(64-d1sqr))+(30*(16+d2sqr)))/50) + +cat("The combined mean is",M.comb) + +cat("The combined standrad deviation is ",sigma.comb) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.2/Ex7.8_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.2/Ex7.8_2.R new file mode 100644 index 00000000..63530e94 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.2/Ex7.8_2.R @@ -0,0 +1,11 @@ +#Page.No 7.28 - 7.29 + +x<-c(10,20,30,40,50,60,70) + +n <- length(x) # number of values + +std <- sd(x) # sample standard deviation + +S.D<-sqrt((std ^ 2) * ((n - 1) / n)) # Population std deveiation + +cat("The standard deviation of the scores is",S.D) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.5/Ex7.8_5.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.5/Ex7.8_5.R new file mode 100644 index 00000000..d40e8144 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.5/Ex7.8_5.R @@ -0,0 +1,18 @@ +#Page.No 7.31 - 7.32 + +# Given distribution table +low_value<-9.5 +high_value<-34.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(2,8,6,2,2) +data<-rep(X_mid,f) + +n <- length(data) # number of values + +std <- sd(data) # sample standard deviation + +S.D<-sqrt((std ^ 2) * ((n - 1) / n)) # Population std deveiation + +cat("The standard deviation of the scores is",S.D) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.6/Ex7.8_6.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.6/Ex7.8_6.R new file mode 100644 index 00000000..0e0e6d57 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.6/Ex7.8_6.R @@ -0,0 +1,17 @@ +#Page.No 7.32 - 7.33 + +# Given distribution data +low_value<-9.5 +high_value<-34.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +f<-c(2,8,6,2,2) +data<-rep(X_mid,f) + +n <- length(data) # number of values +std <- sd(data) # sample standard deviation + +S.D<-sqrt((std ^ 2) * ((n - 1) / n)) # Population std deveiation + +cat("The standard deviation of the scores is",S.D) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.9/Ex7.8_9.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.9/Ex7.8_9.R new file mode 100644 index 00000000..0d9e1893 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH7/EX7.8.9/Ex7.8_9.R @@ -0,0 +1,62 @@ +#Page.No 7.37 + +scores<-c(2,5,4,6,8) +Mn<-mean(scores) +n <- length(scores) # number of values +std <- sd(scores) # sample standard deviation +S.D<-sqrt((std ^ 2) * ((n - 1) / n)) # Population Standrad deviation + + +# (i)Addition of 2 in each scores +scores_new<-scores+2 +Mn_new<-mean(scores_new) +n <- length(scores_new) # number of values +std_new <- sd(scores_new) # sample standard deviation +S.D_new<-sqrt((std_new ^ 2) * ((n - 1) / n)) + +cat("Previously the Mean and standard deviation respectively are",Mn , + "and", S.D) +cat("After addition of 2 in each score Mean has enhanced ",Mn_new-Mn," + and standard deviation remains unchanged i.e ",S.D-S.D_new) + + +#(ii)subtraction of 2 in each scores +scores_sub<-scores-2 +Mn_sub<-mean(scores_sub) +n <- length(scores_sub) # number of values +std_sub <- sd(scores_sub) # sample standard deviation +S.D_sub<-sqrt((std_sub ^ 2) * ((n - 1) / n)) + +cat("Previously the Mean and standard deviation respectively are",Mn , + "and", S.D) +cat("After subtraction of 2 in each score Mean has reduced by ",Mn-Mn_sub, + "and standard deviation remains unchanged i.e ",S.D-S.D_sub) + + +# (iii) multiplication of 2 in each scores +scores_mult<-scores*2 +Mn_mult<-mean(scores_mult) +n <- length(scores_mult) # number of values +std_mult <- sd(scores_mult) # sample standard deviation +S.D_mult<-sqrt((std_mult ^ 2) * ((n - 1) / n)) + +cat("Previously the Mean and standard deviation respectively are",Mn , + "and", S.D) +cat("After multiplication of 2 in each score Mean has multiplied by ",2, + "and the result is ",Mn_mult,"thats is same as ",Mn*2) +cat("standard deviation also multiplied by ",2, + "and the result is",S.D_mult,"thats is same as",S.D*2 ) + +# (iii) division of 2 in each scores +scores_div<-scores/2 +Mn_div<-mean(scores_div) +n <- length(scores_div) # number of values +std_div <- sd(scores_div) # sample standard deviation +S.D_div<-sqrt((std_div ^ 2) * ((n - 1) / n)) + +cat("Previously the Mean and standard deviation respectively are",Mn , + "and", S.D) +cat("After division 2 in each score Mean has divided by ", + 2,"and the result is ",Mn_div,"i.e ", Mn/2) + +cat("standard deviation also divided by ",2,"and the result is",S.D_div,"i.e",S.D/2) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.1/Ex8.10_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.1/Ex8.10_1.R new file mode 100644 index 00000000..fc3a7719 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.1/Ex8.10_1.R @@ -0,0 +1,57 @@ +#Page.No 8.30 - 8.35 + +X<-c(50,41,42,45,60,43,46,47,48,50,58,45,40,35,30,20,18,15,14,10) # TEST I +Y<-c(80,90,95,96,75,70,50,60,55,50,45,45,40,30,30,25,19,18,17,10) # TEST II + +# X table caclculations +low_value<-9.5 +high_value<-64.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +c1<-cut(X,breaks = X_breaks) +table1<-table(c1) +data1<-data.frame(table1) + +f1<-data1$Freq # X values grouped and their frequencies + +x_dash<-(X_mid-round(median(X),digits = 0))/step_value # standard values x' + +fxdash<-f1*x_dash #fx' + +fxdashsqr<-fxdash*x_dash# fx'^2 + + +# Claculation of Y variables +low_value<-9.5 +high_value<-99.5 +step_value<-10 +Y_breaks<-seq(low_value,high_value,step_value) +Y_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) +c2<-cut(Y,breaks = Y_breaks) +table2<-table(c2) +data2<-data.frame(table2) + +f2<-data2$Freq + +y_dash<-round(((Y_mid-(median(Y)))/10),digits = 0) # y' + +fydash<-f2*y_dash #fy' + +fydashsqr<-fydash*y_dash #fy'^2 + +N<-sum(f1) + +fxdashydash<-108 # from scatter diagram + +# calculation of correlation coefficient + +numerator<-(N*sum(fxdashydash))-(sum(fxdash)*sum(fydash)) + +denominator<-sqrt(((N*sum(fxdashsqr))-((sum(fxdash))^2))*((N*sum(fydashsqr))-((sum(fxdash))^2))) + +r<-numerator/denominator + +cat("The correlation coefficient is",r,"positive") + +"The answer provided in the book is wrong" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.2/Ex8.10_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.2/Ex8.10_2.R new file mode 100644 index 00000000..c5ee92e4 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.2/Ex8.10_2.R @@ -0,0 +1,9 @@ +#Page.No 8.36 + +#Raw score method + +X<-c(10,15,18,22,25) +Y<-c(32,18,25,21,24) + +r<-cor(X,Y,method="pearson") +cat("The coefficient of correlation is ",r,"low negative") \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.3/Ex8.10_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.3/Ex8.10_3.R new file mode 100644 index 00000000..1837b33d --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.3/Ex8.10_3.R @@ -0,0 +1,8 @@ +#Page.No 8.37 + +x<-c(5,10,15,20,80) +y<-c(30,37,80,90,95) + +r<-cor(x,y,method="pearson") + +cat("The coefficient of correlation is ",r,"moderate positive") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.4/Ex8.10_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.4/Ex8.10_4.R new file mode 100644 index 00000000..8b402102 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.10.4/Ex8.10_4.R @@ -0,0 +1,8 @@ +#Page.No 8.39 - 8.40 + +x<-c(5,4,6,8,7) +y<-c(4,6,7,8,5) + +r<-cor(x,y,method="pearson") + +cat("The coefficient of correlation is ",r,"moderate positive") \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.1/Ex8.11_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.1/Ex8.11_1.R new file mode 100644 index 00000000..7168268f --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.1/Ex8.11_1.R @@ -0,0 +1,49 @@ +#Page.No 8.41 - 8.43 + +library("ltm") + +#The data +low_value<-9.5 +high_value<-34.5 +step_value<-5 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) + +#Trained data +f1<-c(4,3,6,5,2) +data1<-rep(X_mid,f1) + +#Untrained data +f2<-c(8,6,12,10,4) +data2<-rep(X_mid,f2) + +# Calculation of correlation + +X_mid +f<-f1+f2 +d<-rep(X_mid,f) +#d<-c(rep(12,12),rep(17,9),rep(22,18),rep(27,15),rep(32,6)) #Mid points and their total frequency + +# 0 represents trained and 1 represents untrained +# y gives trainded and untrained groups with their respective frequencies + +y<-c(rep(0,4),rep(1,8),rep(0,3),rep(1,6),rep(0,6),rep(1,12),rep(0,5),rep(1,10),rep(0,2),rep(1,4)) + + +biserial.cor(d,y) + +"The answer given in the book is wrong" + +# Book error +# mean of trained data +Mp<-mean(data1) +print(Mp) +"which is correct " + +# Mean of Untrained data" +Mq<-mean(data2) +print(Mq) +"They mentioned it as 20.9" + +# The difference will be zero hence the whole answer will become zero +Mp-Mq diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.2/Ex8.11_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.2/Ex8.11_2.R new file mode 100644 index 00000000..8c6432fb --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.2/Ex8.11_2.R @@ -0,0 +1,35 @@ +#Page.No 8.44-8.46 + +library("ltm") + +#The data +low_value<-9.5 +high_value<-79.5 +step_value<-10 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) + +#Trained data +f1<-c(2,2,4,7,4,3,3) +data1<-rep(X_mid,f1) + +#Untrained data +f2<-c(8,9,9,9,4,4,7) +data2<-rep(X_mid,f2) + + +# Calculation of correlation + +f<-f1+f2 +X_mid +d<-rep(X_mid,f) + +# 0 represents trained and 1 represents untrained +# y gives trainded and untrained groups with their respective frequencies +y<-c(rep(0,2),rep(1,8),rep(0,2),rep(1,9),rep(0,4),rep(1,9),rep(0,7),rep(1,9),rep(0,4),rep(1,4),rep(0,3),rep(1,4),rep(0,3),rep(1,7)) + +rbis<-biserial.cor(d,y) + +cat("Bi-serial correlation is ",rbis,"which is low positive") + +"The answer may slightly vary due to roundingoff values" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.3/Ex8.11_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.3/Ex8.11_3.R new file mode 100644 index 00000000..497a0e77 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.11.3/Ex8.11_3.R @@ -0,0 +1,40 @@ +#Page.No 8.47- 8.48 + +library("ltm") + +#The data +low_value<-4.5 +high_value<-19.5 +step_value<-3 +X_breaks<-seq(low_value,high_value,step_value) +X_mid<-seq(low_value+step_value/2, high_value-step_value/2, step_value) + +#Trained data +f1<-c(4,4,5,4,3) +data1<-rep(X_mid,f1) + +#Untrained data +f2<-c(7,5,14,7,7) +data2<-rep(X_mid,f2) + + +# Calculation of correlation + +f<-f1+f2 # Total frequency +X_mid # mid point +d<-rep(X_mid,f) + +# 0 represents trained and 1 represents untrained groups +# y gives trainded and untrained groups with their respective frequencies +y<-c(rep(0,4),rep(1,7),rep(0,4),rep(1,5),rep(0,5),rep(1,14),rep(0,4),rep(1,7),rep(0,3),rep(1,7)) + +rbis<-biserial.cor(d,y) +cat("The bi-serial correlation is",rbis,"Negligible Negative") +"The answer given in the book is wrong " + +# Book Error +#negative correlation +# Mean values given differ from the actual mean values +mean(data1) # Mp +mean(data2) #Mq + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.12.1/Ex8.12_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.12.1/Ex8.12_1.R new file mode 100644 index 00000000..5f8a70d3 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.12.1/Ex8.12_1.R @@ -0,0 +1,11 @@ +#Page.no 8.48 - 8.50 + +scores<-c(35,40,32,31,20,18,12,32,10,10) + +items<-c(1,1,1,1,0,0,0,1,0,0) + +library("ltm") # Packge contains point biserial correlation function + +r_pbis<-biserial.cor(scores,items,level = 2) + +cat("Point-biserial correlation is ",r_pbis) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.12.2/Ex8.12_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.12.2/Ex8.12_2.R new file mode 100644 index 00000000..b40c5aac --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.12.2/Ex8.12_2.R @@ -0,0 +1,10 @@ +#Page.No 8.51-8.52 + +scores<-c(40,80,90,17,25) +items<-c(1,1,1,0,0) + +library("ltm") # Packge contains point biserial correlation function + +r_pbis<-biserial.cor(scores,items,level = 2) + +cat("Point-biserial correlation is ",r_pbis,"high positive") \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.13.1/Ex8.13_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.13.1/Ex8.13_1.R new file mode 100644 index 00000000..2b22680a --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.13.1/Ex8.13_1.R @@ -0,0 +1,18 @@ +#Page.No 8.53 - 8.57 + + +r12<-0.9 # correlation between 1st and 2nd variable +r13<-0.6 # correlation between 1st and 3rd variable +r23<-0.2 # correlation between 2nd and 3rd variable + +# (a) keeping 3rd variable constat +r12.3<-(r12-(r13*r23))/(sqrt(1-r13^2)*sqrt(1-r23^2)) + +# (b) keeping 1st variable constant +r23.1<-(r23-(r12*r13))/(sqrt(1-r12^2)*sqrt(1-r13^2)) + +#(c)Keeping 2nd variable constant +r13.2<-(r13-(r12*r23))/(sqrt(1-r12^2)*sqrt(1-r23^2)) + +cat("The partial correlation coefficients keeping the + 1st 2nd 3rd variables as constant respectly are",r23.1,r13.2,r12.3) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.13.2/Ex8.13_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.13.2/Ex8.13_2.R new file mode 100644 index 00000000..b730704d --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.13.2/Ex8.13_2.R @@ -0,0 +1,18 @@ +#Page.No 8.55 + +r12<-15.7 # correlation between 1st and 2nd variable +r13<-0.80 # correlation between 1st and 3rd variable +r23<-4 # correlation between 2nd and 3rd variable + +# (a) keeping 3rd variable constat +r12.3<-(r12-(r13*r23))/(sqrt(1-r13^2)*-sqrt(abs(1-r23^2))) + +# (b) keeping 1st variable constant +r23.1<-(r23-(r12*r13))/(-sqrt(abs(1-r12^2))*-sqrt(abs(1-r13^2))) + +#(c)Keeping 2nd variable constant +r13.2<-(r13-(r12*r23))/(-sqrt(abs(1-r12^2))*-sqrt(abs(1-r23^2))) + +cat("The partial correlation coefficients keeping the + 1st 2nd 3rd variables as constant respectly are",r12.3,r13.2,r23.1) + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.14.1/Ex8.14_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.14.1/Ex8.14_1.R new file mode 100644 index 00000000..af7ebcac --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.14.1/Ex8.14_1.R @@ -0,0 +1,15 @@ +#Page.No 8.57 - 8.59 + +A<-30 +B<-40 +C<-20 +D<-30 + +ans<-(180*sqrt(B*C)/(sqrt(A*D)+sqrt(B*C))) + +cat("converting cos",ans,"to r gives correlation value") + +rt<-0.087 # From the table value corresponding to cosine + +cat("tetrachoric correlation is",rt,"positively correlated") + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.14.2/Ex8.14_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.14.2/Ex8.14_2.R new file mode 100644 index 00000000..f5fe87e2 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.14.2/Ex8.14_2.R @@ -0,0 +1,15 @@ +#Page.No 8.59 + +A<-50 +B<-35 +C<-40 +D<-25 + +ans<-(180*sqrt(A*D)/(sqrt(B*C)+sqrt(A*D))) + +cat("converting cos",ans,"to r gives correlation value") # From the table value + +rt<-0.087 # From the table value corresponding to cosine +# since AD greater than BC correlation is negative + +cat("tetrachoric correlation is",-rt,"Negatively correlated") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.15.1/Ex8.15_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.15.1/Ex8.15_1.R new file mode 100644 index 00000000..48875953 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.15.1/Ex8.15_1.R @@ -0,0 +1,9 @@ +#Page.No 8.60 - 8.61 + +library("psych") # attaching the function + +t<-c(50,80,60,40) # vector of frequencies + +Phi_coefficient<-phi(t,digits = 4) + +cat("The phi coeffient is ",Phi_coefficient) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.15.2/Ex8.15_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.15.2/Ex8.15_2.R new file mode 100644 index 00000000..ab6e763e --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.15.2/Ex8.15_2.R @@ -0,0 +1,9 @@ +#Page.No 8.61-8.62 + +library("psych") # attaching the function + +t<-c(50,40,30,15) # vector of frequencies + +Phi_coefficient<-phi(t,digits = 4) + +cat("The phi coeffient is ",Phi_coefficient,"Low negative correlation") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.1/Ex8.8_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.1/Ex8.8_1.R new file mode 100644 index 00000000..b4e4a983 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.1/Ex8.8_1.R @@ -0,0 +1,14 @@ +# Page.No 8.8 - 8.9 + +# Spearman's Rank Difference Method +score_in_maths<-c(77,83,85,65,50,60,70,80,78,82) +score_in_science<-c(85,60,70,50,40,45,46,44,42,47) + +# Ranks of the scores +R1<-rank(score_in_maths) +R2<-rank(score_in_science) + +# Correlation coefficient +P<-cor(R1,R2) +cat("There is moderate positive correlation i.e ",P) +round(P,digits = 1) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.10/Ex8.8_10.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.10/Ex8.8_10.R new file mode 100644 index 00000000..936cabd0 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.10/Ex8.8_10.R @@ -0,0 +1,13 @@ +# Page.No 8.19 + +#Given Scores +X<-c(45,48,52,47,49,50,46,51) +Y<-c(70,72,80,75,73,76,71,71) + +# Ranks of scores +R1<-rank(X) +R2<-rank(Y) + +P=cor(R1,R2) + +cat("Hence the correlation coefficient is",P , " i.e moderate") \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.11/Ex8.8_11.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.11/Ex8.8_11.R new file mode 100644 index 00000000..bd29f62a --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.11/Ex8.8_11.R @@ -0,0 +1,12 @@ +#Page.N# Page.No 8.20 + +marks_in_maths<-c(50,26,46,25,31,22,29,30,28,18) +marks_in_g.Sci<-c(40,35,34,30,32,28,28,32,29,15) + +#Ranks of the marks +R1<-rank(marks_in_maths) +R2<-rank(marks_in_g.Sci) + +P=cor(R1,R2) + +cat("Here the coeffient of co-ordinatore",P ,"Highly Positive") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.2/Ex8.8_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.2/Ex8.8_2.R new file mode 100644 index 00000000..2a8c8b96 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.2/Ex8.8_2.R @@ -0,0 +1,9 @@ +#Page.No 8.9 - 8.10 + +# Rank of students by teachers +teacher1<-c(1,2,3,4,5) +teacher2<-c(4,3,2,1,5) + +r<-cor(teacher1,teacher2) + +cat("Their is ",r,"or No correlation") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.3/Ex8.8_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.3/Ex8.8_3.R new file mode 100644 index 00000000..1482a1d2 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.3/Ex8.8_3.R @@ -0,0 +1,9 @@ +# Page.No 8.10-8.11 + +# Rank of the students +Rank_in_theory<-c(1,10,2,9,4,8,7,5,6,3) +Rank_in_practical<-c(10,1,4,2,9,3,7,5,6,8) + +p<-cor(Rank_in_theory,Rank_in_practical) + +cat("There is high negative correlation i.e ",p) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.4/Ex8.8_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.4/Ex8.8_4.R new file mode 100644 index 00000000..cfd0ddc3 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.4/Ex8.8_4.R @@ -0,0 +1,13 @@ +#Page.No 8.11 + +#Marks of the five students +marks_in_english<-c(78,80,81,60,90) +marks_is_science<-c(80,83,85,95,50) + +# Ranks +R1<-rank(marks_in_english) +R2<-rank(marks_is_science) + +P<-cor(R1,R2) + +cat("There is Negative correlation i.e ",P) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.5/Ex8.8_5.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.5/Ex8.8_5.R new file mode 100644 index 00000000..9f155c9a --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.5/Ex8.8_5.R @@ -0,0 +1,13 @@ +#Page.No 8.12 + +# Scores in test +scores_in_oriya<-c(40,40,50,30,60,80,90) +scores_in_Geography<-c(50,60,40,40,50,80,95) + +# Ranks +R1<-rank(scores_in_oriya) +R2<-rank(scores_in_Geography) + +P<-cor(R1,R2) + +cat("There is High positive correlation i.e ",P) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.6/Ex8.8_6.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.6/Ex8.8_6.R new file mode 100644 index 00000000..27c8578e --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.6/Ex8.8_6.R @@ -0,0 +1,13 @@ +#Page.no 8.12 - 8.15 + +# Ranks of five students by examiners +R1<-c(3,2,1,4,5) +R2<-c(4,5,3,2,1) +R3<-c(5,4,2,3,1) + +P12<-cor(R1,R2) # Rank correlation between examiner 1 and 2 +P23<-cor(R2,R3) # Rank correlation between examiner 2 and 3 +P13<-cor(R1,R3) # Rank correlation between examiner 1 and 3 + +cat("The rank correlation between Examiners is",P12,P13,P23) +# above three correlations P23 have the highest co-relations diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.7/Ex8.8_7.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.7/Ex8.8_7.R new file mode 100644 index 00000000..3cbc8ccf --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.7/Ex8.8_7.R @@ -0,0 +1,13 @@ +#Page.No 8.15 - 8.16 + +# Rank in efficiency +Rx<-c(1,2,3,4,5,6,7,8,9,10) + +length_of_services_in_years<-c(15,12,10,11,13,10,10,18,11,13) + +Ry<-rank(length_of_services_in_years) + +P<-print(cor(Rx,Ry),digits=0) + +#Hence there is no correlaion between the experience + # and efficiency of employees \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.8/Ex8.8_8.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.8/Ex8.8_8.R new file mode 100644 index 00000000..b61f994f --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.8/Ex8.8_8.R @@ -0,0 +1,14 @@ +# Page.No 8.16 + +X<-c(57,58,33,58,60,63,71,63,74,63) # Scores on creativity + +Y<-c(92,100,100,98,102,95,100,99,106,104) # Scores of intelligence + +# Ranks of scores +R1<-rank(X) +R2<-rank(Y) + +P=cor(R1,R2) # Correlation + +cat("Hence the correlation coefficient between creativity + and intelligence scores of the student is",P) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.9/Ex8.8_9.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.9/Ex8.8_9.R new file mode 100644 index 00000000..7769da2b --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.8.9/Ex8.8_9.R @@ -0,0 +1,11 @@ +#Page.no 8.18 + +test_scores1<-c(50,56,59,62,65) +test_scores2<-c(22,34,28,30,32) + +# Ranks of the given scores +R1<-rank(test_scores1) +R2<-rank(test_scores2) + +P<-cor(R1,R2) +cat("The coefficient of correlation is",P,"which is very low") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.1/Ex8.9_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.1/Ex8.9_1.R new file mode 100644 index 00000000..95a36b60 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.1/Ex8.9_1.R @@ -0,0 +1,20 @@ +# Page.No 8.22 - 8.25 + +#(i) By rank difference method +marks_in_history<-c(6,8,4,5,2) +marks_in_engilsh<-c(9,6,12,10,13) + +#Ranks of marks +R1<-rank(marks_in_history) +R2<-rank(marks_in_engilsh) + +P<-cor(R1,R2) # Correlation + +cat("The correlation is ",P,"Perfect negative correlation") + + +##(ii) By product moment method + +r<-cor(marks_in_history,marks_in_engilsh,method = "pearson") +cat("The correlation is",r,"It is very high negative correlation") + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.2/Ex8.9_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.2/Ex8.9_2.R new file mode 100644 index 00000000..af3b4631 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.2/Ex8.9_2.R @@ -0,0 +1,8 @@ +# Page.No 8.25 - 8.26 + +# Scores +X<-c(55,65,25,50,40,35,15,20,50,45) +Y<-c(50,75,45,55,50,25,35,40,70,55) + +r<-cor(X,Y,method = "pearson") +cat("coefficient of correlation is ",r,"It is a high positive correlation") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.3/Ex8.9_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.3/Ex8.9_3.R new file mode 100644 index 00000000..5895c3a4 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.3/Ex8.9_3.R @@ -0,0 +1,10 @@ +# Page.No 8.27 - 8.28 + +# Scores +X<-c(60,51,43,56,39,48,59,44,37,55) +Y<-c(46,35,35,42,31,34,48,31,30,44) + +r<-cor(X,Y,method = "pearson") + +cat("coefficient of correlation of the given set is ",r, + "which is very high positive correlation") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.4/Ex8.9_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.4/Ex8.9_4.R new file mode 100644 index 00000000..e53ed3af --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH8/EX8.9.4/Ex8.9_4.R @@ -0,0 +1,10 @@ +# Page.No 8.28 - 8.29 + +#Scores +X<-c(65,60,50,40,30,20,80) +Y<-c(50,55,80,90,85,79,77) + +r<-cor(Y,X,method = "pearson") + +cat("The product moment co-efficient of correlation between the above sets of scores is ",r) +"The answer provided in the text book is wrong" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.1/Ex9.7_1.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.1/Ex9.7_1.R new file mode 100644 index 00000000..3b9aa975 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.1/Ex9.7_1.R @@ -0,0 +1,8 @@ +#Page.No 9.13 - 9.14 + +#(a) +ans<-(pnorm(60, mean=50, sd=6)-pnorm(40, mean=50, sd=6))*100 + +cat("Percentage of cases lie between 40 and 60 is",ans) + +"The answer may slightly vary due to rounding off values" diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.2/Ex9.7_2.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.2/Ex9.7_2.R new file mode 100644 index 00000000..7133bc6d --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.2/Ex9.7_2.R @@ -0,0 +1,9 @@ +# Page.no 9.14 + +# To compare scores on tow different tests +z1<-scale(70,center = 75,scale = 10) +z2<-scale(60,center = 50,scale = 6) + +cat("z-score in mathematics is",z2, + "which is greater than z-score in general science",z1) +"so his performance is better in mathematics" \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.3/Ex9.7_3.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.3/Ex9.7_3.R new file mode 100644 index 00000000..edc74d1c --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.3/Ex9.7_3.R @@ -0,0 +1,11 @@ +# Page.no. 9.15 + +# To determine the percentile rank of candidate in his group +scale(50,center = 60,scale = 6) + +pnorm(50, mean=60, sd=6)*100 + +ans<-round(pnorm(50, mean=60, sd=6),digits = 2)*100 + +cat("The percentile rank of the student who secored 50 marks + in an achievement test is ",ans,"%") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.4/Ex9.7_4.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.4/Ex9.7_4.R new file mode 100644 index 00000000..e90c8eba --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.4/Ex9.7_4.R @@ -0,0 +1,10 @@ +# Page.no. 9.16 + +#To determine percentile rank of a candidate +# To find the z- score +scale(60,center = 50,scale = 6) + +#to find the percentage +ans<-round(pnorm(60, mean=50, sd=6),digits = 2)*100 + +cat("The percentile rank of the student is ",ans) diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.5/Ex9.7_5.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.5/Ex9.7_5.R new file mode 100644 index 00000000..fbdb81c6 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.5/Ex9.7_5.R @@ -0,0 +1,11 @@ +#Page.No 9.16 - 9.17 + +#To determine the limits of the scores +# To find the z- score +Z1<-scale(60,center = 50,scale = 5) +Z2<-scale(40,center = 50,scale = 5) + +#To find percentage of cases +ans<-(pnorm(60, mean=50, sd=5)-pnorm(40, mean=50, sd=5))*100 + +cat("Percentage of cases lie between",Z2," and",Z1,"is",ans,"%") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.6/Ex9.7_6.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.6/Ex9.7_6.R new file mode 100644 index 00000000..5b2e0fc6 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.6/Ex9.7_6.R @@ -0,0 +1,9 @@ +#Page.No 9.17 + +# To determine the relative difficulty of the test items +A<--qnorm(0.30) +B<--qnorm(0.40) + +cat("difficulty values of A and B respectively are ",A,B) + +"Question A is relatively difficult" \ No newline at end of file diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.7/Ex9.7_7.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.7/Ex9.7_7.R new file mode 100644 index 00000000..3cba689a --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.7/Ex9.7_7.R @@ -0,0 +1,22 @@ +#Page.No 9.17-9.18 +# To determine the percentage of cases that are above and below given scores + +# To find the z- score +scale(55,center = 52,scale = 5) + +# (a) to find the percentage of cases lie above 55 + +ans<-round(pnorm(55, mean=52, sd=5,lower.tail = FALSE)*100,digits = 2) +cat("The percentage of cases lie above 55 i.e above 0.6sd is ",ans,"%") + +# (b) to find the percentage of cases lie below 55 + +ans<-round(pnorm(55, mean=52, sd=5,lower.tail = TRUE)*100,digits = 2) +cat("The percentage of cases lie above 55 i.e below 0.6sd is ",ans,"%") + +# (C) to find the percentage of cases lie below 50 +scale(50,center = 52,scale = 5) + +ans<-round(pnorm(50, mean=52, sd=5,lower.tail = TRUE)*100,digits = 2) +cat("The percentage of cases lie above 50 i.e above -0.4sd is ",ans,"%") + diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.8/Ex9.7_8.R b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.8/Ex9.7_8.R new file mode 100644 index 00000000..c3a7a714 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/CH9/EX9.7.8/Ex9.7_8.R @@ -0,0 +1,6 @@ +#Page.NO 9.19 +# To determine the score of a candidate whose percentile rank is known + +X<-qnorm(0.84,50,7) + +cat("Thus a candidate secured",X,"marks in an achievement test") diff --git a/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/README.txt b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/README.txt new file mode 100644 index 00000000..7f9bb035 --- /dev/null +++ b/Statistics_In_Education_And_Psychology_by_P._C._Dash_&_Bhabagrahi_Biswal/README.txt @@ -0,0 +1,18 @@ +About The Contributor + +Contributed By: Nivedha R +Course: M.sc(ag)statistics +Branch: Information Technology +College/Institute/Organization: Tamil Nadu Agricultural University + +About The Book + +Book: Statistics In Education And Psychology +Author: P. C. Dash & Bhabagrahi Biswal +Publisher: Dominant Publishers & Distributors Pvt Ltd +Year Of Publication: 2009 +ISBN: 978-93-82007-64-7 +Edition: 2 + + +Textbook Companion Project By FOSSEE, IIT Bombay diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.16/Ex1_16.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.16/Ex1_16.R new file mode 100644 index 00000000..6bba2e24 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.16/Ex1_16.R @@ -0,0 +1,3 @@ +#Describing distribution with numbers (Stemplots) +x<- c(7.2,5.7,6.0,5.0,12.8,7.8,11.6,4.6,2.7,4.9,5.8,13.8,1.5,4.6,3.7,8.3,7.0,3.2,5.8,1.0,7.2,8.0,3.2,7.5,5.4,5.3,6.9,5.8,5.0,9.4,10.4,4.3,6.8,1.0,5.5,5.1,4.6,6.6,4.7,6.1,5.7,1.0,3.8,7.3,6.5,3.0,3.9,8.0,3.0,7.9) +stem(x,scale = 2) \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.20/Ex1_20.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.20/Ex1_20.R new file mode 100644 index 00000000..24f3a6fb --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.20/Ex1_20.R @@ -0,0 +1,3 @@ +#Describing distribution with numbers (Stemplots) +x<- c(23,4,29,44,47,24,40,23,23,44,33,27,60,46,61,11,23,62,31,44,77,14,65,42) +stem(x,scale = 2) \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.21/Ex1_21.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.21/Ex1_21.R new file mode 100644 index 00000000..6ef0124d --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.21/Ex1_21.R @@ -0,0 +1,3 @@ +#Finding mean of the data given +x<- c(23,4,29,44,47,24,40,23,23,44,33,27,60,46,61,11,23,62,31,44,77,14,65,42) +mean(x) \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.22/Ex1_22.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.22/Ex1_22.R new file mode 100644 index 00000000..61327d19 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.22/Ex1_22.R @@ -0,0 +1,3 @@ +#Median +x<- c(4,11,14,23,23,23,23,24,27,29,31,33,40,42,44,44,44,46,47,60,61,62,65,77) +median(x) \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.23/Ex1_23.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.23/Ex1_23.R new file mode 100644 index 00000000..ca89f23b --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.23/Ex1_23.R @@ -0,0 +1,7 @@ +#The quartiles +x<- c(4,11,14,23,23,23,23,24,27,29,31,33,40,42,44,44,44,46,47,60,61,62,65,77) +q1<- quantile(x,0.25,type = 2)#q1 is quartile 1 +#Type 2 seems to be the method the course uses to calulate Q1 and Q3 and IQR. Type 7 is the default method used by R. +q1 +q3<- quantile(x,0.75,type = 2)#q3 is quartlie 3 +q3 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.24/Ex1_24.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.24/Ex1_24.R new file mode 100644 index 00000000..4e6ff24c --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.24/Ex1_24.R @@ -0,0 +1,3 @@ +#Boxplot of the given data +x <- c(77,289,128,59,19,148,157,203,126,118,104,141,290,48,3,2,372,140,438,56,44,274,479,211,179,1,68,386,2631,90,30,57,89,116,225,700,40,73,75,51,148,9,115,19,76,138,178,76,67,102,35,80,143,951,106,55,4,54,137,367,277,201,52,9,700,182,73,199,325,75,103,64,121,11,9,88,1148,2,465,25) +boxplot(x, ylim=c(0,3500), ylab= "Call length", xlab="n=80") \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.26/Ex1_26.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.26/Ex1_26.R new file mode 100644 index 00000000..188a6651 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.26/Ex1_26.R @@ -0,0 +1,5 @@ +#Measuring spread: the standard deviation +avg_wages <- c(75,38,27,48,23,23,20,20,26) +mean(avg_wages) +var(avg_wages) +sd(avg_wages) \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.32/Ex1_32.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.32/Ex1_32.R new file mode 100644 index 00000000..0eaca036 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.32/Ex1_32.R @@ -0,0 +1,9 @@ +#Standardizing Potato chip Bag Weights +#for a bag weighing 9.3 ounces. +w<- 9.3 +z <- (w-9.12)/0.15 +z #This shows the standard deviations above the mean. +#for the bag weighing 8.7 ounces. +w<- 8.7 +z <- (w-9.12)/0.15 +z#This shows the standard deviations below the mean. diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.33/Ex1_33.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.33/Ex1_33.R new file mode 100644 index 00000000..3a047e70 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.33/Ex1_33.R @@ -0,0 +1,7 @@ +#Normal Distribution Calculations +x <- seq(600,1600,length= 200) +y <- dnorm(x, mean = 1026, sd= 209) +plot(x,y, type = "l",lwd = 2 ,col="blue") +x <- seq(820,1600,length= 200) +y <- dnorm(x, mean = 1026, sd= 209) +polygon(c(820,x,1600),c(0,y,0),col="red") diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.34/Ex1_34.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.34/Ex1_34.R new file mode 100644 index 00000000..1e936442 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH1/EX1.34/Ex1_34.R @@ -0,0 +1,7 @@ +#Normal distribution calculation with range. +x <- seq(600,1600,length= 200) +y <- dnorm(x, mean = 1026, sd= 209) +plot(x,y, type = "l",lwd = 2 ,col="blue") +x <- seq(720,820,length= 200) +y <- dnorm(x, mean = 1026, sd= 209) +polygon(c(720,x,820),c(0,y,0),col="red") \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.12/Ex2_12.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.12/Ex2_12.R new file mode 100644 index 00000000..7d506c18 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.12/Ex2_12.R @@ -0,0 +1,6 @@ +#Correlation between the variables and the linear relationship. +wm <- read.csv("worldmarket.csv") +cor(wm$Assets,wm$GDP) #finds the correlation between the 2 variables. +plot(wm$GDP, wm$Assets, xlab = "GDP per capita", ylab = "Net assets per capita", xlim = c(30,70), ylim = c(100,400), pch= 19) +model1 <- lm(wm$Assets ~ wm$GDP, data = wm)#linear regression model. +abline(model1, col="red") #plots line showing linear relationship. \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.12/worldmarket.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.12/worldmarket.csv new file mode 100644 index 00000000..c332fbac --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.12/worldmarket.csv @@ -0,0 +1,16 @@ +Country,GDP,Assets +United Kingdom,43.8,199 +Australia,47.4,166 +United States,47.9,191 +Singapore,40,168 +Canada,45.4,170 +Switzerland,67.4,358 +Netherlands,52,242 +Japan,38.6,176 +Denmark,62.6,224 +France,46,149 +Germany,44.7,145 +Belgium,47.1,167 +Sweden,52.8,169 +Spain,35.3,152 +Ireland,61.8,214 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.16/Ex2_16.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.16/Ex2_16.R new file mode 100644 index 00000000..9bcaeabc --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.16/Ex2_16.R @@ -0,0 +1,4 @@ +#GDP and assets results using softwares +wm <- read.csv("worldmarket.csv") +model1 <- lm(wm$Assets ~ wm$GDP, data = wm)# making linear regression model of the data. +summary(model1) #summary of the linear model. \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.16/worldmarket.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.16/worldmarket.csv new file mode 100644 index 00000000..c332fbac --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.16/worldmarket.csv @@ -0,0 +1,16 @@ +Country,GDP,Assets +United Kingdom,43.8,199 +Australia,47.4,166 +United States,47.9,191 +Singapore,40,168 +Canada,45.4,170 +Switzerland,67.4,358 +Netherlands,52,242 +Japan,38.6,176 +Denmark,62.6,224 +France,46,149 +Germany,44.7,145 +Belgium,47.1,167 +Sweden,52.8,169 +Spain,35.3,152 +Ireland,61.8,214 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.20/Ex2_20.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.20/Ex2_20.R new file mode 100644 index 00000000..dc40e793 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.20/Ex2_20.R @@ -0,0 +1,4 @@ +#Spam Botnets Residuals. +b <- read.csv("spam_botnets.csv") +model1<- lm(b$Spams_per_day~b$Bots) +residuals(model1)#gives the residual values. \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.20/spam_botnets.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.20/spam_botnets.csv new file mode 100644 index 00000000..55a1ebf9 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.20/spam_botnets.csv @@ -0,0 +1,11 @@ +Botnets,Bots,Spams_per_day +Srizbi,315,60 +Bobax ,185,9 +Rustock,150,30 +Cutwail ,125,16 +Storm ,85,3 +Grum,50,2 +Ozdok,35,10 +Nucrypt,20,5 +Wopla,20,0.6 +Spamthru,12,0.35 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.21/Ex2_21.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.21/Ex2_21.R new file mode 100644 index 00000000..a2821525 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.21/Ex2_21.R @@ -0,0 +1,6 @@ +#Residual Plot for Spam Botnets. +b <- read.csv("spam_botnets.csv") +model1<- lm(b$Spams_per_day~b$Bots) +plot(b$Bots,residuals(model1), xlab = "Bots (thousands)", ylab = "Residuals", xlim = c(0,400)) +#this will plot Bots vs residuals scatterplot. +abline(0,0) diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.21/spam_botnets.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.21/spam_botnets.csv new file mode 100644 index 00000000..55a1ebf9 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.21/spam_botnets.csv @@ -0,0 +1,11 @@ +Botnets,Bots,Spams_per_day +Srizbi,315,60 +Bobax ,185,9 +Rustock,150,30 +Cutwail ,125,16 +Storm ,85,3 +Grum,50,2 +Ozdok,35,10 +Nucrypt,20,5 +Wopla,20,0.6 +Spamthru,12,0.35 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.22/Ex2_22.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.22/Ex2_22.R new file mode 100644 index 00000000..2f6baf20 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.22/Ex2_22.R @@ -0,0 +1,8 @@ +#Srizbi is influential.Effect on the regression model on removing a particular data. +b <- read.csv("spam_botnets.csv") +r <- b[-c(1),]# removing first row from the data frame b. +plot(b$Bots,b$Spams_per_day, xlab = "Bots (thousands)", ylab = "Spams per day(billions)", xlim = c(0,400)) +model1<- lm(b$Spams_per_day~b$Bots) #linear regression with data of Srizbi. +model2 <- lm(r$Spams_per_day~r$Bots) #linear regression after removing Srizbi. +abline(model1, col="red")#regression line for model1. +abline(model2, lwd =2, lty=2) #regression line for model2. diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.22/spam_botnets.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.22/spam_botnets.csv new file mode 100644 index 00000000..55a1ebf9 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.22/spam_botnets.csv @@ -0,0 +1,11 @@ +Botnets,Bots,Spams_per_day +Srizbi,315,60 +Bobax ,185,9 +Rustock,150,30 +Cutwail ,125,16 +Storm ,85,3 +Grum,50,2 +Ozdok,35,10 +Nucrypt,20,5 +Wopla,20,0.6 +Spamthru,12,0.35 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.23/Ex2_23.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.23/Ex2_23.R new file mode 100644 index 00000000..b69afa45 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.23/Ex2_23.R @@ -0,0 +1,7 @@ +#Effects on Correlation values on removing particular Data. +b <- read.csv("spam_botnets.csv") +r <- b[-grep("Srizbi",b$Botnets),] #removing Srizbi's data. +t <- b[-grep("Bobax",b$Botnets),] #removing Bobax's data. +cor(b$Spams_per_day,b$Bots) #Correlation of all the 10 values. +cor(r$Spams_per_day,r$Bots) #Correlation after removing Srizbi's data. +cor(t$Spams_per_day,t$Bots) #Correlation after removing Babox's data. \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.23/spam_botnets.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.23/spam_botnets.csv new file mode 100644 index 00000000..55a1ebf9 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.23/spam_botnets.csv @@ -0,0 +1,11 @@ +Botnets,Bots,Spams_per_day +Srizbi,315,60 +Bobax ,185,9 +Rustock,150,30 +Cutwail ,125,16 +Storm ,85,3 +Grum,50,2 +Ozdok,35,10 +Nucrypt,20,5 +Wopla,20,0.6 +Spamthru,12,0.35 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.24/Ex2_24.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.24/Ex2_24.R new file mode 100644 index 00000000..5c8d3847 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.24/Ex2_24.R @@ -0,0 +1,6 @@ +#Predicting the value. +target <- read.csv('target.csv') #original dataset +plot(target$Year,target$Stores, xlab = "Year", ylab = "Stores", xlim = c(1988,2010), ylim = c(400,1800)) #plot of original dataset. +tar1 <- target[-grep(2008,target$Year),] #new dataset after removing the rows with value 2008 for variable Year. +model1<- lm(tar1$Stores~tar1$Year) #linear regression model for tar1. +abline(model1, col="red") # plotting the regression line on the plot. \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.24/target.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.24/target.csv new file mode 100644 index 00000000..88c6587d --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.24/target.csv @@ -0,0 +1,6 @@ +Year,Stores +1990,420 +1991,463 +1992,506 +1993,554 +2008,1682 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.3/Ex2_3.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.3/Ex2_3.R new file mode 100644 index 00000000..fbfa0726 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.3/Ex2_3.R @@ -0,0 +1,3 @@ +#Scatterplot of the data stored in csv file. +b <- read.csv("spam_botnets.csv") #reads data from the csv file and stores the data in the variable named b. +plot(b$Bots,b$Spams_per_day, xlab = "Bots (thousands)", ylab = "Spams per day(billions)", xlim = c(0,400)) #plots the scatterplot. \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.3/spam_botnets.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.3/spam_botnets.csv new file mode 100644 index 00000000..55a1ebf9 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.3/spam_botnets.csv @@ -0,0 +1,11 @@ +Botnets,Bots,Spams_per_day +Srizbi,315,60 +Bobax ,185,9 +Rustock,150,30 +Cutwail ,125,16 +Storm ,85,3 +Grum,50,2 +Ozdok,35,10 +Nucrypt,20,5 +Wopla,20,0.6 +Spamthru,12,0.35 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.4/Ex2_4.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.4/Ex2_4.R new file mode 100644 index 00000000..0908ee12 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.4/Ex2_4.R @@ -0,0 +1,4 @@ +#Scatterplot with a straight line. +b <- read.csv("spam_botnets.csv") +plot(b$Bots,b$Spams_per_day, xlab = "Bots (thousands)", ylab = "Spams per day(billions)", xlim = c(0,400), pch= 19) +abline(lm(b$Spams_per_day~b$Bots, data= b), col= "red") # draws a regression line showing relation between the variables. \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.4/spam_botnets.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.4/spam_botnets.csv new file mode 100644 index 00000000..55a1ebf9 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.4/spam_botnets.csv @@ -0,0 +1,11 @@ +Botnets,Bots,Spams_per_day +Srizbi,315,60 +Bobax ,185,9 +Rustock,150,30 +Cutwail ,125,16 +Storm ,85,3 +Grum,50,2 +Ozdok,35,10 +Nucrypt,20,5 +Wopla,20,0.6 +Spamthru,12,0.35 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.5/Ex2_5.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.5/Ex2_5.R new file mode 100644 index 00000000..687cb588 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.5/Ex2_5.R @@ -0,0 +1,3 @@ +#scatterplot of the data +g <- read.csv("govtdebt.csv") +plot(g$Debt2006,g$Debt2007, xlab = "Debt 2006 (US$ billions)", ylab = "Debt 2007 (US$ billions)", xlim = c(0,500), ylim = c(0,500), pch= 19) \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.5/govtdebt.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.5/govtdebt.csv new file mode 100644 index 00000000..09e3f4c2 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.5/govtdebt.csv @@ -0,0 +1,25 @@ +Country,Debt2006,Debt2007 +Luxembourg,0.65,0.78 +lceland,4.04,4.92 +Slovak Republic,18.44,22.79 +New Zealand,21.44,27.82 +Norway,43.03,49.05 +Czech Republic,38.44,49.36 +Australia,43.91,49.45 +Ireland,47.3,55.29 +Finland,77.58,82.54 +Hungary,76.76,90.24 +Denmark,94.29,92.74 +Switzerland,101.28,107.49 +Portugal,142.97,166.06 +Sweden,185.01,182.11 +Poland,164.41,205.97 +Mexico,195.66,216.76 +Austria,204.51,231.56 +Turkey,244.89,286.96 +Korea,295.07,309.34 +Netherlands,278.67,316.07 +Greece,297.93,352.8 +Canada,347.68,389.83 +Belgium,366.91,420.74 +Spain,427.06,464.99 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.6/Ex2_6.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.6/Ex2_6.R new file mode 100644 index 00000000..e2b36abb --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.6/Ex2_6.R @@ -0,0 +1,5 @@ +#Debt of countries with a smooth fit on the plot. +require(graphics) +g<- read.csv("govtdebt.csv") +with(g, scatter.smooth(g$Debt2006,g$Debt2007)) + diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.6/govtdebt.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.6/govtdebt.csv new file mode 100644 index 00000000..09e3f4c2 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.6/govtdebt.csv @@ -0,0 +1,25 @@ +Country,Debt2006,Debt2007 +Luxembourg,0.65,0.78 +lceland,4.04,4.92 +Slovak Republic,18.44,22.79 +New Zealand,21.44,27.82 +Norway,43.03,49.05 +Czech Republic,38.44,49.36 +Australia,43.91,49.45 +Ireland,47.3,55.29 +Finland,77.58,82.54 +Hungary,76.76,90.24 +Denmark,94.29,92.74 +Switzerland,101.28,107.49 +Portugal,142.97,166.06 +Sweden,185.01,182.11 +Poland,164.41,205.97 +Mexico,195.66,216.76 +Austria,204.51,231.56 +Turkey,244.89,286.96 +Korea,295.07,309.34 +Netherlands,278.67,316.07 +Greece,297.93,352.8 +Canada,347.68,389.83 +Belgium,366.91,420.74 +Spain,427.06,464.99 diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.7/Ex2_7.R b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.7/Ex2_7.R new file mode 100644 index 00000000..aa2c50f4 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.7/Ex2_7.R @@ -0,0 +1,4 @@ +#a better smooth for the debt data. +g <- read.csv("govtdebt.csv") +plot(g$Debt2006,g$Debt2007, xlab = "Debt 2006 (US$ billions)", ylab = "Debt 2007 (US$ billions)", xlim = c(0,500), ylim = c(0,500), pch= 19) +lines(lowess(g$Debt2006,g$Debt2007),col="red") #used to smooth the regression line. \ No newline at end of file diff --git a/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.7/govtdebt.csv b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.7/govtdebt.csv new file mode 100644 index 00000000..09e3f4c2 --- /dev/null +++ b/The_Practice_Of_Statistics_For_Business_And_Economics_by_David_S._Moore,_George_P._Mccabe,_Layth_C._Alwan,_Bruce_A._Craig,_William_M._Duckworth/CH2/EX2.7/govtdebt.csv @@ -0,0 +1,25 @@ +Country,Debt2006,Debt2007 +Luxembourg,0.65,0.78 +lceland,4.04,4.92 +Slovak Republic,18.44,22.79 +New Zealand,21.44,27.82 +Norway,43.03,49.05 +Czech Republic,38.44,49.36 +Australia,43.91,49.45 +Ireland,47.3,55.29 +Finland,77.58,82.54 +Hungary,76.76,90.24 +Denmark,94.29,92.74 +Switzerland,101.28,107.49 +Portugal,142.97,166.06 +Sweden,185.01,182.11 +Poland,164.41,205.97 +Mexico,195.66,216.76 +Austria,204.51,231.56 +Turkey,244.89,286.96 +Korea,295.07,309.34 +Netherlands,278.67,316.07 +Greece,297.93,352.8 +Canada,347.68,389.83 +Belgium,366.91,420.74 +Spain,427.06,464.99 -- cgit