Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One Dimensional Marginal Constructor #446

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/albatross/src/core/distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ struct MarginalDistribution : public DistributionBase<MarginalDistribution> {
assert_valid();
};

MarginalDistribution(double mean_, double variance_)
: MarginalDistribution(Eigen::VectorXd::Constant(1, mean_),
Eigen::VectorXd::Constant(1, variance_)) {}

void assert_valid() const {
ALBATROSS_ASSERT(mean.size() == covariance.rows());
ALBATROSS_ASSERT(mean.size() == covariance.cols());
Expand Down
12 changes: 12 additions & 0 deletions tests/test_core_distribution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@

namespace albatross {

TEST(test_core_distribution, create_one_dim) {

const double mean = M_PI;
const double var = std::log(2);
const MarginalDistribution one_dim(mean, var);
const Eigen::VectorXd mean_vec = Eigen::VectorXd::Constant(1, mean);
const Eigen::VectorXd var_vec = Eigen::VectorXd::Constant(1, var);

const MarginalDistribution from_vectors(mean_vec, var_vec);
EXPECT_EQ(one_dim, from_vectors);
}

TYPED_TEST_P(DistributionTest, test_subset) {

TypeParam test_case;
Expand Down
2 changes: 1 addition & 1 deletion third_party/gzip-hpp
Loading