7 #ifndef IMPISD_VON_MISES_H
8 #define IMPISD_VON_MISES_H
10 #include <IMP/isd/isd_config.h>
15 #include <boost/math/special_functions/bessel.hpp>
17 IMPISD_BEGIN_NAMESPACE
30 vonMises(
double x,
double mu,
double kappa)
31 :
Object(
"von Mises %1%"), x_(x), mu_(mu) {
32 force_set_kappa(kappa);
36 virtual double evaluate()
const {
return logterm_ - kappa_ * cos(x_ - mu_); }
38 virtual double evaluate_derivative_x()
const {
39 return kappa_ * sin(x_ - mu_);
42 virtual double evaluate_derivative_mu()
const {
43 return -kappa_ * sin(x_ - mu_);
46 virtual double evaluate_derivative_kappa()
const {
47 return -cos(x_ - mu_) + I1_ / I0_;
51 virtual double density()
const {
52 return exp(kappa_ * cos(x_ - mu_)) / (2 *
IMP::PI * I0_);
56 void set_x(
double x) { x_ = x; }
57 void set_mu(
double mu) { mu_ = mu; }
58 void set_kappa(
double kappa) {
59 if (kappa_ != kappa) {
60 force_set_kappa(kappa);
69 void force_set_kappa(
double kappa) {
71 I0_ = boost::math::cyl_bessel_i(0, kappa);
72 I1_ = boost::math::cyl_bessel_i(1, kappa);
73 logterm_ = log(2 *
IMP::PI * I0_);
75 double x_, mu_, kappa_, I0_, I1_, logterm_;
Helper functions to check for NaN or infinity.
static const double PI
the constant pi
Various useful constants.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Storage of a model, its restraints, constraints and particles.
Various general useful macros for IMP.
Common base class for heavy weight IMP objects.