Skip to content

Instantly share code, notes, and snippets.

@jfbu
jfbu / figure.tex
Created June 20, 2017 14:52
illustration of a peculiarity of TeX paragraph building
\documentclass{article}
\usepackage{mwe}
\begin{document}
% or anything filling the line with less than inter-word space shrinkability
\noindent\rule{\linewidth}{1pt} % <-- we deliberately leave a space token here
\begin{figure}[htbp]
\centering
% only by way of example, close to real life examples
\documentclass{article}
\newenvironment{foo}{}{}
\begin{document}
\begin{foo}
\noindent\begin{minipage}{\linewidth}
bar!
\end{minipage}
@jfbu
jfbu / test.tex
Created October 27, 2017 08:02
comparison test on powers of 2
\documentclass{article}
\usepackage{bigintcalc,xintcore}
\begin{document}
Bonjour
\pdfresettimer
\romannumeral\xintreplicate{1000}{\edef\x{\xintiiPow{2}{30}}}%
\the\pdfelapsedtime\par
#!/bin/env/py
"""This is a quick Pythonification of the Pascal code in pdftex.web
I know I should use a Python generator rather than variables with
global scope...
Anyway, brief testing showed it does match exactly with actual
\pdfuniformedeviate/\pdfsetrandomseed, and that's what I wanted
in case I attempt some statistics on this PRNG.
\newwrite\out
\newcount\cnt
\def\test #1#2#3{% #1 = seed, #2 = N, #3 = reps
\immediate\openout\out=randomints_tex_#1.txt
\pdfsetrandomseed #1
\cnt0
\loop
@jfbu
jfbu / RNGrandomwalk.py
Last active May 5, 2018 20:08
Python code demonstrating biases in the parity bits of the PDFTeX RNG
#!/bin/env/py
"""This is a quick Pythonification of the Pascal code in pdftex.web
I know I should use a Python generator rather than variables with
global scope...
Anyway, brief testing showed it does match exactly with actual
\pdfuniformedeviate/\pdfsetrandomseed, and that's what I wanted
in case I attempt some statistics on this PRNG.
@jfbu
jfbu / RNGrandomwalk.tex
Last active May 6, 2018 09:00
TeX file confirming that Python code emulated correctly \pdfuniformdeviate
\newcount\cnta
\newcount\cntb
%\newcount\cntc
%\newcount\cntd
\newcount\maxrand
\maxrand "10000000
% \the\maxrand
@jfbu
jfbu / RNGwalkwithshift.tex
Last active May 6, 2018 11:05
Count preponderance of 1s in batches of 165, with all possibly initial shifts. Sole exception: shift=23. See RNGwalkwithshift.out.txt
\newcount\cnta
\newcount\cntb
\newcount\cntc
\newcount\cntd
\newcount\maxrand
\maxrand "10000000
% \the\maxrand
@jfbu
jfbu / RNGwalkwithshift.out.txt
Created May 6, 2018 11:02
Output of RNGwalkwithshift.tex
+++++++++++++++++++++++
10000 runs of 165 draws
+++++++++++++++++++++++
(shift=1, seed=0) 0:4666, 1:5334
(shift=1, seed=1) 0:4723, 1:5277
(shift=2, seed=0) 0:4635, 1:5365
(shift=2, seed=1) 0:4735, 1:5265
@jfbu
jfbu / RNGwalkwithshift23.tex
Created May 6, 2018 11:04
With initial shift of 22, 23 or 24 do 100000 batches of 165. More 1s than 0s for 22 and 24, more 0s than 1s for 23 (about 5sigma).
\newcount\cnta
\newcount\cntb
\newcount\cntc
\newcount\cntd
\newcount\maxrand
\maxrand "10000000
% \the\maxrand