Explore BrainMass
Share

Random-number generation

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

Write an application that uses random-number generation to create sentences. Use four arrays of strings called article, noun, verb and preposition. Create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article and noun. As each word is picked, concatenate it to the previous words in the sentence. The words should be separated by spaces. When the final sentence is output, it should start with a capital letter and end witha period. THe application should generate 20 sentences and output them to a text area.
The article array should contain the articles "the", "a", "one", "some", and "any"; the noun array should contain the nouns "boy", "girl", "dog", "town" and "car"; the verb array should contain the verbs "drove", "jumped", "ran", "walked" and "skipped"; the preposition array should contain the prepositions "to", "from", "over", "under" and "on".

After preceding application is written, modify it to produce a short story consisting of several of these sentences. (How about the possibility of a random term-paper writer?)

© BrainMass Inc. brainmass.com October 24, 2018, 9:30 pm ad1c9bdddf
https://brainmass.com/computer-science/random-number-generation/random-number-generation-128774

Solution Summary

Random-number generation is examined.

$2.19
See Also This Related BrainMass Solution

C++ Code for Testing Random Number Generator

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.

View Full Posting Details