Last active
April 21, 2018 03:42
-
-
Save jeetsukumaran/f9d95af1c4833e4d183aa5464b9529f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L-BFGS-B | 0.0 | 0.000000 | True: b'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL' | |
---|---|---|---|---|
L-BFGS-B | 0.1 | 0.100000 | True: b'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL' | |
L-BFGS-B | 0.2 | 0.200000 | True: b'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL' | |
L-BFGS-B | 0.3 | 0.300000 | True: b'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL' | |
L-BFGS-B | 0.4 | 0.400000 | True: b'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL' | |
L-BFGS-B | 0.5 | 0.500000 | True: b'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL' | |
L-BFGS-B | 0.6 | 0.500000 | True: b'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH' | |
L-BFGS-B | 0.7 | 0.500000 | True: b'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH' | |
L-BFGS-B | 0.8 | 0.500000 | True: b'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH' | |
L-BFGS-B | 0.9 | 0.656250 | True: b'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH' | |
L-BFGS-B | 1.0 | 0.519531 | False: b'ABNORMAL_TERMINATION_IN_LNSRCH' | |
TNC | 0.0 | 0.000000 | True: Local minimum reached (|pg| ~= 0) | |
TNC | 0.1 | 0.100000 | True: Converged (|f_n-f_(n-1)| ~= 0) | |
TNC | 0.2 | 0.200002 | True: Converged (|f_n-f_(n-1)| ~= 0) | |
TNC | 0.3 | 0.300000 | True: Converged (|f_n-f_(n-1)| ~= 0) | |
TNC | 0.4 | 0.400000 | True: Converged (|f_n-f_(n-1)| ~= 0) | |
TNC | 0.5 | 0.500000 | True: Local minimum reached (|pg| ~= 0) | |
TNC | 0.6 | 0.600000 | True: Converged (|f_n-f_(n-1)| ~= 0) | |
TNC | 0.7 | 0.700000 | True: Converged (|f_n-f_(n-1)| ~= 0) | |
TNC | 0.8 | 0.500000 | False: Linear search failed | |
TNC | 0.9 | 0.500000 | False: Linear search failed | |
TNC | 1.0 | 0.500000 | False: Linear search failed | |
SLSQP | 0.0 | 0.000000 | True: Optimization terminated successfully. | |
SLSQP | 0.1 | 0.099992 | True: Optimization terminated successfully. | |
SLSQP | 0.2 | 0.200135 | True: Optimization terminated successfully. | |
SLSQP | 0.3 | 0.300000 | True: Optimization terminated successfully. | |
SLSQP | 0.4 | 0.399910 | True: Optimization terminated successfully. | |
SLSQP | 0.5 | 0.500000 | True: Optimization terminated successfully. | |
SLSQP | 0.6 | 0.600090 | True: Optimization terminated successfully. | |
SLSQP | 0.7 | 0.700000 | True: Optimization terminated successfully. | |
SLSQP | 0.8 | 0.799865 | True: Optimization terminated successfully. | |
SLSQP | 0.9 | 0.900008 | True: Optimization terminated successfully. | |
SLSQP | 1.0 | nan | False: Iteration limit exceeded | |
Nelder-Mead | 0.0 | 0.000012 | True: Optimization terminated successfully. | |
Nelder-Mead | 0.1 | 0.100000 | True: Optimization terminated successfully. | |
Nelder-Mead | 0.2 | 0.200000 | True: Optimization terminated successfully. | |
Nelder-Mead | 0.3 | 0.300000 | True: Optimization terminated successfully. | |
Nelder-Mead | 0.4 | 0.400000 | True: Optimization terminated successfully. | |
Nelder-Mead | 0.5 | 0.500000 | True: Optimization terminated successfully. | |
Nelder-Mead | 0.6 | 0.600000 | True: Optimization terminated successfully. | |
Nelder-Mead | 0.7 | 0.700000 | True: Optimization terminated successfully. | |
Nelder-Mead | 0.8 | 0.800000 | True: Optimization terminated successfully. | |
Nelder-Mead | 0.9 | 0.900000 | True: Optimization terminated successfully. | |
Nelder-Mead | 1.0 | 0.999988 | True: Optimization terminated successfully. | |
Powell | 0.0 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 0.1 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 0.2 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 0.3 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 0.4 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 0.5 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 0.6 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 0.7 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 0.8 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 0.9 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
Powell | 1.0 | 199.770530 | False: Maximum number of function evaluations has been exceeded. | |
BFGS | 0.0 | -19.499997 | False: Desired error not necessarily achieved due to precision loss. | |
BFGS | 0.1 | -159.499984 | False: Desired error not necessarily achieved due to precision loss. | |
BFGS | 0.2 | -539.499965 | False: Desired error not necessarily achieved due to precision loss. | |
BFGS | 0.3 | -959.499982 | False: Desired error not necessarily achieved due to precision loss. | |
BFGS | 0.4 | -839.500036 | False: Desired error not necessarily achieved due to precision loss. | |
BFGS | 0.5 | 0.500000 | True: Optimization terminated successfully. | |
BFGS | 0.6 | 840.499964 | False: Desired error not necessarily achieved due to precision loss. | |
BFGS | 0.7 | 960.500018 | False: Desired error not necessarily achieved due to precision loss. | |
BFGS | 0.8 | 540.500035 | False: Desired error not necessarily achieved due to precision loss. | |
BFGS | 0.9 | 160.500017 | False: Desired error not necessarily achieved due to precision loss. | |
BFGS | 1.0 | 20.500003 | False: Desired error not necessarily achieved due to precision loss. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
from scipy.optimize import minimize | |
from scipy.stats import binom | |
def main(): | |
n = 10 | |
x0 = np.array([0.5]) | |
bounded_methods = ("L-BFGS-B", "TNC", "SLSQP") | |
unbounded_methods = ("Nelder-Mead", "Powell", "BFGS", "COBYLA", ) | |
for method in bounded_methods + unbounded_methods: | |
for k in range(0,11): | |
def f(x, *args): | |
return -1 * binom.pmf(k, n, x[0]) | |
kwargs = {"method": method} | |
if method in bounded_methods: | |
kwargs["bounds"] = ((0.0, 1.0),) | |
res = minimize(f, x0, **kwargs) | |
try: | |
est = res.x[0] | |
except IndexError: | |
est = res.x | |
print("{:10}\t{:0.1f}\t{:8.6f}\t{}: {}".format(method, k/float(n), est, res.success, res.message)) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment