Skip to main content

Curve fitting using both brute force and scipy.optimize

Project description

This is a simple script which tries to find the global minima using scipy.optimize.curve_fit as well as a parameter search over the parameter space. It first generates ntol random models, then selects ntol*returnnfactor best models and does scipy.optimize.curve_fit on all of them. It then returns the best model of them all. This script improves scipy.optimize.curve_fit in two ways - No need to give initial values and thus getting global minima instead of local minima. And second, it automatically normalize and standardizes the data.


  1. Parallelize
  2. Use Genetic algorithm instead of brute-force

USAGE EXAMPLE: import brute_curvefit as bf import numpy as np import matplotlib.pyplot as plt def yourfunc(x, A,B,C): return (x-A)/B +C

params, error = bf.brute_then_scipy(func=yourfunc, x=np.arange(100), y=np.arange(100)**2, restrict=[[-1000,-1000,-1000],[1000,1000,1000]]) plt.plot(np.arange(100), np.arange(100)**2) #plotting data plt.plot(np.arange(100), yourfunc(np.arange(100), *params)) #plotting the fitted function #As simple as that

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for brute-curvefit, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size brute_curvefit-0.0.4-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size brute_curvefit-0.0.4.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page