|
FreeTensor
|
#include <rand_var.h>
Public Member Functions | |
| DiscreteRandVar (const std::string &name, const Ref< RandCondInterface > &cond, const Ref< std::vector< int > > totCnt, const std::vector< int > &initObs) | |
| void | observe (int value, int cnt=1) |
| std::vector< double > | prob () const |
| Ref< DiscreteRandVar > | clone () const |
| const std::string & | name () const |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const DiscreteRandVar &var) |
Discrete random variable, can be any integer in [0, n)
A random variable that can be sampled (infered) and observed (learnt) using Naive Bayes
In Naive Bayes, the probability of an event C given conditions F_i, can be calculated by p(C) \Prod_i P(F_i | C) (https://en.wikipedia.org/wiki/Naive_Bayes_classifier). Here a DiscreteRandVar records P(F_i | C) for each C as prob. When picking the most likely C, one only need to multiply the obsVec vectors from each F_i, and pick a C with highest value
|
inline |
|
inline |
Clone as an indenpenden variable
|
inline |
|
inline |
|
inline |
|
friend |