News:

Please note new Forum URL: forum.designcad.com

Main Menu

Random Number Generator App

Started by DrollTroll, March 27, 2018, 03:22:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DrollTroll

DesignCAD doesn't currently have a function to generate random numbers. Attached is a zip file containing a simple console program that will generate as many pseudorandom numbers as you like (on the range of 0 to 1.0) , and store them in a text file.

Syntax: dc_random.exe count outfile
where count indicates how many numbers to generate, and outfile is the name of the text file in which the numbers are stored.

For example: dc_random 100 c:\DesignCAD\100randomnums.txt  will generate a file named 100randomnums.txt in the folder C:\DesignCAD; the file will contain 100 random floating-point numbers between 0 and 1.

If the count value is omitted, the default value is 100. If the outfile argument is omitted, the file name is dc_random.txt, and is stored in the same folder as the dc_random program. If the path portion of the filename is omitted, the output file will (probably) go into the same folder as the dc_random program, but this may vary depending on how the program is run.

The zip file also contains a sample macro randomnums.d3m that runs the program, generates 100 random numbers, and plots them as y values (with x being the index of the input number). Note that there is no way to guarantee that the program will finish before the macro tries to open the file, so this may not work with a very large sequence of numbers; in such cases, it is best to generate the text file separately.

Enjoy!

DT
25 years with DesignCAD

Dempsey

And the Master has spoken again  ;D

Thanks
Dempsey

Pearlitic

Can you please re-send the Random Number Generator App?  dc_random.exe count outfile


Thank you.

Gary

Rob S

Just download the zip file above, and extract it.
User since forever

Gymbo

Hi,
I've written a macro that produces 20,000 pseudo random numbers between 0 and 1. It also turns those numbers into integers between 0 and 10, adds them to each other and displays the average of those number at the end of the file of the random numbers.

I've attached the macro and a text file with a list of random numbers and the average (4.9895).
Regards,

Jim