[#absl-discrete_distribution]
= xref:absl.adoc[absl]::discrete&lowbar;distribution
:relfileprefix: ../
:mrdocs:

A distribution over random integers&period;

== Synopsis

Declared in `&lt;absl&sol;random&sol;discrete&lowbar;distribution&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename IntType = int&gt;
class discrete&lowbar;distribution;
----

== Description

A discrete distribution produces random integers i, where 0 &lt;&equals; i &lt; n distributed according to the discrete probability function&colon;

P(i&verbar;p0,&period;&period;&period;,pn&hyphen;1)&equals;pi

This class is an implementation of discrete&lowbar;distribution (see &lsqb;rand&period;dist&period;samp&period;discrete&rsqb;)&period;

The algorithm used is Walker&apos;s Aliasing algorithm, described in Knuth, Vol 2&period; absl&colon;&colon;discrete&lowbar;distribution takes O(N) time to precompute the probabilities (where N is the number of possible outcomes in the distribution) at construction, and then takes O(1) time for each variate generation&period; Many other implementations also take O(N) time to construct an ordered sequence of partial sums, plus O(log N) time per variate to binary search&period;

== Types

[cols="1,4"]
|===
| Name| Description
| xref:absl/discrete_distribution/param_type.adoc[`param&lowbar;type`] 
| The parameter set of the distribution&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:absl/discrete_distribution/result_type.adoc[`result&lowbar;type`] 
| The type of the values produced by the distribution&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/discrete_distribution/2constructor-03.adoc[`discrete&lowbar;distribution`]         [.small]#[constructor]#
| Constructors
| xref:absl/discrete_distribution/max.adoc[`max`] 
| Returns the largest value the distribution can produce&period;
| xref:absl/discrete_distribution/min.adoc[`min`] 
| Returns the smallest value the distribution can produce&period;
| xref:absl/discrete_distribution/operator_call-0f.adoc[`operator()`] 
| Function call operators
| xref:absl/discrete_distribution/param-0a.adoc[`param`] 
| `param` overloads
| xref:absl/discrete_distribution/probabilities.adoc[`probabilities`] 
| Returns the normalized probabilities of the outcomes&period;
| xref:absl/discrete_distribution/reset.adoc[`reset`] 
| Resets the internal state of the distribution&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:absl/operator_not_eq-0fd.adoc[absl::operator!&equals;]`
| Compares two distributions for inequality&period;
| `xref:absl/operator_eq-08c.adoc[absl::operator&equals;&equals;]`
| Compares two distributions for equality&period;
|===


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