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

Randomized is brittle #199

Open
wasowski opened this issue Feb 24, 2023 · 0 comments
Open

Randomized is brittle #199

wasowski opened this issue Feb 24, 2023 · 0 comments

Comments

@wasowski
Copy link
Member

wasowski commented Feb 24, 2023

Sometimes it produces a singleton, sometimes it produces a list. We did this because otherwise flatMap had a surprising semantics (if would fix the first choice, and process the second list with the first value fixed). But this ends up in frequent mistakes that we think we have a sample, but we have a single value. I slowly start to understand that it would be better to have lazy / infinite lists for all results (and killing repeat?) but a different semantics of flatMap from the one of lazyLists. One should l.flatMap (a => f(a)) should roughly give l.flatMap (a => f(a).head) - the problem is that we do not want to make it deterministic in the second result accidentally. A good test case is that coin(e).flatMap ( c => (c, coin(e))) should produce a mulitvariate sample with statistically independent components.

One requirement that would be good to meet is that:

for 
  x <- Randomized.Gaussian (...) // or any other distribution, not dependent on y
  y <- Randomized.Gaussian (...) // or any other distribution, not dependent on x
yield (x,y)

should have the same (statistical) semantics as:

for  
  y <- Randomized.Gaussian (...) // or any other distribution, not dependent on x
  x <- Randomized.Gaussian (...) // or any other distribution, not dependent on y
yield (x,y)

Right now is not equivalent if the constructors produce infinite lists (the first will lock the value of x, the second will lock the value of y).

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

No branches or pull requests

1 participant