0

I can't understand what parameters are used by the method norm.pdf(). From the documentation I have find this definition; https://kite.com/python/docs/scipy.stats.norm.pdf But in this code for example the function is used in this way;

import numpy as np 
import scipy as sp
from scipy.stats import norm
import matplotlib.pyplot as plt 

x1 = np.random.normal(-1, 0.5, 15)
x2 = np.random.normal(6, 1, 10)
y = np.r_[x1, x2] # r_ translates slice objects to concatenation along the first axis

x = np.linspace(min(y), max(y), 100)

s = 0.4 #smoothing parameter

#calculate the kernels
kernels = np.transpose([norm.pdf(x, yi, s) for yi in y])

plt.plot(x, kernels, 'k:')

plt.plot(x, kernels.sum(1), 'r')

plt.plot(y, np.zeros(len(y)), 'bo', ms=10)

plt.show()

Someones can explain me how this function works?

Andrea
  • 39
  • 8
  • It calculates probability distribution function for normal distribution. What specifically is unclear for you? – rpoleski May 07 '20 at 20:28
  • Welcome to stack overflow! What is your specific question? What part are you confused about? One thing worth noting: The [actual documentation is here](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.norm.html) for scipy.stats.norm, and the pdf method – G. Anderson May 07 '20 at 20:30
  • I don't understand the parameters in ([norm.pdf(x, yi, s) for yi in y]). – Andrea May 07 '20 at 21:10
  • 1
    Sorry guys, I read better the documentation. The problem was that I didn’t understand that the parameters loc is the mean and scale the standard deviation. Now is clear. Thank you. – Andrea May 07 '20 at 21:26

0 Answers0