From f7850cf2bb61f9f077091e215ff79ab4c606db6c Mon Sep 17 00:00:00 2001 From: Matan Horovitz Date: Mon, 21 Nov 2022 16:59:23 +0200 Subject: [PATCH] more lectures --- 03112022.R | 14 ++++++++++++++ flip.R | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 03112022.R create mode 100644 flip.R diff --git a/03112022.R b/03112022.R new file mode 100644 index 0000000..6bbd305 --- /dev/null +++ b/03112022.R @@ -0,0 +1,14 @@ +#Here's how to do stuff to the power of other stuff. +une = 8^2 +#And how to do a factorial ([num]!) +duex = factorial(100) +#Excresice from slide with wee buggers. Also, this thing autocorrects comments. Wee shite. +wee_buggers = factorial(6) * factorial(4) +# This is a multiply ^ and it is important +colorful_wee_buggers = factorial(4) * factorial(5) * factorial(6) * factorial(3) +# That is the arrangement of the groups ^ +#Now, try being a bastard. +vectroful_wee_buggers = c(4,5,6) +for (wee_bugger in vectroful_wee_buggers) { + print(wee_bugger) +} \ No newline at end of file diff --git a/flip.R b/flip.R new file mode 100644 index 0000000..117e7eb --- /dev/null +++ b/flip.R @@ -0,0 +1,20 @@ +count = 100 +flip <- sample(c("head","tail"), count, replace =T, prob = c(0.75,0.25)) +table(flip) +is_head <- flip == "head" +table(is_head) +#Each TRUE counts as 1, and FALSE as 0; thus you can figure out amount of heads. +sum(is_head) +freq <- c(1:length(is_head)) +for (result in 1:length(is_head)) { + freq[result] <- sum(is_head[1:result]) +} +rel_freq <- freq/1:length(is_head) +plot(rel_freq) +##### +a <- rep(0,count) + +for (i in 1:count) { + a[i] <- i^2 +} +#SEE cumsum \ No newline at end of file