https://github.com/jmssnr/shuffle-kit

shuffle-kit: model and analyze playing card shuffles in Python

https://github.com/jmssnr/shuffle-kit

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.2%) to scientific vocabulary

Keywords

data-analysis playing-cards python shuffle statistics
Last synced: 6 months ago · JSON representation

Repository

shuffle-kit: model and analyze playing card shuffles in Python

Basic Info
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
data-analysis playing-cards python shuffle statistics
Created about 2 years ago · Last pushed about 2 years ago
Metadata Files
Readme License

README.md

logo

docsPyPI - VersionTest

shuffle-kit is a Python package for modelling and analyzing playing card shuffles.

It implements several mathematical models of commonly used shuffles that can be composed into complex sequences.

In addition, several utility functions are provided to faciliate analyzing the various shuffle models.

Installation

Dependencies

shuffle-kit requires:

  • Python (>= 3.11)
  • Numpy (>= 1.26.3)

User installation

The easiest way to install shuffle-kit is via pip:

pip install shuffle-kit

Examples

Basic example of using shuffle-kit

```py from shuffl import gsr, strip, cut, sequence, simulate, Deck from itertools import accumulate

Creates a list of integers from 1..52, representing a

standard deck of 52 cards

deck = Deck(range(1,53))

Creates a riffle, riffle, strip, riffle, cut shuffle sequence

with the Gilbert-Shannon-Reeds model for riffle shuffling

shuffle = sequence([gsr, gsr, strip, gsr, cut])

Simulate the shuffle a 1000 times. For each simulation, the

deck is reset to the initial order

result = simulate(shuffle, deck, 1000)

Compute the empirical cumulative density function of the

original top card, i.e., "1"

ecdf = list(accumulate(result.probability[0]))

Print the probability that the original top card ("1") is

found within the top ten cards after shuffling

print(f"Probability of finding '1' within the top ten cards: {ecdf[9]:.2}") ```

Simulating a guessing game

Here 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.

If 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.

```py from shuffl.games import guessing_game from shuffl import gsr, Deck, sequence

Creates a list of integers from 1..52, representing a

standard deck of 52 cards

deck = Deck(range(1, 53))

Creates a sequence of two riffle shuffles following

the Gilbert-Shannon-Reeds model

shuffle = sequence([gsr, gsr])

Run a simulation of the guessing game described in

Bayer D., Diaconis P. (1992). Trailing the dovetail shuffle to its lair.

The Annals of Applied Probability, Vol. 2, No. 2, 294-313

correctguess = guessinggame(deck, shuffle)

Print the number of correct guesses. On average this should

be around 19.

print(f"Number of correct guesses: {correct_guess}") ```

Owner

  • Login: jmssnr
  • Kind: user

Chemical Engineering PhD; Works in data science in the chemical industry

GitHub Events

Total
Last Year

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 57
  • Total Committers: 1
  • Avg Commits per committer: 57.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 57
  • Committers: 1
  • Avg Commits per committer: 57.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
jmssnr m****s@g****m 57

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 20 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
pypi.org: shuffle-kit
  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 20 Last month
Rankings
Dependent packages count: 9.8%
Forks count: 33.2%
Average: 37.7%
Stargazers count: 42.9%
Dependent repos count: 64.9%
Maintainers (1)
Last synced: 7 months ago

Dependencies

.github/workflows/docs.yaml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
poetry.lock pypi
  • babel 2.14.0
  • certifi 2023.11.17
  • cfgv 3.4.0
  • charset-normalizer 3.3.2
  • click 8.1.7
  • colorama 0.4.6
  • distlib 0.3.8
  • filelock 3.13.1
  • ghp-import 2.1.0
  • griffe 0.39.1
  • identify 2.5.33
  • idna 3.6
  • iniconfig 2.0.0
  • jinja2 3.1.3
  • markdown 3.5.2
  • markupsafe 2.1.4
  • mergedeep 1.3.4
  • mkdocs 1.5.3
  • mkdocs-autorefs 0.5.0
  • mkdocs-material 9.5.4
  • mkdocs-material-extensions 1.3.1
  • mkdocstrings 0.24.0
  • mkdocstrings-python 1.8.0
  • nodeenv 1.8.0
  • numpy 1.26.3
  • packaging 23.2
  • paginate 0.5.6
  • pathspec 0.12.1
  • platformdirs 4.1.0
  • pluggy 1.3.0
  • pre-commit 3.6.0
  • pygments 2.17.2
  • pymdown-extensions 10.7
  • pytest 7.4.4
  • pytest-mock 3.12.0
  • python-dateutil 2.8.2
  • pyyaml 6.0.1
  • pyyaml-env-tag 0.1
  • regex 2023.12.25
  • requests 2.31.0
  • ruff 0.1.14
  • setuptools 69.0.3
  • six 1.16.0
  • urllib3 2.1.0
  • virtualenv 20.25.0
  • watchdog 3.0.0
pyproject.toml pypi
  • pre-commit ^3.6.0 develop
  • pytest ^7.4.4 develop
  • pytest-mock ^3.12.0 develop
  • ruff ^0.1.13 develop
  • mkdocs ^1.5.3 docs
  • mkdocs-material ^9.5.4 docs
  • mkdocstrings ^0.24.0 docs
  • numpy ^1.26.3
  • python ^3.11
.github/workflows/test.yaml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite