DEV Community

Cover image for "Day 58 of My Learning Journey: Setting Sail into Data Excellence! Today's Focus: Maths for Data Analysis (Probability - 4)
Nitin-bhatt46
Nitin-bhatt46

Posted on

"Day 58 of My Learning Journey: Setting Sail into Data Excellence! Today's Focus: Maths for Data Analysis (Probability - 4)

PROBABILITY - 4

Contingency table :-

It is a table which helps us to make Venn Diagrams to get probability.

Example :-

Total students are 100.
Student who take only biology = 40
Student who take only maths = 30
Student who take only both = 10

Image description

This is mostly used in the type of probability.

Type of probability

Joint probability
Marginal probability
Conditional probability
JOINT PROBABILITY :-

Let’s say we have two random variables X and Y. the joint probability of X and Y, P( X= x,Y= y)denotes the probability that X takes the value x and Y takes the value of y at the same time.

Probability of having two events simultaneously is called joint probability.

Creating contingency table in python

pd.crosstab(data_file_name[column_name ] , data_file_name[column_name ],normalize =’all’)

Joint probability distribution :- sum of all the values is 1.

Marginal probability / simple / unconditional

It refers to the probability of an event occurring irrespective of the outcome of some other event. When dealing with random variables , the marginal probability of a random variable is the simple probability of that variable taking a certain value, regardless of the value of other variables.

pd.crosstab(data_file_name[column_name ] , data_file_name[column_name ],normalize =’all’,margins =True )

Conditional probability

It is a measure of the probability of an event occurring, given that another event has already occurred. If the event of interest is A and event B has already occurred, the conditional probability of A given B is usually written as P(A|B).

pd.crosstab(data_file_name[column_name ] , data_file_name[column_name ],normalize =’columns’ )

🙏 Thank you all for your time and support! 🙏

Top comments (0)