Instantly share code, notes, and snippets.

# denis-bz

• Sort options
Created Oct 10, 2019
Holt-Winters double exponential smoothing 2015
View 1-Holt-doubleexp-smoothing.md

## A small example of Holt-Winters double exponential smoothing

in Python2 with NumPy and scipy.signal . This is a good bad example, in that yhat[n] == x[n], i.e. predict next == current (a = 1, b = 0) is ~ optimal.

The files:

Last active Oct 8, 2019
from Denis-iMac ~bz/py/opt/lp/lpgen Tue 2019-10-08 Oct 10:50z
View lpgen34.py
 #!/usr/bin/env python """ lpgen34.py LP testcase generator d=3: 3n^2 x n^3, 3 1s in each column n=55: A 9075 x 166375, 499125 nnz, glpsol simplex 100 minutes d=4: 4n^3 x n^4, 4 1s in each column, n in each row n=16: A 2^14 x 2^16, 2^18 nnz, glpsol simplex 10 hours """ # keywords: linear programming, test case, generator, Latin-square # https://stackoverflow.com/questions/57936789/many-vertex-test-problems-for-the-simplex-method # https://math.stackexchange.com/questions/3370934/3d-permutation-matrices -- 4d too
Created Aug 21, 2019
Runtimes of GLPK on some Netlib test cases 21 Aug 2019 09:50z
View 0-glpk-netlib.md

#### Runtimes of GLPK, the gnu Linear Programming kit, on some Netlib test cases

Keywords: linear programming, LP, GLPK, runtime, test case, Netlib

``````# 16 Aug 2019 08:34z  ~bz/py/opt/lp/netlib  Denis-iMac 10.10.5
Intel(R) Core(TM) i5-3330S CPU @ 2.70GHz
Apple LLVM version 7.0.2 (clang-700.1.81)
GLPSOL: GLPK LP/MIP Solver, v4.65  (uses only 1 core)
``````
Last active Jul 24, 2019
make SuiteSparse CHOLMOD for scikit-sparse
View make-SuiteSparse-CHOLMOD-for-scikit-sparse.md
Created Jun 10, 2019
A 6 x 6 linprog testcase from glpk: 3 methods x sparse / dense give different results 2019-06-10 Jun 12:45z
View 0-transp-linprog.md

#### A 6 x 6 linprog testcase from glpk: 3 methods x sparse / dense give different results

`transp-linprog.py` below is a 6 x 6 testcase of scipy.optimize.linprog from a GLPK example, transp. In outline:

``````for method in ["interior-point", "revised simplex", "simplex"]:
for sparse in [True, False]
try:
linprog( ... )
``````
Last active May 30, 2019
Lower-risk stochastic programming: the Dakota problem 29may2019
View 0-Lower-risk-stochastic-programming-Dakota-problem.md

#### Easy lower-risk stochastic programming: the Dakota problem

Keywords: stochastic programming, risk, linear programming, python

Users of stochastic programming sometimes look only at "expected" payoff and ignore risk. For example, a well-known tutorial problem, Dakota furniture from Higle 2005, gives a max-expected profit \$ 1730, but with 30 % chance of \$ 650 loss, 70 % \$2750 profit. That looks risky to me (an engineer, not a businessman).

Created May 23, 2019
interpol.pandoc, see https://github.com/denis-bz/interpol/issued.4
View intergrid.pandoc
 Intergrid: interpolate data given on an N-d rectangular grid ============================================================ Purpose: interpolate data given on an N-dimensional rectangular grid, uniform or non-uniform, with the fast `scipy.ndimage.map_coordinates` . Non-uniform grids are first uniformized with `numpy.interp` . Background: the reader should know some Python and NumPy
Created Apr 25, 2019
A summary of the problems in glpk-4.65/examples/*.mod
View glpk-examples-summary
 # A summary of the problems in glpk-4.65/examples/*.mod # lp/mip min/max rows cols nnz assign p lp min 17 64 192 bpp p mip min 11 28 56 cal p lp min 0 0 0 cf12a p lp min 20 40 113 cf12b p lp min 58 41 152 cflsq p lp min 40 40 114 color p mip min 92 48 288 cpp p lp min 30 14 59
Created Feb 26, 2019
timeit scipy.sparse linear solvers: spsolve qmr lgmres splu spilu minres 2019-02-26 Feb
View 0-scipy-sparse-solve-time.md

#### timeit scipy.sparse linear solvers: spsolve qmr lgmres splu spilu

Here is a simple test of 5 scipy.sparse solvers of `Ax = b`, with `A = diag*I` + sparse random-uniform 4000 x 4000, density 1e-3.

Keywords: sparse linear solver, test case, random matrix, scipy, GMRES, Krylov

Last active Jan 19, 2019
3-point and 5-point finite-difference derivative approximations
View Diff35.md

### 3-point and 5-point finite-difference derivative approximations

Central differences like

``````diff1 = (f_{t+1} - f{t-1}) / 2,  [0 -1 0 1 0] / 2
diff2 = (f_{t+2} - f{t-2}) / 4,  [-1 0 0 0 1] / 4
``````

approximate the derivative `f'(t)` much better then the one-sided difference `f_{t+1} - f_t`; see e.g. Wikipedia

You can’t perform that action at this time.