LMFIT で ExpressionModel を使用して、次のように表すことができる条件付きモデルに適合させる方法:
from lmfit.models import ExpressionModel
# read(xdata and ydata) here
if xdata < some_parameter_value:
model = ExpressionModel('expression1')
else:
model = ExpressionModel('expression2')
この条件付きモデルを 1 つのモデル (global_model) として記述し、fit メソッドに渡す方法
results = global_model.fit(y, x = x, parameters_dictionary)
some_parameter_value: Parameters クラスを使用して作成された parameters_dictionary のメンバーです