Figure A.1:

Estimated reaction rates from 2000 production-rate measurements subject to measurement noise.

Figure A.1

Code for Figure A.1

Text of the GNU GPL.

main.py


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Converted from rate_estimation_app.m - rate estimation with stoichiometric constraints
# [makes] rate_estimation_app.dat
import numpy as np
from misc import save_ascii

stoi = np.array([[0, 1, 0, -1, -1, 1],
                 [-1, 1, 1, -1,  0, 0],
                 [1, 0, -1, 0, -1,  1]], dtype=float)
r    = np.array([1.0, 2.0])
A    = stoi[:2, :]
R    = A.T @ r

np.random.seed(0)
npoints = 2000
Rmeas   = np.zeros((6, npoints))
for i in range(npoints):
    Rmeas[:, i] = 0.05 * np.random.randn(6) + R

rest = (np.linalg.solve(A @ A.T, A @ Rmeas)).T
save_ascii('rate_estimation_app.dat', rest)