LTirrellsmb raffle tickets probability calc hist
    Updated 2023-07-01
    -- forked from smb raffle tickets probability calc @ https://flipsidecrypto.xyz/edit/queries/6dac6c47-a8eb-4838-9610-9a9dde0cbb0d
    -- forked from smb raffle tickets by minter summary @ https://flipsidecrypto.xyz/edit/queries/79c9816e-abf6-4098-89b7-359c4d941370
    -- forked from smb raffle ticket by minter @ https://flipsidecrypto.xyz/edit/queries/bd062abc-58a8-46e2-8da1-aa740a5610f6
    -- forked from smb raffle ticket cost @ https://flipsidecrypto.xyz/edit/queries/19e46b24-0357-454b-b77a-5e746eea4a28
    -- forked from smb raffle fees @ https://flipsidecrypto.xyz/edit/queries/78da776e-36e1-4f99-a68b-51571cd9e808
    -- forked from smb raffle base @ https://flipsidecrypto.xyz/edit/queries/eb475bf3-6f9b-4748-ab29-5643ee894794
    with
    tix_seq as (
    SELECT
    seq4() as ticket_seq
    FROM
    TABLE (GENERATOR(ROWCOUNT => 250)) v
    ORDER BY
    1
    )
    SELECT
    -- probabilty calculator
    -- https://www.reddit.com/r/runescape/comments/2f7wiy/want_to_cafllculate_your_odds_of_winning_a_raffle/
    -- python code for more precise calculation, but doesn't work in SQL:
    -- import math
    -- def combination_formula(t,n):
    -- return math.factorial(t)/(math.factorial(t-n)*math.factorial(n))
    -- def combination_probability(t,n,x):
    -- return 1 - combination_formula(t-x,n)/combination_formula(t,n)
    -- this will underestimate odds, as there is replacements
    ticket_seq,
    1 - pow(((79385 - 4000) / 79385), ticket_seq) as probability
    from
    tix_seq
    Run a query to Download Data