We said before that a binomial random variable was a special type of discrete random variable.
And what we want to say now is that this Bernoulli random variable is a special kind of binomial random
variable.
And the difference is just that with the Bernoulli random variable, we're modeling exactly one trial,
whereas with the binomial random variable, we were modeling many trials.
So before if we used a binomial random variable to model the probability of flipping a certain number
of heads on a larger number of coin flips, we might have been flipping the coin five times or ten times
or 1000 times.
We had many trials.
When we use a Bernoulli random variable, we drill that down to just one trial.
So all we're doing here is flipping a coin one time, and in that scenario we can use a Bernoulli random
variable to model probability.
We can also, of course build our Bernoulli distribution, which will be a visual representation of
the probability associated with that Bernoulli random variable.
The way that we accomplish using this Bernoulli random variable is by defining success as a one and
failure as a zero.
In other words, we assign numeric mathematical values to these concepts of success and failure.
So if we're flipping a coin one time and we're looking at the probability that we flip heads, we would
define flipping heads as a success and therefore as a one and everything else, in this case, flipping
tails as a failure or zero.
If we're rolling a six sided die one time we have one trial, we could define success as rolling a two.
So rolling a two, we would sort of assign this value of one rolling anything else.
So a one, three, four, five or six would be assigned a failure or a zero value.
It's really this idea of distilling down success and failure to these values.
One and zero that makes this Bernoulli random variable unique and useful.
So if we stick with our example from earlier about the rideshare company where we defined success as
a driver arriving within 10 minutes of the moment when the passenger requests the ride and failure as
a driver taking longer than 10 minutes to arrive After the ride request, we said that the probability
of success was 75%, which means then we know that the Bernoulli distribution looks like this.
We know this right away.
This is just like the binomial distribution in the sense that we have the set of discrete countable
outcomes along the horizontal axis.
In this case, we're using this Bernoulli random variable.
So we assign those values zero and one.
So with the Bernoulli distribution, we will only ever see zero and one along the horizontal axis.
We will always see both zero and one and never any other values.
And then along the vertical axis, we model probability.
So using that rideshare example where we said that the probability of success was 75%, then here at
one we have a 75% probability, and since zero is the probability of failure, just like with the binomial
random variable, if we define the probability of success as P, then the probability of failure has
to be one minus P.
Sometimes we write that as Q, but in this case success is 75%.
So one -75% is 25% or 0.25.
And so we can go ahead and graph in here 0.25 for this probability of failure or the probability of
this idea of zero.
So in this Bernoulli distribution, of course, just like other distributions, these two values here,
the 0.25 value that we see here and the 0.75 value that we see here, these values are always going
to sum to one just like our other distribution.
We're just always going to have only these two values represented zero and one as failure and success
respectively.
Now, once we know that we're dealing with a Bernoulli distribution for a Bernoulli random variable,
just like all of our other distributions that unlocks for us formulas that we already have for mean
variance and standard deviation for Bernoulli distribution.
Here's what those look like.
These are actually adapted directly from the corresponding formulas for a binomial random variable.
The only difference is that they're incorporating these values of one and zero for success and failure.
You can imagine here with this rideshare example, if we wanted to find the mean for just this one particular
trial where our chance of success is 75% and we have these values zero and one, we would find the mean
or the expected value by taking zero, multiplying it by the 25% chance of getting zero.
And then we would add to that the product of one and 0.75.
So our mean would.
Actually look like 0.25.
So 0.25 times zero.
Plus 0.75.
Times one.
This would be our expected value.
If we have these discrete values zero and one, we have a 25% chance of getting quote unquote zero and
a 75% chance of getting quote unquote, one.
And so this is our weighted mean, our expected value.
Of course, we get zero from this first term and we get 0.75 from the second term.
So we get 0.75.
And what we see is that this value here is equivalent to the chance of success.
We defined earlier 0.75 or the chance of getting a one here, 0.75.
And that's always going to be the case because this zero value here is going to zero out this failure
term, which is why we're always going to be left with a mean equal to p the probability of success.
So for a Bernoulli random variable, the mean will always be equal to the chance of success.
P Compare that to the binomial random variable where the mean was equal to n times P where n was the
number of trials and P was the chance of success.
This makes sense also when we think about adapting it this way, because now with the Bernoulli random
variable, which we're saying is a specific kind of binomial random variable, we only have one trial
and so n is equal to one, which means we end up with a mean of one times P, which of course is just
P.
And so of course the mean for the Bernoulli random variable is going to be equal to just P, and we
can use similar logic to get the formulas for variance in standard deviation for the Bernoulli random
variable as adaptations of the formulas for variance in standard deviation of the binomial random variable.
So for example, remember to find variance.
When we have a discrete random variable, we take all of the values that our variable can take on.
So in this case, zero and one, and for each one we subtract the mean.
Well, our mean is P, So we would take here our first value of zero.
So we would say zero, we would subtract the mean, which is p, and then we would square that value.
So this is the square difference between this particular x sub I and the mean, and then we multiply
this by the probability of getting a zero.
Well, in this case that's the probability of failure one minus P.
So we multiply that by one minus P, and we do this for every value that X can possibly take on.
So the only other value here is one.
So we add to this here we have one minus the mean, we square that difference and then we multiply this
by the probability that this value occurs, which in this case is 0.75, it's the probability of success,
it's P, so we multiply by P.
So this is the sum that we find for the variance.
And when we simplify this equation here, we get zero minus P is a negative P, negative P quantity
squared is positive P squared.
So we could say P squared times one minus P, and then here we have p times one minus P quantity squared.
Well, when we expand one minus P quantity squared, that's like saying one minus P times one minus
P, This goes back to algebra.
We have to multiply our first terms one and one.
So one times one is one.
Then we multiply our outer terms one and negative P one times negative P is negative P, Then we multiply
our inner terms negative P times one is a negative P, and then our last terms negative P times negative
P is a positive.
P squared.
And when we simplify again, this is all just algebra.
We get P squared times.
One is P squared, P squared times a negative P is minus P cubed, we'll say plus p times one is P.
Here we have minus P and minus P, that's a minus to P.
So when we multiply P by -$0.02, we get -$0.02 squared and then p times P squared is P cubed.
We get our negative P cubed and our positive P cubed to cancel with each other.
And then we're just left with we'll start with this P here.
So P and then we have P squared -$0.02 squared is a minus P squared, or we can write that as the variance
is equal to when we factor out a P here, we get P times one minus P.
In other words, we rewrote P minus P squared as p times one minus P.
And you see here how we build this formula for variance that we already established over here as the
variance of a newly random variable.
Now if you're not super comfortable with algebra, that's okay.
All of these steps in the middle here is just a bunch of algebra to prove to you that we can get from
this first equation here that we built.
From what we already know about variance down to this equation here to prove to you that this variance
formula works, that it's true that it makes sense for a Bernoulli random variable.
But if all we do is walk away from this lesson, understanding that the variance of a Bernoulli random
variable is given by this formula here, then that's totally fine.
This is really the main takeaway.
We want to understand that in order to find variance for a Bernoulli random variable, we use this formula
here.
In our case, that means that variance is equal to P, which is 0.75 times one minus P or Q.
The probability of failure, which is 0.25, that gives us a value for variance of 0.1875.
And then standard deviation is always just the square root of variance.
So the square root of 0.1875, which is approximately equal to 0.4330.
And so we're able to calculate the mean variance in standard deviation of a Bernoulli random variable.
So the takeaway here is that we're interested in drilling down on this idea of a Bernoulli random variable,
because the thinking behind it is interesting what we're really saying here.
Let's take our rideshare example where we're saying that there's always a 75% chance that a driver arrives
within 10 minutes of the ride being requested.
We're saying that if we distill that down to just one trial, that if somebody requests a ride within
our ridesharing app, that there's a 75% chance that a driver will arrive within 10 minutes for that
particular ride.
But of course, similar to some of the other distributions we've looked at, it's really nonsensical
to think about one particular driver arriving 75% of the time.
One particular driver is either going to arrive within 10 minutes, success or not failure.
One particular driver will always take on one of those two values only and nothing in between.
They will either succeed or fail.
We can always code them as specifically a one or a zero, and every single individual driver we pick
will always be a one or a zero.
No one driver will ever fall in between zero or one as a 0.4 or a 0.637 or a 0.75.
They will always be a zero or a one individually.
And yet we're saying that the probability of success for every single driver is some value between zero
and one.
It is 0.75.
So the whole goal here is just to understand that while every driver is only going to be success or
failure, they're only going to be one or zero, they're only going to be on or off.
They will only ever take on one of two values at the same time we associate with them this probability
of success.
That is some value in between those two exclusive discrete values.
And every single ride has that same probability of success.
P of 0.75.
Even though each individual ride always gets coded as a failure of zero, the driver doesn't arrive
within 10 minutes or a success of one.
The driver does arrive within 10 minutes.