PLearn 0.1
Public Member Functions
PLearn::RandomVar Class Reference

we follow the same pattern as Var & Variable More...

#include <RandomVar.h>

Inheritance diagram for PLearn::RandomVar:
Inheritance graph
[legend]
Collaboration diagram for PLearn::RandomVar:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RandomVar ()
 RandomVar (int length, int width=1)
 RandomVar (RandomVariable *v)
 RandomVar (const RandomVar &other)
 RandomVar (const Vec &vec)
 RandomVar (const Mat &mat)
 RandomVar (const Var &var)
 RandomVar (const RVArray &vars)
 make joint distribution
RandomVar operator[] (RandomVar index)
 extract from joint or element of vector
void operator= (const RVArray &vars)
void operator= (real f)
 these two only work with NonRandomVariables
void operator= (const Vec &v)
 copy v into value
void operator= (const Mat &m)
void operator= (const Var &v)
 assign value to v
RVInstance operator== (const Var &v) const
 associate a RV to an observation v, as in expressions of the form (V==v)
bool operator== (const RandomVar &rv) const
 compare two RandomVars: == if same underlying RandomVariable (same address)
bool operator!= (const RandomVar &rv) const
RVArray operator& (const RandomVar &v) const
 make an array of RV's, as in expressions like X&Y
ConditionalExpression operator| (RVArray rhs) const
ConditionalExpression operator| (RVInstanceArray rhs) const
 This operator represents expressions of the form Y|(X==x && Z==z)

Detailed Description

we follow the same pattern as Var & Variable

Definition at line 354 of file RandomVar.h.


Constructor & Destructor Documentation

PLearn::RandomVar::RandomVar ( )

Definition at line 76 of file RandomVar.cc.

Referenced by operator=().

    :PP<RandomVariable>(new NonRandomVariable(1)) {}

Here is the caller graph for this function:

PLearn::RandomVar::RandomVar ( int  length,
int  width = 1 
)

Definition at line 82 of file RandomVar.cc.

    :PP<RandomVariable>(new NonRandomVariable(length,width)) {}
PLearn::RandomVar::RandomVar ( RandomVariable v)

Definition at line 78 of file RandomVar.cc.

    :PP<RandomVariable>(v) {}
PLearn::RandomVar::RandomVar ( const RandomVar other)

Definition at line 80 of file RandomVar.cc.

    :PP<RandomVariable>(other) {}
PLearn::RandomVar::RandomVar ( const Vec vec)

Definition at line 85 of file RandomVar.cc.

    :PP<RandomVariable>(new NonRandomVariable(Var(vec))) {}
PLearn::RandomVar::RandomVar ( const Mat mat)

Definition at line 87 of file RandomVar.cc.

    :PP<RandomVariable>(new NonRandomVariable(Var(mat))) {}
PLearn::RandomVar::RandomVar ( const Var var)

Definition at line 89 of file RandomVar.cc.

    :PP<RandomVariable>(new NonRandomVariable(v)) {}
PLearn::RandomVar::RandomVar ( const RVArray vars)

make joint distribution

Definition at line 92 of file RandomVar.cc.

    :PP<RandomVariable>(new JointRandomVariable(rvars)) {}

Member Function Documentation

bool PLearn::RandomVar::operator!= ( const RandomVar rv) const [inline]

Definition at line 387 of file RandomVar.h.

References PLearn::PP< T >::ptr.

{ return rv.ptr != this->ptr; }
RVArray PLearn::RandomVar::operator& ( const RandomVar v) const

make an array of RV's, as in expressions like X&Y

Definition at line 136 of file RandomVar.cc.

{
    return RVArray(*this,v,10);
}
void PLearn::RandomVar::operator= ( const Vec v)

copy v into value

Definition at line 108 of file RandomVar.cc.

References PLERROR.

{
    if (!(*this)->isNonRandom())
        PLERROR("RandomVar: can't assign a values to a truly random RV");
    (*this)->value->value << v;
}
void PLearn::RandomVar::operator= ( const RVArray vars)

Definition at line 98 of file RandomVar.cc.

References RandomVar().

{ *this = RandomVar(vars); }

Here is the call graph for this function:

void PLearn::RandomVar::operator= ( const Mat m)

Definition at line 115 of file RandomVar.cc.

References PLERROR.

{ 
    if (!(*this)->isNonRandom())
        PLERROR("RandomVar: can't assign a Var to a truly random RV");
    Var v(m);
    (*this)->value = v;
}
void PLearn::RandomVar::operator= ( real  f)

these two only work with NonRandomVariables

fill value to f

Definition at line 101 of file RandomVar.cc.

References PLERROR.

{
    if (!(*this)->isNonRandom())
        PLERROR("RandomVar: can't assign values to a truly random RV");
    (*this)->value->value.fill(f);
}
void PLearn::RandomVar::operator= ( const Var v)

assign value to v

Definition at line 123 of file RandomVar.cc.

References PLERROR.

{
    if (!(*this)->isNonRandom())
        PLERROR("RandomVar: can't assign a Var to a truly random RV");
    (*this)->value = v;
}
bool PLearn::RandomVar::operator== ( const RandomVar rv) const [inline]

compare two RandomVars: == if same underlying RandomVariable (same address)

Definition at line 386 of file RandomVar.h.

References PLearn::PP< T >::ptr.

{ return rv.ptr == this->ptr; }
RVInstance PLearn::RandomVar::operator== ( const Var v) const

associate a RV to an observation v, as in expressions of the form (V==v)

Definition at line 130 of file RandomVar.cc.

{
    return RVInstance(*this,v);
}
RandomVar PLearn::RandomVar::operator[] ( RandomVar  index)

extract from joint or element of vector

Definition at line 95 of file RandomVar.cc.

{ return new RandomElementOfRandomVariable((*this),index); }
ConditionalExpression PLearn::RandomVar::operator| ( RVArray  rhs) const

This operator represents expressions of the form Y|(X&Z). It is almost the same as & (i.e. it also builds a RVArray), but it allows us to know that the LHS of the | will always be the first element of the array, so if the user types ((Y&Z)|(X&U)) the result will be a 3-element array, because the first two-element array created by (Y&Z) is coerced into a JointRV, which will be the first element of the result.

Definition at line 141 of file RandomVar.cc.

References i, and PLearn::TVec< T >::size().

{
    RVInstanceArray rvia(a.size());
    for (int i=0;i<a.size();i++)
    {
        rvia[i].V = a[i];
        rvia[i].v = a[i]->value;
    }
    return ConditionalExpression(RVInstance(*this,Var((*this)->length())),rvia);
}

Here is the call graph for this function:

ConditionalExpression PLearn::RandomVar::operator| ( RVInstanceArray  rhs) const

This operator represents expressions of the form Y|(X==x && Z==z)

Definition at line 152 of file RandomVar.cc.

{
    return ConditionalExpression(RVInstance(*this,Var((*this)->length())),rhs);
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines