It is possible to create an array with more than one dimension, in this case you can pass both your hours
and age
data into curve_fit
. Such an example might be:
import numpy as np
from scipy.optimize import curve_fit
hours = [1000, 10000, 11000, 11000, 15000, 18000, 37000, 24000,
28000, 28000, 42000, 46000, 50000, 34000, 34000, 46000,
50000, 56000, 64000, 64000, 65000, 80000, 81000, 81000,
44000, 49000, 76000, 76000, 89000, 38000, 80000, 69000,
46000, 47000, 57000, 72000, 77000, 68000]
market_Price = [30945, 28974, 27989, 27989, 36008, 24780, 22980,
23997, 25957, 27847, 36000, 25588, 23980, 25990,
25990, 28995, 26770, 26488, 24988, 24988, 17574,
12995, 19788, 20488, 19980, 24978, 16000, 16400,
18988, 19980, 18488, 16988, 15000, 15000, 16998,
17499, 15780, 8400]
age = [2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 7,
8, 8, 8, 8, 8, 13]
combined = np.array([hours, market_Price])
def f():
# Some function which uses combined where
# combined[0] = hours and combined[1] = market_Price
pass
popt, pcov = curve_fit(f, combined, market_Price)