Random permutation

A random permutation is a random ordering of a set of objects, that is, a permutation-valued random variable. The use of random permutations is often fundamental to fields that use randomized algorithms such as coding theory, cryptography, and simulation. A good example of a random permutation is the shuffling of a deck of cards: this is ideally a random permutation of the 52 cards.

Generating random permutations

Entry-by-entry brute force method

One method of generating a random permutation of a set of size n uniformly at random (i.e., each of the n! permutations is equally likely to appear) is to generate a sequence by taking a random number between 1 and n sequentially, ensuring that there is no repetition, and interpreting this sequence (x1, ..., xn) as the permutation

shown here in two-line notation.

This brute-force method will require occasional retries whenever the random number picked is a repeat of a number already selected. This can be avoided if, on the ith step (when x1, ..., xi − 1 have already been chosen), one chooses a number j at random between 1 and ni + 1 and sets xi equal to the jth largest of the unchosen numbers.

Fisher-Yates shuffles

A simple algorithm to generate a permutation of n items uniformly at random without retries, known as the Fisher–Yates shuffle, is to start with any permutation (for example, the identity permutation), and then go through the positions 0 through n − 2 (we use a convention where the first element has index 0, and the last element has index n − 1), and for each position i swap the element currently there with a randomly chosen element from positions i through n − 1 (the end), inclusive. It's easy to verify that any permutation of n elements will be produced by this algorithm with probability exactly 1/n!, thus yielding a uniform distribution over all such permutations.

unsigned uniform(unsigned m); /* Returns a random integer 0 <= uniform(m) <= m-1 with uniform distribution */

void initialize_and_permute(unsigned permutation[], unsigned n)
{
    unsigned i;
    for (i = 0; i <= n-2; i++) {
        unsigned j = i+uniform(n-i); /* A random integer such that i ≤ j < n */
        swap(permutation[i], permutation[j]);   /* Swap the randomly picked element with permutation[i] */
    }
}

Note that if the uniform() function is implemented simply as random() % (m) then a bias in the results is introduced if the number of return values of random() is not a multiple of m, but this becomes insignificant if the number of return values of random() is orders of magnitude greater than m.

Statistics on random permutations

Fixed points

The probability distribution of the number of fixed points in a uniformly distributed random permutation approaches a Poisson distribution with expected value 1 as n grows. In particular, it is an elegant application of the inclusion–exclusion principle to show that the probability that there are no fixed points approaches 1/e. When n is big enough, the probability distribution of fixed points is almost the Poisson distribution with expected value 1.[1] The first n moments of this distribution are exactly those of the Poisson distribution.

Randomness testing

As with all random processes, the quality of the resulting distribution of an implementation of a randomized algorithm such as the Knuth shuffle (i.e., how close it is to the desired uniform distribution) depends on the quality of the underlying source of randomness, such as a pseudorandom number generator. There are many possible randomness tests for random permutations, such as some of the Diehard tests. A typical example of such a test is to take some permutation statistic for which the distribution is known and test whether the distribution of this statistic on a set of randomly generated permutations closely approximates the true distribution.

See also

References

  1. ^ Durstenfeld, Richard (1964-07-01). "Algorithm 235: Random permutation". Communications of the ACM. 7 (7): 420. doi:10.1145/364520.364540.
  • Random permutation at MathWorld
  • Random permutation generation -- detailed and practical explanation of Knuth shuffle algorithm and its variants for generating k-permutations (permutations of k elements chosen from a list) and k-subsets (generating a subset of the elements in the list without replacement) with pseudocode

Read other articles:

Questa voce o sezione sugli argomenti geologi e geografi non cita le fonti necessarie o quelle presenti sono insufficienti. Puoi migliorare questa voce aggiungendo citazioni da fonti attendibili secondo le linee guida sull'uso delle fonti. Ferdinand Freiherr von Richthofen Ferdinand Freiherr von Richthofen (Pokój, 5 maggio 1833 – Berlino, 6 ottobre 1905) è stato un geografo e geologo tedesco. Indice 1 Biografia 2 Curiosità 3 Onorificenze 4 Bibliografia 5 Altri progetti 6 Collegamenti e…

Anggrek Selop Klasifikasi ilmiah Kerajaan: Plantae Divisi: Magnoliophyta Kelas: Liliopsida Ordo: Asparagales Famili: Orchidaceae Genus: Paphiopedilum Spesies: P. glaucophyllum Nama binomial Paphiopedilum glaucophyllumJ.J.Sm. Sinonim Cypripedium glaucophyllum (J.J.Sm.) Mast. Cordula glaucophylla (J.J.Sm.) Rolfe Paphiopedilum victoria-regina ssp. glaucophyllum (J.J.Sm.) M.W.Wood Anggrek Selop atau Paphiopedilum glaucophyllum adalah salah satu spesies anggrek yang termasuk tanaman endemik Jawa…

Grand Casemates Square Pemandangan Grand Casemates Square, menghadap timur laut ke Batu Gibraltar (2007).Nama sebelumnya La Barcina, La EsplanadaPemilik Pemerintah GibraltarLokasi GibraltarKoordinat 36°08′41″N 5°21′10″W / 36.1448°N 5.3528°W / 36.1448; -5.3528Koordinat: 36°08′41″N 5°21′10″W / 36.1448°N 5.3528°W / 36.1448; -5.3528 Grand Casemates Square (biasa disebut Casemates Square atau Casemates) adalah alun-alun terbesar …

Bivak dari ponco (jas hujan) Bivak (Bahasa Prancis: Bivouac) adalah tempat berlindung sementara (darurat) di alam bebas dari aneka gangguan cuaca, binatang buas, dan angin. Mendirikan bivak adalah teknik penting yang harus dikuasai jika hendak berkemah . Bivak merupakan salah satu kemampuan wajib survival di alam bebas. Karena pembuatannya yang mudah dengan peralatan yang seadanya.[1] Materi penunjang pembuatan bivak adalah: Dari bahan alam, seperti pepohonan (dahan, ranting dan daun) ba…

الحدثكأس ألمانيا 1941 Dresdner SC [الإنجليزية]‏ شالكه 04 2 1 التاريخ2 نوفمبر 1941  الملعبالملعب الأولمبي  الحضور65000   →نهائي كأس ألمانيا 1940  نهائي كأس ألمانيا 1942  ← نهائي كأس ألمانيا 1941 هي المباراة النهائية من منافسة كأس ألمانيا 1941، أقيمت المباراة في 2 نوفمبر 1941، …

Belawan beralih ke halaman ini. Untuk Untuk kecamatan di Medan, lihat Medan Belawan. Pelabuhan BelawanTerminal penumpang pelabuhan Belawan, MedanLokasi di Sumatera Utara dan Pulau SumatraLokasiNegara IndonesiaLokasiMedan, Sumatera UtaraKoordinat03°47′N 98°42′E / 3.783°N 98.700°E / 3.783; 98.700UN/LOCODEID BLWDetailOperatorDirektorat Jenderal Perhubungan LautPemilikPT Pelindo (Dulu Pelabuhan Indonesia I).JenisPelabuhan penumpang & kargoOtoritas pelabuhanKS…

Scottish synthpop group ChvrchesChvrches performing in Los Angeles in 2021Background informationOriginGlasgow, ScotlandGenres Synth-pop electropop indie pop indietronica electronic rock DiscographyChvrches discographyYears active2011–presentLabels Island Records Virgin Goodbye Glassnote Virgin EMI Spinoff ofAereogrammeMembers Iain Cook Martin Doherty Lauren Mayberry Websitechvrch.es Chvrches (stylised CHVRCHΞS and pronounced Churches) are a Scottish synth-pop band from Glasgow, formed in Sept…

Waves or particles moving through space For other uses, see Radiation (disambiguation). Illustration of the relative abilities of three different types of ionizing radiation to penetrate solid matter. Typical alpha particles (α) are stopped by a sheet of paper, while beta particles (β) are stopped by 3mm aluminum foil. Gamma radiation (γ) is dampened when it penetrates lead. Note caveats in the text about this simplified diagram.[clarification needed] The international symbol for type…

Vyna MaryanaLahirTri Vina Maryana9 Juni 1994 (umur 29)Pekalongan, Jawa Tengah, IndonesiaNama lainVyna MaryanaPekerjaanPelawak tunggal, Mahasiswa, penyiar radio Tri Vina Maryana atau lebih populer dengan nama Vyna Maryana (lahir 9 Juni 1994) adalah seorang pelawak tunggal berkebangsaan Indonesia. Vyna tergabung dalam komunitas Stand Up Indo Pekalongan, yang merupakan kota kelahirannya.[1] Vyna merupakan salah satu finalis Stand Up Comedy Indonesia Season 6 yang diselenggarakan o…

Financial calculation reducing the UK's EU contributions The UK rebate (or UK correction) was a financial mechanism that reduced the United Kingdom's contribution to the EU budget in effect since 1985. It was a complex calculation which equated to a reduction of approximately 66% of the UK's net contribution – the amount paid by the UK into the EU budget less receipts from the EU budget.[1][2] Based on a net contribution of €11.7 (£9.6) billion in 2016, the UK Treasury …

Professional basketball team Gary SteelheadsLeagueCBA 2000 IBL 2000–2001 CBA 2001–2006 USBL 2007 IBL 2008Founded2000HistoryGary Steelheads2000–2008ArenaGenesis Convention Center2000–2008LocationGary, IndianaTeam colorsNavy blue, light blue, grayHead coachRob SponOwnershipShowtime Sports and Entertainment, LLCChampionships0 The Gary Steelheads were a professional basketball team. They played in the International Basketball League (IBL), Continental Basketball Association (CBA), and the Un…

2006 single by Mobb Deep featuring 50 Cent and Nate DoggHave a PartySingle by Mobb Deep featuring 50 Cent and Nate Doggfrom the album Get Rich or Die Tryin': Music from and Inspired by the Motion Picture & Blood Money ReleasedMarch 2, 2006GenreHip hopLength3:56LabelG-UnitInterscopeSongwriter(s)Curtis JacksonAlbert JohnsonKejuan MuchitaNathaniel Dwayne HaleFarid NassarProducer(s)FredwreckMobb Deep singles chronology Outta Control (Remix)(2005) Have a Party(2006) Put Em in Their Place(2006…

Voce principale: Brescia Calcio. Associazione Calcio BresciaStagione 1948-1949 Sport calcio Squadra Brescia Allenatore Imre Senkey Presidente Primo Cavellini, poi Alberto Cucchi(comm. straordinario), poi Primo Cavellini(comm. straordinario) Serie B5º posto Maggiori presenzeCampionato: Mariani (42) Miglior marcatoreCampionato: Bertoni (15) 1947-1948 1949-1950 Si invita a seguire il modello di voce Questa voce raccoglie le informazioni riguardanti l'Associazione Calcio Brescia nelle comp…

Escape at DannemoraGenreDramaThrillerPembuatBrett JohnsonMichael TolkinSutradaraBen StillerPemeran Benicio del Toro Patricia Arquette Paul Dano Bonnie Hunt Eric Lange David Morse Penata musikEdward ShearmurNegara asalAmerika SerikatBahasa asliInggrisJmlh. episode7 (daftar episode)ProduksiProduser eksekutif Ben Stiller Brett Johnson Michael Tolkin Bryan Zuriff Michael De Luca Nicky Weinstock Bill Carraro Durasi51–98 menitRumah produksiMichael De Luca ProductionsRed Hour ProductionsRilis a…

Division of naked seeded dioecious plants For the insect, see Cicada. CycadalesTemporal range: Early Permian–Holocene PreꞒ Ꞓ O S D C P T J K Pg N Cycas rumphii with old and new male strobili. Scientific classification Kingdom: Plantae Clade: Tracheophytes Clade: Spermatophytes Clade: Gymnospermae Division: CycadophytaBessey 1907: 321.[2] Class: CycadopsidaBrongn.[1] Order: CycadalesPers. ex Bercht. & J. Presl Extant groupings Cycadaceae Zamiaceae Synonyms Cycadofili…

Resilient and smooth elastic tissue present in animals CartilageLight micrograph of undecalcified hyaline cartilage showing chondrocytes and organelles, lacunae and matrix.IdentifiersMeSHD002356TA98A02.0.00.005TA2381Anatomical terminology[edit on Wikidata] Cartilage is a resilient and smooth type of connective tissue. It is a semi-transparent and non-porous type of tissue. It is usually covered by a tough and fibrous membrane called perichondrium. In tetrapods, it covers and protects the end…

Bicycle/walking path in Santa Clarita, California The Santa Clara River Trail is a paved bicycle and walking path in the city of Santa Clarita, California. The path is currently approximately 8 miles (13 km) in length and generally runs in an east–west direction and closely follows the path of the Santa Clara River and Soledad Canyon Road between the communities of Canyon Country and Valencia through Saugus. A north-south fork connects to the community of Newhall. The trail is generally f…

2016 United States House of Representatives elections in Oklahoma ← 2014 November 8, 2016 (2016-11-08) 2018 → All 5 Oklahoma seats to the United States House of Representatives   Majority party Minority party   Party Republican Democratic Last election 5 0 Seats won 5 0 Seat change Popular vote 781,691 305,222 Percentage 68.98% 26.93% Swing 1.05% 0.30% Election results by district Election results by county Republican   …

Indian actress (1905–1991) Durga KhoteKhote in Mughal E Azam (1960)BornVita Lad(1905-01-14)14 January 1905Bombay, Bombay Presidency, British India (present-day Mumbai, Maharashtra, India)Died22 September 1991(1991-09-22) (aged 86)Bombay, Maharashtra, IndiaOccupationsActressfilm producerYears active1931–1983FamilyViju Khote (nephew) Shubha Khote(niece) Bhavna Balsavar (grand-niece)Awards BFJA Award for Best Actress Filmfare Award for Best Supporting Actress Honours Padma Shri (1968)…

Cette liste est une ébauche concernant l’administration territoriale. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Voici une liste des subdivisions administratives des pays du monde. Liste détaillée Pays Niveau Subdivision administrative Capitale Population Allemagne Land Bade-Wurtemberg Stuttgart 11 100 394 hab. (2019) Basse-Saxe Hanovre 7 993 608 hab. (2019) Bavière Munich 13 124 737 hab. (2019) Berlin 3 …

Kembali kehalaman sebelumnya