Docsity

Probability and Statistics: A Comprehensive Guide with Examples - Prof. Bianconcini, Appunti di Statistica

Toggle sidebar
bg1
1
PROBABILITY
Probability Theory
The branch of mathematics that focuses on the likelihood of random events to occur.
o Probability refers to the chance that an event will occur.
Impossible events are assigned a probability of zero.
Certain (sure) events occur at a probability of 100% or 1.
Anything in between these two values (0 and 1) is probable.
o Events are outcomes of probability-producing experiments:
Rolling a die is an experiment that produces different events with corresponding probabilities.
o An elementary event delineates the most basic outcomes of an experiment.
e.g., rolling a 2 on the die.
Rolling an even number (i.e., 2, 4 or 6) on the die is an event that consists of three elementary
events, namely: rolling a 2,4or 6.
o Sample space: collection of all elementary events that can possibly come out of a specific experiment; it is
denoted using curly brackets
For example, the sample space for rolling the die is {1, 2, 3, 4, 5, 6}, and the sample space for tossing a
coin is {H, T}. The sample space for tossing two coins would be {HH, HT, TH, TT}, which
enumerates all possible outcomes of the experiment
Example: Kickstarter
It has a all-or-nothing funding scheme: only projects that reach their
funding goals are deemed successful and receive any money. 36% of the
projects have reached their funding goals. Among the projects that were
not successful (that is, received no funding), various pledge levels were
obtained, shown in the table
Creating a new project on Kickstarter is an experiment.
o It produces two possible events:
• The project is successful (36% of projects are successful, hence the probability of success is 36%).
• The project is not successful (the remaining 64% of projects).
The event ‘unsuccessful project’ can be further broken down into the six elementary events listed in the
table. We thus can define the sample space for the Kickstarter funding experiment as: {0%, 1% to 20%,
21% to 40%, 41% to 60%, 61% to 80%, 81% to 99%, 100%}
Assigning Probabilities
3 possible definitions of probability depending on how you compute probability
o Classical probabilities are derived mathematically by dividing the number of successful outcomes from the
experiment (i.e., the outcomes we are interested in) by the number of all possible outcomes (i.e., the sample
space).
• The probability of rolling a 2 in a single die roll is 1/6.
• The probability of rolling an even number is 3/6.
o Relative frequency uses past data to project probability.
• According to Kickstarter, 36% of past projects were successful, whereas 64% are not. Hence, we
can expect a 36% chance of a future project being successful.
o Subjective probability
• Based on my own beliefs and my interpretation of the world around me.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Anteprima parziale del testo

Scarica Probability and Statistics: A Comprehensive Guide with Examples - Prof. Bianconcini e più Appunti in PDF di Statistica solo su Docsity!

PROBABILITY

Probability Theory The branch of mathematics that focuses on the likelihood of random events to occur. o Probability refers to the chance that an event will occur. Impossible events are assigned a probability of zero. Certain (sure) events occur at a probability of 100% or 1. Anything in between these two values (0 and 1) is probable. o Events are outcomes of probability-producing experiments: Rolling a die is an experiment that produces different events with corresponding probabilities. o An elementary event delineates the most basic outcomes of an experiment. e.g., rolling a 2 on the die. Rolling an even number (i.e., 2, 4 or 6) on the die is an event that consists of three elementary events, namely: rolling a 2,4or 6. o Sample space : collection of all elementary events that can possibly come out of a specific experiment; it is denoted using curly brackets For example, the sample space for rolling the die is {1, 2, 3, 4, 5, 6}, and the sample space for tossing a coin is {H, T}. The sample space for tossing two coins would be {HH, HT, TH, TT}, which enumerates all possible outcomes of the experiment Example : Kickstarter It has a all-or-nothing funding scheme: only projects that reach their funding goals are deemed successful and receive any money. 36% of the projects have reached their funding goals. Among the projects that were not successful (that is, received no funding), various pledge levels were obtained, shown in the table Creating a new project on Kickstarter is an experiment. o It produces two possible events:

  • The project is successful (36% of projects are successful, hence the probability of success is 36%).
  • The project is not successful (the remaining 64% of projects). The event ‘unsuccessful project’ can be further broken down into the six elementary events listed in the table. We thus can define the sample space for the Kickstarter funding experiment as: {0%, 1% to 20%, 21% to 40%, 41% to 60%, 61% to 80%, 81% to 99%, 100%} Assigning Probabilities 3 possible definitions of probability depending on how you compute probability o Classical probabilities are derived mathematically by dividing the number of successful outcomes from the experiment (i.e., the outcomes we are interested in) by the number of all possible outcomes (i.e., the sample space).
  • The probability of rolling a 2 in a single die roll is 1/6.
  • The probability of rolling an even number is 3/6. o Relative frequency uses past data to project probability.
  • According to Kickstarter, 36% of past projects were successful, whereas 64% are not. Hence, we can expect a 36% chance of a future project being successful. o Subjective probability
  • Based on my own beliefs and my interpretation of the world around me.

Two Foundational Rules

  1. The probability of an event is the sum of the probabilities of the elementary events that make the event Probability (P) of an event (E) is equal to the sum of the probabilities assigned to the elementary events (En) comprising the event, where n is the number of elementary events comprising event E: P(E) = P(E1) + P(E2) + P(E3) + … + P(En) Example : P (Rolling an even number) = P(2) + P(4) + P(6) = 1/6 + 1/6 + 1/6 = ½
  2. The sum of all probabilities in the sample space must equal 1 Basic Relationships in VENN DIAGRAMS The Venn diagram is commonly used to describe sets (groups) and their relationships. Here the grey rectangle describes the sample space and the circle represents event A Example: grey area is the ‘group of executives’ and event A is ‘women’ Complement Rule o The complement of an event A is the event consisting of all sample points that are not in A and is denoted by Ac. o Rule: the sum of all probabilities in a sample space must equal 1. It follows that: Intersection and union of events ○ Grey rectangle: sample space (entire group of executives); ○ Circle A (female executives); ○ Circle B (executives with MBA degrees)
  • The shaded area that is covered by both circles A and B is the intersection of the two events, i.e., female executives who have an MBA degree. The intersection of events A and B is the event containing all sample points that are in both A and B → relationship: P(A and B) or as P(A∩B)
  • The total area covered by circle A and circle B (excluding the intersection) represents the union of the two events: here, including executives who are either female or MBA graduates. The union of events A and B is the event containing all sample points that are in A or in B (in other words, in either A or B - not that are in both!). This relationship is denoted as P(A or B) or as P(A∪B) Mutually Exclusive Events o Event C: ‘selecting an executive with brown eyes. o Event D: ‘selecting an executive with blue eyes. o C and D are mutually exclusive (indeed, no common points!) as the occurrence of one event precludes the occurrence of the other Independent Events o Independence means that the probability of some event, A, will not change if another event, B, will occur. o The probability of rolling a 6 on one die is independent of the outcome of the other die. o By contrast , the event ‘it is raining’ and event ‘taking an umbrella’ are not independent, because the probability of taking an umbrella will changing depending on whether it is raining outside

The Multiplication Rule To examine the intersection of two events o We have previously used the contingency table to obtain P(A and B),but we can also compute it from already-known probabilities. o From the discussion on conditional probabilities, we know that: P(A|B) = P(A and B)/P(B)

  • probabilità condizionata: P(A|B) , si legge "la probabilità di A dato B". o And, therefore, we can rearrange this formula to compute: P(A and B) = P(B)P(A|B) =* P(A)P(B|A)* o This formula is known as the multiplication rule. o Example: we know that P(Male)=0.6 and P(MBA/Male)=0.833, so we can compute: P(Male and MBA)=0.60.833=0. o For independent events, the multiplication rule is simplified to: P(A and B) = P(A)P(B) BAYES’ THEOREM The Bayes’ Theorem is a formula for revising initial probability predictions based on relevant new evidence. Example: You’d like to develop a new game app and plan to obtain the funding via Kickstarter. Based on past data, the probability of successfully funding a project is 36%. If we define event S to be ‘successful project funding’: P(S(success)) = 0.36, and P(Sc(complement of S; no succ))=0.64 → initial evidence Then, you see that there is a difference in the success rates of different types of projects → new evidence
  • approximately 8% of the successfully-funded projects were games → P(G|S)=0.
  • approximately 9% of the not-funded projects were games → P(G|Sc)=0. (→ G stands for the event ‘the project belongs to the games category’) So we’ll use conditional probabilities.

→ We are looking for P(S|G). The formula we should use is: P(S|G) = P(S and G)/P(G) The marginal probability , P(G), can be computed as the sum of all joint probabilities in its corresponding column int he contingency table Example : P(S|G)= P(S and G)/P(S and G)+P(Sc and G) = 0.0288/(0.02888+0.0576) = 0. → the success probability for games projects (33.33%) is just slightly lower than the overall success probability of 36% GENERAL FORMAT FOR THE BAYES’ THEOREM: Another Example : An event organizer is considering 3 locations for an upcoming concert: indoors, under the sky, and in a tent. Each location will yield a different layout depending on the weather that day The event planner believes there is a 60% chance of good weather (event G; P(G)=0.6), and 40% chance of bad weather (event Gc; P(Gc)=0.4) → initial evidence However, he then hires an expert weather specialist, who has a good record of past predictions. She has been able to correctly predict good weather 80% of the time when good weather actually occurred → P(PG|G) = 0. We also know that the specialist correctly predicted bad weather (when bad weather actually occurred) 90% of the time → P(PGc|Gc) = 0. The weather specialist has just delivered her report, which predicts good weather conditions. So, what should be the planner’s revised prediction of the weather conditions? Probability Tree : o Drawing showing all possible events with their probabilities o The tree is shown left-to-right, meaning that events that occur first are presented to the left of later events o The sum of all branches coming out of a specific node should be one (graphical equivalent of the complement rule)

DISCRETE PROBABILITY DISTRIBUTION

Probability of distribution: probability of occurrence of expected values. It helps us make inferences about a population of interest Example: number of Twitter followers you can expect ○ Random variable (X): number of followers you may have on Twitter, based on your observations of the followers of your friends ○ P(X) is the probability of each specific X value (so we use lowercase x) ○ The table displays possible values of X alongside the probabilities of occurrence we expect from each value → 29% chance you’ll get no followers, and so on All data associated with a variable of interest follow some distribution. The distribution may be discrete, describing the probabilities of values of a discrete (countable) random variable, such as number of customers walking into a store in a specific timeframe. Or, it may be continuous, describing the probabilities of intervals of a continuous (measurable) random variable, such as income, time, or distance Random Variable

  • A random variable is a variable that may obtain any value within our sample space, at a given probability.
  • The random variable X is defined as the outcome of rolling a single die. X can obtain any number between 1 and 6, with a probability of 1/6.
  • Random variables can be discrete or continuous.
    • Discrete (result of a counting process): outcome of die roll
    • Continuous(result of a measurement process): time it takes to complete a task Probability Distribution
  • A probability distribution describes the probabilities attached to all values (or intervals) of the random variable.
  • They can be discrete or continuous, based on the random variable they describe.
  • Probability distributions can be displayed as a table (discrete) or a graph (continuous). Example You have a great idea for a new financial app and decide to go ahead and develop it. You are interested in learning about your expected number of downloads. Assume that the information in the table is data you have obtained about the probability distribution of daily app downloads. X represents the number of downloads and P(x) is the probability attached to each value of X. For a more accurate estimate, you can compute the mean and variance of the probability distribution → we compute the sum of each value of X weighted (multiplied) by its corresponding probability → expected value of X, E(X), which is the expected value (or mean) of a random variable X is calculated as the weighted mean of values and their respective probability Expected Value The expected value (or mean) of a random variable X is calculated as the weighted mean of values and their respective probability:

Variance

  • The variance of a random variable X measures the spread of values of this random variable: The variance is the sum of the square deviations times the probability of each value. V(X): variance of X σ²: the corresponding notation for the variance expression inside the summation: weighted average of the squared dev. from the mean (μ). Note the difference between lower case x which represents specific values, and upper-case X which represents the random variable. Bivariate Distribution
  • In the previous examples we looked at a single random variable – this is known as a univariate distribution
  • We can also study the distribution of two random variables , called the bivariate distribution. Example : the table displays the joint distribution of two variables: Number of Participants (X) and Call Length (Y) and P(x,y) is the joint probability of specific values of X and Y
  • Similar to the univariate case, we can compute the average and standard deviation for these variables, using their marginal probabilities. First the weighted average and then the variance of X and Y: Average of X, E(X) = 30.2+40.4+50.2+60.1+7*0.1 = 4.5 → av. number of participants! Variance of X, V(X) = (3 − 4.5)²∗0.2+(4 − 4.5)²∗0.4+(5 − 4.5)²∗0.2+(6 − 4.5)²∗0.1+(7 − 4.5)²∗0.1 = 1. Average of Y, E(Y) = 30 ∗ 0.1 + 60 ∗ 0.7 + 90 ∗ 0.2 = 63 → av. length! Variance of Y, V(Y) = (30 − 63)² ∗ 0.1 + (60 − 63)² ∗ 0.7 + (90 − 63)² ∗ 0.2 = 261 Covariance ○ measure of the shared variation in X and Y; ○ measures the extent to which values of X and Y move in the same direction (or in opposite directions). ○ shows whether or not, on average, X and Y tend to move in the same directions vis-à-vis their respective means ➢ A positive value indicates that they do ➢ A negative value indicates they do not ➢ Zero indicates that they’re independent of each other

Online store example: You want to calculate the cart conversion rate, which is the percentage of customers that complete an order after setting the order up in a shopping cart → in your case, 5% conversion rate X = random variable counting the number of website visitors that have converted the cart into a purchase What’s the probability that, out of 100 visitors with items in the cart, six of them will purchase something? About 15% chance that 6 will complete the purchase What is the probability that, out of 100site visitors who have placed items in their shopping cart, between six to ten customers (inclusive) will complete the purchase? P(6≤X≤10) = P(6)+ P(7)+ P(8)+ P(9)+ P(10) Computing the mean and variance of binomial distributions: μ = np → 𝜇 (mean) or E(X) = 100 ∗ 0.05 = 5 σ2 = np(1− p) → 𝜎² (standard deviation) or V(X) = 100 ∗ 0.05 ∗ 0.95 = 4. σ = (^) √𝑛𝑝( 1 − 𝑝) → 𝜎 (variance) = (^) √ 4. 75 = 2. CONTINUOUS PROBABILITY DISTRIBUTION A continuous random variable, X, ○ Can assume an uncountable number of values → can take on any value at a given probability ○ Because there is an infinite number of values: a. We cannot list each and every value b. The probability of each individual value is virtually 0 (for example, what is the probability that tonight you’ll sleep exactly 7h 5min 29s?), so we look at cumulative probabilities across intervals of values (e.g., probability that you sleep less than 7 hours) ○ The probability distribution obtained from a histogram representing the frequency of classes is a continuous probability distribution ○ E.g. the amount of time devoted to studying statistics each week is a continuous random variable Probability Density Function o The probability density function describes the likelihood that the values of X, the continuous random variable, fall within a given interval. o The total area captured between the line and the x-axis is equal to ‘one’, because the sum of all probabilities in a sample space is one o We can compute the probability of X falling in a specific interval along the x- axis by computing the partial area underneath the density function for this interval

TYPES OF DISTRIBUTION

The uniform distribution Assigns an equal likelihood of occurrence to all possible values of X

  • Suppose you want to find out the probability that a flash sale will take place during a twelve-hour time period between 8am and 8pm.
  • We define X, a random variable, as measuring the time of day when the flash sale takes place.
  • Assume that X can take on any value in a 24-hour interval with equal probabilities.
  • X follows a uniform distribution, which assigns an equal likelihood of occurrence to all possible values of X. Because the uniform distribution has a rectangular shape, the probability of X taking a specific range of values, i.e., between x1 and x2, can be computed as in the picture x1 and x2 define the interval of interest and a and b, respectively, are the lower (0) and upper (24) values of the random variable → in the example: P(8am ≤ 𝑋 ≤ 8pm) = (n of hours between 8am and 8pm) * 1/24 = 12/24 = 0.5 Given the result, there is a 50% chance that the flash sale will take place between 8am and 8pm The Normal Distribution ○ Unimodal: has only one peak, which location is determined by the mean ○ Is symmetrical: each half is a mirror image of the other other (the center point is the mean = median = mode). ○ The standard deviation determines the width of the distribution ○ Is asymptotic to the x-axis The t distribution
  • The normal distribution requires either that large samples are available or that the population standard deviation(s) is known. When this is not the case, we work with the similar t- distribution.
  • The t-distribution is similar in shape to the normal distribution (specifically, to a normal distribution with a mean of zero and a standard deviation of one), but its shape also depends on the sample’s number of degrees of freedom.
  • Degrees of freedom refer to the number of data values that are free to vary in a dataset.
  • As the sample becomes large, the t-distribution approaches the normal distribution.

Website example: Value of a customer visit of 4 miniatures is exactly 1 standard deviation below the mean (see above). Indeed, you can calculate that the corresponding Z score for a 4-minute visit is - 1 → Z = (4-5)/1 = - 1 The Empirical Rule (cfr. Midterm 1) 68% of all values lie within 1 standard deviation from the mean 95% of all values lie within 2 standard deviation from the mean 99.7% of all values lie within 3 standard deviation from the mean P-VALUE It is the probability of obtaining a Z score farther away from the mean than a specified Z score value, shown as the absolute value of z. Since we are using the absolute value of z, farther away can mean being either to the right of a positive Z score value or to the left of a negative Z score value → P(Z ≥ |𝑧|) → P(Z ≥ Z) = P(Z ≤ - Z) Example: Left panel: shaded area left of the Z score value of - 2; the p-value for a Z score of - 2 is: P(Z ≤ - 2)= 0. Right panel: shaded area right of Z value 1.7: P (Z ≥ 1.7) = 1-P(Z ≤ 1.7) = 0.0466 → complement rule! INVERSE PROBABILITY CALCULATIONS To find the Z score value that corresponds to a given probability → 𝑃(𝑍 ≤ 𝑧) = probability Graph Example: Find z such that P(Z>z) = 0. Using the complement rule: P(Z<z) = 1- 0 - 025 = 0. Look for this value inside the table to find that it corresponds to a Z value of 1. Therefore z* = 1.96S