title: Define skewed gaussian function that returns two parameters after fitting
body: <p>I know such questions have been asked a few times already, but still I can't get it: I want to define a function that returns more than one parameter.</p>
  
  <p>I have written the following code to fit data to a skewed gaussian function:</p>
  
  <pre><code>def skew(x, sigmag, mu, alpha, c, a):
      normpdf = (1/(sigmag*np.sqrt(2*math.pi)))*np.exp(-(np.power((x-mu),2)/(2*np.power(sigmag,2))))
      normcdf = (0.5*(1+sp.erf((alpha*((x-mu)/sigmag))/(np.sqrt(2)))))
      return 2*a*normpdf*normcdf + c
  
  popt, pcov = curve_fit(skew, xdata, ydata, p0=(5.5, 57636., 4.5, 0.0001, 0.01))
  y_fit= skew(xdata, popt[0], popt[1], popt[2], popt[3], popt[4])
  </code></pre>
  
  <p>However, my idea is to get the peak of the data distribution, and not the mean returned by the <code>skew</code> function as one of the best fit values. Therefore, I would need the <code>mode</code> of the distribution, which can be calculated as the maximum of the <code>normpdf</code>.</p>
  
  <p>How do I get <code>normpdf</code> from my defined function and get its maximum over fitted data?</p>