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.
FUTURE:
- Parallelize
- 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 plt.show() #As simple as that
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brute_curvefit-0.0.4.tar.gz.
File metadata
- Download URL: brute_curvefit-0.0.4.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94124af5acfcc56efbc2d8a262327027218201148636222d63682ae983083f93
|
|
| MD5 |
39b3021f08513682695b21673f2ffd6e
|
|
| BLAKE2b-256 |
85f2802424624b4f775cf2208596f536653ced71742121d5ebd505f89142c02d
|
File details
Details for the file brute_curvefit-0.0.4-py3-none-any.whl.
File metadata
- Download URL: brute_curvefit-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42655a40a999d59a8375dc8be95eaea128323e2e70842ec9a22c56d757d5ff3a
|
|
| MD5 |
06fe44767fcc96889fb4e0d1aaecc04c
|
|
| BLAKE2b-256 |
620530c424c1ecd16203b35e7201d848a03a30012857fe2808aa23005080526c
|