Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: real random() function in DOORS 7.1
Topic Summary: Is the real random() function buggy in 7.1 ?
Created On: 11-Jul-2006 09:37
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 11-Jul-2006 09:37
User is offline View Users Profile Print this message


Martin Erdelen

Posts: 2
Joined: 2-May-2006

Greetings, the appended trivial DXL script (in DOORS 7.1) generates indeed 1000 real numbers for me, but with an average of 0.000007765, and a maximum of 0.000015. Now, technically this is 0 <= x < 1 as advertised in the doc.s, but it can't be right... Am I missing something here, or is it a known issue? (BTW, int random(N) works fine, generating numbers between 0 and N.) Thanks for any pointers. Cheers, Martin

Edited: 11-Jul-2006 at 09:42 by Martin Erdelen
Report this to a Moderator Report this to a Moderator
 11-Jul-2006 15:11
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Never dealt with Real numbers before. I get only 6 digits after the decimal point with the attached modification of your script, last line is this:
Min-Max-Average = 0.000000 0.000015 0.000008

How did you get more precision?

- Louie
Report this to a Moderator Report this to a Moderator
 12-Jul-2006 06:42
User is offline View Users Profile Print this message


Martin Erdelen

Posts: 2
Joined: 2-May-2006

Thanks for your reply.

The random numbers themselves did have 6 digits after the decimal point, same as for you. But I then transferred them to Excel and calculated the average there (to keep the DXL script as simple as possible); that's why the average has more decimal digits.

But I think for a (uniform) random distribution of real numbers 0 <= x < 1, the average should actually be 0.5, and the maximum 0.999999 (give or take a bit according to sample size and chance).

Or?

Martin

Edited: 12-Jul-2006 at 06:48 by Martin Erdelen
Report this to a Moderator Report this to a Moderator
 12-Jul-2006 08:10
User is offline View Users Profile Print this message


Michael Werner

Posts: 15
Joined: 29-May-2006

just use something like
r *= 10000.0
to get a higher precision

with

r *= 10000000.0
while(r > 10.0) r -= 10.0 //makes it all a bit faster
while(r > 1.0) r -= 1.0

you get a "good" randomfunction for real-numbers between 0 and 1, though the last 7 digits are not
really random.

Min-Max-Average = 0.001385 0.999468 0.495007


Edited: 12-Jul-2006 at 08:11 by Michael Werner
Report this to a Moderator Report this to a Moderator
 12-Jul-2006 08:28
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

I agree, it looks broken to me. It doesn't do what it says on the tin!

But the attached works for me...

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive
Report this to a Moderator Report this to a Moderator
 13-Jul-2006 15:33
User is offline View Users Profile Print this message


Michael Sutherland

Posts: 248
Joined: 13-Sep-2002

Martin,

For integer random numbers, the maximum that will be generated will be 32768, no matter what parameter you run the random() function with. I confirmed this with Telelogic support. I'm not sure if this relates in any to the behavior you are seeing.

-------------------------
Michael Sutherland
michael@galactic-solutions.com
http://galactic-solutions.com
Report this to a Moderator Report this to a Moderator
 3-Aug-2006 18:14
User is offline View Users Profile Print this message


Eric Piallat

Posts: 33
Joined: 26-Jan-2004

I personnaly use this "quick and dirty" generator, taken from ISO/IEC 9899 (C language).

It generates integers between 0 and 65535, and at least I know how it works.




-------------------------
E. Piallat
CeBeNetwork

Edited: 3-Aug-2006 at 18:16 by Eric Piallat
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.