Q:

Linear Interploation using two arrays

I have the following arrays:
List_CD = [2410.412434205376, 2287.6750893063017, 2199.2602314650626, 2124.4647889960825, 2084.5846633116403, 2031.9053600816167, 1996.2844020790524, 1957.1098650203032, 1938.4110044030583, 1900.0783178367647, 1877.6396548046785, 1868.2902104714337, 1844.9165996383219, 1816.8682911816766]
List_Dose = [10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0, 32.0, 34.0, 36.0]

what I am trying to do is to do a simple interpolation using:
dsize = numpy.interp(2000., List_CD, List_Dose)

the result that expect is between 20.0 and 22.0 but I keep getting a value of 10.0
Can anyone help here please?

A:

xp : 1-D sequence of floats
    The x-coordinates of the data points, must be increasing.

Your List_CD is not increasing.
You can sort it in the following way:
d = dict(zip(List_CD, List_Dose))
xp = sorted(d)
yp = [d[x] for x in xp]
numpy.interp(2000., xp, yp)
# returns 21.791381359216665

or:
order = numpy.argsort(List_CD)
numpy.interp(2000., np.array(List_CD)[order], np.array(List_Dose)[order])

