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

Notebooks: sampling.ipynb #206

Merged
merged 232 commits into from
Oct 18, 2022
Merged

Notebooks: sampling.ipynb #206

merged 232 commits into from
Oct 18, 2022

Conversation

mknorps
Copy link
Contributor

@mknorps mknorps commented Oct 7, 2022

Small adjustments to Sampling notebook:

  • add a histogram of samples to give more examples of split between the sampling part vs the distribution construction part and where it is applied.
  • described usage of histogram on simple continuous distribution (map of constant weights)

reubenharry and others added 12 commits September 23, 2022 16:12
Co-authored-by: Arnaud Spiwack <arnaud@spiwack.net>
* Start working on site

* Fix formatting

* revert flake.nix

* clean up the PR files

* Do not change flake.lock
…193)

Bumps [DeterminateSystems/update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) from 13 to 14.
- [Release notes](https://github.com/DeterminateSystems/update-flake-lock/releases)
- [Commits](DeterminateSystems/update-flake-lock@v13...v14)

---
updated-dependencies:
- dependency-name: DeterminateSystems/update-flake-lock
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Flake lock file updates:

• Updated input 'jupyter-flake':
    'git+https://github.com/tweag/monad-bayes?ref=notebooks&rev=a123b9352203dcd245bbd06a3139edb3c6f653ae' (2022-08-30)
  → 'git+https://github.com/tweag/monad-bayes?ref=notebooks&rev=4ef694502bf20a20790a0ad39a7db89750730dc2' (2022-09-23)
• Added input 'jupyter-flake/flake-compat':
    'github:edolstra/flake-compat/b4a34015c698c7793d592d66adbab377907a2be8' (2022-04-19)
• Added input 'jupyter-flake/haskell-nix-utils':
    'github:TerrorJack/haskell-nix-utils/f6fafb5f7ad7ab100bc897e9a278caabab38505d' (2022-07-12)
• Added input 'jupyter-flake/haskell-nix-utils/cabal-extras':
    'github:phadej/cabal-extras/7a8f07aafcdbbeaeefcbb5f7e8e0e12f91b59fcb' (2022-05-25)
• Added input 'jupyter-flake/haskell-nix-utils/cabal-fmt':
    'github:phadej/cabal-fmt/6651ffdccdfce71330f2b5cde9f8f23b616abf82' (2021-08-30)
• Added input 'jupyter-flake/haskell-nix-utils/ekg-json':
    'github:pepeiborra/ekg-json/7a0af7a8fd38045fd15fb13445bdcc7085325460' (2022-05-02)
• Added input 'jupyter-flake/haskell-nix-utils/eventlog2html':
    'github:mpickering/eventlog2html/e959fdf879c2b404a9843d962b726af499b27cb8' (2021-12-06)
• Added input 'jupyter-flake/haskell-nix-utils/gentle-introduction':
    'github:phadej/gentle-introduction/949a99b4d2d8c556bdd455f0e4c4d94f0402ea63' (2022-05-18)
• Added input 'jupyter-flake/haskell-nix-utils/ghcid':
    'github:ndmitchell/ghcid/f48626bf5b64067a84b644bcc56afac686046966' (2022-03-26)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-language-server':
    'github:haskell/haskell-language-server/445192e21daa4f4973e60a13e748ffa910819e79' (2022-07-11)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix':
    'github:input-output-hk/haskell.nix/66ae51e640c624519ba1bb1559a9ef2deccd9726' (2022-07-12)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/HTTP':
    'github:phadej/HTTP/9bc0996d412fef1787449d841277ef663ad9a915' (2016-01-01)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/cabal-32':
    'github:haskell/cabal/48bf10787e27364730dd37a42b603cee8d6af7ee' (2020-10-26)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/cabal-34':
    'github:haskell/cabal/942639c18c0cd8ec53e0a6f8d120091af35312cd' (2021-12-24)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/cabal-36':
    'github:haskell/cabal/f27667f8ec360c475027dcaee0138c937477b070' (2022-01-08)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/cardano-shell':
    'github:input-output-hk/cardano-shell/9392c75087cb9a3d453998f4230930dea3a95725' (2020-12-21)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/flake-utils':
    'github:numtide/flake-utils/3cecb5b042f7f209c56ffd8371b2711a290ec797' (2022-02-07)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/ghc-8.6.5-iohk':
    'github:input-output-hk/ghc/95713a6ecce4551240da7c96b6176f980af75cae' (2020-09-24)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/hackage':
    'github:input-output-hk/hackage.nix/f596b29505d4a1b5d561c7c270a9c3b147534468' (2022-07-12)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/hpc-coveralls':
    'github:sevanspowell/hpc-coveralls/14df0f7d229f4cd2e79f8eabb1a740097fdfa430' (2020-12-09)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/hydra':
    'github:NixOS/hydra/28b682b85b7efc5cf7974065792a1f22203a5927' (2022-03-10)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/hydra/nix':
    'github:NixOS/nix/a1cd7e58606a41fcf62bf8637804cf8306f17f62' (2022-01-24)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/hydra/nix/lowdown-src':
    'github:kristapsdz/lowdown/d2c2b44ff6c27b936ec27358a2653caaef8f73b8' (2021-10-06)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/hydra/nix/nixpkgs':
    'github:NixOS/nixpkgs/82891b5e2c2359d7e58d08849e4c89511ab94234' (2021-09-28)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/hydra/nix/nixpkgs-regression':
    'github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2' (2022-01-24)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/hydra/nixpkgs':
    follows 'jupyter-flake/haskell-nix-utils/haskell-nix/hydra/nix/nixpkgs'
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/nix-tools':
    'github:input-output-hk/nix-tools/e109c94016e3b6e0db7ed413c793e2d4bdb24aa7' (2022-04-08)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/nixpkgs':
    follows 'jupyter-flake/haskell-nix-utils/haskell-nix/nixpkgs-unstable'
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/nixpkgs-2003':
    'github:NixOS/nixpkgs/1db42b7fe3878f3f5f7a4f2dc210772fd080e205' (2021-05-03)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/nixpkgs-2105':
    'github:NixOS/nixpkgs/530a53dcbc9437363471167a5e4762c5fcfa34a1' (2022-02-19)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/nixpkgs-2111':
    'github:NixOS/nixpkgs/0a58eebd8ec65ffdef2ce9562784123a73922052' (2022-03-31)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/nixpkgs-unstable':
    'github:NixOS/nixpkgs/30d3d79b7d3607d56546dd2a6b49e156ba0ec634' (2022-03-25)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/old-ghc-nix':
    'github:angerman/old-ghc-nix/af48a7a7353e418119b6dfe3cd1463a657f342b8' (2021-09-08)
• Added input 'jupyter-flake/haskell-nix-utils/haskell-nix/stackage':
    'github:input-output-hk/stackage.nix/cfa19244bdb8ac3562780a0199fccae1a9220b43' (2022-07-12)
• Added input 'jupyter-flake/haskell-nix-utils/hindent':
    'github:mihaimaruseac/hindent/4c2ea034f4365cd784539f223282907c9e734fba' (2022-06-26)
• Added input 'jupyter-flake/haskell-nix-utils/hooglite':
    'github:phadej/hooglite/18856375932f6744cac7849bd1e816538537863f' (2021-12-29)
• Added input 'jupyter-flake/haskell-nix-utils/pointfree':
    'github:bmillwood/pointfree/2fb1b2e1a48b7297b4f157eb4f3085ad6fa40443' (2021-04-10)
• Added input 'jupyter-flake/haskell-nix-utils/warp-wo-x509':
    'github:phadej/warp-wo-x509/98648f7520d228e6a14747223f0bbd68620b9318' (2021-11-14)
• Added input 'jupyter-flake/haskell-nix-utils/weeder':
    'github:ocharles/weeder/c58ed2a8c66dcf0b469f8343efb6b6f61c7c40f3' (2022-05-22)
• Added input 'jupyter-flake/jupyter-flake':
    'git+https://github.com/tweag/monad-bayes?ref=notebooks&rev=a123b9352203dcd245bbd06a3139edb3c6f653ae' (2022-08-30)
• Added input 'jupyter-flake/jupyter-flake/flake-utils':
    'github:numtide/flake-utils/c0e246b9b83f637f4681389ecabcb2681b4f3af0' (2022-08-07)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith':
    'github:tweag/jupyterWith/0b7f2e843f023c89283daf53eabce322efc9ca7c' (2022-08-29)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/flake-compat':
    'github:teto/flake-compat/8e15c6e3c0f15d0687a2ab6ae92cc7fab896bfed' (2021-09-15)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/flake-utils':
    'github:numtide/flake-utils/c0e246b9b83f637f4681389ecabcb2681b4f3af0' (2022-08-07)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell':
    'github:gibiansky/IHaskell/53f8e0773822ddf2cd392309ba27c8ff8e30202e' (2022-08-26)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/flake-compat':
    'github:edolstra/flake-compat/12c64ca55c1014cdc1b16ed5a804aa8576601ff2' (2021-08-02)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/flake-utils':
    'github:numtide/flake-utils/7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19' (2021-09-13)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls':
    'github:haskell/haskell-language-server/311107eabbf0537e0c192b2c377d282505b4eff1' (2021-11-18)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls/flake-compat':
    'github:edolstra/flake-compat/12c64ca55c1014cdc1b16ed5a804aa8576601ff2' (2021-08-02)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls/flake-utils':
    'github:numtide/flake-utils/997f7efcb746a9c140ce1f13c72263189225f482' (2021-08-20)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls/gitignore':
    'github:hercules-ci/gitignore.nix/211907489e9f198594c0eb0ca9256a1949c9d412' (2021-01-26)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls/nixpkgs':
    'github:NixOS/nixpkgs/5e47a07e9f2d7ed999f2c7943b0896f5f7321ca3' (2021-09-06)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls/pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/397f0713d007250a2c7a745e555fa16c5dc8cadb' (2021-06-29)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls/pre-commit-hooks/flake-utils':
    follows 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls/flake-utils'
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls/pre-commit-hooks/nixpkgs':
    follows 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/hls/nixpkgs'
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/ihaskell/nixpkgs':
    'github:NixOS/nixpkgs/5f0194220f2402b06f7f79bba6351895facb5acb' (2021-10-18)
• Added input 'jupyter-flake/jupyter-flake/jupyterWith/nixpkgs':
    'github:nixos/nixpkgs/eabc38219184cc3e04a974fe31857d8e0eac098d' (2022-08-02)
• Added input 'jupyter-flake/jupyter-flake/nixpkgs':
    'github:NixOS/nixpkgs/ce6aa13369b667ac2542593170993504932eb836' (2022-05-30)
• Removed input 'jupyter-flake/jupyterWith'
• Removed input 'jupyter-flake/jupyterWith/flake-compat'
• Removed input 'jupyter-flake/jupyterWith/flake-utils'
• Removed input 'jupyter-flake/jupyterWith/ihaskell'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/flake-compat'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/flake-utils'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/hls'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/hls/flake-compat'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/hls/flake-utils'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/hls/gitignore'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/hls/nixpkgs'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/hls/pre-commit-hooks'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/hls/pre-commit-hooks/flake-utils'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/hls/pre-commit-hooks/nixpkgs'
• Removed input 'jupyter-flake/jupyterWith/ihaskell/nixpkgs'
• Removed input 'jupyter-flake/jupyterWith/nixpkgs'
• Updated input 'jupyter-flake/nixpkgs':
    'github:NixOS/nixpkgs/ce6aa13369b667ac2542593170993504932eb836' (2022-05-30)
  → 'github:NixOS/nixpkgs/2da64a81275b68fdad38af669afeda43d401e94b' (2022-09-01)
• Added input 'jupyter-flake/pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/8cb8ea5f1c7bc2984f460587fddd5f2e558f6eb8' (2022-08-18)
• Added input 'jupyter-flake/pre-commit-hooks/flake-utils':
    follows 'jupyter-flake/flake-utils'
• Added input 'jupyter-flake/pre-commit-hooks/nixpkgs':
    follows 'jupyter-flake/nixpkgs'
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/2da64a81275b68fdad38af669afeda43d401e94b' (2022-09-01)
  → 'github:NixOS/nixpkgs/ae1dc133ea5f1538d035af41e5ddbc2ebcb67b90' (2022-09-22)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/8cb8ea5f1c7bc2984f460587fddd5f2e558f6eb8' (2022-08-18)
  → 'github:cachix/pre-commit-hooks.nix/60cad1a326df17a8c6cf2bb23436609fdd83024e' (2022-09-13)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/ae1dc133ea5f1538d035af41e5ddbc2ebcb67b90' (2022-09-22)
  → 'github:NixOS/nixpkgs/10ecda252ce1b3b1d6403caeadbcc8f30d5ab796' (2022-09-30)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/60cad1a326df17a8c6cf2bb23436609fdd83024e' (2022-09-13)
  → 'github:cachix/pre-commit-hooks.nix/2a4f1cfaa01b8b31edc7d3004454c4a0c38d50d8' (2022-09-30)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@netlify
Copy link

netlify bot commented Oct 7, 2022

Deploy Preview for monad-bayes-site ready!

Name Link
🔨 Latest commit 3559d87
🔍 Latest deploy log https://app.netlify.com/sites/monad-bayes-site/deploys/634830910bfcc00008e61174
😎 Deploy Preview https://deploy-preview-206--monad-bayes-site.netlify.app/sampling
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Oct 7, 2022

Deploy Preview for monad-bayes canceled.

Name Link
🔨 Latest commit 83b5802
🔍 Latest deploy log https://app.netlify.com/sites/monad-bayes/deploys/634ea57de3483f00081240e7

@mknorps
Copy link
Contributor Author

mknorps commented Oct 7, 2022

@reubenharry Could you explain the weighted vs unweighted sampling a bit more? I do not understand why we need weighted in caseof a normal distribution:
image

@reubenharry
Copy link
Contributor

@reubenharry Could you explain the weighted vs unweighted sampling a bit more? I do not understand why we need weighted in caseof a normal distribution: image

I think you're right, and unweighted would be fine. I believe they're equivalent here (since there were no factor statements), but unweighted is clearer, I agree.

@mknorps
Copy link
Contributor Author

mknorps commented Oct 12, 2022

@reubenharry Could you explain the weighted vs unweighted sampling a bit more? I do not understand why we need weighted in caseof a normal distribution: image

I think you're right, and unweighted would be fine. I believe they're equivalent here (since there were no factor statements), but unweighted is clearer, I agree.

The problem I have with this statement is that it needs weighted or a unweighted . weighted functions at all. It is not clear for me:

  • why we have to treat sampling from continuous distribution with additional weights by default and not having weights as an option?
  • if the above is necessary due to implementation logic, could you explain why it is so?

@reubenharry
Copy link
Contributor

@reubenharry Could you explain the weighted vs unweighted sampling a bit more? I do not understand why we need weighted in caseof a normal distribution: image

I think you're right, and unweighted would be fine. I believe they're equivalent here (since there were no factor statements), but unweighted is clearer, I agree.

The problem I have with this statement is that it needs weighted or a unweighted . weighted functions at all. It is not clear for me:

  • why we have to treat sampling from continuous distribution with additional weights by default and not having weights as an option?
  • if the above is necessary due to implementation logic, could you explain why it is so?

I don't think we need weighted, or even unweighted. The only thing is that we need some weights to give to the histogram, so we could just supply those (something like fmap (,1) (replicateM n model2) (That ends up being what weighted does anyway, which is why the code is the way it is, but I agree it's confusing).

@mknorps mknorps marked this pull request as ready for review October 13, 2022 15:33
@mknorps mknorps requested a review from reubenharry October 13, 2022 15:33
Base automatically changed from notebooks to master October 18, 2022 08:09
Copy link
Contributor

@reubenharry reubenharry left a comment

Choose a reason for hiding this comment

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

These changes look good to me!

@mknorps mknorps mentioned this pull request Oct 18, 2022
14 tasks
@mknorps mknorps merged commit c79cfde into master Oct 18, 2022
@mknorps mknorps deleted the maria/notebooks-sampling branch October 18, 2022 13:23
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.

3 participants