-
Notifications
You must be signed in to change notification settings - Fork 6
Add gaussian random noise #25
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
Conversation
|
@giordano could you investigate why the CI checks are failing on this one? I do not understand the first error message and google is not helping |
|
I think the error was temporary, just rerunning the job made it go away. However there is another problem with the tests now: we're generating random numbers without fixing the seed ( |
|
The random numbers are generated with a fixed seed. I create a random number generator and initialize it with It is then used to generate the random numbers for sampling the gaussian random fields Do you prefer doing it in a different way? Ok, I admit the last line looks a bit obscure, maybe I could make it more readable. |
|
Uh, oh... ok, I missed it 😬 I thought that was the reason why the tests are failing, they're failing also for me locally. With which Julia version did generate the reference numbers for the test? Can you please rebase on |
|
Hi,
|
|
Thanks for comments Alex!
|
|
Hi, |
…ns/platforms Allowed sampling from gaussian random field generator with a set of random numbers in addition to a random number generator. Changed unit test to use this approach. I would like to also have a statistical test using a rng but will need some input for that.
|
Hooray, tests pass! |
make sure that modifying f worked as expected Co-Authored-By: Mosè Giordano <[email protected]>
src/TDAC.jl
Outdated
| grf::GaussianRandomFields.GaussianRandomField, | ||
| random_numbers::AbstractVector{T}) where T | ||
|
|
||
| @assert length(random_numbers) == length(field) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this assertion is wrong. Consider for example
julia> using GaussianRandomFields, TDAC
julia> x = 1.:10.;
julia> y = 1.:10.;
julia> grf = TDAC.init_gaussian_random_field_generator(1.0,1.0,1.0,x,y,0);
julia> f = zeros(100);
julia> rnn = randn(100);
julia> TDAC.sample_gaussian_random_field!(f, grf, rnn);
ERROR: DimensionMismatch("length of random points vector must be equal to 1024")
Stacktrace:
[1] #sample#10 at /home/mose/.julia/dev/GaussianRandomFields/src/gaussian_random_fields.jl:142 [inlined]
[2] sample_gaussian_random_field!(::Array{Float64,1}, ::GaussianRandomField{CirculantEmbedding,CovarianceFunction{2,Matern{Float64}},Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Array{Float64,2},Tuple{Array{Float64,2},FFTW.cFFTWPlan{Complex{Float64},-1,false,2}}}, ::Array{Float64,1}) at /home/mose/.julia/dev/TDAC/src/TDAC.jl:169
[3] top-level scope at REPL[54]:1
[4] eval(::Module, ::Any) at ./boot.jl:331
[5] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
[6] run_backend(::REPL.REPLBackend) at /home/mose/.julia/packages/Revise/C272c/src/Revise.jl:1075
[7] top-level scope at none:0Changing rnn to have 1024 elements:
julia> rnn = randn(1024);
julia> TDAC.sample_gaussian_random_field!(f, grf, rnn);
ERROR: AssertionError: length(random_numbers) == length(field)
Stacktrace:
[1] sample_gaussian_random_field!(::Array{Float64,1}, ::GaussianRandomField{CirculantEmbedding,CovarianceFunction{2,Matern{Float64}},Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Array{Float64,2},Tuple{Array{Float64,2},FFTW.cFFTWPlan{Complex{Float64},-1,false,2}}}, ::Array{Float64,1}) at /home/mose/.julia/dev/TDAC/src/TDAC.jl:168
[2] top-level scope at REPL[56]:1
[3] eval(::Module, ::Any) at ./boot.jl:331
[4] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
[5] run_backend(::REPL.REPLBackend) at /home/mose/.julia/packages/Revise/C272c/src/Revise.jl:1075
[6] top-level scope at none:0It's the output of GaussianRandomFields.sample that should have 100 elements, not random_numbers. Not sure how to quickly check the length of sample
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think the appropriate check would be
prod(length.(grf.pts)) == length(field)but I feel like I had to dig too much deep into GaussianRandomFields internals to find this. I'd suggest to just remove the check and let broadcast fail naturally if there is a dimension mismatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for digging into this! I guess I tried to take a short-cut here and it was wrong.
The appropriate check would be to use what the other instance of sample_gaussian_random_field() uses to get the number of random numbers from the generator, randdim(grf)
The error message from just letting it fail is more helpful though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, do you think it would be appropriate to use the GaussianRandomFields namespace explicitly when calling functions from it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think it would be appropriate to use the GaussianRandomFields namespace explicitly when calling functions from it?
I personally don't mind too much. The sample name is exported from that module, so we could omit it, but I think it's fine also to qualify the call, to make it easier to understand where it's coming from.
Adding functionality to generate gaussian random fields with the GaussianRandomFields.jl package.
Also initialises all particles to the true initial state.
Adding background noise to particles to address #6
TODO: Add noise to observations to address #17