22library

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

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

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

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

View Full Document
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.
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.

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

View Full Document
4 Standard Random Standard random. Our library to generate pseudo-random numbers.
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 ()

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/10/2012 for the course CSE 1002 taught by Professor Marico during the Spring '08 term at FIT.

### 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
Ask a homework question - tutors are online