SOPA Algorithm, best possible probability sorting Algorithm
Project description
Online Optimal Sort
Onsort is a small library providing utilities for online ranking (sorting) numbers comming from a know distribution at random.
It was inspired by the PlaceIt game and here you will find the algorithms to compute the probability of winning the game with the best strategy as well as the continuous variant.
Content
The library contains two modules:
-
Continuous: where we have the scripts for calculating the probability of winning the continous version as well as one script for sorting numbers in a random continous distriboutin from 0 to 1.
-
discrete: where we have a script for getting the probability for solving the original game.
As the probability can be calculated analytically the code is semi-symbolic, notice that the full symbolic solution for more than 8-10 slots can take very long time.
Usage example:
If wanting to use the library for sorting we have the following script:
from onsort.continuous.online_sort import sort
# the data can be generated randomly, comming from online stream
arr = [0.76931784, 0.06506234, 0.07066391, 0.70643678, 0.94615554]
sort_gen = sort(5)
slots = next(sort_gen) # initialize generator
for n in arr:
slots = sort_gen.send(n)
print(slots)
Run test
poetry shell
pytest .
pytest --cov=pytrade tests/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file onsort-0.1.0.tar.gz.
File metadata
- Download URL: onsort-0.1.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.5.0-9-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43072dc72098dba9413d367454e1c835d5b0a125f01db0fa84c7f69a1a248cef
|
|
| MD5 |
cef0c015960b8980c4dadd5d1881cd51
|
|
| BLAKE2b-256 |
0e545e59190734130da002d4bda29ed9d939eba32df33b61569936727711f909
|
File details
Details for the file onsort-0.1.0-py3-none-any.whl.
File metadata
- Download URL: onsort-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.5.0-9-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ed1616603463a31e9c3cf9bd72bf231faaaafe32da8010f62c11e2b813bc21b
|
|
| MD5 |
7f9cd7dc682048c93f44111be8dac786
|
|
| BLAKE2b-256 |
f8ae14dcde2908aae5adbaadbf73618c208ae94444f8a9ea95a90e9d8dad1dbd
|