Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. Today I needed to write a function that would select a random set of N=5 items, containing at most one special item, from a set of R=24 regular and S=4 special items.

Today I needed to write a function that would select a random set of N=5 items, containing at most one special item, from a set of R=24 regular and S=4 special items.

Scheduled Pinned Locked Moved Uncategorized
2 Posts 1 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mjd@mathstodon.xyzM This user is from outside of this forum
    mjd@mathstodon.xyzM This user is from outside of this forum
    mjd@mathstodon.xyz
    wrote last edited by
    #1

    Today I needed to write a function that would select a random set of N=5 items, containing at most one special item, from a set of R=24 regular and S=4 special items.

    I calculated that the number of sets with no special items is \( \binom{R}{N} =\binom{24}{5} = 42504 \).

    And I calculated that the number of sets with one special item is \( \binom{R}{N-1} \cdot S = \binom{24}{4} · 4 = 42504 \) — the same, so the probability of getting a set with one special item is exactly ½.

    Then I spent a lot of time trying to figure out where my mistake was. Surely not a bug in my venerable binomial-coefficient-computing program?

    No, they are equal, and it is a pure coincidence, an effect of the fact that \( R-N+1 = N\cdot S\).

    If any of the three numbers had been different, the two groups would have been different sizes.

    mjd@mathstodon.xyzM 1 Reply Last reply
    0
    • mjd@mathstodon.xyzM mjd@mathstodon.xyz

      Today I needed to write a function that would select a random set of N=5 items, containing at most one special item, from a set of R=24 regular and S=4 special items.

      I calculated that the number of sets with no special items is \( \binom{R}{N} =\binom{24}{5} = 42504 \).

      And I calculated that the number of sets with one special item is \( \binom{R}{N-1} \cdot S = \binom{24}{4} · 4 = 42504 \) — the same, so the probability of getting a set with one special item is exactly ½.

      Then I spent a lot of time trying to figure out where my mistake was. Surely not a bug in my venerable binomial-coefficient-computing program?

      No, they are equal, and it is a pure coincidence, an effect of the fact that \( R-N+1 = N\cdot S\).

      If any of the three numbers had been different, the two groups would have been different sizes.

      mjd@mathstodon.xyzM This user is from outside of this forum
      mjd@mathstodon.xyzM This user is from outside of this forum
      mjd@mathstodon.xyz
      wrote last edited by
      #2

      This reminds me of the time that Reddit's `r/programmingCircleJerk` described one of my blog posts as “Haskaller too smart to get anything done”.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups