title: Scipy.stats's fit and pdf functions
body: <p>I want to know how <code>scipy.stats</code> uses its methods <code>fit</code> and <code>pdf</code>. According to the documentation, <code>fit(data, a, loc = 0, scale = 1)</code> estimates parameters for <code>data</code> while <code>pdf(x, a, loc=0, scale=1) computes probability density function </code>. But I couldn't find how <code>fit</code> and <code>pdf </code>are actually performed, statistically and mathematically.</p>
  <p>I am using the <code>sm.datasets.elnino</code> data, using the <a href="https://stackoverflow.com/questions/6620471/fitting-empirical-distribution-to-theoretical-ones-with-scipy-python">code</a> from tmthydvnprt</p>
  <pre><code>import warnings
  import numpy as np
  import pandas as pd
  import scipy.stats as st
  import statsmodels as sm
  import matplotlib
  import matplotlib.pyplot as plt
  
  data = pd.Series(sm.datasets.elnino.load_pandas().data.set_index('YEAR').values.ravel())
  
  
  y, x = np.histogram(data, bins = 50, density = True)
  x = (x + np.roll(x, -1))[:-1] / 2.0
  distribution = st.gennorm
  
  params = distribution.fit(data)
  arg = params[:-2]
  loc = params[-2]
  scale = params[-1]
  pdf = distribution.pdf(x, loc = loc, scale = scale, *arg)
  sse = np.sum(np.power(y - pdf, 2.0))
  </code></pre>
  <p>Using <code>data</code>, <code>arg</code> = 4.3836, <code>loc</code> = 23.2991, <code>scale</code> = 3.8499.</p>
  <p><strong>I want to know what <code>arg</code>, <code>loc</code>, and <code>scale</code> represent and how they are calculated.</strong></p>
  <p>Thank you.</p>