22library

22library - 2.2 Libraries and Clients Introduction to...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
2.2 Libraries and Clients Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008 · January 26, 2009 9:53 tt
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Libraries Library. A module whose methods are primarily intended for use by many other programs. Client. Program that calls a library. API. Contract between client and implementation. Implementation. Program that implements the methods in an API.
Background image of page 2
Random Numbers Jon von Neumann (left), ENIAC (right) The generation of random numbers is far too important to leave to chance. Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Standard Random Standard random. Our library to generate pseudo-random numbers.
Background image of page 4
5 public class StdRandom { // between a and b public static double uniform ( double a , double b ) { return a + Math . random () * ( b - a ); } // between 0 and N-1 public static int uniform ( int N ) { return ( int ) ( Math . random () * N ); } // true with probability p public static boolean bernoulli ( double p ) { return Math . random () < p ; } // gaussian with mean = 0, stddev = 1 public static double gaussian ()
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

22library - 2.2 Libraries and Clients Introduction to...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online