title: Curve fitting with cubic spline
body: <p>I am trying to interpolate a cumulated distribution of e.g. i) number of people to ii) number of owned cars, showing that e.g. the top 20% of people own much more than 20% of all cars - off course 100% of people own 100% of cars. Also I know that there are e.g. 100mn people and 200mn cars.</p>
  <p>Now coming to my code:</p>
  <pre><code>#import libraries (more than required here)
  import pandas as pd
  from scipy import interpolate
  from scipy.interpolate import interp1d
  from sympy import symbols, solve, Eq
  import matplotlib.pyplot as plt
  from matplotlib import pyplot as plt
  %matplotlib inline
  import plotly.express as px
  from scipy import interpolate
  
  curve=pd.read_excel('inputs.xlsx',sheet_name='inputdata')
  </code></pre>
  <p>Input data: <a href="https://i.stack.imgur.com/luiOP.png" rel="nofollow noreferrer">Curveplot</a> (cumulated people (x) on the left // cumulated cars (y) on the right)</p>
  <pre><code>#Input data in list form (I am not sure how to interpolate from a list for the moment)
  cumulatedpeople = [0, 0.453086, 0.772334, 0.950475, 0.978981, 0.999876, 0.999990, 1]
  cumulatedcars= [0, 0.016356, 0.126713, 0.410482, 0.554976, 0.950073, 0.984913, 1]
  
  x, y = points[:,0], points[:,1]
  interpolation = interp1d(x, y, kind = 'cubic')
  
  number_of_people_mn= 100000000
  
  oneperson = 1 / number_of_people_mn
  dataset = pd.DataFrame(range(number_of_people_mn + 1))
  dataset.columns = [&quot;nr_of_one_person&quot;]
  dataset.drop(dataset.index[:1], inplace=True)
  
  #calculating the position of every single person on the cumulated x-axis (between 0 and 1)
  dataset[&quot;cumulatedpeople&quot;] = dataset[&quot;nr_of_one_person&quot;] / number_of_people_mn
  
  #finding the &quot;cumulatedcars&quot; to the &quot;cumulatedpeople&quot; via interpolation (between 0 and 1)
  dataset[&quot;cumulatedcars&quot;] = interpolation(dataset[&quot;cumulatedpeople&quot;])
  
  plt.plot(dataset[&quot;cumulatedpeople&quot;], dataset[&quot;cumulatedcars&quot;])
  plt.legend(['Cubic interpolation'], loc = 'best')
  plt.xlabel('Cumulated people')
  plt.ylabel('Cumulated cars')
  plt.title(&quot;People-to-car cumulated curve&quot;)
  plt.show()
  </code></pre>
  <p>However when looking at the actual plot, I get the following result which is false: <a href="https://i.stack.imgur.com/krl8X.png" rel="nofollow noreferrer">Cubic interpolation</a></p>
  <p>In fact, the curve should look almost like the one from a linear interpolation with the exact same input data - however this is not accurate enough for my purpose: <a href="https://i.stack.imgur.com/WBcXl.png" rel="nofollow noreferrer">Linear interpolation</a></p>
  <p>Is there any relevant step I am missing out or what would be the best way to get an accurate interpolation from the inputs that almost looks like the one from a linear interpolation?</p>