codemorphis.com Forum Index codemorphis.com
Software development: pure and simple.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Random Number Generator component question

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    codemorphis.com Forum Index -> Visual Programming Forum
View previous topic :: View next topic  
Author Message
DavidCbs



Joined: 02 Apr 2004
Posts: 17
Location: Suffolk, England

PostPosted: Wed Aug 04, 2004 1:42 pm    Post subject: Random Number Generator component question Reply with quote

Firstly, congratulations on the release of 1.1 . The enhancements and additions make Synopsis even easier to work with and offer yet more programming opportunities. I particularly like the icon graphics and the new implementation of the Service Call component.

My question regards the Set Seed service of the RNG component. Could you help me please by expanding on the use of this service. What does it achieve and in what situations is its use desirable or necessary?

As an example I am using two RNGs in a loop to produce a series of x and y coordinates that are then used to place graphics randomly within a defined area. I haven't used the Set Seed but the result seems to be alright.

Thanks in advance.
_________________
DavidCbs
Back to top
View user's profile Send private message AIM Address
CodeMorphis



Joined: 02 Dec 2003
Posts: 252

PostPosted: Thu Aug 05, 2004 8:15 pm    Post subject: Reply with quote

Thank you for your comments about Synopsis 1.1. The improvements made in Synopsis 1.1 are in great part due to the feedback that we received from users of Synopsis 1.0. We hope to continue to make improvements to the Synopsis product to deliver a continuously stronger visual programming and rapid prototyping tool. Please always feel free to post comments and suggestions as we use them to decide future feature sets and development projects.

For your question regarding the Random Number Generator component (from the Math tab of the Synopsis component tray), perhaps a little background information will help you out.

Any random number generator on a computer makes use of a mathematical algorithm to produce a sequence of numbers. In all cases, regardless of the machine or software involved, the name "random number generator" is in fact a slight misnomer. This is because a machine cannot give you true randomness - it needs some kind of formula to generate the sequence of numbers. If you knew what the formula was, you could compute and thus predict the numbers that would be generated. To help to "jumble" the numbers generated, we can make use of a seed number. This seed number defines a starting point for the number sequence generated.

To see how the seed number affects the sequence generated, consider the simple program below.



You can download this Synopsis 1.1 program here:
http://www.codemorphis.com/articles/Random_num_gen/Random_number_program.vpd

In our program we first call the "Set seed" service of the Random Number Generator component and then call the "Rand" service twice. The seed set in our program is 100. Note the output of the program in the console output area. We ran the program twice. For each run, the output is identical: the sequence of numbers generated is 65 followed by 16. This happens because we initialize the random number generator with the same seed number. If we were to use a different seed number for each run of the program, we could expect a different sequence of numbers.

In your program, you are not using the "Set seed" service. In fact, the random generator component is initialized with a default seed number. So yes your program will work but the numbers generated on each program run depend on the current state of the random generator component.

Often, programs will use some user interface method to allow the user to quietly (and unknowingly) specify a random number seed. For example, you could use the number of seconds that a system has been active or use the user's last mouse click coordinate. Thus, the seed number helps to prevent the case where on each run of your program, the sequence of random numbers is the same.

Hope that this explains things a little better. Please do not hesitate to ask more questions.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DavidCbs



Joined: 02 Apr 2004
Posts: 17
Location: Suffolk, England

PostPosted: Mon Aug 09, 2004 9:43 am    Post subject: RNG and seed Reply with quote

Thanks for your help, I have a much better understanding now. I was not able to access your RNG demo programme via the link. Just got a page with one "t" on it. However I have used both seeded and seedless RNGs successfully in a small programme.
_________________
DavidCbs
Back to top
View user's profile Send private message AIM Address
CodeMorphis



Joined: 02 Dec 2003
Posts: 252

PostPosted: Mon Aug 09, 2004 12:49 pm    Post subject: Reply with quote

The link to the VPD file seems to be working - it has been tested again just now. Perhaps there happened to be a server error when you tried it.

For your convenience, here is the same link again:

http://www.codemorphis.com/articles/Random_num_gen/Random_number_program.vpd

Thanks!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    codemorphis.com Forum Index -> Visual Programming Forum All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group