Mathcad includes a function, hist, for computing frequency distributions for histograms:
Returns a vector representing the frequencies with which values in A fall in the intervals represented by the int vector. The elements in both int and A must be real. In addition, the elements of int must b~ in ascending order. The resulting vector is one element shorter than int.
Mathcad interprets int as a set of points defining a sequence of intervals in a histogram. The values in int must should be in ascending order. The result of this function is a vector f, in which Ii is the number of values in A satisfying the condition:
Mathcad ignores data points less than the first value in int or greater than the last value in int. Figure 14-2 shows how to use histograms in Mathcad.
Mathcad comes with a number of functions for generating random numbers having a variety of probability distributions. The functional forms of the distributions associated with the following functions are given in the section “Probability distributions” on page 281.
Each time you recalculate an equation containing one of these functions, Mathcad generates new random numbers. To force Mathcad to generate new random numbers, click on the equation containing the function and choose Calculate from the Math menu. Figure 14-3 shows an example of how to use Mathcad’s random number generator. Figure 14-4 shows how to generate a large vector of random numbers having a specified distribution.
These functions have a “seed value” associated with them. Each time you reset the seed, Mathcad generates new random numbers based on that seed. A given seed value will always generate the same sequence of random numbers. Choosing Calculate from the Math menu advances Mathcad along this random number sequence. Changing the seed value, however, advances Mathcad along an altogether different random number sequence.
To change the seed value, choose Options from the Math menu and change the value of “seed” on the Built-In Variables tab. Be sure to supply an integer.
To reset Mathcad’s random number generator without changing the seed value, choose Options from the Math menu, click on the Built-In Variables tab, and click “OK” to accept the current seed. Then click on the equation containing the random number generating function and choose Calculate from the Math menu. Since the randomizer has been reset, Mathcad generates the same random numbers it would generate if you restarted Mathcad.
If you want to check a test case several times with the same random numbers, reset the random number generator between calculations as described above.
To see a new set of random numbers, change the seed value as described above. This causes Mathcad to generate a different set of random numbers from what you see when you start Mathcad. Each time you want to reset Mathcad to regenerate these random numbers, reset the seed as described above. To see a different set of random numbers, change the seed value.