0% found this document useful (0 votes)
5 views34 pages

03 R Probability

The document provides an overview of probability concepts relevant to statistical computing and R programming, focusing on definitions, types of probabilities, and their calculations. It covers events, conditional probabilities, intersections, unions, complements, and random variables, distinguishing between discrete and continuous random variables and their respective probability distributions. Additionally, it discusses the properties of probability distributions, including shape, skew, and modality.

Uploaded by

nothinspecialhr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views34 pages

03 R Probability

The document provides an overview of probability concepts relevant to statistical computing and R programming, focusing on definitions, types of probabilities, and their calculations. It covers events, conditional probabilities, intersections, unions, complements, and random variables, distinguishing between discrete and continuous random variables and their respective probability distributions. Additionally, it discusses the properties of probability distributions, including shape, skew, and modality.

Uploaded by

nothinspecialhr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Statistical Computing

&
R Programming

Probability
(Module 3)

Prepared/Adopted/Modified for :
Statistical Computing & R Programming – BCA V Semester
Vidya Vikas First Grade College
Mysore
2025-26
Probability

The concept of probability is central to statistical
reasoning.

A probability is a number that describes the
“magnitude of chance” associated with making a
particular observation or statement.
statement

It’s always a number between 0 and 1 (inclusive)
and is often expressed as a fraction.

Exactly how you calculate a probability depends on
the definition of an event.
Probability

Let’s say you roll a six-sided, fair die.

Let A be the event “you roll a 5 or a 6.”
6

You can assume that each outcome on a standard
die has a probability of occurring 1/6 in any given
roll.

Then, you have
Events and Probability

In statistics, an event refers to a specific outcome that can
occur.

To describe the chance of event A actually occurring, you
use a probability, denoted by Pr(A).
Pr(A)
– At the extremes, Pr(A) = 0 suggests A cannot occur,
occur and
– Pr(A) = 1 suggests that A occurs with complete certainty.
certainty

This is what’s known as a frequentist probability,
probability or
classical probability.
probability
– We are going to study this.
Events and Probability

Let B be the event “It will rain today.”
today

Unlike event A, B is not straight forward to observe in mathematical
sense.
– That is, B can’t be objectively observed and quantity can’t be easily
computed.

But, based on your prior observations/experience, you can say
Pr(B) = 0.6 or something else.

This type of probability is known as Bayesian Probability,
Probability which
uses prior knowledge or subjective belief to calculate probability.
– We are not going to study about this for now
Events and Probability – Multiple Events

Computing probabilities when considering multiple
events is determined by several important rules.

We will consider following 2 events for considering
multiple events :

Assume you roll a standard die and define
– event A to be “you roll a 4 or more”. Pr(A) = ½ and
– event B to be “you roll an even number.” Pr(B) = ½
Conditional Probability

A conditional probability is the probability of one
event occurring after taking into account the
occurrence of another event.
– Pr(A|B) represents “the probability that A occurs, given
that B has already occurred,”
– Pr(B|A) represents “the probability that B occurs, given
that A has already occurred.”

A : you roll a 4 or more ; B : you roll an even number.


Conditional Probability

If Pr(A|B) = Pr(A), then the two events are
independent;

if Pr(A|B) ≠ Pr(A), then the two events are
dependent.

Generally, you can’t assume that Pr(A|B) = Pr(B|A).
Conditional Probability

A : you roll a 4 or more ; B : you roll an even number.

We know Pr(A) = ½.

Consider Pr(A|B) : Probability that the outcome is a 4
or more, given an even number has occurred.

Since there are three even numbers, 2, 4, and 6, the
probability that you roll a 4 or more, assuming an even
number had occurred, is 2/3.

Thus, Pr(A|B) ≠ Pr(A).
– Hence, the two events are not independent.
Intersection
A : you roll a 4 or more ; B : you roll an even number.

The intersection of two events Pr(A ∩ B), and is read as
“the probability that both
A and B occur simultaneously.”

It is common to represent this as
a Venn diagram

Theoretically,


If Pr(A ∩ B) = 0, then A & B are mutually exclusive.
exclusive

In that case, Pr(A ∩ B) = Pr(A) x Pr(B)
Intersection


In our die example, what is the probability that on a
single toss you roll an even number and it’s a 4 or
more?

We know that Pr(A|B) = 2/3 and Pr(B) = 1/2

Hence Pr( A ∩ B) = 2/3 × 1/2 = 1/3

A : you roll a 4 or more ; B : you roll an even number.


Union

The union of two events is written as Pr(A ∪ B) and is read as
“the probability that A or B occurs.”


Why subtract intersection ? :
– otherwise, we will be counting Pr(A ∩ B) twice.

If A & B are mutually exclusive:

In our die example, what’s the probability that you observe an
even number or one that’s at least 4?

Pr(A ∪ B) = 1/2 + 1/2 − 1/3 = 2/3.
A : you roll a 4 or more ; B : you roll an even number.
Complement

The probability of the complement of an event is
written as Pr(Ā) and is read as “the probability that A
does not occur.”


In our die example, what is the
probability that you do not roll
a 4 or greater ?:
Pr(Ā) = 1 − 1/2 = 1/2
A : you roll a 4 or more ; B : you roll an even number.
Random Variables
and
Probability Distributions
Random Variable

A random variable is a variable whose possible
values are outcomes of a random process (or occurs
by chance).
– It associates a numerical value with each outcome of a
random experiment.

For a random variable, there is a probability
associated with the chances of observing a specific
value, or one within a specific interval.
Probability Distribution

A probability distribution is a mathematical function
that defines the likelihood of different outcomes in a
sample space.
– It provides a systematic way to assign probabilities to
various possible events or values of a random variable.

In other words, a probability distribution describes
how the probabilities are spread across the different
possible outcomes or values.
Realizations

Random variables deals with the consideration of
possible outcomes of a variable.

When you’ve actually made observations of a
random variable, these are referred to as
realizations.

Suppose you roll a die.
– Define the random variable Y to be the result.
– The possible realizations are Y = 1, Y = 2, Y = 3, Y = 4,
Y = 5, and Y = 6.
Realizations

Suppose you roll a die.
– Define the random variable Y to be the result.
– The possible realizations are Y = 1, Y = 2, Y = 3, Y = 4, Y = 5, and
Y = 6.

Suppose you plan to play cricket tomorrow.
– Define the random variable W to be the temperature tomorrow.
– Technically, the possible realisations of W lie in the interval
-∞ < W < ∞

Y is a discrete random variable;

W is a continuous random variable.
Discrete and Continuous Random Variables

Discrete Random Variable :
– For a countable number of distinct values.

Examples include the number of heads in multiple coin flips or the
outcome of rolling a six-sided die.

Continuous Random Variable :
– For an uncountably infinite number of possible values within
a range.

Examples include the height of a person, the time it takes for an
event to occur, or the temperature measured with a thermometer.
Discrete Random Variables

Probability distributions of discrete random variables are
called probability mass functions.

A Probability Mass Function (PMF) is a way to describe the
likelihood of each possible outcome of a discrete random
variable. It tells you the chance of each possible outcome
happening

For each possible value x of the random variable, the PMF
is denoted as P(X=x), representing the probability of X
taking the value x.

The sum of all these probabilities for all possible values
equals 1

Probability Mass Function (PMF) :
Discrete Random Variables

Example PMF for a Fair Die:

P(X=1) = P1 = 1/6

P(X=2) = P2 = 1/6

P(X=3) = P3 = 1/6

P(X=4) = P4 = 1/6

P(X=5) = P5 = 1/6

P(X=6) = P6 = 1/6

The sum of these probabilities is 1.
Discrete Random Variables

A cumulative probability for a random variable X is “the
probability of observing less than or equal to x” and written as
Pr(X ≤ x).

In a die, the cumulative probability at a certain number, say 3
(denoted as P(X ≤ 3)), tells you the chance of rolling a 1, 2, or 3.

Example Cumulative Distribution Function (CDF) for a Fair Die:

F(1) = P(X ≤ 1) = 1/6

F(2) = P(X ≤ 2) = 2/6

F(3) = P(X ≤ 3) = 3/6

F(4) = P(X ≤ 4) = 4/6

F(5) = P(X ≤ 5) = 5/6

F(6) = P(X ≤ 6) = 1
Discrete Random Variables

The cumsum() function is used to get
the cumulative sum.
Discrete Random Variables

The mean, denoted by E(X) or μ, represents the average or central
value of a random variable.

It is the "long-run average" value of X, weighted by probabilities:

Mean (Expected Value):


[Multiply each possible value by its probability, then add them all
up.]
Discrete Random Variables

The variance, denoted by Var(X) or σ2, measures the
degree of spread or dispersion of the random
variable's values.


Alternative (shortcut formula) :

Where
Continuous Random Variables

A continuous random variable has no limit to the
number of possible realizations.

Applies to random variables with an uncountable
number of possible values, often within a range.

Describes the probabilities associated with intervals
or ranges of values rather than individual points.
Continuous Random Variables

A probability distribution tied to a continuous random
variable is called a probability density function.

A Probability Density Function (PDF) is a concept
used to describe the likelihood of different values
occurring for a continuous random variable.

Continuous Random Variables
Continuous Random Variables

any function f(w) that defines a probability density for
a random variable W must possess the following
properties:


Formally, integration is the mathematical operation
used to find areas under a
continuous function, denoted
with the ∫ symbol.
Shape, Skew, and Modality

Some terminology used to describe the appearance
of probability mass and density functions

Symmetry

Skew

Modality
Shape, Skew, and Modality

Symmetry: A distribution is symmetric if you can
draw a vertical line down the center, and it is equally
reflected with 0.5 probability falling on either side of
this center line.

A symmetric probability distribution
implies that the mean and the median
of the distribution are identical.
Shape, Skew, and Modality

Skew : If a distribution is asymmetric, you can qualify your
description further by discussing skew.

When the “tail” of a distribution (in other words,moving away
from its measures of centrality) tapers off longer in one
direction than the other, it is in this direction that the
distribution is said to be skewed.

Positive or right skew indicates a tail extending longer to the right
of center; Negative or left skew refers to a tail extending longer
to the left of center.

You could also qualify the strength or
prominence of the skew.
Shape, Skew, and Modality

Modality : A probability
distribution doesn’t
always necessarily have a single peak.

Modality describes the number of easily identifiable
peaks in the distribution of interest.

Unimodal, bimodal, and trimodal, for example, are
the terms used to describe distributions with one,
two, and three peaks, respectively.
Shape,
Skew,
and
Modality

You might also like