Skip to content

Commit 8429fcb

Browse files
authored
Fix mse for least squares PCE (#128)
1 parent b3130d5 commit 8429fcb

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "UncertaintyQuantification"
22
uuid = "7183a548-a887-11e9-15ce-a56ab60bad7a"
33
authors = ["Jasper Behrensdorf <behrensdorf@irz.uni-hannover.de>", "Ander Gray <ander.gray@liverpool.ac.uk>"]
4-
version = "0.7.1"
4+
version = "0.7.2"
55

66
[deps]
77
Bootstrap = "e28b5b4c-05e8-5b66-bc03-6f0c0a0a06e0"

src/models/pce/polynomialchaosexpansion.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function polynomialchaos(
3131
y = A \ samples[:, output]
3232

3333
ϵ = samples[:, output] - A * y
34-
mse = dot(ϵ, ϵ)
34+
mse = mean.^ 2)
3535

3636
to_physical_space!(random_inputs, samples)
3737

test/models/pce/polynomialchaosexpansion.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616

1717
@testset "LeastSquares" begin
1818
ls = LeastSquares(SobolSampling(1000))
19-
pce, _, _ = polynomialchaos(x, model, Ψ, :y, ls)
19+
pce, samples, mse = polynomialchaos(x, model, Ψ, :y, ls)
20+
21+
new_samples = samples[:, Not(:y1, :y)]
22+
evaluate!(pce, new_samples)
23+
ϵ = mean((new_samples.y .- samples.y) .^ 2)
2024

2125
@test mean(pce) -1.5 rtol = 1e-10
2226
@test var(pce) 0.5 rtol = 1e-10
27+
@test mse ϵ atol = eps()
2328
end
2429

2530
@testset "GaussQuadrature" begin

0 commit comments

Comments
 (0)