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

1

"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! 🙏

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

AWS GenAI Live!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️