more lectures
This commit is contained in:
14
03112022.R
Normal file
14
03112022.R
Normal file
@@ -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)
|
||||||
|
}
|
||||||
20
flip.R
Normal file
20
flip.R
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user