random: remove bmrand() and prand()
We do not need these functions in Spot. * spot/misc/random.cc, spot/misc/random.hh (bmrand, prand): Remove. * NEWS: Mention it.
This commit is contained in:
parent
74215eaa4a
commit
0bbcb7f35d
3 changed files with 6 additions and 57 deletions
4
NEWS
4
NEWS
|
|
@ -158,6 +158,10 @@ New in spot 2.4.1.dev (not yet released)
|
||||||
function also do not take to list of atomic propositions as an
|
function also do not take to list of atomic propositions as an
|
||||||
argument anymore.
|
argument anymore.
|
||||||
|
|
||||||
|
- The spot::bmrand() and spot::prand() functions have been removed.
|
||||||
|
They were not used at all in Spot, and it's not Spot's objective
|
||||||
|
to provide such random functions.
|
||||||
|
|
||||||
Bugs fixed:
|
Bugs fixed:
|
||||||
|
|
||||||
- Automata produced by "genaut --ks-nca=N" were incorrectly marked
|
- Automata produced by "genaut --ks-nca=N" were incorrectly marked
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015 Laboratoire de Recherche et
|
// Copyright (C) 2011-2015, 2017 Laboratoire de Recherche et
|
||||||
// Développement de l'Epita (LRDE).
|
// Développement de l'Epita (LRDE).
|
||||||
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
|
|
@ -87,46 +87,4 @@ namespace spot
|
||||||
else
|
else
|
||||||
return t - (p / q);
|
return t - (p / q);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
|
||||||
bmrand()
|
|
||||||
{
|
|
||||||
static double next;
|
|
||||||
static bool has_next = false;
|
|
||||||
|
|
||||||
if (has_next)
|
|
||||||
{
|
|
||||||
has_next = false;
|
|
||||||
return next;
|
|
||||||
}
|
|
||||||
|
|
||||||
double x;
|
|
||||||
double y;
|
|
||||||
double r;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
x = 2.0 * drand() - 1.0;
|
|
||||||
y = 2.0 * drand() - 1.0;
|
|
||||||
r = x * x + y * y;
|
|
||||||
}
|
|
||||||
while (r >= 1.0 || r == 0.0);
|
|
||||||
r = sqrt(-2 * log(r) / r);
|
|
||||||
next = y * r;
|
|
||||||
has_next = true;
|
|
||||||
return x * r;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
prand(double p)
|
|
||||||
{
|
|
||||||
double s = 0.0;
|
|
||||||
long x = 0;
|
|
||||||
|
|
||||||
while (s < p)
|
|
||||||
{
|
|
||||||
s -= log(1.0 - drand());
|
|
||||||
++x;
|
|
||||||
}
|
|
||||||
return x - 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2015 Laboratoire de Recherche et Développement
|
// Copyright (C) 2015, 2017 Laboratoire de Recherche et Développement
|
||||||
// de l'Epita (LRDE).
|
// de l'Epita (LRDE).
|
||||||
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
|
|
@ -66,13 +66,6 @@ namespace spot
|
||||||
/// Statistics, 1974, vol 23, pp 96-97.
|
/// Statistics, 1974, vol 23, pp 96-97.
|
||||||
SPOT_API double nrand();
|
SPOT_API double nrand();
|
||||||
|
|
||||||
/// \brief Compute a pseudo-random double value
|
|
||||||
/// following a standard normal distribution. (Box-Muller)
|
|
||||||
///
|
|
||||||
/// This uses the polar form of the Box-Muller transform
|
|
||||||
/// to generate random values.
|
|
||||||
SPOT_API double bmrand();
|
|
||||||
|
|
||||||
/// \brief Compute pseudo-random integer value between 0
|
/// \brief Compute pseudo-random integer value between 0
|
||||||
/// and \a n included, following a binomial distribution
|
/// and \a n included, following a binomial distribution
|
||||||
/// with probability \a p.
|
/// with probability \a p.
|
||||||
|
|
@ -113,12 +106,6 @@ namespace spot
|
||||||
const double s_;
|
const double s_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Return a pseudo-random positive integer value
|
|
||||||
/// following a Poisson distribution with parameter \a p.
|
|
||||||
///
|
|
||||||
/// \pre <code>p > 0</code>
|
|
||||||
SPOT_API int prand(double p);
|
|
||||||
|
|
||||||
/// \brief Shuffle the container using mrand function above.
|
/// \brief Shuffle the container using mrand function above.
|
||||||
/// This allows to get rid off shuffle or random_shuffle that use
|
/// This allows to get rid off shuffle or random_shuffle that use
|
||||||
/// uniform_distribution and RandomIterator that are not portables.
|
/// uniform_distribution and RandomIterator that are not portables.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue