Help save net neutrality! Learn more.
Close

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

Download this file

64 lines (47 with data), 1.4 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
#include <config.h>
#include "DWeib.h"
#include <rng/RNG.h>
#include <util/nainf.h>
#include <vector>
#include <cmath>
#include <JRmath.h>
using std::vector;
using std::string;
#define SHAPE(par) (*par[0])
#define SCALE(par) (pow(*par[1], -1/(*par[0])))
#define V(par) (*par[0])
#define LAMBDA(par) (*par[1])
namespace bugs {
DWeib::DWeib()
: RScalarDist("dweib", 2, DIST_POSITIVE)
{}
string DWeib::alias() const
{
return "dweibull";
}
bool
DWeib::checkParameterValue (vector<double const *> const &par) const
{
//We can get underflow and overflow when changing parameterization
return (*par[0] > 0 && *par[1] > 0 && jags_finite(SCALE(par)) && SCALE(par) > 0);
}
double DWeib::d(double x, PDFType type,
vector<double const *> const &par, bool give_log) const
{
return dweibull(x, SHAPE(par), SCALE(par), give_log);
}
double DWeib::p(double q, vector<double const *> const &par, bool lower,
bool give_log) const
{
return pweibull(q, SHAPE(par), SCALE(par), lower, give_log);
}
double DWeib::q(double p, vector<double const *> const &par, bool lower,
bool log_p) const
{
return qweibull(p, SHAPE(par), SCALE(par), lower, log_p);
}
double DWeib::r(vector<double const *> const &par, RNG *rng) const
{
return rweibull(SHAPE(par), SCALE(par), rng);
}
}