FrankenNumPy

Docs/Context

Algorithm References and Citations

FrankenNumPy is a clean-room port. We re-implemented the algorithms by reading the published references and NumPy's C source, then wrote new Rust against the same mathematical contract. Significant references behind specific kernels:

RNG and distributions

  • PCG64 / PCG64DXSM: M. E. O'Neill, PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation, 2014. DXSM is the variant NumPy 1.20+ ships as its high-quality default.
  • Mersenne Twister (MT19937): M. Matsumoto and T. Nishimura, Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator, ACM TOMACS 8(1), 1998.
  • Philox: J. K. Salmon et al., Parallel Random Numbers: As Easy as 1, 2, 3, SC'11.
  • SFC64: C. Doty-Humphrey, PractRand, 2014 (Small Fast Counting generator).
  • SeedSequence: adapted from M. E. O'Neill's C++11 std::seed_seq (2015); shipped in NumPy's bit_generator.pyx alongside the broader RNG-policy framework formalized in NEP 19 (R. Kern, 2018).
  • Lemire bounded integers: D. Lemire, Fast Random Integer Generation in an Interval, ACM TOMS 45(1), 2019.
  • Ziggurat sampling: G. Marsaglia and W. Tsang, The Ziggurat Method for Generating Random Variables, J. Stat. Software 5(8), 2000.
  • BTPE binomial: V. Kachitvichyanukul and B. W. Schmeiser, Binomial random variate generation, CACM 31(2), 1988.
  • HRUA hypergeometric: E. Stadlober, Sampling from Poisson, binomial and hypergeometric distributions: ratio of uniforms as a simple and fast alternative, Math. Statist. Sektion 303, 1989.
  • PTRS Poisson: W. Hörmann, The Transformed Rejection Method for Generating Poisson Random Variables, Insurance: Math. Econ. 12, 1993.
  • Marsaglia–Tsang gamma: G. Marsaglia and W. Tsang, A Simple Method for Generating Gamma Variables, ACM TOMS 26(3), 2000.

Linear algebra

  • Householder QR: A. S. Householder, Unitary triangularization of a nonsymmetric matrix, J. ACM 5(4), 1958.
  • Golub–Kahan bidiagonalization + implicit shifted QR for SVD: G. H. Golub and W. Kahan, Calculating the Singular Values and Pseudo-Inverse of a Matrix, SIAM JNA 2(2), 1965; J. Demmel and W. Kahan, Accurate singular values of bidiagonal matrices, SIAM JSSC 11(5), 1990.
  • Implicit QR for unsymmetric eigenvalues: J. G. F. Francis, The QR Transformation, Comput. J. 4(3), 1961.
  • Symmetric tridiagonal QL/QR: H. Bowdler, R. S. Martin, C. Reinsch, J. H. Wilkinson, The QR and QL algorithms for symmetric matrices, Numer. Math. 11, 1968.
  • Padé approximation for expm: N. J. Higham, The Scaling and Squaring Method for the Matrix Exponential Revisited, SIAM JMAA 26(4), 2005.
  • Matrix logarithm via Schur–Padé: N. J. Higham and L. Lin, A Schur–Padé Algorithm for Fractional Powers of a Matrix, SIAM JMAA 32(3), 2011.
  • Polar decomposition: N. J. Higham, Computing the Polar Decomposition with Applications, SIAM JSSC 7(4), 1986.

FFT

  • Cooley–Tukey decimation-in-time: J. W. Cooley and J. W. Tukey, An Algorithm for the Machine Calculation of Complex Fourier Series, Math. Comp. 19(90), 1965.
  • Bluestein chirp-Z: L. I. Bluestein, A linear filtering approach to the computation of the discrete Fourier transform, IEEE Trans. AU 18(4), 1970.

Special functions, signal, statistics

  • Modified Bessel I0 for Kaiser windowing: piecewise rational approximations from W. J. Cody, Rational Chebyshev approximations for the modified Bessel functions I_0(x) and I_1(x), Math. Comp. 28(125), 1974.
  • Histogram bin selection (Sturges, sqrt-choice, auto): H. A. Sturges, The choice of a class interval, J. ASA 21(153), 1926; D. Freedman and P. Diaconis, On the histogram as a density estimator: L2 theory, Z. Wahr. Verw. Gebiete 57, 1981.
  • Polynomial evaluation (Horner) and orthogonal-polynomial recurrence (Clenshaw): W. G. Horner, A new method of solving numerical equations of all orders, by continuous approximation, Phil. Trans. R. Soc. 109, 1819; C. W. Clenshaw, A note on the summation of Chebyshev series, MTAC 9(51), 1955.

Format and infrastructure

  • NPY 1.0 / 2.0 binary format: R. Kern, NEP 1: A Simple File Format for NumPy Arrays, 2007, plus the version-2.0 extension to support long headers.
  • RaptorQ fountain code: M. Luby, A. Shokrollahi, M. Watson, T. Stockhammer, L. Minder, RaptorQ Forward Error Correction Scheme for Object Delivery, IETF RFC 6330, 2011.

Every kernel ported from one of these papers has at least one oracle test in the conformance suite that compares its output against NumPy's implementation of the same algorithm, at one or more curated seeds and input distributions.


This section in the README on GitHub