René's URL Explorer Experiment


Title: In-place sampling · Issue #8 · randomized-algorithm/random · GitHub

Open Graph Title: In-place sampling · Issue #8 · randomized-algorithm/random

X Title: In-place sampling · Issue #8 · randomized-algorithm/random

Description: If you want to sample k items out of n, Fisher Yates shuffles your item array. Hereunder is an efficient no shuffle implementation. Something better can probably be achieved with prefix sums and rank/select. Theorem We can sample k items...

Open Graph Description: If you want to sample k items out of n, Fisher Yates shuffles your item array. Hereunder is an efficient no shuffle implementation. Something better can probably be achieved with prefix sums and ra...

X Description: If you want to sample k items out of n, Fisher Yates shuffles your item array. Hereunder is an efficient no shuffle implementation. Something better can probably be achieved with prefix sums and ra...

Opengraph URL: https://github.com/randomized-algorithm/random/issues/8

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"In-place sampling","articleBody":"If you want to sample k items out of n, Fisher Yates shuffles your item array.\r\nHereunder is an efficient no shuffle implementation. Something better can probably be achieved with prefix sums and rank/select.\r\n\r\n#### Theorem\r\n\r\nWe can sample k items out of n with k random draws and O(k log k) time, without modifying the items array.\r\n\r\n#### Proof\r\n\r\nTODO fix proof\r\n\r\nGiven n items, at draw i=1,2,...,n with a binary search tree containing all previously drawn items indices between 0 and n-1, pick a random integer x between 0 and n - i. Binary search for its corresponding index value as follows: start with p = 0 the number of predecessors of the current node, let l be the size of the left subtree of the current node, let v be the value of the current node, if x + p + l + 1 \u003c v\r\nthe current node becomes the left child, otherwise the current node becomes the right child and p = p + l + 1. If there is no such child, insert x + p in the case of a left child, x + p + l + 1 in the case of a right child.\r\n\r\nIf x + p + l + 1 \u003c v, then x cannot be in the right subtree of v. The item index corresponding to x would be x + p + l + 1 if it was the right child of v which is smaller than v. Pick any node c in the right subtree of v. Let g be the number of predecessors of c in the right subtree of v. The value of c is at least v + 1 + g because all indices are distinct. Suppose c has no right child. The item index of x as a right child of c is x + p + l  + 1 + g + 1 \u003c v + g + 1 \u003c= c. Suppose c has no left child. The item index of x as a left child of c is x + p + l + 1 + g \u003c v + g \u003c v + g + 1 \u003c= c.\r\n\r\nIf x + p + l + 1 \u003e v, then x cannot be in the left subtree of v. If v has no left child, then l = 0 and the value of x as the left child of v would be x + p which is larger or equal to v (indices must be distinct). Pick any node c in the left subtree of v.\r\nLet s be the number of successors of s in the left subtree of v. The value of c is at most v - s - 1 because all indices are distinct. Suppose c has no left child. The item index of x as a left child of c is x + p + l - s - 1 \u003e v - s - 2 so x + p + l - s - 1 \u003e= v - s - 1 = c.","author":{"url":"https://github.com/make-github-pseudonymous-again","@type":"Person","name":"make-github-pseudonymous-again"},"datePublished":"2017-03-03T17:37:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/8/random/issues/8"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0843ac6c-4bac-95ef-aeda-2717ce53ee04
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8FE8:19BE69:88D213:B6E439:698F7F9D
html-safe-noncea2c220d68e9f45c860fcf0fa00ed1f3dc3aac4a10800e62f0c7781426a825aa3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkU4OjE5QkU2OTo4OEQyMTM6QjZFNDM5OjY5OEY3RjlEIiwidmlzaXRvcl9pZCI6IjU1Nzk3OTk5MDUzMDY2NDAyODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac55112dc125000559a93a8819fa674a85cd23a912d54691d1a5cd7ec4d838f5ff
hovercard-subject-tagissue:211754103
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/randomized-algorithm/random/8/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a795094d8576c252201874ceca120d27b04ae12cda24e1a032fa11e33a572cbe/randomized-algorithm/random/issues/8
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a795094d8576c252201874ceca120d27b04ae12cda24e1a032fa11e33a572cbe/randomized-algorithm/random/issues/8
og:image:altIf you want to sample k items out of n, Fisher Yates shuffles your item array. Hereunder is an efficient no shuffle implementation. Something better can probably be achieved with prefix sums and ra...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemake-github-pseudonymous-again
hostnamegithub.com
expected-hostnamegithub.com
None4763146d672e989a41c6c0bd715790c0c59341d9f855508c8a3196e1e480b8f7
turbo-cache-controlno-preview
go-importgithub.com/randomized-algorithm/random git https://github.com/randomized-algorithm/random.git
octolytics-dimension-user_id87477532
octolytics-dimension-user_loginrandomized-algorithm
octolytics-dimension-repository_id24736215
octolytics-dimension-repository_nworandomized-algorithm/random
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24736215
octolytics-dimension-repository_network_root_nworandomized-algorithm/random
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8b442a4e0d8e68ffb351da689499018fde153e49
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/randomized-algorithm/random/issues/8#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Frandomized-algorithm%2Frandom%2Fissues%2F8
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Frandomized-algorithm%2Frandom%2Fissues%2F8
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=randomized-algorithm%2Frandom
Reloadhttps://patch-diff.githubusercontent.com/randomized-algorithm/random/issues/8
Reloadhttps://patch-diff.githubusercontent.com/randomized-algorithm/random/issues/8
Reloadhttps://patch-diff.githubusercontent.com/randomized-algorithm/random/issues/8
randomized-algorithm https://patch-diff.githubusercontent.com/randomized-algorithm
randomhttps://patch-diff.githubusercontent.com/randomized-algorithm/random
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Frandomized-algorithm%2Frandom
Fork 0 https://patch-diff.githubusercontent.com/login?return_to=%2Frandomized-algorithm%2Frandom
Star 1 https://patch-diff.githubusercontent.com/login?return_to=%2Frandomized-algorithm%2Frandom
Code https://patch-diff.githubusercontent.com/randomized-algorithm/random
Issues 5 https://patch-diff.githubusercontent.com/randomized-algorithm/random/issues
Pull requests 2 https://patch-diff.githubusercontent.com/randomized-algorithm/random/pulls
Actions https://patch-diff.githubusercontent.com/randomized-algorithm/random/actions
Projects 0 https://patch-diff.githubusercontent.com/randomized-algorithm/random/projects
Wiki https://patch-diff.githubusercontent.com/randomized-algorithm/random/wiki
Security 0 https://patch-diff.githubusercontent.com/randomized-algorithm/random/security
Insights https://patch-diff.githubusercontent.com/randomized-algorithm/random/pulse
Code https://patch-diff.githubusercontent.com/randomized-algorithm/random
Issues https://patch-diff.githubusercontent.com/randomized-algorithm/random/issues
Pull requests https://patch-diff.githubusercontent.com/randomized-algorithm/random/pulls
Actions https://patch-diff.githubusercontent.com/randomized-algorithm/random/actions
Projects https://patch-diff.githubusercontent.com/randomized-algorithm/random/projects
Wiki https://patch-diff.githubusercontent.com/randomized-algorithm/random/wiki
Security https://patch-diff.githubusercontent.com/randomized-algorithm/random/security
Insights https://patch-diff.githubusercontent.com/randomized-algorithm/random/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/randomized-algorithm/random/issues/8
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/randomized-algorithm/random/issues/8
In-place samplinghttps://patch-diff.githubusercontent.com/randomized-algorithm/random/issues/8#top
https://patch-diff.githubusercontent.com/make-github-pseudonymous-again
apihttps://github.com/randomized-algorithm/random/issues?q=state%3Aopen%20label%3A%22api%22
https://github.com/make-github-pseudonymous-again
https://github.com/make-github-pseudonymous-again
make-github-pseudonymous-againhttps://github.com/make-github-pseudonymous-again
on Mar 3, 2017https://github.com/randomized-algorithm/random/issues/8#issue-211754103
make-github-pseudonymous-againhttps://patch-diff.githubusercontent.com/make-github-pseudonymous-again
apihttps://github.com/randomized-algorithm/random/issues?q=state%3Aopen%20label%3A%22api%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.