35#ifndef STK_LAW_UNIFORMDISCRETE_H
36#define STK_LAW_UNIFORMDISCRETE_H
79 inline int const&
a()
const {
return a_;}
81 inline int const&
b()
const {
return b_;}
83 inline Real const&
n()
const {
return n_;}
90 virtual int rand()
const;
94 virtual Real pdf(
int const& x)
const;
98 virtual Real lpdf(
int const& x)
const;
117 static int rand(
int a,
int b);
162 if ((x <
a_)||(x >
b_))
return 0.;
168 if ((x <
a_)||(x >
b_))
return -Arithmetic<Real>::infinity();
169 return -std::log(
n_);
174 if (t <=
a_)
return 0.;
175 if (t >=
b_)
return 1.;
176 return (
b_ - (
int)t)/
n_;
181 if ((p > 1.) || (p < 0.))
185 if (p == 1.)
return b_;
186 if (p == 0.)
return a_;
187 return(
int)((1.-p) *
a_ + p *
b_);
195 GetRNGstate();
Real s =
a + Rf_runif(0,
double(
b -
a + 1)); PutRNGstate();
return s;
201 if ((x <
a)||(x >
b))
return 0.;
207 if ((x <
a)||(x >
b))
return -Arithmetic<Real>::infinity();
208 return -std::log(
b-
a+1);
211{
return (
b - t)/(
b-
a+1);}
213{
return (
int)((1.-p) *
a + p *
b);}
In this file we define the interface base class IUnivLaw for all probabilities laws.
#define STKDOMAIN_ERROR_1ARG(Where, Arg, Error)
#define STKINVALIDARGUMENT_ERROR_2ARG(Where, Arg1, Arg2, Error)
#define _T(x)
Let x unmodified.
virtual Real icdf(Real const &p) const
The inverse cumulative distribution function is.
Interface base class for all the univariate distributions.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.
static bool isFinite(Type const &x)