100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary - Computational probability with R (MAS2906)

Rating
-
Sold
-
Pages
16
Uploaded on
24-04-2025
Written in
2024/2025

Topics covered: • Discrete and continuous random variables • Probability distributions (Binomial, Poisson, Normal, etc.) • Expectation, variance, and moments • Law of Large Numbers and Central Limit Theorem • Monte Carlo simulation • Generating random variables in R • Visualisation and interpretation of results in R

Show more Read less










Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
April 24, 2025
Number of pages
16
Written in
2024/2025
Type
Summary

Content preview

,Week 1 and 2


1) Data
types
:




Logical (true/false)
·




· Character
("string") "data"

·
Double (5 0) .
X = 5 0 .




·

Infinity (infl 2 = 5/0




2) Vectors :

Va C(10
,
20
,
30)
w



naming the vector

VIa second
elementS o the output is 20


3) Data frames :

Each row represents a case or observation Examples to find how
many
we use :



and each column represents a variable sum (names column = = 1)

simple code: data. frame (column 1 Column 2)
name ,
eghow many "action" movies
to see specific rows and columns we use: sum (data s action = = 1)

name[ ,
I which command

raclumn which (name I
budget == max (movies Sbudget ,narm-Truel)
um

7 [2 3]
egname[3 ,
name ,
ignore N A
.





all colums ot row 3 row 2 column 3
,




To find a specific column name we use
,
$ Graphical and numerical summaries


name height (access the
heightcolumn) code : ( S
eg summary
we can do plots from the data frames Wit min 1st median , mean 3rd q , max
gives
·
, q , ,



1) For
histogram : his+ (x)

2) For boxplot : boxplot(x)

(namecolumn "blue")
eg hist ,
breaks-
-
"Sturges" -
col =




default , optional number

4)
Writing functions :
default arguments
-
square s function()E add function (a
1 b
,
= = a) [

return (x" 2) return (a +b)



3 3

square (5) add()
W
so"This wil I return 25
will return 3

, 5) Conditionals and loops :


·
If statements


x= 5


If (xx0)[


print ("positive")

3
·
If-else statements

If the if the condition is false it will allow an alternative condition.


X -
3



If (x > 0) [

print ("positive")

Yelsed
print ("negative")
3
·
If-else - if statements


multiple conditions to be checked



syntax
:




if (condition 1) [

#
code if cone 1 istrue


Jelseif (condition2)E
# code if condit 2 is true
.




JelseE
# code if
nothing above
is true


3


·
For loops

used to repeat a block of code for afixed number of iterations. example
total o

syntax
:



for (variable in sequence) [ for (J in-5 : -1) E

# code to execute in each iteration total <total + exp(j) /ja
3 3

print (total)
£5.36
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
corinageorgiou

Get to know the seller

Seller avatar
corinageorgiou University of Glasgow (Scotland)
View profile
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
2 year
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions