
| T | Component type, should be derivative of Pdf. |
"Regular" methods such as getSize(), getTotalWeight() and getExpectation() use only those components stored on the local node. Special "distributed" methods such as getDistributedSize(), getDistributedTotalWeight() and getDistributedExpectation() use all components stored across the nodes.
Definition at line 40 of file MixturePdf.hpp.
Public Member Functions | |
| MixturePdf () | |
| Default constructor. | |
| MixturePdf (const unsigned int N) | |
| Constructor. | |
| virtual | ~MixturePdf () |
| Destructor. | |
| MixturePdf< T > & | operator= (const MixturePdf< T > &o) |
| Assignment operator. | |
| virtual void | setDimensions (const unsigned int N, const bool preserve=false) |
| Set the dimensionality of the distribution. | |
Local storage methods | |
Use these methods if:
| |
| void | add (const T &x, const double w=1.0) |
| Add a component to the distribution on the local node. | |
| const T & | get (const unsigned int i) const |
| Get component on the local node. | |
| T & | get (const unsigned int i) |
| Get component on the local node. | |
| void | set (const unsigned int i, const T &) |
| Set component on the local node. | |
| const std::vector< T > & | getAll () const |
| Get components on the local node. | |
| std::vector< T > & | getAll () |
| Get components on the local node. | |
| double | getWeight (const unsigned int i) const |
| Get component weight on the local node. | |
| void | setWeight (const unsigned int i, const double w) |
| Set component weight on the local node. | |
| const vector & | getWeights () const |
| Get the weights of all components on the local node. | |
| void | setWeights (const vector &ws) |
| Set the weights of all components on the local node. | |
| void | clear () |
| Clear all components from the distribution on the local node. | |
| unsigned int | getSize () const |
| Get the number of components in the distribution on the local node. | |
| double | getTotalWeight () const |
| Get the total weight of components on the local node. | |
| void | normalise () |
| Normalise weights on the local node to sum to 1. | |
| virtual vector | sample () |
| Sample from the distribution on the local node. | |
| virtual double | densityAt (const vector &x) |
| Calculate the density on the local node at a given point. | |
| virtual const vector & | getExpectation () |
| Get the expected value of the distribution on the local node. | |
Distributed storage methods | |
Use these methods if:
| |
| unsigned int | getDistributedSize () const |
| Get the number of components in the distribution across all nodes. | |
| double | getDistributedTotalWeight () const |
| Get the total weight of components across all nodes. | |
| void | distributedNormalise () |
| Normalise weights across all nodes to sum to 1. | |
| virtual vector | distributedSample () |
| Sample from the full distribution. | |
| virtual std::vector < vector > | distributedSample (const unsigned int P) |
| Draw multiple samples from the full distribution. | |
| virtual double | distributedDensityAt (const vector &x) |
| Calculate the density of the full distribution at a given point. | |
| virtual vector | distributedDensityAt (std::vector< vector > &xs) |
| Perform multiple density calculations from the full distribution. | |
| virtual vector | getDistributedExpectation () |
| Get the expected value of the full distribution. | |
| void | redistributeBySize () |
| Redistribute components across nodes by number. | |
| void | redistributeByWeight () |
| Redistribute components across nodes by weight. | |
Protected Member Functions | |
| virtual void | dirty () |
| Called when changes are made to the distribution, such as when a new component is added. | |
| MixturePdf | ( | ) | [inline] |
Default constructor.
Initialises the mixture with zero dimensions. This should generally only be used when the object is to be restored from a serialization. Indeed, there is no other way to resize the mixture to nonzero dimensionality except by subsequently restoring from a serialization.
Definition at line 484 of file MixturePdf.hpp.
| MixturePdf | ( | const unsigned int | N | ) | [inline] |
Constructor.
One or more components should be added with add() after construction.
| N | Dimensionality of the distribution. |
Definition at line 490 of file MixturePdf.hpp.
| ~MixturePdf | ( | ) | [inline, virtual] |
| indii::ml::aux::MixturePdf< T > & operator= | ( | const MixturePdf< T > & | o | ) | [inline] |
Assignment operator.
Both sides must have the same dimensionality, but may have different number of components.
Definition at line 501 of file MixturePdf.hpp.
| void setDimensions | ( | const unsigned int | N, | |
| const bool | preserve = false | |||
| ) | [inline, virtual] |
Set the dimensionality of the distribution.
| N | Dimensionality of the distribution. | |
| preserve | True to preserve the current sufficient statistics of the distribution in the lower dimensional space, false if these may be discarded. |
Implements Pdf.
Reimplemented in DiracMixturePdf, StandardMixturePdf, StandardMixturePdf< indii::ml::aux::GaussianPdf >, and StandardMixturePdf< indii::ml::aux::KernelDensityPdf< NT, KT > >.
Definition at line 670 of file MixturePdf.hpp.
| void add | ( | const T & | x, | |
| const double | w = 1.0 | |||
| ) | [inline] |
Add a component to the distribution on the local node.
| x | The component. | |
| w | Unnormalised weight of the component. |
Definition at line 524 of file MixturePdf.hpp.
| const T & get | ( | const unsigned int | i | ) | const [inline] |
Get component on the local node.
| i | Index of the component. |
i th component. Definition at line 546 of file MixturePdf.hpp.
| T & get | ( | const unsigned int | i | ) | [inline] |
Get component on the local node.
| i | Index of the component. |
i th component.Definition at line 552 of file MixturePdf.hpp.
| void set | ( | const unsigned int | i, | |
| const T & | x | |||
| ) | [inline] |
Set component on the local node.
| i | Index of the component. | |
| x | Value of the component. |
Definition at line 557 of file MixturePdf.hpp.
| const std::vector< T > & getAll | ( | ) | const [inline] |
Get components on the local node.
; set of weighted components defining the distribution, as a vector. Definition at line 563 of file MixturePdf.hpp.
| std::vector< T > & getAll | ( | ) | [inline] |
Get components on the local node.
; set of weighted components defining the distribution, as a vector.Definition at line 568 of file MixturePdf.hpp.
| double getWeight | ( | const unsigned int | i | ) | const [inline] |
Get component weight on the local node.
| i | Index of the component. |
i th component. Definition at line 573 of file MixturePdf.hpp.
| void setWeight | ( | const unsigned int | i, | |
| const double | w | |||
| ) | [inline] |
Set component weight on the local node.
| i | Index of the component. | |
| w | Weight of the i th component. |
Definition at line 579 of file MixturePdf.hpp.
| const indii::ml::aux::vector & getWeights | ( | ) | const [inline] |
Get the weights of all components on the local node.
Definition at line 601 of file MixturePdf.hpp.
| void setWeights | ( | const vector & | ws | ) | [inline] |
Set the weights of all components on the local node.
| ws | Vector of the weights of all components. |
Definition at line 606 of file MixturePdf.hpp.
| void clear | ( | ) | [inline] |
Clear all components from the distribution on the local node.
Definition at line 656 of file MixturePdf.hpp.
| unsigned int getSize | ( | ) | const [inline] |
Get the number of components in the distribution on the local node.
; the number of components in the distribution. Definition at line 626 of file MixturePdf.hpp.
| double getTotalWeight | ( | ) | const [inline] |
Get the total weight of components on the local node.
; the total weight of components. Definition at line 665 of file MixturePdf.hpp.
| void normalise | ( | ) | [inline] |
Normalise weights on the local node to sum to 1.
Definition at line 631 of file MixturePdf.hpp.
| indii::ml::aux::vector sample | ( | ) | [inline, virtual] |
Sample from the distribution on the local node.
Implements Pdf.
Definition at line 699 of file MixturePdf.hpp.
| double densityAt | ( | const vector & | x | ) | [inline, virtual] |
Calculate the density on the local node at a given point.
| x | ; the point at which to calculate the density. |
; the density at
. Implements Pdf.
Definition at line 711 of file MixturePdf.hpp.
| const indii::ml::aux::vector & getExpectation | ( | ) | [inline, virtual] |
Get the expected value of the distribution on the local node.
; expected value of the distribution. Implements Pdf.
Definition at line 691 of file MixturePdf.hpp.
| unsigned int getDistributedSize | ( | ) | const [inline] |
Get the number of components in the distribution across all nodes.
; the number of components in the distribution. Definition at line 728 of file MixturePdf.hpp.
| double getDistributedTotalWeight | ( | ) | const [inline] |
Get the total weight of components across all nodes.
; the total weight of components across all nodes. Definition at line 736 of file MixturePdf.hpp.
| void distributedNormalise | ( | ) | [inline] |
| indii::ml::aux::vector distributedSample | ( | ) | [inline, virtual] |
Sample from the full distribution.
Definition at line 766 of file MixturePdf.hpp.
| std::vector< indii::ml::aux::vector > distributedSample | ( | const unsigned int | P | ) | [inline, virtual] |
Draw multiple samples from the full distribution.
This is significantly more efficient than multiple calls to distributedSample(), as it involves less message passing.
| P | ; number of samples to draw. |
. Definition at line 817 of file MixturePdf.hpp.
| double distributedDensityAt | ( | const vector & | x | ) | [inline, virtual] |
Calculate the density of the full distribution at a given point.
| x | ; the point at which to calculate the density. |
; the density at
. Definition at line 856 of file MixturePdf.hpp.
| indii::ml::aux::vector distributedDensityAt | ( | std::vector< vector > & | xs | ) | [inline, virtual] |
Perform multiple density calculations from the full distribution.
This is significantly more efficient than multiple calls to distributedDensityAt(const vector&), as it involves less message passing.
| xs | The points on this node at which to calculate densities. |
Definition at line 867 of file MixturePdf.hpp.
| indii::ml::aux::vector getDistributedExpectation | ( | ) | [inline, virtual] |
Get the expected value of the full distribution.
; expected value of the full distribution. Definition at line 890 of file MixturePdf.hpp.
| void redistributeBySize | ( | ) | [inline] |
Redistribute components across nodes by number.
This attempts to redistribute the components of the full distribution across nodes, so that each node stores as close to an equal number of components as possible.
Definition at line 915 of file MixturePdf.hpp.
| void redistributeByWeight | ( | ) | [inline] |
Redistribute components across nodes by weight.
This attempts to redistribute the components of the full distribution across nodes, so that the total weight of components at each node is as close to an equal number as possible.
Definition at line 1013 of file MixturePdf.hpp.
| void dirty | ( | ) | [inline, protected, virtual] |
Called when changes are made to the distribution, such as when a new component is added.
This allows pre-calculations to be refreshed.
Reimplemented in DiracMixturePdf, StandardMixturePdf, StandardMixturePdf< indii::ml::aux::GaussianPdf >, and StandardMixturePdf< indii::ml::aux::KernelDensityPdf< NT, KT > >.
Definition at line 1115 of file MixturePdf.hpp.
1.5.3