Skip to content

Commit

Permalink
Fix mse for least squares PCE (#128)
Browse files Browse the repository at this point in the history
andreaperin authored Sep 5, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b3130d5 commit 8429fcb
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UncertaintyQuantification"
uuid = "7183a548-a887-11e9-15ce-a56ab60bad7a"
authors = ["Jasper Behrensdorf <[email protected]>", "Ander Gray <[email protected]>"]
version = "0.7.1"
version = "0.7.2"

[deps]
Bootstrap = "e28b5b4c-05e8-5b66-bc03-6f0c0a0a06e0"
2 changes: 1 addition & 1 deletion src/models/pce/polynomialchaosexpansion.jl
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ function polynomialchaos(
y = A \ samples[:, output]

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

to_physical_space!(random_inputs, samples)

7 changes: 6 additions & 1 deletion test/models/pce/polynomialchaosexpansion.jl
Original file line number Diff line number Diff line change
@@ -16,10 +16,15 @@

@testset "LeastSquares" begin
ls = LeastSquares(SobolSampling(1000))
pce, _, _ = polynomialchaos(x, model, Ψ, :y, ls)
pce, samples, mse = polynomialchaos(x, model, Ψ, :y, ls)

new_samples = samples[:, Not(:y1, :y)]
evaluate!(pce, new_samples)
ϵ = mean((new_samples.y .- samples.y) .^ 2)

@test mean(pce) -1.5 rtol = 1e-10
@test var(pce) 0.5 rtol = 1e-10
@test mse ϵ atol = eps()
end

@testset "GaussQuadrature" begin

2 comments on commit 8429fcb

@FriesischScott
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/90862

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.2 -m "<description of version>" 8429fcbb678e0d13d9504ae8379fbb3d93e918cf
git push origin v0.7.2

Please sign in to comment.