[081fbe]: src / modules / bugs / distributions / DRound.cc  Maximize  Restore  History

Download this file

101 lines (80 with data), 1.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
#include <config.h>
#include <util/nainf.h>
#include "JRmath.h"
#include "DRound.h"
#include <cfloat>
#include <algorithm>
using std::min;
using std::max;
using std::vector;
using std::vector;
#define T(par) (*par[0])
#define NDIGITS(par) (*par[1])
static inline double value(vector<double const *> const &par)
{
return fprec(T(par), NDIGITS(par));
}
static double tol = sqrt(DBL_EPSILON);
namespace bugs {
DRound::DRound()
: ScalarDist("dround", 2, DIST_SPECIAL)
{
}
bool
DRound::checkParameterValue(vector<double const *> const &parameters) const
{
return true;
}
bool DRound::checkParameterDiscrete(vector<bool> const &mask) const
{
return mask[1];
}
double
DRound::logDensity(double y, PDFType type,
vector<double const *> const &par,
double const *lower, double const *upper) const
{
return fabs(y - value(par)) < tol ? 0 : JAGS_NEGINF;
}
double DRound::randomSample(vector<double const *> const &par,
double const *lower, double const *upper,
RNG *rng) const
{
/*
The random sample from DRound is not random at all,
but deterministic.
*/
return value(par);
}
double DRound::typicalValue(vector<double const *> const &par,
double const *lower, double const *upper) const
{
return value(par);
}
unsigned int DRound::df() const
{
return 0;
}
double DRound::l(vector<double const *> const &par) const
{
return value(par);
}
double DRound::u(vector<double const *> const &par) const
{
return value(par);
}
bool DRound::isSupportFixed(vector<bool> const &fixmask) const
{
return fixmask[0] && fixmask[1];
}
double DRound::KL(vector<double const *> const &par1,
vector<double const *> const &par2) const
{
if (value(par1) == value(par2)) {
return 0;
}
else {
return JAGS_POSINF;
}
}
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks