0 Members and 1 Guest are viewing this topic.
A few weeks ago I was doing a Monte-Carlo simulation (yes, that is a thing!), and needed to generate a lot of random sequences; I was using EXCEL to generate them.See: https://en.wikipedia.org/wiki/Monte_Carlo_methodThere were a number of methods on the web that would generate random numbers "with replacement", but I wanted to do it "without replacement".- If you are running a clinical trial, you can't give two different patients the same bottle of medicine- And you don't want any bottles left over at the end- And you don't want to allocate more people to one arm of the trial than the other - What you want is a random permutation: - Randomly assign 100 people to 100 bottles of medicine; once you have assigned a bottle to a person, that bottle is removed from consideration. - It also works in the opposite direction: once you have assigned a person to a bottle, that person is removed from consideration.I found a method on the web that is pretty much what bored chemist suggested, generating a random permutation:- Generate a row of random numbers (however many you need): EXCEL has a RND() function.- Lookup the list of random numbers and pick the nth largest, using the "LARGE()" function- Find the index of that entry using the "MATCH()" function- It seems rather roundabout, but it works well.- I wanted to generate a hundred random permutations: Just copy the equations 100 times- I wanted to run the simulation many times with different inputs: Every time you click "Calculate", it generates a new simulation and graphs the results... This is the method I used: https://superuser.com/questions/972507/can-i-produce-a-row-in-excel-which-is-random-permutation-of-another-rowBut I think Alan only wanted to generate 1 random permutation.Apparently, EXCEL in Microsoft365 has a new RANDARRAY function that can be used to randomly permute a list by coupling it with the SORTBY function:https://www.ablebits.com/office-addins-blog/2020/07/15/excel-randarray-function-generate-random-numbers/
I thought several ideas had already been presented. Are you looking for some improvement, refinement or continued discussion?
which was to note that there are different interpretations of "random" within a closed set, some of which may permit (or even guarantee) duplicates.
As usual, the discussion has moved way off the original point, which was to note that there are different interpretations of "random" within a closed set, some of which may permit (or even guarantee) duplicates.
A random variable X is a measurable function X : Ω → E from a set of possible outcomes Ω to a measurable space E. The technical axiomatic definition requires Ω to be a sample space of a probability triple ( Ω , F , P ). The probability that X takes on a value in a measurable set S ⊆ E is written as P ( X ∈ S ) = P ( { ω ∈ Ω ∣ X ( ω ) ∈ S } ) [Based on Wikipedia entry for "Random variable"