{"id":19028156,"url":"https://github.com/jmssnr/shuffle-kit","last_synced_at":"2026-05-01T22:30:17.745Z","repository":{"id":218592402,"uuid":"745823359","full_name":"jmssnr/shuffle-kit","owner":"jmssnr","description":"shuffle-kit: model and analyze playing card shuffles in Python","archived":false,"fork":false,"pushed_at":"2024-02-22T20:06:45.000Z","size":879,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-23T23:36:11.287Z","etag":null,"topics":["data-analysis","playing-cards","python","shuffle","statistics"],"latest_commit_sha":null,"homepage":"https://jmssnr.github.io/shuffle-kit/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmssnr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-20T08:49:07.000Z","updated_at":"2024-02-19T09:55:07.000Z","dependencies_parsed_at":"2024-11-08T21:10:11.373Z","dependency_job_id":"d973c122-9175-478b-981b-a3aa91b53380","html_url":"https://github.com/jmssnr/shuffle-kit","commit_stats":null,"previous_names":["jmssnr/shuffle-kit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmssnr%2Fshuffle-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmssnr%2Fshuffle-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmssnr%2Fshuffle-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmssnr%2Fshuffle-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmssnr","download_url":"https://codeload.github.com/jmssnr/shuffle-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240079610,"owners_count":19744720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-analysis","playing-cards","python","shuffle","statistics"],"created_at":"2024-11-08T21:10:06.269Z","updated_at":"2026-05-01T22:30:17.701Z","avatar_url":"https://github.com/jmssnr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![logo](./docs/logos/shuffle-kit-logo-small.png)\n\n[![docs](https://github.com/jmssnr/shuffle-kit/actions/workflows/docs.yaml/badge.svg)](https://github.com/jmssnr/shuffle-kit/actions/workflows/docs.yaml)_![PyPI - Version](https://img.shields.io/pypi/v/shuffle-kit)_[![Test](https://github.com/jmssnr/shuffle-kit/actions/workflows/test.yaml/badge.svg)](https://github.com/jmssnr/shuffle-kit/actions/workflows/test.yaml)\n\n**shuffle-kit** is a Python package for modelling and analyzing playing card shuffles.\n\nIt implements several mathematical models of commonly used shuffles that can be composed into complex sequences.\n\nIn addition, several utility functions are provided to faciliate analyzing the various shuffle models.\n\n# Installation\n\n## Dependencies\n\nshuffle-kit requires:\n\n- Python (\u003e= 3.11)\n- Numpy (\u003e= 1.26.3)\n\n## User installation\n\nThe easiest way to install shuffle-kit is via pip:\n\n`pip install shuffle-kit`\n\n# Examples\n\n## Basic example of using shuffle-kit\n\n```py\nfrom shuffl import gsr, strip, cut, sequence, simulate, Deck\nfrom itertools import accumulate\n\n# Creates a list of integers from 1..52, representing a\n# standard deck of 52 cards\ndeck = Deck(range(1,53))\n\n# Creates a riffle, riffle, strip, riffle, cut shuffle sequence\n# with the Gilbert-Shannon-Reeds model for riffle shuffling\nshuffle = sequence([gsr, gsr, strip, gsr, cut])\n\n# Simulate the shuffle a 1000 times. For each simulation, the\n# deck is reset to the initial order\nresult = simulate(shuffle, deck, 1000)\n\n# Compute the empirical cumulative density function of the\n# original top card, i.e., \"1\"\necdf = list(accumulate(result.probability[0]))\n\n# Print the probability that the original top card (\"1\") is\n# found within the top ten cards after shuffling\nprint(f\"Probability of finding '1' within the top ten cards: {ecdf[9]:.2}\")\n```\n\n## Simulating a guessing game\n\nHere we play a round of the guessing game described in Bayer and Diaconis (1992). Consider a shuffled deck of 52 cards, face down on the table. The task is to guess the top card. After each guess, the top card is turned over and discarded. \n\nIf the deck is perfectly shuffled the average number of correct guesses is around 4.5. However, if the deck is riffle shuffled _k_ times, then there exists a conjectural optimal strategy that achives a higher number of correct guesses depending on _k_.\n\n```py\nfrom shuffl.games import guessing_game\nfrom shuffl import gsr, Deck, sequence\n\n# Creates a list of integers from 1..52, representing a\n# standard deck of 52 cards\ndeck = Deck(range(1, 53))\n\n# Creates a sequence of two riffle shuffles following\n# the Gilbert-Shannon-Reeds model\nshuffle = sequence([gsr, gsr])\n\n# Run a simulation of the guessing game described in\n# Bayer D., Diaconis P. (1992). Trailing the dovetail shuffle to its lair.\n# The Annals of Applied Probability, Vol. 2, No. 2, 294-313\ncorrect_guess = guessing_game(deck, shuffle)\n\n# Print the number of correct guesses. On average this should\n# be around 19.\nprint(f\"Number of correct guesses: {correct_guess}\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmssnr%2Fshuffle-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmssnr%2Fshuffle-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmssnr%2Fshuffle-kit/lists"}