summaryrefslogtreecommitdiff
path: root/R_Book_by_R_Author
diff options
context:
space:
mode:
Diffstat (limited to 'R_Book_by_R_Author')
-rw-r--r--R_Book_by_R_Author/CH4/EX4.1.a/Ex4_1a.R30
-rw-r--r--R_Book_by_R_Author/CH4/EX4.1.c/Ex4_1c.R10
-rw-r--r--R_Book_by_R_Author/README.txt18
3 files changed, 58 insertions, 0 deletions
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