शुरू करेंमुफ़्त में शुरू करें

Simulating the probability of A and B

You can also use simulation to estimate the probability of two events both happening.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Foundations of Probability in R

पाठ्यक्रम देखें

अभ्यास निर्देश

  • Randomly simulate 100,000 flips of coin A, each of which has a 40% chance of being heads. Save this as a variable A.
  • Randomly simulate 100,000 flips of coin B, each of which has a 20% chance of being heads. Save this as a variable B.
  • Use the "and" operator (&) to combine the variables A and B to estimate the probability that both A and B are heads.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Simulate 100,000 flips of a coin with a 40% chance of heads
A <- 

# Simulate 100,000 flips of a coin with a 20% chance of heads
B <- 

# Estimate the probability both A and B are heads
कोड संपादित करें और चलाएँ