0
$\begingroup$

So I saw someone use this code to find out how much overlap two normal distributions have.

from statistics import NormalDistribution

NormalDist(mu=2.5, sigma=1).overlap(NormalDist(mu=5.0, sigma=1))
# 0.2112995473337106

So I'm trying to find out how much overlap these probability distributions have Graph of Probability Distribution of data I tried the overlap.() code in my code but I keep getting an error saying

AttributeError: 'numpy.ndarray' object has no attribute 'overlap'

so like y_l[0]-y_l[n] is supposed to the data of each distribution

ov_l = []
for i in range(0, int(s_lvl) - 1):
    y1 = y_l[i]
    y2 = y_l[i + 1]
    z = y1.overlap(y2)
    ov_l.append(round((z * 100.0, 1)))
print(ov_l)

I'm not super familiar with python yet so I think I might have gotten this part wrong

y_l = []
xx = np.linspace(0 , 3500000, 1000)
for i in range(0, int(s_lvl)):
    y = norm.pdf(xx, mn_l[i], var_l[i])
    y_l.append(y)
    #ov_l.append(round())
    plt.plot(xx, y)

so s_lvl is supposed to be the number of distributions I want to see and mn_l and var_l is supposed be a list of the average of one level and the Standard Deviation for each level.

I was wondering if there was an easy way like x.overlap(y) to find out how much they overlap. if not, a way to find out how much overlap probability distributions have. Or I might be doing something wrong(most likely)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.