Re: [PHP] shuffle or mt_rand



Ryan A wrote:
Hey,

Have a quick question about which is better to get real random values, shuffle or mt_rand.

I am trying to shuffle a deck of cards and reading another thread I saw that after a
> couple of thousand random generations patterns have been observed
> using rand()... so its better to use mt_rand().

Well they do different things - shuffle() randomises an array, whereas mt_rand() gives you a random number. If you want to randomise an array, use shuffle(). If you want a random number, use mt_rand().

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
.



Relevant Pages

  • Re: "how to split a string in a random way"
    ... I created an integer array and I pass it along with a ... number to Factorize(). ... This time I send array1 through the Shuffle() method just prior to sending ... Dim array3 As Integer= Utility.GenArray ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Card dealing and random repetition
    ... and inspiring for an 'elegant' way to simulate a shuffle. ... The dealer divide the deck in two parts, trying to make them equally big (but I estimate the error margin being between 1 to 5 cards from the count of 26 cards per half-deck). ... adding a random probability of the next card on the array being picked instead of the next of the other array. ...
    (comp.programming)
  • Checkout magicstream cipher
    ... var i = 0; ... countval= new Array(); ... the stream from the shuffle ... // Deck one is used in shuffle the other deck is static overlay. ...
    (sci.crypt)
  • Re: round-robin an arraylist
    ... Of all of them the work on the Array is the fastest. ... RemoveAt(), Addparadigm to do the shuffle is only slightly slower than the ... public class RoundRobin { ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Card dealing and random repetition
    ... inspiring for an 'elegant' way to simulate a shuffle. ... The dealer divide the deck in two parts, array ... left-half-deck (here there is a slight probability of 2 card staying ...
    (comp.programming)