Skip to content

Commit

Permalink
Uniform discrete distribution (#1250)
Browse files Browse the repository at this point in the history
Addition of a discrete distribution with sampling strategy.
  • Loading branch information
mandd authored Jun 11, 2020
1 parent 1c7c2cb commit 923835f
Show file tree
Hide file tree
Showing 18 changed files with 759 additions and 12 deletions.
12 changes: 12 additions & 0 deletions developer_tools/XSDSchemas/Distributions.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<xsd:element name="Binomial" type="BinomialDistribution" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="Poisson" type="PoissonDistribution" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="Categorical" type="CategoricalDistribution" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="UniformDiscrete" type="UniformDiscreteDistribution" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="MarkovCategorical" type="MarkovCategoricalDistribution" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="Custom1D" type="Custom1DDistribution" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="NDInverseWeight" type="NDInverseWeightDistribution" minOccurs="0" maxOccurs="unbounded"/>
Expand Down Expand Up @@ -192,6 +193,17 @@
<xsd:attribute name="verbosity" type="verbosityAttr" default="all"/>
</xsd:complexType>

<xsd:complexType name="UniformDiscreteDistribution">
<xsd:all>
<xsd:element name="lowerBound" type="xsd:decimal" minOccurs="1"/>
<xsd:element name="upperBound" type="xsd:decimal" minOccurs="1"/>
<xsd:element name="strategy" type="xsd:string" minOccurs="1"/>
<xsd:element name="nPoints" type="xsd:string" minOccurs="0"/>
</xsd:all>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="verbosity" type="verbosityAttr" default="all"/>
</xsd:complexType>

<xsd:complexType name="stateType">
<xsd:simpleContent>
<xsd:extension base="xsd:decimal">
Expand Down
44 changes: 44 additions & 0 deletions doc/user_manual/ProbabilityDistributions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,50 @@ \subsubsection{1-Dimensional Discrete Distributions.}
</Distributions>
\end{lstlisting}

\paragraph{Uniform Discrete Distribution}
\label{subsec:UniformDiscrete}

The \textbf{UniformDiscrete} distribution is a discrete distribution which describes a random variable
that can have $N$ values having equal probability value.
This distribution allows the user to choose two kinds of sampling strategies: with or without replacement.
In case the ``without replacement'' strategy is used, the distribution samples from the set of specified $N$ values
reduced by the previously sampled values.
After, the sampler has generated values for all variables, the distribution is
resetted (i.e., the set of values that can be sampled is returned to $N$).
In case the ``with replacement'' strategy is used, the distribution samples always from the complete set of specified $N$ values.

\specBlock{a}{Uniform Discrete}
%
\attrIntro
\vspace{-5mm}
\begin{itemize}
\itemsep0em
\item \nameDescription
\end{itemize}
\vspace{-5mm}
\subnodeIntro
\begin{itemize}
\item \xmlNode{lowerBound}, \xmlDesc{integer, required parameter}, lower bound.
\item \xmlNode{upperBound}, \xmlDesc{integer, required parameter}, upper bound.
\item \xmlNode{nPoints}, \xmlDesc{integer, optional parameter}, number of points between lower and upper bound
\item \xmlNode{strategy}, \xmlDesc{string, required parameter}, type of sampling strategy
(withReplacement or withoutReplacement).
%
\end{itemize}

Example:
\begin{lstlisting}[style=XML]
<Distributions>
...
<UniformDiscrete name="UD_dist">
<lowerBound>3</lowerBound>
<upperBound>8</upperBound>
<strategy>orderedWithReplacement</strategy>
</UniformDiscrete>
...
</Distributions>
\end{lstlisting}

\paragraph{Markov Categorical Distribution}
\label{subsec:markovCategorical}

Expand Down
2 changes: 1 addition & 1 deletion doc/user_manual/generated/generateOptimizerDoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ def insertSolnExport(tex, obj):

fName = os.path.abspath(os.path.join(os.path.dirname(__file__), 'optimizer.tex'))
with open(fName, 'w') as f:
f.writelines(msg)
f.writelines(msg)
Loading

0 comments on commit 923835f

Please sign in to comment.