Welcome everyone to this section of the course on data distributions.
In this section, we're going to be exploring concepts that allow us to better understand different
distributions of data.
Recall our discussions of data visualizations and specifically histograms.
Earlier in the course, you should notice that this is actually a visualization of how this particular
dataset is distributed.
So we can almost think of it as modeling the distribution of the data itself.
For example, I can see the distribution of the total bill from the tips data set that we've been exploring.
This allows me to realize that most of the values are going to fall between $10 and $30, meaning that
if I were to randomly pick a bill value, it has a higher likelihood of falling between $10 and $30,
then being above $45.
When thinking about our real world data sets, we can use data distributions to model outcomes depending
on how the data itself is actually distributed.
In this section, we're going to be exploring how to understand distributions and some different types
of common distributions.
So we're going to start off with some higher level ideas behind data distributions, including probability
mass functions and discrete uniform distribution as an example of a PMF or probability mass function.
And then we'll discuss probability density functions and the continuous uniform distribution as an example
of a PDF or probability density function.
Then we'll also talk about cumulative distribution functions.
After that, we'll take a quick tour of some specific distributions like binomial distribution, Bernoulli
distribution, and Poisson distribution.
As you encounter real world data sets, you're going to begin to see behavior and patterns in the distribution
of the data that are actually common characteristics to a particular data distribution, matching a
real world data set to a particular distribution that is some theoretical mathematical model can actually
be a very powerful tool.
For example, understanding that certain data sets in the real world, such as the height of people
are normally distributed, allows you to apply statistical operations related to normal distributions.
As a quick note, we actually cover normal distributions, otherwise known as Gaussian distributions
in the next section because it's actually a very specific and important distribution that shows up a
lot in real life.
So another example could be the binomial distribution, which can help you model events in which you
have a sequence of independent event outcomes, for example, that could be used by a casino to model
out the probability of winning on games such as Blackjack or Bacharach, which could help the casino
itself manage expectations of future revenues from certain tables.
Before we dive deeper into data distribution, let's give you an intuition of how to think about data
distributions, especially the differences between probability mass functions and probability density
functions, which are often confusing to beginners.
Talking about data distributions.
Let's begin with probability mass functions otherwise known as PM.
Now, the formal definition of a probability mass function is, quote, a function that gives the probability
that a discrete random variable is exactly equal to some value.
Now, that's a lot of words.
And this definition can seem very intimidating and confusing at first glance.
But let's break it down and we'll realize it's actually pretty straightforward and it unlocks a lot
of potential use cases for us.
Let's start off with that very last word.
Function.
A function simply takes an input and then applies some transformation and returns the output.
For example, I could define a function as f of x, where x is what you pass into the function and I
could define it as f of x is equal to x plus one.
That's a simple function that simply adds one to the input x, so that f of two is equal to three because
two plus one is equal to three.
Hopefully you already realize that and knew the definition of that sort of function.
That means a probability function is similar, except it's going to return a probability value.
For a probability mass function.
It returns the probability that a discrete random variable is exactly equal to some value.
Let's dive into that idea a little further.
This means a probability mass function can be written as the following F of x is equal to the probability
that X is equal to some particular value.
That is a particular probability value where capital X is the discrete random variable and x is the
certain value.
So let's explore a simple example of a discrete random variable in order to fully understand probability
mass functions.
Imagine you are running a security test program on 100 employees, one of whom is the CEO.
The security test program is going to send a test phishing email to one random employee out of the 100
total employees.
The question arises what is the probability that the CEO is going to be the one to receive the test
phishing email.
Now, you can kind of figure this out in your head, but I want to frame it in terms of probability
mass functions.
Again, notice a few distinct features of the situation.
There are a discrete number of employees 100, and we should also mention they're discrete because there's
really no employees between two employees.
So if you have employee Bob and employee Cindy, there's no employee value that's between Bob and Cindy.
Thus they're discrete and you have 100 separate employees.
We're also interested in the probability of a particular event outcome.
So the discrete number of employees gives you an idea that it should be probability mass instead of
probability density, which will be for continuous situations, which we'll talk about later on.
And again, we're interested in the probability of a particular event outcome where the phishing email
happens to go specifically to the CEO.
This means we have a probability match function.
I'm looking for F of x as my function, where it's going to be the probability that x is equal to a
particular value.
In this case, I'm looking for the probability that X is equal to CEO.
Essentially, what's the probability that this particular event of sending the email happens to go to
the CEO?
If we know there are only 100 employees and they all have an equal or uniform chance of being picked,
then the odds of picking the CEO.
That is, what's the probability that X happens to be equal to the CEO are simply one out of 100 or
0.01 or 1% chance of picking the CEO, which kind of makes sense.
You probably already knew in your head that if you're going to have an equal chance of picking any employee
and only one of them is the CEO, then your chances are one over n or one over 100.
And in this case, since the outcomes were discrete.
Again, we label this as a probability mass function.
It is the discrete outcomes that allow us to model this as a mass function.
And in this particular case we had what's known as a discrete uniform distribution.
Keep in mind that's not always the case.
For example, maybe the CEO could have multiple emails because he or she is so important.
And in that case, maybe it's not going to be uniform because the CEO actually has a higher chance of
being picked.
But in this case, we kept it discrete uniform.
When visualizing probability mass functions, you're going to see a distinct probability points for
each outcome.
For example, if we only had ten employees with equal chances of being chosen, what would the PMF distribution
visual look like?
Well, the probability mass function for ten employees with a uniform chance could be visualized as
the following.
Here we're looking at a visualization of the PMF for the case where there's only ten employees.
So keep a note here that there's no line connecting each particular employee.
That's because each employee is discrete employee number one and employee number two, three and so
on.
There is no employee 2.5.
And then on the Y axis, I can see the probability of picking the employee, which happens to be equal
to one over n or one over ten, which is the same thing as 0.1.
So what about probability density functions?
So what happens in situations where the outcomes are not discrete, for example, instances where the
outcomes are continuous?
In this particular case, that means we're dealing with a probability density function.
The formal definition of a probability density function is the following A function whose value at any
given sample in the sample space can be interpreted as providing a relative likelihood that the value
of the random variable would be close to that sample.
Holy smokes, that's a lot.
So again, let's break it down.
This appears actually kind of similar to the PMF definition.
But the key difference is that we're looking and working with a continuous random variable instead of
what's known as a discrete random variable.
This requires a small shift in our mindset.
Imagine that we're going to now send out the test phishing emails to multiple accounts using a third
party service.
Typically, once we hit send, the emails are sent out within 1 to 3 minutes after we actually push
the button.
No how we're now framing this problem differently.
It's now actually a continuous random variable.
If we're thinking about the question how long after I hit send will the phishing email actually take
to go out to the person?
So now I'm not even thinking about who's the phishing email going to hit.
Instead, I'm thinking about the question after you hit send, how long does it take for the email to
actually reach the inbox?
So, for example, what's the probability of having the email go out over 60 seconds long?
So again, what if we wanted to know the probability that the emails get sent at exactly the one minute
mark and ought to be very clear When I say exactly one minute, I mean precisely.
Exactly one minute.
So 60.00000 0 seconds, etc. after we hit send.
Well, you should be thinking about is does that question even make sense?
It's probably almost impossible that using this third party provider, the email I sent is going to
be sent at exactly 60.000 0 seconds, etc. And the reason for that is because we're now dealing with
a continuous feature or a continuous random variable, because now we're dealing with time instead of
the separate discrete employees.
I now have a continuous random variable that is could be 60 seconds, 61, 62 and there actually are
values in between two points in that random variable.
There are values between 60 seconds and 61 seconds, and there's kind of an infinite amount of values
if I keep getting precise enough.
Hopefully you remember that from our discussions of continuous features.
So for continuous random variables, we switch our thinking from exact outcomes, which we did for discrete
random variables like exactly employee number one or exactly the CEO to either approximations or interval
ranges, since those make way more sense for continuous random variables.
Thus the term the density function.
And if you go back to the original definition, that's why it said close to or approximate a certain
value.
So we're not looking for an exact match to a discrete outcome.
Instead, it starts making a lot more sense for continuous random variables to talk about ranges or
intervals.
For example, it'd be more useful to know what's the probability that the time it takes to send the
email is less than one minute.
So this allows us again, to answer the question what's the probability that emails are sent out in
one minute or less?
And now I'm dealing with a range or an interval, and that makes a lot more sense for a continuous random
variable.
Thus we can think about it as a probability density function.
There are many different types of probability density functions, such as a normal distribution or something
like a Boltzmann distribution.
In fact, there are actually so many different types of distributions, both probability mass functions
and probability density functions.
You can actually view a list of them on Wikipedia, and I would encourage you to visit this link or
just Google search list of probability distributions on Wikipedia and check them all out and explore
them.
Maybe be even a little confused by them, but then understand that they're actually all just examples
of either a PMF or a PDF.
And we're going to dive into a few of them in this particular section of the course.
The key insight for understanding data distributions is that once you can actually connect a real world
set of events or data points to a particular data distribution, you can leverage the properties of
that data distribution to calculate probabilities.
For example, in the very first example that I just talked about in this lecture, where probability
mass functions and security, phishing emails, I had 100 employees, all with an equal chance of being
picked.
That's my real world situation if I think about the theoretical match to it.
It's actually a discrete uniform distribution.
It's discrete because all the employees were discrete and it's uniform since they all had the same probability
of being chosen.
That means I can actually look up the properties of a discrete uniform distribution on something like
Wikipedia, and then I'll realize that there's actually a bunch of formulas already defined.
And in fact, a discrete uniform distribution has a property that the probability of a single discrete
outcome is simply one over n where n is the number of discrete event possibilities.
Our example wn was equal to 100 employees.
Thus the CEO had a one over 100 probability of being picked.
That can seem super obvious to anybody who doesn't even know what theta distributions are.
But as the data distributions get more complex, it becomes necessary to actually look up the formula.
So again, a discrete uniform distribution is a simpler use case where one over MN may have been obvious
even if you didn't realize it was a discrete uniform distribution.
But keep in mind there are many real world situations that match up to more complex data distributions
like a binomial distribution, trying to figure out the odds of winning a hand at blackjack or something
like that.
So calculating those event probabilities would be difficult without referencing prior works or proofs.
So we want to make sure we take advantage of all the work mathematicians have already done for us in
history.
That way we already can connect real world data sets to theoretical data distributions and then we can
match up the properties.
So again, again, fortunately for us, mathematicians of the past such as Bernoulli, have already
done the hard work for us.
We can stand on their shoulders to quickly assess what formulas to use once we know the data distribution
that we're actually working with.
Let's continue exploring data distributions as well as taking a deeper dive into the concepts such as
PMS and PDFs discussed in this lecture.