Most of obligatory assignment 1c done
This commit is contained in:
BIN
Oblig1C/Oblig 1c - Kombinatorikk og sannsynlighet.pdf
Normal file
BIN
Oblig1C/Oblig 1c - Kombinatorikk og sannsynlighet.pdf
Normal file
Binary file not shown.
13
Oblig1C/Oblig1C.Rproj
Normal file
13
Oblig1C/Oblig1C.Rproj
Normal file
@@ -0,0 +1,13 @@
|
||||
Version: 1.0
|
||||
|
||||
RestoreWorkspace: Default
|
||||
SaveWorkspace: Default
|
||||
AlwaysSaveHistory: Default
|
||||
|
||||
EnableCodeIndexing: Yes
|
||||
UseSpacesForTab: Yes
|
||||
NumSpacesForTab: 2
|
||||
Encoding: UTF-8
|
||||
|
||||
RnwWeave: Sweave
|
||||
LaTeX: pdfLaTeX
|
||||
50
Oblig1C/Oppg3RSript.R
Normal file
50
Oblig1C/Oppg3RSript.R
Normal file
@@ -0,0 +1,50 @@
|
||||
install.packages("VennDiagram")
|
||||
|
||||
library(VennDiagram)
|
||||
|
||||
P_A <- 0.8
|
||||
P_B <- 0.2
|
||||
P_AB <- 0.1
|
||||
|
||||
bare_A <- P_A - P_AB
|
||||
bare_B <- P_B - P_AB
|
||||
utenfor <- 1 - (bare_A + bare_B + P_AB)
|
||||
bare_A
|
||||
bare_B
|
||||
utenfor
|
||||
|
||||
#Sjekk at verdier stemmer
|
||||
bare_A + bare_B + utenfor + P_AB
|
||||
|
||||
|
||||
#3b
|
||||
P_union <- P_A + P_B - P_AB
|
||||
P_union
|
||||
|
||||
P_A_uten_B <- bare_A
|
||||
P_A_uten_B
|
||||
|
||||
|
||||
#3c
|
||||
P_komplement_intersection <- 1 - P_AB
|
||||
P_komplement_intersection
|
||||
#DeMorgan's lov sier at P(AB)^c = P(A^c u B^c)
|
||||
#Derfor er sannsynligheten den samme
|
||||
|
||||
|
||||
#3d
|
||||
P_A_gitt_B <- P_AB / P_B
|
||||
P_B_gitt_A <- P_AB / P_A
|
||||
P_A_gitt_B
|
||||
P_B_gitt_A
|
||||
#Forskjellen mellom disse to er at P_A_gitt_B er
|
||||
#sannsynligheten for at A skjer gitt at B allerede
|
||||
#har skjedd - P_B_gitt_A er da sannsynligheten for
|
||||
#at B skjer gitt at A allerede har skjedd
|
||||
|
||||
|
||||
#Venn Diagrammet
|
||||
draw.pairwise.venn(area1 = P_A, area2 = P_B,
|
||||
cross.area = P_AB, category = c("A", "B"),
|
||||
fill = c("lightblue", "pink"),
|
||||
lty = "blank")
|
||||
49
Oblig1C/Oppg3Venn.svg
Normal file
49
Oblig1C/Oppg3Venn.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 108 KiB |
0
Oblig1C/Oppg4RScript.R
Normal file
0
Oblig1C/Oppg4RScript.R
Normal file
Reference in New Issue
Block a user