title: Using scipy.interpolate.interp1d to calculate the x value where y =0.95
body: <p>I have two arrays for x and y. I do not have a relationship between the two arrays but I want to be able to linearly interpolate between the points to y=f(x) so I can then calculate the x value where y = 0.95. The method I have used so far is as follows:</p>
  
  <pre><code>import numpy as np
  from scipy.interpolate import interp1d    
  
  def NearestValue(array,value):
  #returns the index of the element of the array which is closest to value
  
  idx = (np.abs(array-value)).argmin()
  return idx
  
  x =[[   0. ],[   9.9],[  19.8],[  31.5],[  41.9],[  49.1],[  59. ],[  70. ],[  80.4],[ 100. ]]
  
  y= [ 0.011905, 0.140795, 0.600562, 0.757247, 0.874564, 0.934559, 0.961719, 0.986099,  0.990284, 0.998254]
  
  f = interp1d(x,y)
  
  x_new  = np.linspacex(x[0],x[9],1000)
  y_new = f(x_new)
  
  NearestIndex = NearestValue(y_new,0.95)
  
  x_nearest = x_new[NearestIndex]
  </code></pre>
  
  <p>This method returns the value from x_new which has the closest corresponding y_new value closest to 0.95. Is there a way which I can calculate the x value where y is exactly 0.95?   </p>