gsl seeding random number generator

This is a discussion on gsl seeding random number generator within the C Programming forums, part of the General Programming Boards category; The first argument is a pointer to your random number generator state, and the second argument is the seed....

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    The first argument is a pointer to your random number generator state, and the second argument is the seed.

  2. #17
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    Right, but I guess I don't know how to make the result actually depend on s...

  3. #18
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by sqytoad View Post
    Right, but I guess I don't know how to make the result actually depend on s...
    That's not your job, that's the job of the people who made the random number generator. All your job is, is to feed s into the function.

    In other words: I have no idea what you think you're asking here.

  4. #19
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    I'm sorry, I have been really confusing.
    I've been messing with one of their sample programs, and it basically goes through like this.
    T = gsl_rng_taus2;
    r = gsl_rng_alloc (T);
    printf ("%e\n", gsl_rng_uniform (r));

    But changing s isn't as simple as just having
    s=123;
    gsl_rng_set (r,s)

    because that doesn't do anything. The sample from the generator just depends on r, the seed should affect r since it affects the generator T...
    And I don't really know...sorry I'm being so vague, but I just don't know how to get it to work.

  5. #20
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I don't have GSL installed, unfortunately, so I can't try it out, but doesn't this:
    Code:
    T = gsl_rng_taus2;
    r = gsl_rng_alloc(T);
    gsl_rng_set(r, 123L);
    for (int i=0; i < 5; i++) {
        printf("&#37;e\n", gsl_rng_uniform(r));
    }
    printf("\n");
    gsl_rng_set(r, 123L);
    for (int i=0; i < 5; i++) {
        printf("%e\n", gsl_rng_uniform(r));
    }
    print out the same five numbers, twice in a row? (If you'll pardon the C99 for loops.)

  6. #21
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    Yeah, it did. (Assuming you meant the same sequence of 5 different numbers, twice.)

    Why do you have the L after 123?
    Because that makes sense to me...I wasn't really doing much different.

  7. #22
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    "L" means long.

  8. #23
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    Oh, all right.
    Well, everything works now. Seriously, thanks a lot for your patience.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Random number generator
    By rehan in forum C++ Programming
    Replies: 1
    Last Post: 02-25-2008, 01:14 AM
  2. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  3. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 09:56 AM
  4. Testing Random Number Generator
    By Roaring_Tiger in forum C Programming
    Replies: 7
    Last Post: 08-12-2005, 12:48 AM
  5. how to link random number generator with cpu?
    By chris285 in forum C++ Programming
    Replies: 5
    Last Post: 04-28-2003, 05:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21