Free Essay

Random Numbers

In:

Submitted By Frances606
Words 9330
Pages 38
Random numbers in C++ and The Pythagorean Theorem

Name
Course
Date

Random numbers in C++ and The Pythagorean Theorem
Introduction
Computer programs in light of the technological advances that have been made, arguably make up for the most important concepts in such developments. A set of instructions designed to assist a computer to prefer a given task is referred to as a computer program. There are numerous languages used to create/design computer for instance Java Script, Java, C++, SQL and Sage (Laine, 2013). Computer programming is defined as a process of developing a working set of computer instructions meant to aid the computer in the performance of a given task. Computer programming starts with the formulation of a valid computer problem. This process is then followed by the development of an executable computer program, for instance Firefox Web Brower (Laine 2013). It is worth noting that there are other programs in the same realm. Computer programming is a diverse field that is of utmost importance in the modern world, especially with the continuous expansion of the internet. Perhaps the relevance of this can be underlined by the fact that computer programming has carved out as a course on itself. Computer programming is offered under several courses studied in colleges and universities (Laine, 2013). Computer programming is not only for computer students but for all who use computers on a day to day basis. This is by extension everyone since the use of computers is almost becoming a basic requirement. Computer programming requires a trained individual for the interpretation of data into information. Through the utilization of computer programming experts are able to create programs to real life problems like insurance policing and risk assessment. After which experts are able to address bugs in the designed programs for perfect of computer system operation (Laine, 2013).
Before an individual can learn how to develop a computer program, he/she must first learn how a computer works. After which the individual’s role assumes that of imputing instructions for the computer to execute (Laine, 2013). It is worth noting that the imputing of instructions is what determines the effectiveness of the computer program. This forms the backbone of the entire program. Basically computer programming is what is referred to as software writing, and it involves the use of process and procedures to achieve the set objective. Software writing for a program that outputs random numbers begins by writing a set of instructions in a source code representation. The source code representation must adhere to computer programming requirements (Laine, 2013). The instructions institute and manipulate different objects such as numbers, signs, graphics and words. Thus creating a computer program is an involving and delicate process much like building a home or composing music. Computer programming is therefore viewed by many as an art rather than an engineering activity. Computer intelligence is only dependent on the computer user (Laine, 2013). As such, computers are viewed as obedient devices that output the results of input data. A computer does exactly as instructed by the user, sometimes the results are not as expected in such a case fault rests with the computer user. Computer programming equips individuals with the know-how to express commands successfully for the desired results (Laine, 2013).
How Computer Programs Function
Every computer program functions by executing or implementing a stream of bytes that are coded in computer-machine language. These streams of bytes act like instructions to guide the computer program on what to do (Laine, 2013). It is extremely difficult for humans to code information directly using machine language, even for most system hackers. This is because the in-built coded system is the determinant of the instructions fed into it. As such simpler ways of coding instructions into the computer program involve the use of high level languages. High level languages have basically replaced the low-level assembler languages which are viewed as being thin and dependent of machine codes (Laine, 2013).
Interestingly, while the computer programmers are disposed to various means and methods of feeding the high level languages, the interpretation is basically the same. This explains the similarity and uniformity in solutions that are produced across the globe over different programs that have been developed independently for the same purpose.
There different types of high-level languages that are used by computer programmers. The source code of a given program is regarded as a transitional phase for instructions before they are availed to the computer in machine code form (Laine, 2013). Meet me fhill606 at goggle male dot com, I will do your paper and deliver directly to you for free.
The source code is referred to as the human generated and editable portion of the computer program that is created using a high level language like Logo.

Application-Specific Language (4GL)
Examples: Mathematica, SQL | High-Level Language
Examples: Logo, Smalltalk | Low-Level Language
Example: C | Assembler Language
Example: Intel X86 | |

Computers as such use binary numbers to represent information making source code different from machine code. Machine code utilizes decimal, binary, octal and hexadecimal numbers to store and process information (Laine, 2013). The role of a programmer is to create a source code that can be channeled into a machine code that the machine will recognize and obey. In the event that such information has been entered erringly, then there will be an error response. This is because it has by-passed the random entrance at this stage. This machine code bears symbolic meaning which the machine understands and follows (Laine, 2013). Below is a representation of how numbers and special characters are presented in binary, octal, decimal and hexadecimal form within the computer’s framework.
The numeric against the symbolic format Decimal
Number | in
Binary | in
Octal | in
Hexadecimal | 1 | 1 | 1 | 1 | 2 | 10 | 2 | 2 | 3 | 11 | 3 | 3 | 4 | 100 | 4 | 4 | 5 | 101 | 5 | 5 | 6 | 110 | 6 | 6 | 7 | 111 | 7 | 7 | 8 | 1000 | 10 | 8 | 9 | 1001 | 11 | 9 | 10 | 1010 | 12 | A | 11 | 1011 | 13 | B | 12 | 1100 | 14 | C | 13 | 1101 | 15 | D | 14 | 1110 | 16 | E | 15 | 1111 | 17 | F | 16 | 10000 | 20 | 10 |

|

ASCII
Character | in
Binary | in
Octal | in
Decimal | in
Hexadecimal | space | 00100000 | 040 | 32 | 20 | ! | 00100001 | 041 | 33 | 21 | ( | 00101000 | 050 | 40 | 28 | ) | 00101001 | 051 | 41 | 29 | 0 | 00110000 | 060 | 48 | 30 | 1 | 00110001 | 061 | 49 | 31 | 2 | 00110010 | 062 | 50 | 32 | 3 | 00110011 | 063 | 51 | 33 | A | 01000001 | 101 | 65 | 41 | B | 01000010 | 102 | 66 | 42 | C | 01000011 | 103 | 67 | 43 | D | 01000100 | 104 | 68 | 44 | A | 01100001 | 141 | 97 | 61 | B | 01100010 | 142 | 98 | 62 | C | 01100011 | 143 | 99 | 63 | D | 01100100 | 144 | 100 | 64 |

RANDOM NUMBERS
Random numbers are important for a number of reasons. For instance, random numbers are used to generate data encryption keys. They are also used in simulating and modeling complex entities/phenomena (Taylor & George , 2011). Random numbers are also used in the select of random samples form a population of data. Random numbers are utilized in literature and music to create an aesthetic atmosphere. Popular games and gambling utilize random numbers to enhance the aspect of diversity and unpredictability (Taylor & George , 2011). With regards to single values, a random numbers is a singular entity drawn from a set of possible values all of which have equal probability; they follow uniform distribution. Meet me fhill606 at goggle male dot com, I will do your paper and deliver directly to you for free.. A sequence of random numbers contains values that are independent of each other (Taylor & George , 2011).
With regards to computer programming, programmers have learnt the necessity of incorporating randomness in computer programs. This is an integral process owing to the nature of the system which is principled on randomness. Nevertheless a computer can never really do something that is totally by chance, because it follows set instructions blindly making it predictable to a range (Taylor & George , 2011). This is usually done at the command of the programmer. Failure to output results according to input instructions means the computer has a malfunction or is corrupted. There are two main mechanisms of generating/producing random numbers utilizing a computer (Taylor & George , 2011). The first approach is referred to as Pseudo-Random Number Generators (PRNGs). The second approach is called True Random Number Generators (TRNGs). The two mechanisms possess diverse characteristics, and encase different advantages and disadvantages (Taylor & George 2011).
C++ Programming
C++ programming language is one of most utilized programming languages and is used on numerous system hardware and operating system canvass (Hiscotta, 2014). Its utility is governed by its efficiency as a compiler to native code, making it applicable in the design of system software, device drivers, application software, entertainment software (video games), high performance server and client application, and embedded software. Globally, there are several groups renowned with the mass production of proprietary and free C++ compiler software one such company is Microsoft (Hiscotta, 2014). These different C++ compiler software developers have researched into the faults associated C++ programming. Meet me fhill606 at goggle male dot com, I will do your paper and deliver directly to you for free..
They have realized 50% of the issues are user related. While 70-85% of failure issues are attributed to other causes like software was installed incorrectly or missing/deleted software components (Hiscotta, 2014). The failures associated with C++ are minimal because of its simplicity to use. The failures that do occur can be represented in a graph as shown below where the X-axis represents years, starting from 1994-2003. While the Y-axis represents percentage errors recorded for a particular year and their cause (Hiscotta, 2014).

Pseudo-Random Number Generators (PRNGs)
Despite what the name suggests “Pseudo” the numbers generated are not as random as expected. For instance an individual who is familiar with lottery tickets understands that there is a formula used to obtain the numbers. As such, PRNGs are regarded as computer algorithms that follow certain mathematical formulas to calculate and produce tables that contain sequences of numbers that seem random (Haahr, 2013). The best example of such a PRNG is seen in the Linear Congruential Method. A lot of research has been invested in the study of pseudo-random number theory. This accounts for the widest literature review available regarding this field. The research has been so successful that modern algorithms appear to generate pseudo-random numbers that are completely random (Haahr, 2013).
The most basic difference between Pseudo-Random Number Generators and True Random Number Generators can be understood by rolling a dice. PRNGs will use mathematical formulas to calculate the outcome of the dice roll. It associates the task to the results obtained when an individual rolls dices several times and records the findings (Haahr, 2013). So when an individual asks for a dice roll, the computer program simply outputs the number next in the list from the predetermined values that had been calculated using the mathematical formula. In effect the numbers seem random but they are actually preordained (Haahr, 2013). TRNGs work by instructing the computer to actually roll the dice, but mostly the computer uses other components that are easier to connect to the computer unlike a dice.
PRNGs are regarded as being efficient and deterministic (Haahr, 2013). They are viewed as being efficient seen they can produce numerous random numbers in a short time interval. They are said to be deterministic because they can reproduced a given sequence of random numbers in future as long as the start of the program is known (Haahr, 2013). Meet me fhill606 at goggle male dot com, I will do your paper and deliver directly to you for free..
Efficiency is important is the goal of is to create an application that produces many random variables at a go. Determinism is good for it allows the application the feature of replaying events at a later stage, for instance a statistical model that replays frequency distribution data for multiple uses (Haahr, 2013).
PRNGs are periodic meaning that at some point the sequence of random numbers will repeat itself. Periodicity is not at all desired, for this reason modern PRNGs have been designed with a period that is extremely long, so long that it can be ignored in practical instances (Haahr, 2013). As such, PRNGs are suitable for programs that require a lot of random numbers and need for them to be replayed with ease. Good examples of such programs are simulation and modeling programs/applications. PRNGs are not considered suitable for programs or applications that require truly random and unpredictable outcomes like gambling (Haahr, 2013). This is because they have consistencies which would render the program almost unplayable. They do not work on a varied extent of uncertainty in number generation.
Even though very good PRNG algorithms exist, this does not mean they will yield the desired result. Sometime depending on the operating system used the results could be very good or not so good. For instance utilizing PHP, a web programming language the results obtained using Microsoft Windows and results obtained using Linux are slightly different. When Linux is used the sequence of random numbers generated is very good (Haahr, 2013). However, when Microsoft Windows is used the sequence of random numbers obtained is less than satisfactory. A researcher discovered in 2008, that utilizing PRNG in MacOS to simulate virus infection yielded results that were not so good (Haahr, 2013). As such, despite the ease of utilizing PRNGs it is important to understand which one works best with what.
Random Numbers in C++
A random number generator (RNG) is viewed as a device/tool that can be used to output sequences of values that follow no particular pattern. Random number generators are required to be tested using several statistical requirements for the purposes of validation. One application that is very important and requires randomness is cryptography. Other application like gaming and gambling also require randomness but cryptography is something that is used and devised by thousands of programmers globally. The worldwide need for randomness has resulted in the development of numerous random number generating techniques. Nevertheless all these techniques are classed under two groups, physical and computational. Both physical and computational groups have their weakness and strengths depending on their ability to devise random numbers and prioritize security. Physical methods are considered non deterministic, dependent on physical phenomena and quite unpredictable. Computational methods are more efficient than physical methods, deterministic (which also makes the application vulnerable to malicious replay attacks) and periodic meaning sequences of random numbers will be repeat a given point.
The Random number generation process is generally an easy process to identify and this makes it susceptible to attackers and hackers. If the hacker/attacker is able to forecast the sequence of random numbers, then the integrity and privacy of information contained therein is compromised. This deficiency has been utilized by hackers to access various sites. Attacks on random number generators are mostly hard to detect (let alone prevent) by using an upstream test to survey over the numbers. These attacks are so quick and easy such that the attack only requires only a single entirely into the system. The efficiency of attacks carried out on random number generators is enhanced by the non-requirement of information to be sent back to the attackers system. This only happens with computer virus that attack computer passwords and key. However, preventive computer programs that are being developed use numbers that are coded in a manner that cannot be simply manipulated and thus improving the safety of accessibility.
For instance RANDU a random number generator used in computer systems for decades was only recently proved unreliable because of its flawed nature. Research revealed that computer knowledge from a time RANDU was first designed was not so suitable for modern use.
Microsoft Company develops its own random number generator for all of its Windows products. Microsoft uses a random number generator referred to as CryptGenRandom to employ randomness in all Windows operating system. CryptGenRandom is also used in another Microsoft product referred to as Cryptographic Application Programming Interface, creating random numbers wherever they are required. This random number generator used by Microsoft is speculated to be cryptographically secure. Nevertheless no actually application algorithm regarding this generator has been published for verification and validation. However some computer programmers have used reversed engineering to conduct tests on the algorithm and their research has revealed certain imperfections with the program. A good attacker will only need to steal the state bits for him or her to gain access to current and past random numbers generated using CryptGenRandom. This is a major problem assuming the attacker employs reverse engineering and retrieves sensitive past data from the CryptGenRandom. For instance if an individual had transacted online and purchase several items using his/her credit card the attacker can use reverse engineering to retrieve the random key utilized in cards and user passwords to online stores. Furthermore, the CryotGenRandom function operates with aid of a user account as such any individual who owns an account can be able to access sensitive information like state bits.
Research has totally confirmed that identifying weakness in random number generators is difficult. While this borders on almost impossibility, it is not entirely impossible. One who have to carry out tests on infinitely many sequences of random numbers to true discredit the randomness of numbers generated by a certain application. The question thus because can a programmer predict the next sequence beyond the trappings of chance? If the answer is yes then the random number generator harbors some flaws. Again this can be proved through a series of tests that probably requires an infinite number of sequences. The breaking of crypto is viewed to be of less importance in the world of program as compared to establishing whether or not a random number generator is weak. The establishment of weakness in a random number generator is arrived at with the help of observation and belief that the encryption can be broken. By regarding the procedure used in the generation of random patterns a programmer can more easy establish whether or not a given random number generator is weak or not.
Once the programmer determines that he/she can predict the subsequent series of random number, he/she is capable of determining which sequences where used to generate keys and pads (pads are normally used one time only). This reduces the effort employed in the search for secret keys and certain distributions in the stream of random numbers. Pads demand that the programmer reverses the process that led to the creation of the one-time pad. But this is a simple matter if the programmer is capable of retrieving the secret key.
Computers are lack the capability to manipulate physical variables, like shuffling cards or tossing a coin (Haahr, 2013). This is partly because they rely on inputs as well as an inbuilt binary code system. Computers relay on a binary coding system that works on the basis of “true or false” only. As such, in an electric world there is no in-between an outcome is either true or false (Haahr, 2013). According to the intended working of a computer, it is expected to output values that are very much predictable. Therefore, the addition of three and four will always output the value seven, nothing else like ten or thirty four. Consequently computers normally simulate randomness, but do not execute fully random commands and results (Haahr, 2013).
Using PRNG to develop a random number sequence in C++ requires starting with a seed that performs mathematical alterations to output values that appear different from the seed (Haahr, 2013). The program again takes the resultant number and performs mathematical alterations to transform the resultant number to a new number. The seed and the resultant numbers all appear unrelated and thus acquiring randomness. A complex algorithm with generate numerous random numbers before it repeats itself (Haahr, 2013).
It is usually simple to write a PRNG that is not too complex. Below is program that outputs 100 pseudo-random numbers: 12345678910111213141516171819202122232425262728293031 | #include <stdafx.h>#include <iostream>using namespace std; unsigned int PRNG(){ // our initial starting seed is 5323 static unsigned int nSeed = 5323; // Take the current seed and generate a new value from it // Due to our use of large constants and overflow, it would be //meet me fhill606 at goggle male I will do your paper and deliver directly to you // very hard for someone to predict what the next number is // going to be from the previous one. nSeed = (8253729 * nSeed + 2396403); // Take the seed and return a value between 0 and 32767 return nSeed % 32767;} int main(){ // Print 100 random numbers for (int nCount=0; nCount < 100; ++nCount) { cout << PRNG() << "\t"; // If we've printed 5 numbers, start a new column if ((nCount+1) % 5 == 0) cout << endl; }} |
The result of this program is: 20433 22044 9937 30185 29341 14783 29730 8430 3076 28768 18053 16066 26537 100 30493 4943 19511 19251 6669 32117 31575 3373 32383 30496 12710 23999 11929 5425 9938 12107 28541 1938 3450 20283 16726 6440 4938 26094 24391 12248 24803 30416 16244 19590 6644 24646 4873 2841 23831 23476 17958 8827 17400 32129 32760 25744 25405 13591 8859 15932 19086 19666 19265 14179 1165 27168 20996 29427 5857 3434 18964 11980 564 4620 400 17362 16934 11889 419 9714 19808 29699 3694 25612 5512 20256 10009 10247 1860 1846 1487 14030 2615 16035 8107 28736 267 29395 9438 20294
The above program appears to be very effective in the generation of pseudo-random numbers. Each number seems different from the previous number. The algorithm achieves the set objective but it’s not very good due to so elements. These elements are functions that are provided in C++ programming for the generation of random numbers (Haahr, 2013).
Generating Random Numbers in C++
C++ is equipped with a pseudo-random number generator within itself. The generator is utilized in two different functions that are located in the cstdlid header. The first is srand(), this function is used to set the initial value of the seed, as such it should only be used once (Haahr, 2013). The second is rand(), this function generates the next random number different from the seed that is set by srand(). Meet me fhill606 at goggle male I will do your paper and deliver directly to you. The function sets the values in sequential form.
A simple program that utilizes these functions can be written as follows: 12345678910111213141516171819 | #include <stdafx.h>#include <iostream>#include <cstdlib> // for rand() and srand()using namespace std; int main(){ srand(5323); // set initial seed value to 5323 // Print 100 random numbers for (int nCount=0; nCount < 100; ++nCount) { cout << rand() << "\t"; // If we've printed 5 numbers, start a new column if ((nCount+1) % 5 == 0) cout << endl; }} |
The program will offer the following output: 17421 8558 19487 1344 26934 7796 28102 15201 17869 6911 4981 417 12650 28759 20778 31890 23714 29127 15819 29971 1069 25403 24427 9087 24392 15886 11466 15140 19801 14365 18458 18935 1746 16672 22281 16517 21847 27194 7163 13869 5923 27598 13463 15757 4520 15765 8582 23866 22389 29933 31607 180 17757 23924 31079 30105 23254 32726 11295 18712 29087 2787 4862 6569 6310 21221 28152 12539 5672 23344 28895 31278 21786 7674 15329 10307 16840 1645 15699 8401 22972 20731 24749 32505 29409 17906 11989 17051 32232 592 17312 32714 18411 17112 15510 8830 32592 25957 1269 6793 The question that is offer asked is how to generate random numbers with regards to real life events like tossing a coin, rolling a die or shuffling cards (Haahr, 2013). These events are subjective to a number of variables like fiction, gravity, acceleration and air resistance. It is due to these various variables that real life events like tossing a coin and rolling a die are unpredictable and uncontrollable. As such, these events produce results that are random (Haahr, 2013). The range of the rand() function The rand() function normally generates integers called pseudo random numbers that are between the value zero and RAND_MAX. RAND_MAX is a constant set at 32767 and it is located in the cstdlib (Haahr, 2013). With regards to real life events like tossing a coin, random numbers between zero and RAND_MAX are not needed. As such, the programmer defines the lower limit as nLow and the upper limit as nHigh (Haahr, 2013). For instance when simulating random numbers from a dice roll nLow will be one and nHigh will be six. The use of nLow and nHigh with rand()in a C++ program can be shown as follows; 12345 | // Generate a random number between nLow and nHigh (inclusive)unsigned int GetRandomNumber(int nLow, int nHigh){ return (rand() % (nHigh - nLow + 1)) + nLow;} |
By running the above program several times we are able to see that the results are the same for every run. However, it is important to note that every run has to be done at a consistent manner for the general integrity of the results. As such each number in the sequence is seems random to the previous one, but the sequence itself is not random. The same inputs contribute to the same results making the sequence very predictable(Haahr, 2013). The instances where the programmer needs the random numbers to be repeated, this is mostly utilized in scientific simulations. Also such an application is useful when one is trying to debug the program with as given random number generator. But in most cases this attribute is not desired in a computer application(Haahr, 2013). For instance the computer game hi-lo, requires that the player guesses a number and the computer proceeds to explain whether the guess is too low or too high. In such a case the player would not want the computer to pick the same number over and over again; making the game monotonous and predictable(Haahr, 2013).
Every number generated in a PRNGs sequence is a produce of the precursor, following a deterministic system(Haahr, 2013). Hence given a particular seed, the sequence generated by PRNGs will remain the same. As such, similar results are obtained in previous C++ program example because the seed is 5323(Haahr, 2013). To fix this problem one needs to select a seed that is random. Hence a seed that changes every time the computer program is run would be most desirable to achieve this objective(Haahr, 2013). After selecting such an entity, a programmer can proceed to generating sequences of random numbers from that particular seed. The best mechanism to utilize is set the computer system clock as the seed. Due to the fact that time will not be the same for different program runs, makes the system clock a good seed. The program will utilize the system clock to generate random sequences every time the computer application is run(Haahr, 2013).
Any C++ programming language compiler software is equipped with the time() function that outputs the number of seconds past since midnight of January 1st of 1970(Haahr, 2013). To apply this function in the program one needs only to introduce the ctime header and then initialize a srand() that calls to time(0), as shown below; 123456789101112131415161718 | #include <stdafx.h>#include <iostream>#include <cstdlib> // for rand() and srand()#include <ctime> // for time()using namespace std; int main(){ srand(time(0)); // set initial seed value to system clock for (int nCount=0; nCount < 100; ++nCount) { cout << rand() << "\t"; if ((nCount+1) % 5 == 0) cout << endl; }} |
Consequently, the above program will now generate different sequences of pseudo-random numbers every time the program is run. Understanding Randomized values; Creating and Utilizing Different Seeds
A programmer at any point in his/her life must be able to design a program that generates random values. This is probably the greatest determinant for the effectiveness or otherwise of any system. To numerous people the prospect of creating a random number generating program is viewed as a challenging task that is better left to experts(Haahr, 2013). There are simple programs that can be coded to generate random numbers. Using C++ programming language, a programmer is able to randomize values at a very basic level. With programming starters, the idea is to introduce them to notion of randomized values(Haahr, 2013). The programmer is normally given the task of creating and running a simple program that produces only several random numbers like ten or a hundred. A short range program helps starters understand the concept of randomization easily without overlooking the creation and design process(Haahr, 2013).
Most of the programs in the world utilize random numbers as such a programmer must have an in depth understanding of how to generate random numbers(Haahr, 2013). For instance a simple program that outputs a hundred random numbers can be used to create the framework for a game. Games demand randomness for them to sustain the illusion of unpredictability and keep the player entertained(Haahr, 2013). The number realize by the function rand is controlled by the seed. A simple seed (5323) like the one used in the above program acts like the starting point of the program. The above seed is meant to remain 5323 no matter how many times the program is run. As such the sequence of random numbers produced by this program will remain the same for every run(Haahr, 2013).
For us to eliminate this repetition of results another function can be introduced that allows for variation in the sequence generated. The function is referred to as srand and is capable of generation more than one seed (5323). The srand function employs the user to special or input the seed before the program begins(Haahr, 2013). By so doing a user who inputs a different seed every time will generate a different sequence for each instance. Hence a user can use any other seed in addition to the available one (5323) if he/she wants to a different sequence of hundred random numbers. As such, the problem then becomes how to set an arbitrary seed that will automatically shift the seed from the purpose of generating a different sequence(Haahr, 2013).
A program that requires the user to set the seed every time the program is run is not very efficient. Hence, the system clock is adapted for use as a seed. The system clock can replace the 5323 seed to allow for the automatic variation of the seed without requiring the user to input or specify anything(Haahr, 2013). A time function exits in C++ which the programmer can use to set time_t or time_h in the data to replace the initial seed 5323. By doing this the computers clock is used as the new seed that replaces the 5323 in the data making possible for the user to generate different sequences. Adhering strictly to these adjustments the new program can be written smoothly in Visual C++ 6.0 and compiled with little ease in most computers(Haahr, 2013). The program will actually output a different sequence of random numbers, depending on what time of the day the program is run. Using a simple dice game program we can illustrate and explain how a programmer can change the seed as will 1. Header: iostream 2. Reason: Input/Output stream 3. Header: stdlib 4. Reason: For functions rand and srand 5. Header: time.h 6. Reason: For function time, and for data type time_t 7. */ 8. #include <iostream> 9. #include <cstdlib> 10. #include <time.h> 11. /* 12. These constants define our upper 13. and our lower bounds. The random numbers 14. will always be between 1 and 6, inclusive. 15. */ 16. const int LOW = 1; 17. const int HIGH = 6; 18. using namespace std; 19. int main() 20. { 21. /* 22. Variables to hold random values 23. for the first and the second die on 24. each roll. 25. */ 26. int first_die, sec_die; 27. /* 28. Declare variable to hold seconds on clock. 29. */ 30. time_t seconds; 31. /* 32. Get value from system clock and 33. place in seconds variable. 34. */ 35. time(&seconds); 36. /* 37. Convert seconds to a unsigned 38. integer. 39. */ 40. srand((unsigned int) seconds); 41. /* 42. Get first and second random numbers. 43. */ 44. first_die = rand() % (HIGH - LOW + 1) + LOW; 45. sec_die = rand() % (HIGH - LOW + 1) + LOW; 46. /* 47. Output first roll results. 48. */ 49. cout<< "Your roll is (" << first_die << ", " 50. << sec_die << "}" << endl << endl; 51. /* 52. Get two new random values. 53. */ 54. first_die = rand() % (HIGH - LOW + 1) + LOW; 55. sec_die = rand() % (HIGH - LOW + 1) + LOW; 56. /* 57. Output second roll results. 58. */ 59. cout<< "My roll is (" << first_die << ", " 60. << sec_die << "}" << endl << endl; 61. return 0; 62. }
True Random Number Generator (TRNGs)
TRNGs unlike PRNGs require physical phenomena to simulate randomness from. The best examples are; the time variation between consecutive keystrokes and the movement of the mouse (Haahr, 2013). It is nevertheless important to determine which source is the most appropriate for given random simulation. The use of time variation between keystroke is sometimes restrictive because of it is controlled and decoded by the operating system (Haahr, 2013). As such, several keystrokes are consolidated together before they are relayed to the program that requires them. Therefore, the program that requires the keystrokes, will interpret the keys were all pressed simultaneously. This will in turn ruin the randomness of the entire process (Haahr, 2013).
Nevertheless, there are several other ways to introduce true randomness into a computer. This method has been manipulated on a number of occasions and has been the premise of wide literature review. A good example is the use of a radioactive source as the physical phenomenon. The extra point in time when a radioactive object decays is totally unpredictable, and this can be easily detect and entered into the computer (Haahr, 2013). The process thus avoids buffering from the operating system, making the collected information totally random. Further, the buffering is regulated in only the tiniest of requited bits for the operating system as a general mechanism.HotBits Services found in Fourmilab, Switzerland utilize this technique to generate random numbers. Another appropriate physical phenomenon could be atmospheric noise (Haahr, 2013). Atmospheric noises are random and can be easily detected using an ordinary radio. A random number generator that utilizes this technique is Random.org. Other physical phenomena that can be used include background noises recorded in offices or laboratories (Haahr, 2013). Patterns should be Avoided especially periodic noises from electronic sources. For instance the rotation of a computer fan is not random because it is controlled by the computer periodically. A thunderstorm is a random number generator because it is very unpredictable (Haahr, 2013).
There are probably infinite sources of random number as long as caution is exercised. The company Silicon Graphics utilized the Lavarand generator to produce random numbers (Haahr, 2013). The lavarand generator depended on snapshots of lava lamps. This technique is no longer used due to the discovery of better random number generators. One such generator is the Java EntropyPool approach, which utilizes a number of sources to generate random numbers (Haahr, 2013). The source included random bits obtained from other web pages. Ignoring the source used, the most important thing to identify is the unpredictable change that occurs with respect to the data recorded (Haahr, 2013). For instance, Hotbits analyses the changes in delay between successive radioactive decays, while Random. Org assesses the changes in amplitude between consecutive atmospheric noises.
TRNGs are not normally favored because they are generally unsuccessful in the generation or random numbers. TRNGs compared to PRNGS take more time to generate random numbers, thus they are not efficient (Haahr, 2013). TRNGs are non-deterministic as such random numbers cannot be replayed or reproduced. Sometimes the same sequences maybe produced but this is all by chance not due to deterministic reproduction. TRNGs are therefore said to have no period.
A comparison table can be constructed as follows, that elaborates the different characteristics of TRNGs and PRNGs. Characteristic | Pseudo-Random Number Generators | True Random Number Generators | Determinism | Deterministic | Non-deterministic | Efficiency | Excellent | Poor | Periodicity | Periodic | Aperiodic |

As such, the characteristics of TRNGs make them applicable for uses that PRNGs are less suitable for like games and data encryption. The non-deterministic nature of TRNGs makes them less suitable for applications that carry out simulation and modeling. TRNGs normally require more data than is available to generate random numbers (Haahr, 2013). Here are examples of different applications and the best random number generator for each. Application | Most Appropriate Generator | Games and Gambling | TRNGs | Random Samples (e.g. clinical examinations) | TRNGs | Lotteries and Draws | TRNGs | Simulation and Modeling | PRNGs | Security (data encryption) | TRNGs |

Quantum Physics and Chaotic Behaviors

Literature review
While the argument over the subject of the application and use of the quantum phenomena has evidently been accepted by a wide array of concept uses, such theoretical practice does not however seem to have met the empirical threshold to have wide literature review. The reason normally extended for this scenario is that the equation has been constant, and can only be affected be different variables. This is to be compared with other subjects, say, the metaphysical world where various concepts can always be argued and analyzed in the absence of changing the variables, in this case being the constants.
The use of Quantum physics in the generation of random numbers requires subjectivity. Since physics generally deals with deterministic systems, quantum physics is hard to classify under deterministic or non-deterministic (Haahr, 2013). As such for a person to utilize quantum physics in the generation of random number he/she must subjectively argue that the system is deterministic. Chaotic systems on the other hand can be easily manipulated to conform to deterministic needs. As such, random numbers generated by a chaotic behavior like thunderstorms can be predicted if information is well understood (Haahr, 2013). Nevertheless it is impossible to know the movement and velocity of every molecule found in the planet’s weather system. Hence this inconsistency and lack of accuracy is what makes it impossible to carry out precise weather forecasting or predict the behavior of weather systems (Haahr, 2013).
Users of TRNGs normally argue over the subject of using quantum phenomena or chaotic behaviors as sources of data. The argument is due to the diverse views held by philosophers regarding the deterministic nature of the universe. The argumentative question is whether or not events occurring in the universe are predetermined (Haahr, 2013). Quantum mechanism is a topic in physics that uses mathematics to theoretically convey the universe in terms of atomic and subatomic classes. Random number generators which utilize quantum physic depend on the random behavior exhibited by subatomic particles when they are subjected to given conditions (Haahr, 2013). There is no known cause for the movement of subatomic particles as such it is seen to be non-deterministic. Chaotic systems regard the view that minute changes in the initial conditions can cause dramatic changes in the overall behavior of a given system (Haahr, 2013). The best examples of this are weather systems. In such there is a phenomenon referred to as the butterfly effect. The butterfly effect states that the beating wings of a butterfly can critically influence the occurrence of a tornado in another country (Haahr, 2013).
It is for this reason that random numbers cannot be successfully generated from such systems even when determinism is assumed. The same can be said for the generation of random numbers by use of the lavarand generator (Alex, 2008).
The Monte Carlo Simulation
Monte Carlo (MC) simulation is a technique in physical sciences that depends upon the quantity of random numbers applied. MC simulations are more successful with use of more random numbers. MC simulations normally utilize pseudo-random number generators because of their efficiency and deterministic nature. A good example of MC simulation is a Random Walk from point A to into B. PRNGs used in Monte Carlo simulations cannot be fully assessed for reliability. Correlation resulting from several PRNGs can lead to erroneous findings and conclusions. This has been illustrated in the use of high precision Monte Carlo simulations. Where the researchers used PRNGs mixed with various special simulation algorithms. If a random walk is used across n number of blocks, according to the Grassberger idea the errors observe are caused by depth-first algorithms. Mersenne Twist Pseudo-random Number Generators
Mersenne Twister tools are regarded as being incredibly fast, reliable and very flexible in the generation of random numbers. Mersenne Twist PRNGs are equipped with an extremely long period making them convenient for some applications like in gaming or gambling (Haahr, 2013). There are several features that make Mersenne Twist PRNGs exception. The first feature deals with delivery; Mersenne Twist PRNGs packages are capable ofadapting to various computer systems without crippling efficiency. For example, they can work in a 32-bit integer system as easily as they do in a 64-bit integer system. Mersenne Twist PRNGs packages are capable of generation an automatic seed the desired application. For instance they are capable of creating a seed that changes whenever the application in run, an example of such an application is a Roulette Game (Haahr, 2013). Other features include the ability for Mersenne Twist PRNGs to generate multiple uncorrelated PRNG streams, devise functions for popular distributions like Poisson and Bernoulli, and allow easily storage of pseudo-random numbers for future use.One major drawback with using Mersenne Twist PRNGs is that truncation of the output cause the Mersenne twister to become cryptographically insecure.
Mersenne twist algorithm utilize a seed that is valued as 19937 bits, the value is subsequently stored in an array in the form of 624 elements which are made up of 32-bit values. The system works in a manner such that a single array cannot be replaced with a single-bit storage unit, this stems for the ideology that 219937-1 is in fact a prime number creating a Mersenne prime. If a given shift register utilizes a number of cells similar to those employed by the exponent of the Mersenne prime, then the duration for testing the periodicity of that particular shift register is drastically simplified. In advanced situations a simpler testing process is utilized, this process is referred to as the Inversive Decimation method. The method can be used to test for the periodicity of any shift register. It was the development of this technique by the creators of the Mersenne Twister that paved the way for the design of large maximum-period shift registers.

PYTHAGOREAN THEOREM
In the field of mathematics, the Pythagorean Theorem which is also commonly referred to as Pythagoras’s Theorem revolves around the Euclidean geometry among the three sides of a triangle. It is a relation that was created and that has been used widely in basic mathematical calculations. While there seem to be widespread indication of the fact that Babylonian mathematicians understood the concept, they did not restrict it to the field of mathematics entirely.The Pythagorean Theorem was created by a scholar referred to a Pythagoras. Pythagoras is rumored to have lived either in the fifth or sixth century Before Christ (B.C.) (Bogomolny, 2012). Pythagoras founded a school dedicated to the study of mathematics, natural sciences and philosophy. The school was referred to as the Pythagorean School of Crotona. The school was mostly held together by brotherhood ties as such, it was destroyed by the actions of democratic forces witnessed in Italy (Bogomolny, 2012). Even after the brotherhood was dispersed all over Italy it continued to exist in secret. The brotherhood that consisted of Pythagoras and several of his colleagues is championed with numerous contributions to the field of mathematics (Bogomolny, 2012). His work has been credited for having the single most impact in the field of arithmetic with due consideration to other comparable developments that have been made on the same area.
This formula has received arguably the single widest number of proofs that prove its existence. There is some debate as to who exactly came up with the theory. However, since it is Pythagoras who proved it, it has always been credited to him by the proof of rearrangement. A generalization of this theorem is the law of cosines. This allows for the computation of any side of a triangle using the two known sides and the angular inclination between them. Perhaps the widest acclaimed proof that has been advanced for this proof is the law of quadratic reciprocity. Further, a proof that is based on the proportionality of the sides of two similar sides of two triangles is also employed as a proof of the Theorem.
It is worth noting that for the formal proof of the theorem, the four elementary lemmata are required. They include: 1. If two triangles have two sides of the one equal of the one equal to two sides of the other, each to each, and the angles included by those sides equal, then the triangles are congruent. 2. The area of a rectangle is equal to the product of two adjacent sides. 3. The area of a triangle is half that of any parallelogram on the same base and having the same altitude. 4. The area of a square is equal to the product of two of its sides.
The Pythagorean Theorem establishes the fundamental principle that in a right angled triangle; the square of side “a” (a2) added to the square of side “b” (b2) is equivalent to the square of side “c” (c2). This can be represented in algebraic form as a² + b² = c², c represents the hypotenuse of the right angled triangle while a and b indicate the legs of the right angled triangle (Bogomolny, 2012). The Pythagorean Theorem is mostly applied in Euclidean Geometry as a mechanism of determining the distance in between two points. The Pythagorean Theorem is believed to be used so often in academics, that any individual who went to High School will remember it due to its simplicity (Bogomolny, 2012).
We can prove the validity of the Pythagorean Theorem through a number of ways. This validity has ideally been premised on a number of graphical equations. While this is the case, it is certainly not limited in the manner of applicability. One can start by graphically representing and analyzing the Pythagorean Theorem with the help of three squares to each side of a right angled triangle. The angle ACB is right angled indicating that ACB is a right angled triangle (Head, 2012). This marks the most basic of triangular representations that can be used as a proof of this derivative. As such, we can obtain the areas or the three squares where the hypotenuse is represented by the red square and the legs are represented by the green and blue squares. From this we obtain (assume) the area of red square is Z, the areas of the green square is Y and that of the blue square is X (Head, 2012). Therefore, this can be useful in the creation of a relationship that is;
Area of the green square is Y
Area of the blue square is X
Area of the red square is Z
Area of green sq. (Y) + Area of blue sq. (X)= Area of red sq. (Z)
Y+X=Z
Which bears resembles to the algebraic representation that is; a² + b² = c²

The Pythagorean Theorem is credited to and named after Pythagoras because he was the first individual to prove it. He used a number of dissections to proof the theorem; later his work was used by others to formulate their own proof (Head, 2012). There are currently more than a hundred ways to prove the Pythagorean Theorem, but will focus on only four methods of proving the Pythagorean Theorem. These methods of proving include Pythagoras’ proof, Bhaskara's first proof, Bhaskara's second proof and Garfield's Proof (Head, 2012).

Pythagoras’ Proof
Letting a and b denote the legs, and c the hypotenuse of a right angled triangle. Now consider the two triangles illustrated in the second figure each having a+b on the outsides (Head, 2012). The first/initial square is created from six pieces, two leg squares and four right angled triangle that are congruent to the given right angled triangle (Head, 2012). The second/accompanying square is dissected into five distinct pieces, the square taking the hypotenuse and four right angled triangles passed congruently to the given triangle. By subtract equal function from each other it becomes evident that the square on the hypotenuse is equivalent to the sum of the legs squared (Head, 2012).
Regard the two figures below;

The area of the first/initial square is designed by
(a+b)2 or given by 4(1/2ab)+a2+b2
The area of the second/accompanying square is given by
(a+b)2 or 4(1/2ab)+c2
Consequently the two squares have the same areas, they can be equated to each other, while subtracting equals. In such a case will ignore (a+b)2=(a+b)2 because it does not proof anything further. Using the other case;
4(1/2ab)+a2+b2=4(1/2ab)+c2
Eliminating 4(1/2ab) by subtracting from an equal we get; a2+b2=c2 The above equation proves the Pythagorean Theorem.
The second proof to use is that designed by Bhaskara his first and second proofs. These proofs have been used because of their appropriateness for a classroom atmosphere. The final proof will use methods applied by President James Garfield, who despite of his political escapades was a brilliant mathematician (Head, 2012).
Bhaskara’s First Proof
Bhaskaras’s proof is also structured like a dissection proof, it bears several similarities with the one used by Pythagoras. Bhaskara was an India born mathematician who lived in the second century and was affiliated with Hinduism. Bhaskara used the following figures to establish his proof for the Pythagorean Theorem.

In the above representation both the yellow squares and the blue squares are congruent. The initial step that Bhaskara followed was to solve of the area of big square utilizing two different techniques. The first technique employed the area formula for a square (Head, 2012).
Hence; A=c2
The second technique required that the area of each component be calculate, after which their areas we to be summed together.
Hence;
Area of the blue right angled triangle=4(1/2)ab
Area of the yellow square =(b-a)2
Area of the big square is =4(1/2)ab+(b-a)2
This can be simplified as
=2ab+b2-2ab+a2
=b2+a2
A square has the same area regardless of technique used
Meet me fhill606 at goggle male dot com, I will do your paper and deliver directly to you for free.
Therefore;
A=c2=b2+a2
Thus proving the Pythagorean Theorem
Bhaskara’s second proof
In the first proof Bhaskara use several triangles to prove the Theorem. In this second proof Bhaskara utilizes one right angled triangle, from which he proceeds to draw an altitude to the hypotenuse (Head, 2012). The second proof relays on similarity to prove the Pythagorean Theorem.

Bhaskara generated two triangles ABC and CBE, from this two Bhaskara set forth to prove their similarity (Head, 2012). Utilizing the AA postulate Bhaskara stated that triangle ABC was indeed similar to triangle CBE. Bhaskara identified that angle B was congruent to angle B, and angle C was also congruent to angle E (Head, 2012). which made the internal ratios equals; s/a=a/c Bhaskara multiplied both sides with ac to obtain; sc=a2 Bhaskara generated two triangles ABC and ACE, from this two Bhaskara set forth to prove their similarity. Utilizing the AA postulate Bhaskara stated that triangle ABC was indeed similar to triangle ACE. Meet me fhill606 at goggle male dot com, I will do your paper and deliver directly to you for free.
Bhaskara identified that angle A was congruent to angle A, and angle C was also congruent to angle E. which made the internal ratios equals; r/b=b/c By multiplying both sides with bc he obtained; rc=b2 hence when the two results were summed up together the following was obtained sc+rc=a2+b2 c(s+r)=a2+b2 c2=b2+a2 Thus proving the Pythagorean Theorem with all fullness

Garfield’s Proof
The Garfield Proof was conjured by the twentieth president of United States of America, five years before he was elected president. He discovered the proof during a mathematical debate held in congress in 1876 (Head, 2012). The proof was consequently published in a New England Journal that dealt with all matters academic. Meet me fhill606 at goggle male dot com, I will do your paper and deliver directly to you for free.. The proof required the use of right trapezoid. The area of the trapezoid was then calculated using two different techniques (Head, 2012). The first technique required the use of the formula for finding the area of a trapezoid. The second techniques simply summed up the area of three different right angled triangles that were created from the trapezoid. Garfield used the following trapezoid to establish his proof for the Pythagorean Theorem (Head, 2012).

Garfield started by finding the area of the trapezoid employing the area formula for a trapezoid.
A=(1/2)h(b1+b2)
With regard to the above figure h=a+b, b1=a and b2=b
A=(1/2)(a+b)(a+b)
A=(1/2)(a2+2ab+b2)
He then proceeded to calculate the area of trapezoid by adding the areas of three triangles.
The area of the yellow triangle is;
A=(1/2)ba
The area of the red triangle is
A=1/2(c2)
The area of the blue triangle is;
A=1/2(ab)
Thus the sum of their areas is;
½(ba)+ ½(c2)+½(ab)= ½(ba+c2+ab)= ½(2ab+c2)
This area is similar to that of the entire trapezoid
½(a2+2ab+b2)= ½(2ab+c2)
Garfield finalized the equation by multiplying with 2 and subtracting 2ab on both sides to obtain
Meet me fhill606 at goggle male dot com, I will do your paper and deliver directly to you for free.. (Head, 2012); a2+b2=c2 Proving the Pythagorean Theorem, which states that a right angled triangle; the square of side “a” (a2) added to the square of side “b” (b2) is equivalent to the square of side “c” (c2).

Bibliography
Alex, Random number generation, 2014. Available from: < http://www.learncpp.com/cpp-tutorial/59-random-number-generation/>. [7 December 2008].
Bogomonly, A, Pythagorean Theorem, 2012. Available from: < http://www.cut-the-knot.org/pythagoras/>. [3 October 2014].
Haahr, D. M, Introduction to Randomness and Random Numbers, 2013. Available from: < http://www.random.org/randomness/>. [3 October 2014].
Head, A, Pythagorean Theorem, 2012. Available from: < http://jwilson.coe.uga.edu/emt668/emt668.student.folders/headangela/essay1/pythagorean.html>. [3 October 2014].
Hiscotta, R, 10 Programming Languages You Should Learn in 2014, 2014. Available from: < http://mashable.com/2014/01/21/learn-programming-languages/>. [3 October 2014].
Laine, O, What Is Computer Programming?,2013. Available from: < http://www.bfoit.org/itp/Programming.html>. [3 October 2014].
Taylor, G & George, C, Behind Intel’s New Random-Number Generator, 2011. Available from: < http://spectrum.ieee.org/computing/hardware/behind-intels-new-randomnumber-generator>. [3 October 2014].

Similar Documents

Premium Essay

College Admissions Essay: Random Sequence Of Numbers

...If an entire world can be expressed in ones and zero, then why not our living world? In seeing a random sequence of numbers such as 413270, it brings a slew of thoughts to mind. 314 are the first three digits of pi. 4, 3, 2, 1 speaks to me of the applied math and cause of history. 2.71 is my favorite number though an outdated concept for a mature individual. A random sequence of numbers can provide many memories. One of the saddest things lost in childhood is the interest in a favorite number. Nobody over the age of 10 asks another what their favorite number is. Perhaps as we mature we become less attached to certain digit sequences and closer to the meanings of such digits. A favorite number may end up being any numeral that represents a large sum of money. Favorite colors, shapes, and numbers lose importance as we grow and become more aware of our own wants and needs. My favorite number when I was 12 years old was the number 7. I had no particular love of 6 or 8 or any even number for that matter. My birth month, July, is the seventh month and 7 seemed to me to be a significant piece of my personality. It may seem absurd that a number may be of note for someone, but to a 12 year old girl or to a regular lottery ticket purchaser a number is the difference between happiness and misery. As I aged, my favorite number...

Words: 553 - Pages: 3

Free Essay

Random Numbers in C++

...Random numbers in C++ and The Pythagorean Theorem Literature Review Name Course Date Literature Review The increase in technological advancements has seen a similar increase in the number of computer programs which are designed to command a computer to carry out a given specified task. The number of languages that are available which are used in this creation and design include Java Script, C++, Java and Sage. It is worth noting that while these are the most notable ones, the number of languages in computer programming design might be higher. However, computer programmers argue that the rest of the languages, despite being of equal capabilities, have not met the required usage to warrant widespread literature review. Hiscotta is particularly critical of this in 10 programming languages you should learn in 2014 by asserting that The field of computer programming is particularly important with regards to the increasing use and adoption of the internet use. This has seen the field carve out a distinct field of study which is purely dedicated to the understanding of how the programs work. The first step in the design of the computer programs is the basic understanding of the dynamics that are involved in the working of computers. This forms the initial step which will eventually be accompanied by software writing involving random numbers with the sole undertaking of coming up with a particular outcome. Of critical importance is the adherence to source code representation...

Words: 1434 - Pages: 6

Premium Essay

Jet Copies Case Study

...COPIES CASE STUDY James C. Kessler Strayer University Introduction to Management Science Math 540 Dr. Yaw Kyei January 3, 2013 Jet Copies Case Study 2 Days-to-Repair I typed the name jet copies into the A1 slot. Then I made the letters bold and used the cells section to increase the row height and the column width. I also increased the font size. I then typed in the probability of weekly demand section. Increasing the font size and making it bold. I set up three columns, P(x), cumulative, and repair time. This was taken from the table that was given. Because we need 52 weeks of information I set numbers for 60 weeks, starting with column E6. I then went to G6 and typed in =RAND() to start a random number sequence and hit enter. I then clicked on G6 and right clicked and held down to set up 60 random numbers. I then went to the clipboard section and clicked copy. Then we clicked on F6, then right clicked, then clicked on past special, then clicked on values, then clicked ok to set the values we would use. Then I left clicked on G6, then clicked on delete, then clicked entire column to remove. To develop the probability of breakdowns I had to assume values for P(y). We were given six operating times and given .33 as the highest probability, we then assumed the others with the total equaling 1.00. I then set up the cumulative column, and the operating time to breakdown column. Now I can do the calculation to get the times between...

Words: 920 - Pages: 4

Free Essay

Random Number Exponential Distribution

...Frequencytest.m r = rand(1000,1); x = zeros(20,1); for i=1:1000 for j=0:19 if(r(i)>=j*0.05 && r(i)<(j+1)*0.05) x(j+1)=x(j+1)+1; end end end a=0; for k = 1:20 a = a + (x(k)-50)*(x(k)-50)/50; end a Pokers_test.m r = randi([0,999],1000,1); a=0; b=0; c=0; for i = 1:1000 if r(i)==0 b=b+1; elseif (r(i)>0)&&(r(i)<=10) c=c+1; elseif (r(i)>10)&&(r(i)<100) x=mod(r(i),10); y=(r(i)-x)/10; if (x==y || x==0) c=c+1; else a=a+1; end else x=mod(r(i),10); y=mod(((r(i)-x)/10),10); z=(((r(i)-x)/10)-y)/10; if (x==y)&&(y==z) b=b+1; elseif (x~=y)&&(x~=z) a=a+1; else c=c+1; end end end a b c chisq = (a-720)*(a-720)/720 + (b-10)*(b-10)/10 + (c-270)*(c-270)/270 normal.m r=rand(200,1); r=sort(r); x=zeros(100,1); a=zeros(100,2); for n=1:100 i=2*n-1 x(n,1)= sqrt(-2*log(r(i,1)))*cos(2*pi*r(i+1,1)); a(n,2)=x(n,1); a(n,1)=exp(-x(n,1)*x(n,1))/(2*pi); end plot(a(:,1),a(:,2)) Exp_dist.m r=rand(100,1); r=sort(r); x=zeros(100,1); a=zeros(100,2); for n=1:100 x(n,1)=-log(1-r(n,1)); a(n,2)=x(n,1); a(n,1)=exp(-x(n,1)); end plot(a(:,1),a(:,2)) r = rand(1000,1); x = zeros(20,1); for i=1:1000 for j=0:19 ...

Words: 373 - Pages: 2

Free Essay

Jet Copies

...between breakdowns; lost revenue; putting it together). Days to repair With regards to the days to repair component, it was calculated by using the probability distribution of repair times that was given. This was used along with a set of random numbers based on 100 breakdowns a year. Then, a vlookup was used and the probability distribution per day to come up with the days to repair, which varies based on the random number that excel generates. The random number represents the probability of how many days it would take to repair the copier. Interval between breakdowns The formula is x=4√r1 as espoused by Taylor III (2011)where x equals the weeks between machine breakdowns and r1 equals the random number was used . Here the time between breakdowns component was implemented by taking the formula for elapsed time between the various times the copier would break down. Excel automatically calculated the formula once it was put into it and the breakdowns were calculated based on that information. Lost revenue The lost revenue was calculated by taking the median revenue to be earned in a given day and multiplying this by the calculated days to repair. Since the repair time can vary from 1 to 4 days, we generate four random numbers r1, r2, r3 and r4 between 2000 and 8000. Therefore, it was calculated annually by taking the sum of the lost revenue column and dividing it by the cumulative time divided by 52 for 52 weeks in a year. This calculates the annual loss of revenue...

Words: 536 - Pages: 3

Free Essay

Jet Copies Assignment Mat 540

...Jamie Banks, Ernie Moore and Terri Jones were students in State University. They always have to go far to make copies in Klecko’s copy center as there was no copying service nearby where they live by the south gate. One day while James was standing in line at Klecko’s copy center waiting for his turn, he realizes how much time they are wasting just by waiting as most students use the same machine to get copies. James got an idea from other student who was waiting for his turn as James, if he can have a copy center by the Southgate where most of the students live, he easily can make lots of money. James shares his idea with friends Ernie and Terri and they liked the idea. Three of them decided to start the copying business and they would call it JET Copies named after the first letter of their name. They bought a copier similar to the one used at the university for $18,000.00.They enquire about the reliability of the copier and came to know that the university copier broke down frequently and when it did it often require between 1 and 4 days to get it repaired. As Repair time include the time portion during which technicians are working on a machine to effect repair starting from preparation, fault location, fault correction and final check time, it needs time between 1 and 4 days to get it repaired. During this repair time they will always lose Revenue and they become worried. So they decided they might need back up copier to use in these repair time in order...

Words: 820 - Pages: 4

Free Essay

Extra Sensory Perception Test

...will be able to distribute the envelopes back to the volunteers with the according signature. Second Step: a) Identify the component to be repeated. The component to be repeated is to simulate randomly matching people with their signature. b) Explain how you will model the component’s outcome. I will use the numbers 0 through 9 to represent the envelopes. Using a random number generator I will list out 10 random numbers in the order they were received. I’ll then count how many of the random numbers are still in their numerical place. For example, if 0 was the first random number and 9 was the last random number picked then that would be counted as two correct matches. c) Explain how you will combine the components to model a trial. By using the numbers 0-9 to model the envelopes, I will use random number generator to simulate matching the envelopes to the volunteers. I will not count any numbers that are repeated because each number is representative of one specific envelope and cannot be given to two volunteers. After counting how many numbers are in their regular numerical place one trial is complete. After running 20 trials I will take the average number of people matched to their signatures by chance. Anything above this average will be considered...

Words: 820 - Pages: 4

Free Essay

Rng, How Ring Is Changing Games

...frustrated with what I now know is called RNG. I would drive myself crazy as a child asking myself “how is it that he got a shiny Pokémon when I am playing the same game as him?” pseudo-RNG was the answer, but at the time I couldn’t even have fathomed a complex numbering system/algorithm that takes things like, frame rate, date and time, and battery life, and positioning to determine rather or not I would encounter a rare Pokémon or not. Which, in essence, is why I believe that pseudo-RNG should be done away with in game development in substitute for a more decipherable algorithm that rewards those who strategize instead of the luck of the draw. RNG is an acronym for Random Number Generator, which is essentially any algorithm used in computing when an outcome needs to be as random as possible. But it can never truly be random. There will always...

Words: 505 - Pages: 3

Free Essay

Jey Copies

...average number of days that it took for the company to repair the copier if it broke down. The average was between 1 and 4 days to have the machine repaired. For this data, a probability distribution table was developed and programmed into excel. Once the probability table is loaded into excel, they are averaged into a random number range that generates numbers from 0.00 to 1.0. The system then generated an average number days it would take to repair the machine base to the random number generated. 2. Write a brief description of how you implemented the intervals between break downs. When the company looked at the number of intervals between breakdowns, there was no exact numbers to go by to create a probability distribution. What they did instead was to talk to the college who already owned one and go by their data. It was then determined that the average repair days would be between 0 and 6 days. This time the formula took the maximum number of and averaged it with the square root of the random numbers generated again from 0.00 to 1.0. Excel would then come up with the average number of days it would be between machine break down based on these numbers. 3. Write a brief description of how you implemented lost revenue. When looking at the lost revenue, the first thing I did was look at the average revenue that was generated per day. JET averaged between 2000 and 8000 copies per day at $0.10 per copy. What I did in this instance is took the median number which...

Words: 633 - Pages: 3

Premium Essay

Jet Copies

...Jet Copies Case Study 1. In Excel, use a suitable method for generating the number of days needed to repair the copier, when it is out of service, according to the discrete distribution shown. 2. In Excel, use a suitable method for simulating the interval between successive breakdowns, according to the continuous distribution shown. 3. In Excel, use a suitable method for simulating the lost revenue for each day the copier is out of service. 4. Put all of this together to simulate the lost revenue due to copier breakdowns over 1 year to answer the question asked in the case study. 5. In a word processing program, write a brief description/explanation of how you implemented each component of the model. Write 1-2 paragraphs for each component of the model (days-to-repair; interval between breakdowns; lost revenue; putting it together). 6. Answer the question posed in the case study. How confident are you that this answer is a good one? What are the limits of the study? Write at least one paragraph. Answers 1. # of days P(x) Cumulative 1 0.2 0 2 0.45 0.2 3 0.25 0.65 4 0.1 0.9 Q: 2-4. Break Random times b/w Random Repair Random Lost cumulative down # 1 Break (weeks) # 2 Time #3 Revenue time 1 0.78468 5.314929 0.88991 3 2237 $6,711 5.314929 2 0.512227 4.294201 0.831365 2 3244 $6,488 9.60913 3 0.389251 3.743399 0.912647 2 5874 $11,748 13.35253 4 0.998082 5.994243 0.216353 1 3330 $3,330 19.34677 5 0.963834 5.890502 0.415313 4 5487 $21,948...

Words: 1051 - Pages: 5

Free Essay

Basic Statistics

...law of large numbers    2.slide * Statistical concept that larger the sample population (or the number of observations) used in a test, the more accurate the predictions of the behavior of that sample, and smaller the expected deviation in comparisons of outcomes. * As a general principle it means that, in the long run, the average (mean) of a long series of observations may be taken as the best estimate of the 'true value' of a variable. 3.slide * In other words, what is unpredictable and chancy in case of an individual is predictable and uniform in the case of a large group. * This law forms the basis for the expectation of probable-loss upon which insurance premium rates are computed. Also called law of averages. Law of Large Numbers Observe a random variable X very many times. In the long run, the proportion of outcomes taking any value gets close to the probability of that value. The Law of Large Numbers says that the average of the observed values gets close to the mean μ X of X. 4.slide ; Law of Large Numbers for Discrete Random Variables * The Law of Large Numbers, which is a theorem proved about the mathematical model of probability, shows that this model is consistent with the frequency interpretation of probability. 5.slide ; Chebyshev Inequality * To discuss the Law of Large Numbers, we first need an important inequality called the Chebyshev Inequality. * Chebyshev’s Inequality is a formula in probability theory that relates...

Words: 1299 - Pages: 6

Premium Essay

Sdasdasd

...CHAPTER 6 RANDOM VARIABLES PART 1 – Discrete and Continuous Random Variables OBJECTIVE(S): • Students will learn how to use a probability distribution to answer questions about possible values of a random variable. • Students will learn how to calculate the mean and standard deviation of a discrete random variable. • Students will learn how to interpret the mean and standard deviation of a random variable. Random Variable – Probability Distribution - Discrete Random Variable - The probabilities of a probability distribution must satisfy two requirements: a. b. Mean (expected value) of a discrete random variable [pic]= E(X) = = 1. In 2010, there were 1319 games played in the National Hockey League’s regular season. Imagine selecting one of these games at random and then randomly selecting one of the two teams that played in the game. Define the random variable X = number of goals scored by a randomly selected team in a randomly selected game. The table below gives the probability distribution of X: Goals: 0 1 2 3 4 5 6 7 8 9 Probability: 0.061 0.154 0.228 0.229 0.173 0.094 0.041 0.015 0.004 0.001 a. Show that the probability distribution for X is legitimate. b. Make a histogram of the probability distribution. Describe what you see. 0.25 0.20 0.15 0.10 ...

Words: 3495 - Pages: 14

Free Essay

Statistics - Binomial and Poisson Probability

...Objectives 1. Understand the concepts of a random variable and a probability distribution. 2. Be able to distinguish between discrete and continuous random variables. 3. Be able to compute and interpret the expected value, variance, and standard deviation for a discrete random variable. 4. Be able to compute and work with probabilities involving a binomial probability distribution. 5. Be able to compute and work with probabilities involving a Poisson probability distribution. A random variable is a numerical description of the outcome of an experiment. A discrete random variable may assume either a finite number of values or an infinite sequence of values. A continuous random variable may assume any numerical value in an interval or collection of intervals. Discrete Probability Distributions n Random Variables n Discrete Probability Distributions n Expected Value and Variance n Binomial Distribution n Poisson Distribution [pic] A random variable is a numerical description of the outcome of an experiment. A discrete random variable may assume either a finite number of values or an infinite sequence of values. A continuous random variable may assume any numerical value in an interval or collection of intervals. Example: JSL Appliances n Discrete random variable with a finite number of values n Let x = number of TVs sold at the store in one day, where...

Words: 789 - Pages: 4

Free Essay

Qat1 Task 1

...Expected Value Category name Value Frequency Probability Cumulative Probability Random No interval Category 1 $ 22.00 0.02 0.02 0.02 2 Category 2 $ 23.00 0.35 0.35 0.37 37 Category 3 $ 24.00 0.16 0.16 0.53 53 Category 4 $ 25.00 0.44 0.44 0.97 97 Category 5 $ 28.00 0.03 0.03 1 100 Category 6 0 1 100 Total 1 The probability for each cost is shown. The total of probability is 1. We find the cumulative probability to assign range to each category. Each category is represented by a range of random numbers between 1 to 100. To match the probability with random numbers we multiply cumulative probability by 100 So Labor Cost per Unit Random numbers 1 to 2 represents $ 22.00 Random numbers 3 to 37 represents $ 23.00 Random numbers 38 to 53 represents $ 24.00 Random numbers 54 to 97 represents $ 25.00 Random numbers 98 to 100 represents $ 28.00 so if random number is 75 then it is in range 54--97 so labor cost is $ 25 Similarly for Utilities cost Expected Value Category name Value Frequency Probability Cumulative Probability Random No interval Category 1 $ 3.00 0.36 0.36 0.36 36 Category 2 ...

Words: 352 - Pages: 2

Free Essay

Filatoi

...costs (between $5,040 and $6,860) U = rent, utilities, other unavoidable costs = $3,995 What are the monthly variable costs? F = food costs M = number of meals served in month F = $11 x M What are the monthly total costs? L + U + F = L + 3,995 + 11 x M 2 Gentle Lentil’s Monthly Earnings,cont. What are the monthly revenues? R = monthly revenues P = price of meal R = PxM What are the monthly earnings? X = monthly earnings = revenues – costs = P x M – ( L + 3,995 + 11 x M ) = (P – 11 ) x M – L – 3,995 Which of these quantities are random variables? P M L X = = = = price of prix fixe meal number of meals sold labor cost monthly earnings 3 (X is a function of random variables, so it is a random variable) Assumptions Regarding the Behavior of the Random Variables M P = number of meals sold per month We assume that M obeys a Normal distribution with µ = 3,000 and σ = 1,000 = price of the prix fixe meal We assume that P obeys the following discrete probability distribution Scenario Very healthy market Healthy market Not so healthy market Unhealthy market Price of Prix Fixe Meal $20.00 $18.50 $16.50 $15.00 Probability 0.25 0.35 0.30 0.10 L = labor costs per month We assume that L obeys a uniform distribution with a minimum of $5,040 and maximum of $6,860 4 The Behavior of the Random Variables, cont. X = earnings per month We do not know the distribution of X . We assume, however, that X = (P – 11 ) x M – L – 3,995 Always...

Words: 3675 - Pages: 15