# bdm::RV Class Reference

Class representing variables, most often random variables. More...

`#include <libBM.h>`

List of all members.

## Public Member Functions
void | from_setting (const Setting &root)
| UI for class RV (description of data vectors).
virtual string | to_string ()
| This method returns a basic info about the current instance.
virtual void | to_setting (Setting &root) const
| This method save all the instance properties into the Setting structure.
virtual void | validate ()
| This method TODO.
Constructors
| RV (Array< std::string > in_names, ivec in_sizes, ivec in_times)
| Full constructor.
| RV (Array< std::string > in_names, ivec in_sizes)
| Constructor with times=0.
| RV (Array< std::string > in_names)
| Constructor with sizes=1, times=0.
| RV ()
| Constructor of empty RV.
| RV (string name, int sz, int tm=0)
| Constructor of a single RV with given id.
Algebra on Random Variables
ivec | findself (const RV &rv2) const
| Find indices of self in another rv,.
bool | equal (const RV &rv2) const
| Compare if `rv2` is identical to this `RV`.
bool | add (const RV &rv2)
| Add (concat) another variable to the current one,.
RV | subt (const RV &rv2) const
| Subtract another variable from the current one.
RV | subselect (const ivec &ind) const
| Select only variables at indeces ind.
RV | operator() (const ivec &ind) const
| Select only variables at indeces ind.
RV | operator() (int di1, int di2) const
| Select from data vector starting at di1 to di2.
void | t (int delta)
| Shift `time` shifted by delta.
Relation to vectors
str | tostr () const
| generate `str` from rv, by expanding sizes TODO to_string..
ivec | dataind (const RV &crv) const
void | dataind (const RV &rv2, ivec &selfi, ivec &rv2i) const
int | mint () const
| Minimum time-offset.
## Protected Attributes
int | dsize
| size of the data vector
int | len
| number of individual rvs
ivec | ids
| Vector of unique IDs.
ivec | times
| Vector of shifts from current time.
## Access functions
int | _dsize () const
int | countsize () const
| Recount size of the corresponding data vector.
ivec | cumsizes () const
int | length () const
int | id (int at) const
int | size (int at) const
int | time (int at) const
std::string | name (int at) const
void | set_time (int at, int time0)
std::ostream & | operator<< (std::ostream &os, const RV &rv)
| Printing output e.g. for debugging.

## Detailed Description

Class representing variables, most often random variables.

The purpose of this class is to decribe a vector of data. Such description is used for connecting various vectors between each other, see class datalink.

The class is implemented using global variables to assure uniqueness of description:

In is a vector

## Member Function Documentation

bool bdm::RV::add | ( | const RV & | rv2 | ) |

Add (concat) another variable to the current one,.

Returns:
  true if all rv2 were added, false if rv2 is in conflict

References countsize(), dsize, findself(), ids, len, and times.

Referenced by bdm::compositepdf::getrv(), bdm::merger::merger(), bdm::ArxDS::set_drv(), and bdm::compositepdf::setrvc().

void bdm::RV::dataind | ( | const RV & | rv2,
|  | ivec & | selfi,
|  | ivec & | rv2i |
| ) |  |  | const

generate mutual indeces when copying data betwenn self and crv. Data are copied via: data_of_this(selfi) = data_of_rv2(rv2i)

References findself(), ids, bdm::str::ids, length(), times, bdm::str::times, and tostr().

ivec bdm::RV::dataind | ( | const RV & | crv | ) | const

when this rv is a part of bigger rv, this function returns indeces of self in the data vector of the bigger crv. Then, data can be copied via: data_of_this = cdata(ind);

References _dsize(), dsize, ids, bdm::str::ids, times, bdm::str::times, and tostr().

Referenced by bdm::enorm< sq_T >::condition(), bdm::enorm< sq_T >::marginal(), bdm::datalink_m2e::set_connection(), and bdm::datalink::set_connection().

ivec bdm::RV::findself | ( | const RV & | rv2 | ) | const

Find indices of self in another rv,.

Returns:
  ivec of the same size as self.

References ids, length(), and times.

Referenced by add(), dataind(), and subt().

void bdm::RV::from_setting | ( | const Setting & | root | ) | `[virtual]`

UI for class RV (description of data vectors).

            rv = {
                    type = "rv"; //identifier of the description
                    // UNIQUE IDENTIFIER same names = same variable
                    names = ["a", "b", "c", ...];   // which will be used e.g. in loggers

                    //optional arguments
                    sizes = [1, 2, 3, ...];         // (optional) default = ones()
                    times = [-1, -2, 0, ...];       // time shifts with respect to current time (optional) default = zeros()
            }

Reimplemented from bdm::bdmroot.

References bdm::UI::get().

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

- libBM.h
- libBM.cpp