title: Decay curve best fit SciPy
body: <p>I am having a problem when I try to find best fit to my data. Using <strong>scipy.optimize.curve_fit</strong> to create best fit. My data and code is:</p>
  
  <p><strong>EDIT</strong> You can download the data file from <a href="https://drive.google.com/file/d/0B6c0e-DwluM5RmJFemgyT3NkeTg/view?usp=sharing" rel="nofollow noreferrer" title="data file">here</a>.
  data is,  </p>
  
  <pre><code>         a             b            b2
  55478   1.07E+43    54395.93833 
  56333   1.63E+43    54380.01385 
  57540   2.57E+43    52393.31605 
  61866   7.32E+43    52212.22838 52212.22838
  </code></pre>
  
  <p>code:</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  
  from __future__ import division
  
  import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  import fit
  import glob
  import os
  from scipy.optimize import curve_fit
  import matplotlib.patches as patches
  
  pf = pd.read_csv('/home/imhotep/Desktop/lala.csv', sep=',', encoding ='utf-8')
  
  
  
  a1= pf['a'].max()
  b1 = pf['b2'].max()
  npoc=100
  
  x = np.linspace((b1), (pf['b'].max()),npoc)
  yy = np.linspace((pf['a'].min()), (pf['a'].max()), npoc)
  
  
  fig = plt.figure()
  
  ax4 = fig.add_subplot(111)
  
  def h(x,k):
      return a1* (((x-(b1))/(k))**(-(5./3.)))
  
  
  popt,pcov = curve_fit(h,x,yy)
  
  print 'POPT,', popt,'PCOV',pcov
  y_fi1 = h(x, *popt)
  
  ax4.plot(x, y_fi1, label='fit', ls='-', color='blue')
  
  ax4.plot(pf['b'], pf['a'], ls='None', color='blue', marker='o')
  
  plt.show()
  </code></pre>
  
  <p>like that. When I run the code I'm getting that fit:
  <a href="https://i.stack.imgur.com/kzb0z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kzb0z.png" alt="fit"></a></p>
  
  <p>But, it should be roughly like that:</p>
  
  <p><a href="https://i.stack.imgur.com/jPM3v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jPM3v.png" alt="fitted"></a></p>
  
  <p>Can anyone tell me where I go wrong? I am beginner about curve fitting. </p>