ArticleslgStudy

biology

Permuted congruential generator

Permuted congruential generator is a biology topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Permuted congruential generator rather than just read about it. In short: A permuted congruential generator (PCG) is a pseudorandom number generation algorithm developed in 2014 by Dr. M.E.

Key takeaways

  • Permuted congruential generator belongs to biology; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Permuted congruential generator to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Permuted congruential generator from memory before moving on to harder problems.

Reference excerpt

A permuted congruential generator (PCG) is a pseudorandom number generation algorithm developed in 2014 by Dr. M.E. O'Neill which applies an output permutation function to improve the statistical properties of a modulo-2n linear congruential generator (LCG). It achieves excellent statistical performance with small and fast code, and small state size. LCGs with a power-of-2 modulus are simple, efficient, and have uniformly distributed binary outputs, but suffer from a well-known problem of short periods in the low-order bits. A PCG addresses this by adding an output transformation between the LCG state and the PCG output. This adds two elements to the LCG:

if possible, the LCG modulus and state is expanded to twice the size of the desired output, so the shortest-period state bits do not affect the output at all, and the most significant bits of the state are used to select a bitwise rotation or shift which is applied to the state to produce the output. The variable rotation ensures that all output bits depend on the most-significant bit of state, so all output bits have full period.

Variants The PCG family includes a number of variants. The core LCG is defined for widths from 8 to 128 bits, although only 64 and 128 bits are recommended for practical use; smaller sizes are for statistical tests of the technique. The additive constant in the LCG can be varied to produce different streams. The constant is an arbitrary odd integer, so it does not need to be stored explicitly; the address of the state variable itself (with the low bit set) can be used. There are several different output transformations defined. All perform well, but some have a larger margin than others. They are built from the following components:

RR: A random (input-dependent) rotation, with output half the size of input. Given a 2b-bit input word, the b−1 most significant bits are used for the rotate amount, the next-most-significant 2b−1 bits are rotated right and used as the output, and the low 2b−1+1−b bits are discarded. RS: A random (input-dependent) shift, for cases where rotates are more expensive. Again, the output is half the size of the input. Beginning with a 2b-bit input word, the most significant b−3 bits are used for a shift amount, which is applied to the next-most-significant 2b−1+2b−3−1 bits, and the least significant 2b−1 bits of the result are output. The low 2b−1−2b−3−b+4 bits are discarded. XSH: An xorshift operation, x ^= x >> constant. The constant is chosen to be half of the bits (rounded down) not discarded by the following RR or RS operation. XSL: A simplified version of xorshift, folding the value in half by XORing the high half into the low. The folded value is used for subsequent rotations. RXS: An xorshift by a variable (input-dependent) amount. The most significant b−2 bits are used to select a shift amount between b−2 and 2b−2+b−3. M: A multiply by a fixed constant. Each of these operations is either invertible (and thus one-to-one) or a truncation (and thus 2k-to-one for some fixed k), so their composition maps the same fixed number of input states to each output value. This preserves the equidistribution of the underlying LCG. These are combined into the following recommended output transformations, illustrated here in their most common sizes:

XSH-RR: An xorshift mixes some high-order bits down, then bits 63–59 select a rotate amount to be applied to bits 27–58. (64→32 bits) count = (int)(x >> 59); x ^= x >> 18; return rotr32((uint32_t)(x >> 27), count);. XSH-RS: Similar, but fewer bits select the shift amount. (64→32 bits) count = (int)(x >> 61); x ^= x >> 22; return (uint32_t)(x >> (29 - count));. XSL-RR: A simplified version of XSH-RR, this is optimized for 128-bit states implemented using two words on 64-bit machines. (128→64 bits) count = (int)(x >> 122); x64 = (uint64_t)(x ^ (x >> 64)); return rotr64(x64, count); RXS-M-XS: The slowest and strongest output transformation when used to produce half-size output, this becomes the weakest when used as intended, to produce an output the same size as the state. For use when the state size must be limited to 32 or 64 bits. (32→32 bits) count=(int)(x >> 28); x ^= x >> (4 + count); x *= 277803737u; return x ^ (x >> 22); (64→64 bits) count=(int)(x >> 59); x ^= x >> (5 + count); x *= 12605985483714917081u; return x ^ (x >> 43); XSL-RR-RR: Similar to the preceding, this turns 128 bits of state into 128 bits of output, when the application demands it. (128→128 bits) count = (int)(x >> 122); low64 = rotr64((uint64_t)(x ^ (x >> 64)), count); high64 = rotr64((uint64_t)(x >> 64), low64 & 63); return (uint128_t)high64 << 64 | low64; Finally, if a generator period longer than 2128 is required, the generator can be extended with an array of sub-generators. One is chosen (in rotation) to be added to the main generator's output, and every time the main generator's state reaches zero, the sub-generators are cycled in a pattern which provides a period equal to 2 to the power of the total state size.

Example code The generator recommended for most users is PCG-XSH-RR with 64-bit state and 32-bit output. It can be implemented as:

The generator applies the output transformation to the initial state rather than the final state in order to increase the available instruction-level parallelism to maximize performance on modern superscalar processors. A slightly faster version eliminates the increment, reducing the LCG to a multiplicative (Lehmer-style) generator with a period of only 262, and uses the weaker XSH-RS output function:

The time saving is minimal, as the most expensive operation (the 64×64-bit multiply) remains, so the normal version is preferred except in extremis. Still, this faster version also passes statistical tests. When executing on a 32-bit processor, the 64×64-bit multiply must be implemented using three 32×32→64-bit multiply operations. To reduce that to two, there are 32-bit multipliers which perform almost as well as the 64-bit one, such as 0xf13283ad, 0xffffffff0e703b65 or 0xf2fc5985.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Permuted congruential generator

Start with the simplest possible case. Write down what Permuted congruential generator claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In biology, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Permuted congruential generator before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Permuted congruential generator ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Permuted congruential generator

In research
Permuted congruential generator appears in biology research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Permuted congruential generator in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Permuted congruential generator is common in secondary-school and first-year university syllabi. It links to neighbouring topics Modular arithmetic, Pseudorandom number generators, so understanding it makes those chapters shorter.
In everyday life
Look for Permuted congruential generator outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Permuted congruential generator” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Permuted congruential generator in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Permuted congruential generator means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Permuted congruential generator out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Permuted congruential generator in simple terms?

A permuted congruential generator (PCG) is a pseudorandom number generation algorithm developed in 2014 by Dr. M.E.

Why does Permuted congruential generator matter?

Because it connects several biology ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Permuted congruential generator?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Permuted congruential generator.

Tags

  • Modular arithmetic
  • Pseudorandom number generators

Keep exploring