[#absl-LogUniform]
= xref:absl.adoc[absl]::LogUniform
:relfileprefix: ../
:mrdocs:

Produces random integral values whose logarithm is uniformly distributed&period;

== Synopsis

Declared in `&lt;absl&sol;random&sol;distributions&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename IntType,
    typename URBG&gt;
IntType
LogUniform(
    URBG&& urbg,
    IntType lo,
    IntType hi,
    IntType base = 2);
----

== Description

`absl&colon;&colon;LogUniform` produces random values distributed where the log to a given base of all values is uniform in a closed interval &lsqb;lo, hi&rsqb;&period; `T` must be an integral type, but may be inferred from the types of `lo` and `hi`&period;

I&period;e&period;, `LogUniform(0, n, b)` is uniformly distributed across buckets &lsqb;0&rsqb;, &lsqb;1, b&hyphen;1&rsqb;, &lsqb;b, b&circ;2&hyphen;1&rsqb;&period;&period; &lsqb;b&circ;(k&hyphen;1), (b&circ;k)&hyphen;1&rsqb;&period;&period; &lsqb;b&circ;floor(log(n, b)), n&rsqb; and is uniformly distributed within each bucket&period;

The resulting probability density is inversely related to bucket size, though values in the final bucket may be more likely than previous values&period; (In the extreme case where n &equals; b&circ;i the final value will be tied with zero as the most probable result&period;

If `lo` is nonzero then this distribution is shifted to the desired interval, so LogUniform(lo, hi, b) is equivalent to LogUniform(0, hi&hyphen;lo, b)&plus;lo&period;

See https&colon;&sol;&sol;en&period;wikipedia&period;org&sol;wiki&sol;Reciprocal&lowbar;distribution

Example&colon;

absl&colon;&colon;BitGen bitgen&semi; &period;&period;&period; int v &equals; absl&colon;&colon;LogUniform(bitgen, 0, 1000)&semi;

== Return Value

A random value drawn from the log&hyphen;uniform distribution&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *urbg*
| The uniform random bit generator&period;
| *lo*
| The inclusive lower bound of the interval&period;
| *hi*
| The inclusive upper bound of the interval&period;
| *base*
| The logarithm base determining the bucket sizes&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
