diff --git a/Multi_fitter_test_file.py b/Multi_fitter_test_file.py new file mode 100644 index 0000000..5fb5a73 --- /dev/null +++ b/Multi_fitter_test_file.py @@ -0,0 +1,39 @@ +import numpy as np +from scipy.optimize import minimize + + +# example model +def model(params, x): + return params[0] * x + params[1] + + +# Cost function +def cost_function(params, x_data, y_data): + return np.sum((model(params, x_data) - y_data) ** 2) + + +# Global cost function +def global_cost_function(params, experiments): + total_cost = 0 + for x_data, y_data in experiments: + total_cost += cost_function(params, x_data, y_data) + return total_cost + + +# Example data for two experiments +x_data_1 = np.array([0, 1, 2, 3]) +y_data_1 = np.array([1, 3, 5, 7]) + +x_data_2 = np.array([0, 1, 2, 3]) +y_data_2 = np.array([2, 4, 6, 8]) + +experiments = [(x_data_1, y_data_1), (x_data_2, y_data_2)] + +# Initial guess/parameters +initial_params = [1, 0] + +# Run the optimization +result = minimize(global_cost_function, initial_params, args=(experiments,)) + +# Optimized parameters +print("Optimized parameters:", result.x) diff --git a/__pycache__/Model.cpython-311.pyc b/__pycache__/Model.cpython-311.pyc index 7f5f490..a9b4952 100644 Binary files a/__pycache__/Model.cpython-311.pyc and b/__pycache__/Model.cpython-311.pyc differ