30 #include <opencog/util/platform.h>
31 #include <opencog/util/exceptions.h>
38 using namespace opencog;
83 throw RuntimeException(TRACE_INFO,
84 "Don't know how to merge %s into a SimpleTruthValue using the default style",
85 typeid(*other).name());
86 auto count2 = other->getCount();
88 auto mean_new = (
mean*
count + other->getMean()*count2)/(
count+count2);
89 return std::make_shared<SimpleTruthValue>(mean_new,count_new);
92 throw RuntimeException(TRACE_INFO,
93 "Unknown or not yet implemented merge strategy");
100 sprintf(buf,
"(stv %f %f)",
109 if (NULL == stv)
return false;
111 #define FLOAT_ACCEPTABLE_MEAN_ERROR 0.000001
119 #define FLOAT_ACCEPTABLE_COUNT_ERROR 0.0002
134 cf = std::min(cf, 0.9999998f);
135 return static_cast<count_t>(
KKK * cf / (1.0f - cf));
virtual count_t getCount() const =0
count_t count
Total number of observations used to estimate the mean.
a TruthValue that stores a mean and the number of observations (strength and confidence) ...
strength_t getMean() const
TruthValuePtr merge(TruthValuePtr, TVMergeStyle ms) const
#define FLOAT_ACCEPTABLE_COUNT_ERROR
std::shared_ptr< TruthValue > TruthValuePtr
static confidence_t countToConfidence(count_t)
TruthValueType getType() const
confidence_t getConfidence() const
#define FLOAT_ACCEPTABLE_MEAN_ERROR
virtual bool operator==(const TruthValue &rhs) const
static count_t confidenceToCount(confidence_t)
SimpleTruthValue(strength_t mean, count_t count)
virtual strength_t getMean() const =0
std::string toString() const
strength_t mean
Mean of the strength of the TV over all observations.