Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Is it Random enough?

  1. #11
    Join Date
    May 2008
    Location
    UK
    Beans
    1,451
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Is it Random enough?

    Just a thought : 175 runs is far too small a sample - to test the randomness you need to be doing 1000s or 10,000s of runs.
    Tony - Happy to try to help.
    Unless otherwise stated - all code posted by me is untested. Remember to Mark the Thread as Solved.
    Ubuntu user number # 24044 Projects : TimeWarp - on the fly Backups

  2. #12
    Join Date
    Sep 2007
    Location
    Christchurch, New Zealand
    Beans
    1,328
    Distro
    Ubuntu

    Re: Is it Random enough?

    I don't quite follow what you want, but you can calculate what to expect.

    Think of your set of files as an N sided dice... so selecting one at random is like rolling that dice. Thus it should produce what is known as a "binomial distribution". You can calculate the expected frequency with: n! * p^k*(1-p)^(n-k) / (k!*(n-k)!)

    p = probability i.e. 1/N of files in your set.
    k = number of times you can expect the same file
    n = the number of samples i.e. 175 in your case

  3. #13
    Join Date
    Jun 2010
    Location
    asoko
    Beans
    834
    Distro
    Ubuntu

    Re: Is it Random enough?

    something is definitely not right here. as some of you may have guessed from my code snippet, this utility is for queuing up a random episode of of somthing from my video collection. I added a series of 200 files, but have had to skip at least 8 of them in the last 12-16 hours of use. probably about 30 runs. I think I;m going to try salting the number a little and see where that gets me.

  4. #14
    Join Date
    Jan 2008
    Location
    Auckland, New Zealand
    Beans
    3,129
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Is it Random enough?

    Maybe the problem is it's too random. Each item has an equal chance of being picked every time, regardless of whether it's already been selected. Instead you might want to have a a list of all the items and after selecting one randomly, remove that from the list.

    This is an interesting read on the topic: http://blogs.msdn.com/b/shawnhar/arc...andomness.aspx
    Last edited by ad_267; November 13th, 2010 at 09:30 AM.

  5. #15
    Join Date
    Sep 2007
    Location
    Christchurch, New Zealand
    Beans
    1,328
    Distro
    Ubuntu

    Re: Is it Random enough?

    I found a binomial chance calculator on line.

    Assuming a true random distribution it calculated that from your 200 files (i.e single trial success is 0.005) Pick one at random 175 times. Then on average about 42% of your files will not be chosen, about 36% will be chosen once, 16% will be played twice and less 6% more than twice.

  6. #16
    Join Date
    Jun 2010
    Location
    asoko
    Beans
    834
    Distro
    Ubuntu

    Re: Is it Random enough?

    well, I've come to some interesting conclusions.

    I decided to breed my own rng, by multiplying two randoms together and modding them, just for salt. I noticed that my liking for the new algorithm went up, even though all the metrics on the diagnostics went down.

    @works: yeah, that describes the output I'm getting pretty well. neat to see the math in action!

    ultimately, you guys are right; "random" is not really the path to the ends I seek, so I bit the bullet and added features to record and administer a history of viewed files. a file won;t replay unless there is no history item data within the last 6 months, but I'm sure I'll have to tweak that. I already had data persistence code in place, so adding on to it was trivial enough.

    this has been a very interesting conversation. thanks everyone for your thoughts and ideas!

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •