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; Hi, I'm trying to use gsl to provide random numbers for my program. I can get the basic defaults to ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    32

    gsl seeding random number generator

    Hi, I'm trying to use gsl to provide random numbers for my program. I can get the basic defaults to work, but I was trying to get this part:
    "By setting the two variables on the command line we can change the default generator and the seed,
    $ GSL_RNG_TYPE="taus" GSL_RNG_SEED=123 ./a.out"

    I'm using a compiler where you just have to hit a key to get it to compile/run, but there's a box where you can add command line options, so I did, but nothing changed. I have a feeling I'm just doing something stupid because I'm not used to talking about these things, but does anyone have any suggestions?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Are those command-line options for the compiler, or for when you actually run the program?

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    I guess I can't tell for sure. I've gotten pretty confused because I've been trying to figure everything out at once. I think I was assuming for running the program...
    This is where I was looking for one of the programs I was trying to duplicate:
    http://www.gnu.org/software/gsl/manu...variables.html

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    31
    Hi,

    They are environmental variables for your shell, have a look at the example source code.

    Cheers,

    Dan.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by sqytoad View Post
    I guess I can't tell for sure. I've gotten pretty confused because I've been trying to figure everything out at once. I think I was assuming for running the program...
    This is where I was looking for one of the programs I was trying to duplicate:
    http://www.gnu.org/software/gsl/manu...variables.html
    Yes. we know they're command-line options for running the program -- I mean the box you're trying to type them into! Is that for running the compiler, or the program? (If the former, then you're in the wrong box.)

  6. #6
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    Yeah, that's where I've been looking, but I wasn't sure exactly how to change them...

  7. #7
    Registered User
    Join Date
    Jul 2005
    Posts
    31
    Here is a list of some other RNG

    e.g if you want gfsr4 RNG then,

    GSL_RNG_TYPE="gfsr4"

    then if you want use a different seed,

    GSL_RNG_SEED=983759

    then just run your code as normal from the command line.

    Full description of the RNG (e.g. use the string after the last underscore as the abbreviation in you GSL_RNG_TYPE variable).

  8. #8
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    Oh, sorry, tabstop, my bad. lol I'm not 100% sure it's not a box for the compiler, but I'm definitely not using the one in compiler options. I'll look and see again if there's another box somewhere, but in any case, do you think I just need the "GSL_RNG_SEED=123" part, or would I need the full line starting with the $? I don't know if it's implied since it's in the box.

    EDIT: Oh, and boyfarrell, I've been looking at those pages, but my question is really just about the command line stuff in general, since I haven't had to do anything with it before - I just hit a key. So I've been trying to figure that stuff out. It doesn't seem complicated, but I haven't gotten it to work, yet...
    Last edited by sqytoad; 06-23-2008 at 05:46 PM.

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by sqytoad View Post
    Oh, sorry, tabstop, my bad. lol I'm not 100% sure it's not a box for the compiler, but I'm definitely not using the one in compiler options. I'll look and see again if there's another box somewhere, but in any case, do you think I just need the "GSL_RNG_SEED=123" part, or would I need the full line starting with the $? I don't know if it's implied since it's in the box.
    The $ is the command prompt. You know, the thing the computer puts on the screen to tell you that it's your turn to do something. The two variable names and the values are what you're looking for. What IDE are you using?

    (Note: It may be easier to do this in a command prompt window.)

  10. #10
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    Oh, that actually explains some of my confusion from reading about this stuff... :S
    I'm using dev-C++.

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    In Dev-C++, the only box that might have worked was Execute->Parameters, but that goes after the program name, not before.

    You can change environment variables from the Control Panel, or at a command prompt window.

  12. #12
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    All right, thanks.
    Do I need to figure out how to run/compile completely from the command-prompt window, or is there a way to change them and still run it like I'm used to?

    (And how do you do it form the control panel?)

  13. #13
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Control Panel -> System -> Advanced tab -> Environment variables button (If you do this, you can just hit the button, you don't need to type.)

    Once you've compiled it with Ctrl-F9, you have to remember where the executable went, go to that directory, and type the magic words.

  14. #14
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    Thank you SO much.

  15. #15
    Registered User
    Join Date
    Jun 2008
    Posts
    32
    Hey, so actually it seems you can use this function, as well, to change the seed:
    void gsl_rng_set (const gsl_rng * r, unsigned long int s).
    From this page
    http://www.gnu.org/software/gsl/manu...alization.html
    I was trying some things, but now I'm at loss as to how to actually do it. How do I actually set the seed as something else? :S

Page 1 of 2 12 LastLast
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