Independence

  • Two events and can be said to be independent if the probability of their intersection is the product of their probability
  • "Independent events" should not be confused with "disjoint events", for two disjoint events and
  • Example by Julia
using Random
Random.seed!(1)

numbers = 10:25
N = 10^7

first(x) = Int(floor(x/10))
second(x) = Int(x%10)

numThirteen, numFirstIsOne, numSecondIsThree = 0, 0, 0

for _ in 1:N
    X = rand(numbers)
    global numThirteen += X == 13
    global numFirstIsOne += first(X) == 1
    global numSecondIsThree += second(X) == 3
end

probThirteen, probFirstIsOne, probSecondIsThree = 
    (numThirteen, numFirstIsOne, numSecondIsThree) ./ N

println("P(13) = ", round(probThirteen, digits=4),
    "\nP(1_) = ", round(probFirstIsOne, digits=4),
    "\nP(_3) = ", round(probSecondIsThree, digits=4),
    "\nP(1_)*P(3_) = ", round(probFirstIsOne*probSecondIsThree, digits=4))

results matching ""

    No results matching ""