Skip to content

Commit 566efef

Browse files
committed
Multinomial Distribution
1 parent a302de8 commit 566efef

File tree

2 files changed

+50
-10
lines changed

2 files changed

+50
-10
lines changed

17.multinominal_distribution.py

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,43 @@
1-
# Multinomial Distribution
2-
31
'''
4-
IMP Points:
2+
Multinomial Distribution ka use binomial distribution jaisa hi hai but binomial distribution kewal 2 event ke liye work karta hai.
3+
4+
Jaise ki 0 ya 1 ya fir is case me baat kare to head ya teal ke liye.
5+
6+
But Multinomial me jab 2 se jada event hone ke chanse hote hai to iska use kiya data hai.
7+
8+
Isko hum is tarah bhi samjh sakte hai ki jaise python me hum condtion use karte hai but agar 2 condtion ho to kewal if aur else se kaam chal jata hai.
9+
10+
But jab 2 se jada condtion ho to multiple condtion ke liye elif ka use karte hai.
11+
12+
Wise hi yaha par probability ke case me jab aysi situaltion aye ki 2 se jada case bane ki probability hai.
13+
14+
Example ke liye kah sakte hai ki hum coin ko uchal rahe hai but head ya teal ke alawa toss miss bhi ho sakta hai aur ayse case ke liye hi multinomial distribution use kiya jata hai.
515
6-
1. ye binomial ka bhai hai wo kewal 2 hi condtion ke bich me probability find karta tha, jaise 0 ya 1 or head or tels.
7-
2. But Multinomial naam se hi pata chal raha hai ki 2 se jada case ke liye to jaise head aur tell to hoga but tie hone ke bhi chances hai tab kya hoga?
16+
Multinomial Distribution method ke arguments:
17+
18+
1. n - int or array like int value. Kitne event honge. Jaise dise ke case me 6 taraf hote hai
19+
2. pvals - Ye float values hoti hain. kitni probability ho sakti hai. Jaise dice me koi bhi number ke aane ki probability: [1/6, 1/6, 1/6, 1/6, 1/6, 1/6] hogi.
20+
3. size - Ye int ya tuple value de sakte hain. matix measn hum kitnit bar dice ko uchalenge usko numpy me random ka use karke generate kar sakte hai.
21+
22+
Ye method last me return me numpy array wapas karega joki ek matrix hoga. Aue isko narray bhi kaha jata hai.
823
'''
924

10-
from numpy import random as r
11-
import seaborn as sns
25+
import numpy.random as r
1226
import matplotlib.pyplot as plt
27+
# import seaborn as sns
28+
# result of multinomial
29+
mdResult = r.multinomial(20, [1/6.]*6, size=2)
30+
print('\nmdResult: \n',mdResult)
31+
# plt.hist use to show graph
32+
'''
33+
plt.hist() me aane wale arguments:
34+
35+
array result
36+
scale: graph me hitrogram ki spacing ya density
37+
dinsity: ye density
38+
'''
39+
40+
count, bins, ignored = plt.hist(mdResult, 5, density=True)
41+
# sns.distplot(r.multinomial(n=12, pvals=[1/6,1/6,1/6,1/6,1/6,1/6], size=1))
42+
plt.show()
1343

14-
sns.distplot(r.multinomial(n=6, pvals=[1/6, 1/6, 1/6, 1/6, 1/6, 1/6]))
15-
print(r.multinomial(n=6, pvals=[1/6, 1/6, 1/6, 1/6, 1/6, 1/6]))
16-
plt.show()

18.Exponential_Distribution.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'''
2+
Exponential Distribution:
3+
4+
5+
'''
6+
7+
import numpy.random as r
8+
# import seaborn as sns
9+
import matplotlib.pyplot as plt
10+
11+
data = r.exponential(3, 10000)
12+
count, bins, ignored = plt.hist(data, 14, density=True)
13+
plt.show()

0 commit comments

Comments
 (0)