FreeTensor
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
freetensor::DiscreteRandVar Class Reference

#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< DiscreteRandVarclone () const
 
const std::string & name () const
 

Friends

std::ostream & operator<< (std::ostream &os, const DiscreteRandVar &var)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ DiscreteRandVar()

freetensor::DiscreteRandVar::DiscreteRandVar ( const std::string &  name,
const Ref< RandCondInterface > &  cond,
const Ref< std::vector< int > >  totCnt,
const std::vector< int > &  initObs 
)
inline

Member Function Documentation

◆ clone()

Ref< DiscreteRandVar > freetensor::DiscreteRandVar::clone ( ) const
inline

Clone as an indenpenden variable

◆ name()

const std::string & freetensor::DiscreteRandVar::name ( ) const
inline

◆ observe()

void freetensor::DiscreteRandVar::observe ( int  value,
int  cnt = 1 
)
inline

◆ prob()

std::vector< double > freetensor::DiscreteRandVar::prob ( ) const
inline

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const DiscreteRandVar var 
)
friend

The documentation for this class was generated from the following file: