Liberty BASIC Community Forum
« LBPE RND( n ) and RANDOMIZE page »

Welcome Guest. Please Login or Register.
Nov 22nd, 2017, 01:33am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: LBPE RND( n ) and RANDOMIZE page  (Read 1243 times)
tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1687
xx LBPE RND( n ) and RANDOMIZE page
« Thread started on: Oct 28th, 2011, 2:08pm »

RND( n ) and RANDOMIZE

(since I cannot write to discussion as of now)

Alyce, you wrote:
Quote:
When run many times, any pseudorandom number generator will display a bias. The bias displayed by Liberty BASIC's RND() is slight, but in rare instances it might be significant.

I really cannot undertand part about "any pseudorandom number generator will display a bias" - is it along the lines of "all humans are mortal"?
but bias displayed by Liberty BASIC's RND() is much more pronounced then any other language I cared about to check random number. It is big enough to often be visible in numerical simulations. For example if we simulate throwing a coin - if we count RND() >0.5, bias will be around 0.5 %.

As for Mersenne twisted DLL,
Chris posted two versions.
MersTwistLB-GCC.zip (9.5KB)
MersTwistLB.zip (2.0MB)
Latest file is so big because it includes about 7 Mb *.ncb file - it is auto-generated VS file that should be deleted from archive.
(Visual Studio ncb file)

I mailed to Chris suggestion to repost files to somewhere nearer, like LB CommunityWiki::ADD-ON DLL PAGE
but he apparently does not read forum mail. Since you posted a page on RND and link this DLL, I suggest it again. Plase, reupload DLL to the wiki so link will not get lost (like got lost links fo Liberty Belle).
User IP Logged

damned Dog in the Manger
Admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 14485
xx Re: LBPE RND( n ) and RANDOMIZE page
« Reply #1 on: Oct 28th, 2011, 2:55pm »

on Oct 28th, 2011, 2:08pm, tsh73 wrote:
I really cannot undertand part about "any pseudorandom number generator will display a bias" - is it along the lines of "all humans are mortal"?


Yes, it is obvious and redundant. I have found that it is necessary to spell things out to avoid misunderstandings. What is obvious to you and me might not be obvious to somebody else.

Quote:
but bias displayed by Liberty BASIC's RND() is much more pronounced then any other language I cared about to check random number.


The place for that discussion is here on the forum and it has been discussed quite a lot. The article points folks to a solution they can use if the bias is unacceptable to them.

Quote:
I mailed to Chris suggestion to repost files to somewhere nearer, like LB CommunityWiki::ADD-ON DLL PAGE
but he apparently does not read forum mail. Since you posted a page on RND and link this DLL, I suggest it again. Plase, reupload DLL to the wiki so link will not get lost (like got lost links fo Liberty Belle).


I have already asked Chris for permission to include it on LBPE. He has not yet been available to answer. I'm sure he will respond when he visits. He is quite a busy fellow and we must understand that our members and staff have lives outside of the forum. wink

If you are unhappy with the article at LBPE, why not write your own article for the community forum? Add code and links as needed. We'd really like to see the community forum become more active. smiley

User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1687
xx Re: LBPE RND( n ) and RANDOMIZE page
« Reply #2 on: Oct 30th, 2011, 2:46pm »

Quote:
If you are unhappy with the article at LBPE, why not write your own article for the community forum?

I am not happy with LB RND/RANDOMIZE.

So it looks like this:
I'll write article.
It will turn to (angry) bug report. (I can restrain "angry" part if needed).
I'll post it to Liberty BASIC Bug Tracker (because it IS a bug report).
THEN you very likely will say that it is not a bug at all?
(After all, you did not mention ANY of RND/RANDOMIZE problems in your article!)

Just go ahead and say - LB RND/RANDOMIZE problems - bugs or not?

Because if you think it's not a bug,
then, very likely, article will get deleted. In that case I'd rather save my frustration and will not write it at all.

EDIT
list of LB RND/RANDOMIZE problems
1. distribution is not uniform
2. (consequence of (2)), bias exceeds bias of other compared languages (QB, C, C#). As an example, if we count RND() >0.5, bias will be around 0.5 %
3. It is promised that without exactly calling RANDOMIZE, sequence will be different each time program is run. However there are cases that starts RND somewher near in the sequence
4. small changes in seed used with RANDOMIZE very likely lead to small changes in next RND value.
5. (consequence of (4)), prescripted seed range (0..1) is not convenient for using with RANDOMIZE
6. If RANDOMIZE is called with wrong seed (like -1), it will "break" subsequent calls for RND. Error will appear in call to RND, and will continue until RANDOMIZE called with right argument or IDE is restarted.
« Last Edit: Oct 30th, 2011, 3:09pm by tsh73 » User IP Logged

damned Dog in the Manger
Admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 14485
xx Re: LBPE RND( n ) and RANDOMIZE page
« Reply #3 on: Oct 30th, 2011, 3:48pm »

Anatoly, I'm sorry you are not happy with my tutorial. It appears that we view the article on LBPE differently. I wrote it as a "how to" use RND() and randomize. You seem to want it to be an article that points out the perceived weaknesses.

It is a SIMPLE explanation and "how to" for RND() and randomize. It DOES point out the issue of bias. It DOES point users to a solution. It is not meant to be an in depth discussion of algorithms and complex ideas.

Most people, including John, Rod and Stefan, tell me that the RNG for Liberty BASIC is acceptable to 99% of users. I see no point in nit-picking in a simple tutorial.

I am not a member of the bug tracker wiki, so I cannot speak to how your report will be accepted there.

As for the community wiki, nobody will delete your article. It would only be removed or edited if it contained false information or bad language.
« Last Edit: Oct 30th, 2011, 4:18pm by Admin » User IP Logged

tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1169
xx Re: LBPE RND( n ) and RANDOMIZE page
« Reply #4 on: Oct 30th, 2011, 3:57pm »

I sympathise with your feelings, tsh.
But I agree that the place to report the problems is as a bug report. You have accurately summarized the problems in the present version of LB.

Alyce is concerned that people reading explanations of how a function works should not be distracted by suggestions it is faulty. I agree...

BECAUSE
...it is only those using LB in unusual ways that will see any significant effects. I use rnd() a great deal, and it's problems never 'bit' me. But I certainly would not write a commercial lottery program using LB. I'd be open to all sorts of legal challenges!

HOPEFULLY
LB5 may use a better generator and seeding procedure. And meanwhile the Mersenne code is fine.

AND
for 60 years people have produced PRNGs with varying degrees of problems- and only much later realised their shortcomings. The German Enigma & other coding machines of World War II were basically PRNG's. A lot of cryptography is based on them. But for things like monte Carlo analysis of neutron paths in a reactor they worked fine at the time.

*********************

There are I suppose other 'bugs' /things we 'ought' to alert new users to, like the order used in sorting; the direction positive & negative numbers are 'INT'd; etc. That x =x +1 is shorthand for assigning a new value to x, not a mathematical nonsense equality. Or that 10 *1 /10 may not EXACTLY =1 when binary & floating point is involved. Learning about these is part of the whole experience of growing as a programmer.
These things crop up regularly when less-experienced coders meet problems with them.
Perhaps a link could be added called 'possible problems?' from the LBPE page explaining those keywords and their uses, to a page that you, I and other interested parties create, where the problems could be explained with example programs. I've demo programs showing the kind of deviant behaviour that simple PRNGs usually demonstrate, biut that may still lurk in the more complex ones. I'm sure you and others have similar material.

In the UK we put healtgh warnings on alcohol & cigarettes. Perhaps all pages about 'random numbers' should have a Government Health Warning!
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1687
xx Re: LBPE RND( n ) and RANDOMIZE page
« Reply #5 on: Oct 31st, 2011, 12:57am »

I agree that
SIMPLE explanation and "how to" for RND() and randomize
at LBPE
is surely wrong place to put detailed bug report.

It just seem that I belong to that 1% of users sad
User IP Logged

damned Dog in the Manger
Admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 14485
xx Re: LBPE RND( n ) and RANDOMIZE page
« Reply #6 on: Oct 31st, 2011, 07:33am »

on Oct 31st, 2011, 12:57am, tsh73 wrote:
I agree that
SIMPLE explanation and "how to" for RND() and randomize
at LBPE
is surely wrong place to put detailed bug report.

It just seem that I belong to that 1% of users sad


Thank you for understanding.

There IS a place to put a detailed bug report on a wiki and it is here:

http://libertybasicbugs.wikispaces.com/Improved+RND%28%29+function

I see that you've added to the discussion area for that page. Why not place your "discussion" text on the actual page? Very few people read the discussions for these pages and they often go unnoticed. (That's why I've set up LBPE to funnel discussions to this forum, instead.)

Articles on LBPE cover a variety of subjects. LBPE is not meant to be a substitute for the helpfile, nor is it meant to cover all possible information for a subject. For instance, I wrote a simple graphics printing article. Rod thought there was much more to say, so he wrote a far more detailed article on printing graphics. No single article on LBPE claims to be all-encompassing for any topic. wink
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls