Skip to content

Instantly share code, notes, and snippets.

View andyfaff's full-sized avatar

Andrew Nelson andyfaff

  • Sydney, Australia
View GitHub Profile
@andyfaff
andyfaff / gist:24c96a3d5dbc7b0272b2
Last active August 29, 2015 14:06
scipy.optimize benchmarks for global optimizers.
Based on http://infinity77.net/global_optimization/index.html, and others.
http://infinity77.net/global_optimization/index.html
https://github.com/andyfaff/scipy/tree/go_benchmark
python -u benchmark_global_optimizers.py
success % nfev
Problem basin de anneal basin de anneal
AMGM 100.0 100.0 100.0 1111 995 4231
MACHEPS = np.finfo(np.float64).eps
def estimate_mrqcof(self, xk, *args):
'''
Estimates the gradient and hessian matrix for the fit
(differential_evolution can't do this).
'''
temp_parameters = np.copy(self.parameters)
derivmatrix = np.zeros((len(xk), self.numpoints), np.float64)
@andyfaff
andyfaff / gist:22eb2cff2263e83453ee
Created August 17, 2015 06:45
McStas build log
=== Picked flavor: mcstas
/Users/anz/Documents/Andy/programming/McCode-master/mcstas -> /Users/anz/Documents/Andy/programming/McCode-master/dist
=== OSXpkg ===
mkdist: simple_cpack_file OUT=/Users/anz/Documents/Andy/programming/McCode-master/dist/mcstas-OSXpkg-2.0-mac_maverics.pkg GEN=PackageMaker HINT=
mkdist: prepare_cpack: cmake -Denable_mcstas=1 -DCMAKE_INSTALL_PREFIX=/usr/local -DNO_ALTERNATIVES=0 -DCMAKE_TOOLCHAIN_FILE=/Users/anz/Documents/Andy/programming/McCode-master/cmake/toolchains/mac_maverics.cmake .
-- The C compiler identification is Clang 6.0.0
-- Check for working C compiler: /usr/bin/cc
@andyfaff
andyfaff / emcee_line.ipynb
Created September 4, 2015 09:15
emcee in lmfit
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfaff
andyfaff / lmfit_model_selection.ipynb
Created September 23, 2015 06:42
model selection with lmfit
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfaff
andyfaff / gist:3af1f722b0032edef6e2
Created October 6, 2015 20:06
profiling asteval initiation
>>> %load_ext line_profiler
>>> from lmfit import Parameters,Parameter
>>> from lmfit.asteval import Interpreter
>>> %lprun -f Interpreter.__init__ -f Parameters.__init__ Parameters()
Timer unit: 1e-06 s
Total time: 0.005639 s
File: /Users/anz/miniconda3/envs/dev3/lib/python3.4/site-packages/lmfit-0.9.1_17_g4a9b540-py3.4.egg/lmfit/asteval.py
Function: __init__ at line 72
@andyfaff
andyfaff / fixing_sigma.ipynb
Created January 27, 2016 05:05
fixing_sigma
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfaff
andyfaff / gist:9a7930f3d93a99f478cdadae4d1bb3b2
Created April 1, 2016 04:35
scipy.stats sampling from arbitrary distribution
import numpy as np
import scipy.interpolate as interpolate
from scipy.integrate import simps
from scipy.stats import rv_continuous
class arbitrary(rv_continuous):
def __init__(self, hist, bin_edges, xtol=1e-14, seed=None):
_hist = np.array(hist, float)
_bin_edges = np.asfarray(bin_edges)
if _bin_edges.size - 1 != hist.size:
@andyfaff
andyfaff / emcee_line_example.ipynb
Created November 4, 2016 01:37
lmfit, emcee, line fit example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file has been truncated, but you can view the full file.
Building, see build.log...
Build OK
============================= test session starts ==============================
platform darwin -- Python 3.6.1, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /Users/anz/Documents/Andy/programming/scipy, inifile: pytest.ini
collected 23150 items / 2 skipped
scipy/_lib/tests/test__gcutils.py ......
scipy/_lib/tests/test__threadsafety.py ..
scipy/_lib/tests/test__util.py ..