26 #include <gsl/gsl_math.h>
27 #include <gsl/gsl_integration.h>
31 #include <opencog/util/platform.h>
32 #include <opencog/util/exceptions.h>
34 #define W() getU()-getL();
39 using namespace opencog;
50 double L_, U_, k_, s_;
51 double *in_params =
static_cast<double*
>(params);
56 double f = (pow((x - L_), (k_ * s_))) * pow((U_ -x), (k_ * (1 - s_)));
66 double result = 0.0, abserr = 0.0;
69 params[0] =
static_cast<double>(L_);
70 params[1] =
static_cast<double>(U_);
71 params[2] =
static_cast<double>(k_);
72 params[3] =
static_cast<double>(s_);
77 gsl_integration_qng (&F, lower, upper,
78 1e-1, 0.0, &result, &abserr, &neval);
133 return (
U == itv->
U &&
L == itv->
L
179 if (denominator > 0) result = numerator / denominator;
187 idiff = (idiff + max) / 2;
191 idiff = (min + idiff) / 2;
193 }
while (lte || gte);
283 W = std::max(W, static_cast<strength_t>(0.0000001));
307 return other->clone();
315 sprintf(buf,
"[%f,%f,%f,%f,%f,%d]",
316 static_cast<float>(
mean),
317 static_cast<float>(
L),
318 static_cast<float>(
U),
320 static_cast<float>(
diff),
strength_t findDiff(strength_t idiff)
find diff by dichotomy
confidence_t getConfidence() const
void setFirstOrderDistribution(const std::vector< strength_t * > &)
void init(strength_t l=0.0f, strength_t u=0.0f, confidence_t c=DEFAULT_CONFIDENCE_LEVEL)
const std::vector< strength_t * > & getFirstOrderDistribution() const
std::shared_ptr< TruthValue > TruthValuePtr
static double integralFormula(double x, void *params)
void setConfidenceLevel(confidence_t)
std::vector< strength_t * > firstOrderDistribution
TruthValueType getType() const
static confidence_t DEFAULT_CONFIDENCE_LEVEL
static strength_t diffError
confidence_t getConfidenceLevel() const
std::string toString() const
confidence_t confidenceLevel
referred as "b" in the paper
void copy(const IndefiniteTruthValue &)
TruthValuePtr merge(TruthValuePtr, TVMergeStyle ms=DEFAULT) const
static strength_t DensityIntegral(strength_t lower, strength_t upper, strength_t L_, strength_t U_, count_t k_, strength_t s_)
TruthValuePtr clone() const
strength_t getMean() const
virtual bool operator==(const TruthValue &rhs) const
it is a strict equality comparison, without error interval tolerance