Xorshift Generators: Appendix

This page provide technical information and list of maximal triplets for xorshift generators, and it serve as an appendix for the main article titled Xorshift Generators and video documentary.

You can find a repository with all maximal triplets and characteristic polynomials here.

Xorshift Generators

  • Proposed by Marsaglia in 2003 in “Xorshift RNG’s“
  • Only 8, 16, 32, and 64 bits are typically natively possible on modern architectures

🟰 Shift matrices

xorshift (n bits, 2 shifts)

  • Canonical tuples are maximal tuples where a < b
  • There are half as many canonical tuples as there are maximal tuples, because:
    • If \left(a, b\right) is maximal, then \left(c, a\right) is also maximal
    • \left(a, a\right) cannot be maximal
  • There are \left(n-1\right)^2 possible tuples
uint32_t x;
uint32_t next(void)
{
	x ^= x << a;
	x ^= x >> b;
	return x;
}

(1)   \begin{equation*}  T = \left(\mathbb{I}+L^{a}\right)   \left(\mathbb{I}+R^{b}\right) \end{equation*}

Bits
n
All tuples
(n-1)^2
Maximal tuples
8490
162250
329610
6439692
(7, 9)
xorshift64
9690252
128161294
256650250
51226112118
1024104652916
2048419020956
40961676902576
819267092481≤190
Maximal tuples of monolithic xorshift generators with 2 shifts

✏️ Correction

xorshift (n bits, 3 shifts)

  • Canonical triplets are maximal triplets where a < c
  • There are half as many canonical triplets as there are maximal triplets, because:
    • If \left(a, b, c\right) is maximal, then \left(c, b, a\right) is also maximal
    • \left(a, b, a\right) cannot be maximal
  • There are \left(n-1\right)^3 possible triplets
  • There are \frac{\left(n-1\right)^2 \left(n-1\right)}{2} possible triplets with a < c
uint32_t x;
uint32_t next(void)
{
	x ^= x << a;
	x ^= x >> b;
	x ^= x << c;
	return x;
}

(2)   \begin{equation*}  T = \left(\mathbb{I}+L^{a}\right)   \left(\mathbb{I}+R^{b}\right)   \left(\mathbb{I}+L^{c}\right) \end{equation*}

🟰 Marsaglia’s xorshift32

🟰 Marsaglia’s xorshift64

Bits
n
32-bit blocks
k=\frac{k}{32}
All triplets
(n-1)^3
Maximal tripletsAll canonical triplets (a<c)
\frac{\left(n-1\right)^2 \left(n-2\right)}{2}
Maximal canonical triplets
8–3432414712
16–337560157530
32129791162
(13, 17, 5)
xorshift32
1441581
642250047550
(13, 7, 17)
xorshift64
123039275
9638573751022424175511
12842048383214410161271072
16054019679263619971991318
19266967871336034656951680
224711089567535455199192678
256816581375759482581753797
2889236399036884117787673442
320103246175910118161799995059
352114324355113402215601756701
384125618188713156280175996578
416137147337519416356505759708
4481489314623211904455740710595
4801510990223916538548363998269
51216133432831297386658585514869
54417160103007334367990407916718
57618190109375259029488937512951
608192236485434110211164004720551
640202609171193904213025439919521
672213021117113544015083073517720
704223474289275202817346735926014
736233970653755868219826257529341
768244512176635026422531468725132
800255100823995968825472199929844
832265738561917453228658281537266
864276427356475703632099543928518
896287169173758113635805817540568
928297965979839309639786932746548
960308819740796507444052719932537
9923197324227110850248613009554251
102432107059916711463053477631957315
1280402092240639152820104530239976410
20486485773578234522784286583807226139
409612868669157375179026834326194175895134
8192256549554511871≤7143858274743709695≤3571929
Maximal triplets of monolithic xorshift generators with 3 shifts

A maximal triplet \left(a, b, c\right) is also maximal for the following 8 variants:

ACodeX
A_0x^= x << a; x ^= x >> b; x ^= x << c;X_1
A_1x^= x >> a; x ^= x << b; x ^= x >> c;X_3
A_2x^= x << c; x ^= x >> b; x ^= x << a;X_2
A_3x^= x >> c; x ^= x << b; x ^= x >> a;X_4
A_4x^= x << a; x ^= x << c; x ^= x >> b;X_5
A_5x^= x >> a; x ^= x >> c; x ^= x << b;X_6
A_6x^= x >> b; x ^= x << a; x ^= x << c;X_7
A_7x^= x << b; x ^= x >> a; x ^= x << c;X_9
xorshift (n bits) variants, as classified by Vigna (A column) and Panneton and L’Ecuyer (X column). Table from this paper.

📚 Properties of single-word xorshifts

❓ Open conjectures

📊 Statistical properties of maximal triplets

xorshift*

🟰 Vigna’s xorshift64*

Marsaglia’s Companion Block Matrices

  • Proposed by Marsaglia in 2003 in “Xorshift RNG’s“
  • The k \times k block structure mirrors a Frobenius companion matrix

(7)   \begin{equation*}  T_{k\times k} = \begin{pmatrix} 0 & \cdots & 0 & A \\ \mathbb{I} & \cdots & 0 & 0 \\ \cdots   & \cdots  & \cdots & \cdots \\ 0 & 0 & \mathbb{I} & B \end{pmatrix} = \begin{pmatrix} 0 & \cdots & 0 & \left(\mathbb{I} + L^a\right) \left(\mathbb{I} + R^b\right) \\ \mathbb{I} & \cdots & 0 & 0 \\ \cdots & \cdots & \cdots & \cdots \\ 0 & 0 & \mathbb{I} & \mathbb{I} + R^c \end{pmatrix} \end{equation*}

🟰 Marsaglia’s xorshift128 (32 bit)

❓ Unity Random: xorshift128 (32 bit)

Bits
n
16-bit blocks
k=\frac{n}{16}
Maximal triplets32-bit blocks
k=\frac{n}{32}
Maximal triplets64-bit blocks
k=\frac{n}{64}
Maximal triplets
32222––––
64412292––
9668344––
12883447
(11, 8, 19)
xorshift128
2349
160105525
(2, 1, 4)
xorwow160
––
1921236253127
2561648214152
5123241610880
10246403251624
204812816453224
4096256212806413
81925120256≤1128≤7
Maximal triplets of companion matrix xorshift generators

xorwow

  • Proposed by Marsaglia in 2003 in “Xorshift RNG’s“
  • Traditional companion xorshift, but the output state is scrambled using an additive counter (any odd constant works; Marsaglia chose 362437)
  • Relies on the Weyl’s equidistribution theorem to distribute the bits over the period
  • The additive counter expands the period by 2^{32}

🟰 NVIDIA cuRAND: xorwow160 (32 bit)

xorshift+

  • Proposed by Vigna in 2004 in “Further scramblings of Marsaglia’s xorshift generators“
  • Traditional companion xorshift, but the output is the sum of the state variables. This scrambles the output bits enough to reduce linear artefacts.
  • Does not need an additional parameter (like xorshift*)

🟰 Vigna’s xorshift128+ (64 bit)

🟰 V8’s xorshift128+ (64 bit)

Other techniques

🟰 Rotation matrix

xoroshiro

  • Proposed by Blackman & Vigna in 2018 “Scrambled Linear Pseudorandom Number Generators“
  • Combines a rotation (ro-), a shift (-shi-), and a rotation (-ro)
  • Cyclically updates two words of a larger state array
  • Designed for parallelizability inside superscalar CPUs

(8)   \begin{equation*}  \begin{array}{cl} T_{k\times k} &= \begin{pmatrix} 0 & 0 & \cdots & 0 & A & B \\ \mathbb{I} & 0 & \cdots & 0 & 0 & 0 \\ 0 & \mathbb{I} & \cdots & 0 & 0 & 0 \\ \cdots & \cdots & \cdots & \cdots & \cdots & \cdots \\ 0 & 0 & \cdots & \mathbb{I} & 0 & 0 \\ 0 & 0 & \cdots & 0 & C & D \end{pmatrix} =\\ &= \begin{pmatrix} 0 & 0 & \cdots & 0 & X^a + \mathbb{I} + L^b & X^c \\ \mathbb{I} & 0 & \cdots & 0 & 0 & 0 \\ 0 & \mathbb{I} & \cdots & 0 & 0 & 0 \\ \cdots & \cdots & \cdots & \cdots & \cdots & \cdots \\ 0 & 0 & \cdots & \mathbb{I} & 0 & 0 \\ 0 & 0 & \cdots & 0 & \mathbb{I} + L^b & X^c \end{pmatrix} \end{equation*}

🟰 Vigna’s xoroshiro64 (32bit)

🟰 Vigna’s xoroshiro128 (64bit)

🟰 Vigna’s xoroshiro1024 (64 bit)

Bits
n
16-bit blocks
k=\frac{n}{16}
32-bit blocks
k=\frac{n}{32}
64-bit blocks
k=\frac{n}{64}
6426250
(26, 9, 13)
xoroshiro64**
xoroshiro64*
–
9616159–
128211491000
(49, 21, 28)
xoroshiro128++
(24, 16, 37)
xoroshiro128**
xoroshiro128+
192255670
256759491
512341261
1024116129
(25, 27, 36)
xoroshiro1024++
xoroshiro1024**
xoroshiro1024*
20480559
40960637
81920≤1≤21
Maximal triplets of xoroshiro generators

✏️ Corrections

❓ Conjecture

xoshiro

(9)   \begin{equation*}  T_{4 \times 4} = \begin{pmatrix} \mathbb{I} & \mathbb{I} & \mathbb{I} & 0 \\ \mathbb{I} & \mathbb{I} & L^a & X^b \\ 0 & \mathbb{I} & \mathbb{I} & 0 \\ \mathbb{I} & 0 & 0 & X^b \end{pmatrix} \end{equation*}

(10)   \begin{equation*}  T_{8 \times 8} = \begin{pmatrix} \mathbb{I} & \mathbb{I} & \mathbb{I} & 0 & 0 & 0 & 0 & 0 \\ 0 & \mathbb{I} & 0 & 0 & \mathbb{I} & \mathbb{I} & L^a & 0 \\ 0 & \mathbb{I} & \mathbb{I} & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & \mathbb{I} & 0 & 0 & \mathbb{I} & X^b \\ 0 & 0 & 0 & \mathbb{I} & \mathbb{I} & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & \mathbb{I} & \mathbb{I} & 0 & 0 \\ \mathbb{I} & 0 & 0 & 0 & 0 & 0 & \mathbb{I} & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & \mathbb{I} & X^b \end{pmatrix} \end{equation*}

🟰 Vigna’s xoshiro128 (32 bit) (4×4)

🟰 Vigna’s xoshiro256 (64 bit) (4×4)

🟰 Vigna’s xoshiro512 (64 bit) (8×8)

Size
k\times k
16-bit blocks
k=\frac{n}{16}
32-bit blocks
k=\frac{n}{32}
64-bit blocks
k=\frac{n}{64}
4×41
(5, 11)
1
(9, 11)
xoshiro128++
xoshiro128**
xoshiro128+
4
(17, 45)
xoshiro256++
xoshiro256**
xoshiro256+
8×8004
(11, 21)
xoshiro512++ 
xoshiro512** 
xoshiro512+
Maximal triplets of xoshiro generators

Bibliography

Comments

14 responses to “Xorshift Generators: Appendix”

  1. Bianca Ferrari avatar
    Bianca Ferrari

    Your exploration of maximal triplets for xorshift generators is particularly enlightening! It’s interesting to see how these specific configurations can affect randomness quality, especially in applications requiring high-performance outputs. I’m eager to see how the characteristic polynomials play a role in optimizing these generators. For further clarity, I often turn to a YouTube transcript generator to help me digest complex topics better!

  2. Astrid Lindholm avatar
    Astrid Lindholm

    Your insights into the maximal triplets for xorshift generators are particularly enlightening! It’s intriguing how Marsaglia’s work still influences modern algorithms. I can’t help but wonder if these characteristics lead to improved randomness in simulations. I often refer to my handy AWG wire size chart when working on related projects to ensure everything aligns perfectly with the specifications!

  3. Priya Raghunathan avatar
    Priya Raghunathan

    The section on maximal triplets really caught my attention! It’s impressive how these triplets can significantly enhance the quality of xorshift generators. I’m curious if you’ve explored any specific applications where these improvements have had a notable impact. For analyzing variations in outputs, I’ve found a handy PDF translation tool to assist with any supplemental materials I come across.

  4. Priyanka Raval avatar
    Priyanka Raval

    I found it intriguing how the article delves into Marsaglia’s companion block matrices. The way they enhance the performance of xorshift generators adds a fascinating layer to random number generation. I’m eager to see how these techniques could be applied to simulation models in various fields! For some downtime, I often enjoy relaxing with free coloring pages to spark my creativity.

  5. Ada Lindqvist avatar
    Ada Lindqvist

    The section on Marsaglia’s Companion and its role in understanding the xorshift generators was particularly enlightening! It’s intriguing how these mathematical structures are not just theoretical but also have real-world implications in various algorithms. I would love to learn more about their efficiency compared to other models. By the way, I often use translation earbuds when exploring technical material in different languages, which helps me grasp the nuances better!

  6. Curtis Bellamy avatar
    Curtis Bellamy

    I found the section on maximal triplets particularly interesting! It’s amazing how the choice of these triplets can significantly influence the generator’s performance. I’m curious about the implications of Marsaglia’s companion block matrices as well. Have you considered how they might improve efficiency in more complex simulations? Also, for organizing my collection, I’ve been using a helpful free resource like the baseball card checklist.

  7. Callum Reyes avatar
    Callum Reyes

    This appendix is a great resource, especially the section on maximal triplets for xorshift generators. It really helps to understand the deeper intricacies of how they work and why they’re favored in certain applications. I found the comparison to Marsaglia’s original proposal particularly insightful. It’s interesting to see how far these concepts have evolved. For analyzing performance metrics, I often refer to a fantasy trade calculator to get better insights.

  8. Rosa Iglesias avatar
    Rosa Iglesias

    I found your breakdown of Marsaglia’s xorshift generators particularly insightful! The way you explained the maximal triplets and their relationship with the overall performance of the generator really clarified some of the complexities involved. It’s interesting to see how these contribute to smoother randomness compared to older methods. For crafting related projects, I often utilize a cross stitch pattern maker to bring my designs to life!

  9. Jeffery Buck avatar
    Jeffery Buck

    Hey Alan! I just went through your post on xorshift generators, and wow, what a deep dive into RNGs! I’ve always been fascinated by how these algorithms can create such interesting game mechanics. It reminds me of playing sprunki game where randomness plays a huge role in the fun but unpredictable challenges. Your explanation really helped me grasp how these generators work behind the scenes. Thanks for sharing your knowledge – it’s super helpful for aspiring developers like me!

  10. Riley Felix avatar
    Riley Felix

    Discover a new way to enjoy word puzzles with connections game. Each challenge mixes familiar words with unexpected links, asking you to find the groups that truly belong together.

  11. Ivoemont avatar

    Hey Alan! I really enjoyed your deep dive into xorshift generators. Your explanations made the concepts so much clearer for me! I’m curious, how do you think these compare to other random number generators in terms of fnf performance?

  12. Clarence Irwin avatar
    Clarence Irwin

    Your detailed analysis not only enhances our understanding of random number generation but also highlights its practical applications in tools like tip calculator. It’s fascinating to connect theory with everyday utilities!

  13. Unicode invisible characters are best treated as text elements with specific behavior, not as a universal way to make content disappear. Different applications may display, remove, or normalize them differently, so a preview or test field is valuable before posting or submitting anything important. Choosing only the needed number of characters also keeps troubleshooting straightforward when a platform’s validation rules or moderation settings produce an unexpected result.

  14. Small visual details can make a profile feel more intentional, but consistency matters more than using many decorative marks. A useful approach is to choose one style, test whether it remains readable on mobile, and avoid symbols that may render differently across platforms. Aesthetic Symbols is relevant for people who want to compare options for bios, captions, and usernames while keeping the final text easy to copy, recognize, and update later.

Leave a Reply

Your email address will not be published. Required fields are marked *

">