Skip to content

Instantly share code, notes, and snippets.

@denis-bz
denis-bz / 0-German-energy.md
Last active Jul 12, 2021
Electricity in Germany from coal, wind etc.
View 0-German-energy.md

Electricity in Germany from coal, wind etc.

Keywords: electricity, Germany, renewable, wind, python, pandas

Purpose: summarize data on electricity sources in Germany from the electricity market site smard.de:

total 502489 GWh  365 days, 2020-07-01 .. 2021-06-30:
                 GWh    %   GW
Braunkohle   96253.2 19.2 11.0
@denis-bz
denis-bz / rki_excel.py
Created Jun 10, 2021
Read German Corona data rki.de/.../Fallzahlen_Kum_Tab.xlsx in python pandas
View rki_excel.py
#!/usr/bin/env python3
""" https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Fallzahlen_Kum_Tab.html .xlsx
-> python pandas read_excel
"""
# sheets, from openpyxl --
# 0 Erlaeuterungen 20 rows 1 cols
# 1 Fälle-Todesfälle-gesamt 509 rows 16384 cols ?!
# 2 BL_7-Tage-Fallzahlen (fixiert) 39 rows 396 cols
# 3 BL_7-Tage-Inzidenz (fixiert) 21 rows 396 cols
# 4 LK_7-Tage-Fallzahlen (fixiert) 419 rows 207 cols
@denis-bz
denis-bz / 0-fitting-1-over-x-with-polynomials.md
Last active May 23, 2021
Fitting 1 / x with polynomials in relative error
View 0-fitting-1-over-x-with-polynomials.md

Fitting 1 / x with polynomials in relative error

Keywords, topics: approximation, relative error, inverse, Chebyshev polynomial, Krylov, python

23may-relfit-c1 1-d10-15-20-wend8

This plot shows polynomials of degrees 10, 15, 20 that fit 1 / x on the range 0.1 .. 2.1, shifted to fits of 1 / (1.1 + x) on -1 .. 1.

@denis-bz
denis-bz / 0-tri101-inverse.md
Last active Apr 3, 2021
A simple matrix with interesting inverse 31 Mar 2021
View 0-tri101-inverse.md

A simple matrix with interesting inverse

Keywords: sparse linear solver, python, scipy, testcase, matrix, GMRES, poisson, plot

2apr-tri101-inv

A simple testcase for GMRES

Wikipedia GMRES says

@denis-bz
denis-bz / 0-Mittelmann-ip-simplex.md
Last active Jan 26, 2021
Mittelmann interior-point and simplex benchmarks 24 Jan 2021
View 0-Mittelmann-ip-simplex.md

Mittelmann interior-point and simplex benchmarks from http://plato.asu.edu/bench.html

Keywords, tags: linear programming, benchmark, Mittelmann, HiGHS, python, scipy, sparse-matrix

26jan-Mittelmann-ip-simplex

This plot shows the runtimes of various LP interior-point and simplex programs on Mittelmann's benchmark problems.

To plot similar rows / similar columns near each other,

@denis-bz
denis-bz / 0-LP-benchmarks-Mittelmann-HiGHS.md
Last active Jan 21, 2021
A few Mittelmann LP benchmarks run with HiGHS-ipm 19 Jan 2021
View 0-LP-benchmarks-Mittelmann-HiGHS.md

A few Mittelmann LP benchmarks run with HiGHS-ipm

Keywords, tags: linear programming, benchmark, Mittelmann, HiGHS, python, scipy, sparse-matrix

Here are logfiles for a few of the Mittelmann linear programming benchmark problems, run with the HiGHS interior-point solver via python-scipy. lpbar

@denis-bz
denis-bz / lpgen34.py
Created Jan 17, 2021
LP sparse testcase generator: 4n^3 x n^4, 4n^4 non0 17 Jan 2021
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
@denis-bz
denis-bz / 0-Stripy.md
Created Jan 8, 2021
Stripy: percentile stripes for scatterplots
View 0-Stripy.md

Stripy: percentile stripes for scatterplots

Keywords: scatterplot, percentiles, quantiles, visualize, regression, nonparametric

ozone-stripy-4june

What does this show ? Consider a fat vertical line at a given x in one of these plots. The colored bands are, from low to high,

@denis-bz
denis-bz / triangles_in_sparsegraph.py
Created Nov 17, 2020
triangles_in_sparsegraph.py triangles_to_edges.py 17 Nov 2020
View triangles_in_sparsegraph.py
#!/usr/bin/env python3
""" triangles in a sparse graph """
# Keywords: sparse-graph, sparse-matrix, scipy, mesh, triangles
# w Polygon_mesh Mesh_generation ...
import numpy as np
from scipy import sparse
# https://docs.scipy.org/doc/scipy/reference/sparse.csgraph.html
# some type names --
@denis-bz
denis-bz / 0-invop.md
Last active Mar 10, 2021
Inverse operators for scipy.sparse eigs, arpack 15 Nov 2020
View 0-invop.md

Invop() inverse operator for scipy.sparse eigenvalues with ARPACK

Problem: find a few eigenvalues λ and eigenvectors v of
A v = λ v, \ A a scipy.sparse matrix, largest or smallest |λ|
or K v = λ M v with stiffness matrix K and mass matrix M.

Purpose: experiment with different linear solvers, with verbose to track solver calls.
Keywords: scipy.sparse, linear-solvers, eigenvalue, generalized-eigenvalue, Arpack, logging

In the following examples, eigs( A [M] [Minv] [OPinv] [sigma] ... ) \