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

fix randnfun lambda #2441

Merged
merged 1 commit into from
Jul 11, 2023
Merged

fix randnfun lambda #2441

merged 1 commit into from
Jul 11, 2023

Conversation

trefethen
Copy link
Contributor

For large wavelength lambda, randnfun should give results that are nearly constant, but not exactly constant. For example, this is wrong:

>> rng(1), svd(randnfun(100,3))
ans =
   2.187063552007912
   0.000000000000000
   0.000000000000000

I've made a change so that now we get more reasonable results:

>> rng(1), svd(randnfun(100,3))
ans =
   1.033145328179523
   0.067353879945334
   0.000180359044226

The problem was in the "circulant embedding" part of the computation. randnfun uses a subset of an interval on which a periodic random function is constructed. It was defining the subset by

     dom2 = dom(1) + [0 1.2*diff(dom)];

but I've changed this to


    dx = max(0.2,2*lambda/diff(dom));
   dom2 = dom(1) + [0 (1+dx)*diff(dom)];

@bhashemi bhashemi merged commit 859a50c into master Jul 11, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants