forked from probsys/hierarchical-irm
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from probcomp/052924-clang-format
Update code to be clang-formatted
- Loading branch information
Showing
24 changed files
with
3,495 additions
and
4,138 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
#pragma once | ||
|
||
template <typename SampleType = double> class Distribution { | ||
// Abstract base class for probability distributions in HIRM. | ||
public: | ||
// N is the number of incorporated observations. | ||
int N = 0; | ||
|
||
// Accumulate x. | ||
virtual void incorporate(const SampleType& x) = 0; | ||
|
||
// Undo the accumulation of x. Should only be called with x's that | ||
// have been previously passed to incorporate(). | ||
virtual void unincorporate(const SampleType& x) = 0; | ||
|
||
// The log probability of x according to the posterior predictive | ||
// distribution: log P(x | incorporated_data), where P(x | data) = | ||
// \integral_{theta} P(x | theta ) P(theta | data) dtheta | ||
// and theta are the parameters of the distribution. | ||
virtual double logp(const SampleType& x) const = 0; | ||
|
||
// The log probability of the data we have accumulated so far according | ||
// to the prior: log P(data | alpha) where alpha is the vector of | ||
// hyperparameters of the prior and P(data) | ||
// = \integral_{theta} P(data | theta) P(theta | alpha) dtheta. | ||
virtual double logp_score() const = 0; | ||
|
||
// A sample from the predictive distribution. | ||
// TODO(thomaswc): Consider refactoring so that this takes a | ||
// PRNG parameter. | ||
virtual SampleType sample() = 0; | ||
|
||
virtual ~Distribution() = default; | ||
template <typename SampleType = double> | ||
class Distribution { | ||
// Abstract base class for probability distributions in HIRM. | ||
public: | ||
// N is the number of incorporated observations. | ||
int N = 0; | ||
|
||
// Accumulate x. | ||
virtual void incorporate(const SampleType& x) = 0; | ||
|
||
// Undo the accumulation of x. Should only be called with x's that | ||
// have been previously passed to incorporate(). | ||
virtual void unincorporate(const SampleType& x) = 0; | ||
|
||
// The log probability of x according to the posterior predictive | ||
// distribution: log P(x | incorporated_data), where P(x | data) = | ||
// \integral_{theta} P(x | theta ) P(theta | data) dtheta | ||
// and theta are the parameters of the distribution. | ||
virtual double logp(const SampleType& x) const = 0; | ||
|
||
// The log probability of the data we have accumulated so far according | ||
// to the prior: log P(data | alpha) where alpha is the vector of | ||
// hyperparameters of the prior and P(data) | ||
// = \integral_{theta} P(data | theta) P(theta | alpha) dtheta. | ||
virtual double logp_score() const = 0; | ||
|
||
// A sample from the predictive distribution. | ||
// TODO(thomaswc): Consider refactoring so that this takes a | ||
// PRNG parameter. | ||
virtual SampleType sample() = 0; | ||
|
||
virtual ~Distribution() = default; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.