Table of contents
1.
Introduction
2.
Variate
3.
Discrete Random Variable
4.
Continuous Random Variable
5.
Function Of Random Variables
6.
Random Variable And Probability Distribution
7.
Frequently Asked Questions
7.1.
What is Sample Space?
7.2.
What is a function? 
7.3.
What are the importance of random variable?
8.
Conclusion
Last Updated: Mar 27, 2024

Random Variables

Author Urwashi Priya
0 upvote

Introduction

A random variable is just like a function. A function denotes by X, where the domain is our sample space, S, and the output is always a subset of real numbers, R.

X:S→R

Generally, on performing an experiment, we are mainly interested in some function of the outcome as opposed to the actual outcome itself. For instance, in tossing dice, we are often interested in the sum of two dice and are not really concerned about the separate value of each die. That is, we may be interested in knowing that the sum is 7 and not be concerned over whether the actual outcome was (1,6) or (2,5) or (3,4) or (4,3) or (5,2) or (6,1). Also, in flipping a coin, we are interested in counting the total number of heads that occur and do not care about the actual head-tail sequence resulting. These real-valued functions defined on the sample space are known as random variables. In other terms, we can also state that the real value of a random experiment is called a random variable.

Random Variables

Variate

All random variables obeying the law of probability is referred to as variate. It is just a generalization of the concept mentioned above about random variable. In random variables, we just need to remember two formulas, one is mean and the other is variance. Mean is the other name for average. If R is the random variable and probability is given by P, then

Mean=ΣRP.

Variance refers to the deviation from the mean.

Var(R) = σ2 = E(R2) – [E(R)]2

where,

E(R2) = ∑R2P and E(R) = ∑ RP

Discrete Random Variable

A variable that can take one value from a discrete set of values. Here the values can be finite, infinite countable.

Example: Let x denote the sum of 2 dice. Now x is a discrete random variable as it can take one value from the set {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} since the sum of two dice can only be one of these values.

Continuous Random Variable

A variable that can take one value form a continuous range of values.

Example 1: x denotes the volume of Pepsi in a 500 ml cup. Now x may be a number from 0 to 500, any of which values x may take. 

Example 2: Noise voltage that is generated by an electronic amplifier has a continuous amplitude. Therefore sample space S and random variable X both are continuous.

Question:

Suppose a manager want to improve sell of their samosa

No of samosa(X)

Customers

Probability P(X=x)

1

450

0.45

2

340

0.34

3

110

0.11

4

40

0.04

5

40

0.04

6

20

0.02

Total

1000

1

What are the probability that out of 1000 customers buy more than 4 samosa?

Solution: P(X>4)=P(X=5)+P(X=6)

=0.04+0.02

=0.06

 

Till now, I assume you must have got a basic idea about random variables.

Function Of Random Variables

Say X be a random variable, and Y=g(X), then y also becomes a random variable.

So we can easily calculate probability mass function(PMF), cumulative distributive function(CDF) and also the expected value.

R🇾={g(x) //this defines the range of y.

If the probability mass function of x is already known, then to find for y, it would be

P🇾(y) = P(Y=y)

         = P(g(X)=y)

         = ∑Pâ‚“(x) (till x:g(x)=y)

Random Variable And Probability Distribution

The probability distribution of a random variable can be listing and the probabilities of the outcomes.

Various probability distributions along with their formulas are:

  • Binomial distribution

P(x) = nCx · px (1 − p)n−x

Where,

n = Total number of events

r (or) x = Total number of successful events.

p = Probability of success on a single trial.

nCr = [n!/r!(n−r)]!

1 – p = Probability of failure.

 

  • Poisson distribution

f(x) =(e– λ λx)/x!

Where,

e is the base of the logarithm

x is a Poisson random variable

λ is an average rate of value

 

  • Bernoulli’s distribution

P(x)=(p^x)*((1−p)^1−x)

  • Exponential distribution
  • Normal distribution

Frequently Asked Questions

What is Sample Space?

Each possible outcome that can be obtained is called as sample space. If we refer to any specific outcome, it is called a sample point. For example: on throwing a dice, we can obtain 1, 2, 3, 4, 5, 6. These 6 numbers together form a sample space, but if we refer to any specific number, it is called a sample point.

What is a function? 

A function can be visualised as a box that takes some input and gives an output. The box decides what operation has to be performed. Representation of a function: f(x).

What are the importance of random variable?

In order to analyse risks at a bigger scale beforehand, the random variable is used highly. 

Conclusion

This article taught us about random variables and their types. 

We hope you could easily take away all critical and conceptual techniques by walking over the given examples. 

Refer to our guided paths on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must have a look at the problemsinterview experiences, and interview bundle for placement preparations.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!

Live masterclass