Explore BrainMass
Share

C++ Code for Testing Random Number Generator

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

I am using "Numerical Recipes (3rd Edition)" to create a numerical method that computes random numbers. My problem is that I'd like to use tests such as Chi-Square to test the uniformity/performance of the generator, but I don't know how to do this.

You can see my basic number generator in the readable file randomnumbers. I've included portions from "Numerical Recipes" (which you can easily find on Scribd) on random numbers and statistical functions. Based on the structure of the codes, I need help writing a program that uses Chi-Square (or something else appropriate from statistical functions.pdf) to test my random number generator.

I am extremely new to c++, so if my bid is too low please let me know. I'm not sure how long the necessary code will be or how much expertise it will require, so I don't know how much you will charge.

In case you can't read my cpp code, it's very basic:

#include <iostream>
#include "/Users/.../Documents/NR/code/nr3.h"
#include "/Users/.../Documents/NR/code/ran.h"

int main(){
Int seed = 12345678;
Ran myran(seed);
for(int i=0;i<10;i++){
cout<<"Using ran = " << myran.doub() <<endl;
}
return 0;
}

and returns 10 random numbers. This is just an example, it probably isn't my final code, just something simple for you to see what I'm going for. Please note that I am very weak with c++ and really don't know much about what I'm doing.

https://brainmass.com/math/number-theory/code-testing-random-number-generator-456054

Solution Preview

Hi,

I wrote the program using the following link as a reference: ...

Solution Summary

C++ Code for testing random number generators are examined.

\$2.19
Similar Posting

C# and Java Applications: Random Number Generation Examples

1. Write a C# application that generates a 3-digit random number 100 times. Display the output for each of the generated numbers and the sum of all 100 numbers. Every 10th number you should display a String consisting of any phrase of your choice concatenated with the current random number.
A possible partial output for your program is shown below:
101
899
234
823
239
099
460
382
534
This 10th number is: 834

Demonstrate your code compiles and runs without issue. (You can use screen captures to demonstrate this functionality in a word document).

2. Submit your java file together with a text file containing your test data. Test data in this case is simply a list of inputs and corresponding outputs of your test program.
(Eliminating duplicates) Write a method to eliminate the duplicate values in the array using following method header:
Public static int [ ] eliminateDuplicates (int [ ] numbers)
Write a test program that reads in ten integers, invoke the method, and displays the result.
Here is the sample run of the program:
Enter ten numbers: 1 2 3 2 1 6 3 4 5 2 Enter
The distinct numbers are: 1 2 3 6 5 4

View Full Posting Details