Java Reference
In-Depth Information
To illustrate the different distributions, I generated 10,000 numbers using nextRandom() first
and then using nextGaussian() . The code for this is in Random4.java (not shown here) and
is a combination of the previous programs with code to print the results into files. I then plot-
ted histograms using the R statistics package (see http://www.r-project.org ; the R script used
to generate the graph is in javasrc under src/main/resources ). The results are shown in Fig-
ure 5-1 .
Figure 5-1. Flat (left) and Gaussian (right) distributions
See Also
The javadoc documentation for java.util.Random , and the warning in Introduction about
pseudorandomness versus real randomness.
For cryptographic use, see class java.security.SecureRandom , which provides crypto-
graphically strong pseudorandom number generators (PRNG).
Calculating Trigonometric Functions
Problem
You need to compute sine, cosine, and other trigonometric functions.
Search WWH ::




Custom Search