Skip to content

Commit 3b0977b

Browse files
author
Pedro Arruda
committed
bugfix for posterior sampler
1 parent 5960bd7 commit 3b0977b

File tree

7 files changed

+21
-9
lines changed

7 files changed

+21
-9
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ppca_rs"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
edition = "2021"
55
publish = false
66

examples/big_toy_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
transform = np.random.binomial(1.0, 0.1, size=(200, 16))
77
real_model = PPCAModel(
8-
transform=np.matrix(transform, dtype="float64").T.T,
8+
transform=np.matrix(transform, dtype="float64"),
99
isotropic_noise=0.1,
1010
mean=np.zeros((200, 1), dtype="float64"),
1111
)
1212

13-
print("Generating syntetic sample")
13+
print("Generating synthetic sample")
1414
sample = real_model.sample(100_000, 0.2)
1515

1616
print("Initializing model")

ppca/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ppca"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
edition = "2021"
55
authors = ["Pedro Bittencourt Arruda <[email protected]>"]
66
description = "Rust implementation of the Probabilistic Principal Component Analysis model"

ppca/src/ppca_model.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,23 @@ impl Distribution<DVector<f64>> for PosteriorSampler {
596596
where
597597
R: Rng + ?Sized,
598598
{
599+
// State noise:
599600
let standard: DVector<f64> = (0..self.state.len())
600601
.map(|_| rand_distr::StandardNormal.sample(rng))
601602
.collect::<Vec<_>>()
602603
.into();
603-
self.model.mean() + self.model.transform() * (&self.state + &self.cholesky_l * standard)
604+
// Output noise:
605+
let noise: DVector<f64> = (0..self.model.output_size())
606+
.map(|_| {
607+
let standard: f64 = rand_distr::StandardNormal.sample(rng);
608+
self.model.0.output_covariance.isotropic_noise * standard
609+
})
610+
.collect::<Vec<_>>()
611+
.into();
612+
613+
noise
614+
+ self.model.mean()
615+
+ self.model.transform() * (&self.state + &self.cholesky_l * standard)
604616
}
605617
}
606618

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "ppca-rs"
7-
version = "0.5.0"
7+
version = "0.5.1"
88
requires-python = ">=3.7"
99
description = "Python+Rust implementation of the Probabilistic Principal Component Analysis model"
1010
readme = "readme.md"

python/ppca_rs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99

1010

11-
__version__ = "0.5.0"
11+
__version__ = "0.5.1"
1212

1313

1414
@dataclass(frozen=True)

0 commit comments

Comments
 (0)