Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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.
\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
#!/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 / 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
\documentclass{article}
\newenvironment{foo}{}{}
\begin{document}
\begin{foo}
\noindent\begin{minipage}{\linewidth}
bar!
\end{minipage}
@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