Results 1 to 3 of 3

Math Help - Computer Science

  1. #1
    Senior Member
    Joined
    Apr 2009
    From
    Atlanta, GA
    Posts
    409

    Computer Science

    Hi everybody. I am looking for the simplest way to generate "random" numbers given nonrandom input, except I need the output to always be the same, given the same input.

    This is a simplification of what I am really doing as part of a website. I want to feature a certain random article as the "Article of the Day." Each day it must change at random. But during the day, one user logging on two different times must see the same one. And two users logging in on the same day must see the same one. I know I can hardcode a list, but I want the algorithm to update itself automatically, and throw new articles in the selection pool as they are added by users (only at the end of each day, though).

    I know the function f(x)=kx(1-x) behaves chaotically when k is between 3 and 4. So an example algorithm might be letting k=3.98 and taking the (N+100)th iteration of the number .5, where N represents the day of the year (1-366). The answer, A, would then be a number between 0 and 1, so A times the number of articles saved in the system would return a whole number that tags a random article.

    There are some technical problems with this particular function, and I fear it is overkill. Are there any standard ways of doing what I am describing?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Media_Man View Post
    Hi everybody. I am looking for the simplest way to generate "random" numbers given nonrandom input, except I need the output to always be the same, given the same input.

    This is a simplification of what I am really doing as part of a website. I want to feature a certain random article as the "Article of the Day." Each day it must change at random. But during the day, one user logging on two different times must see the same one. And two users logging in on the same day must see the same one. I know I can hardcode a list, but I want the algorithm to update itself automatically, and throw new articles in the selection pool as they are added by users (only at the end of each day, though).

    I know the function f(x)=kx(1-x) behaves chaotically when k is between 3 and 4. So an example algorithm might be letting k=3.98 and taking the (N+100)th iteration of the number .5, where N represents the day of the year (1-366). The answer, A, would then be a number between 0 and 1, so A times the number of articles saved in the system would return a whole number that tags a random article.

    There are some technical problems with this particular function, and I fear it is overkill. Are there any standard ways of doing what I am describing?

    Does the language not support a pseudo random number generator, if so use that. Failing that look at volume 2 of Don Knuth's TAOCP "Semi-Numerical Algorithms"

    CB

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member alunw's Avatar
    Joined
    May 2009
    Posts
    188
    You might like to visit this web site: Random Number Generators - the pLab project - Home and especially this page
    A collection of classical pseudorandom number generators with linear structures - advanced version
    The first Hoaglin LCG is very easy to implement and works very well for me (in some code I wrote that draws fractals using random iteration this random number generator produced far better results than the one in the C library). But for your problem I'd probably calculate a day number from the date and multiply it by some moderately sized prime number and mod it by the number of articles.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Oracles in computer science
    Posted in the Discrete Math Forum
    Replies: 2
    Last Post: November 7th 2011, 05:05 PM
  2. computer science problem
    Posted in the Algebra Forum
    Replies: 2
    Last Post: March 19th 2010, 06:16 PM
  3. Help with Computer Science Java
    Posted in the Advanced Math Topics Forum
    Replies: 1
    Last Post: October 1st 2009, 06:24 PM
  4. Computer science: Functions help
    Posted in the Pre-Calculus Forum
    Replies: 3
    Last Post: January 27th 2009, 01:59 AM
  5. Calculus on science computer
    Posted in the Calculus Forum
    Replies: 2
    Last Post: July 18th 2007, 08:10 PM

Search Tags


/mathhelpforum @mathhelpforum