SSJ User s Guide. Package stat Tools for Collecting Statistics. Version: December 21, 2006

Similar documents
SSJ User s Guide. Package simevents Simulation Clock and Event List Management

SSJ User s Guide. Package simevents Simulation Clock and Event List Management

SYSC Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

CMSC 132: Object-Oriented Programming II

CHAPTER 6: CREATIONAL DESIGN PATTERNS

Configuration Provider: A Pattern for Configuring Threaded Applications

Design Patterns: Part 2

Object-Oriented Design

Designing and Writing a Program. Divide and Conquer! The Design-Code-Debug Cycle. Documentation is Code. Pair Programming 3/8/2012

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

SSJ User s Guide. Package rng Random Number Generators. Version: December 17, 2014

Lecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting

DESIGNING, CODING, AND DOCUMENTING

The GoF Design Patterns Reference

6.092 Introduction to Software Engineering in Java January (IAP) 2009

Using a Declarative Chain of Responsibility Pattern to Write Robust, Self- Correcting Distributed Applications

CSCI 1301: Introduction to Computing and Programming

6.170 Lecture 15 Design Patterns

CS 349 / SE 382 Design Patterns. Professor Michael Terry January 21, 2009

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Part 1: Group Brainstorm (NO computers during this time) Part 2: Submit Individual Brainstorm (You can now use a computer)

Towards a Java Framework for Knowledge Representation and Inference

Mat 2170 Week 9. Spring Mat 2170 Week 9. Objects and Classes. Week 9. Review. Random. Overloading. Craps. Clients. Packages. Randomness.

Prototype. Design Pattern. from: Design Patterns (Gamma, Helm, Johnson, and Vlissides) p Justin Hendrix CSPP Winter 2010

Patterns for polymorphic operations

JOURNAL OF OBJECT TECHNOLOGY

SSJ User s Guide. Package randvar Generating Non-Uniform Random Numbers

C++ INTERFACE CLASSES STRENGTHENING ENCAPSULATION

CMSC 132: Object-Oriented Programming II

Student Responsibilities. Mat 2170 Week 9. Notes About Using Methods. Recall: Writing Methods. Chapter Six: Objects and Classes

25.1 Introduction Façade Design Pattern Identification Problem Structure Participants...

More on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson

KWIC Implemented with Event Based Architectural Style

Python Class Definition. Java Class Definition. Python Class Use public class Student { Java Class Use. Python Class Definition 10/6/2016

Tuesday, October 4. Announcements

2/17/04 Doc 8 Adapter & Strategy slide # 1

Microthread. An Object Behavioral Pattern for Managing Object Execution. 1.0 Intent. 2.0 Also Known As. 3.0 Classification. 4.0 Motivation/Example

CS445 Week 9: Lecture

Object-oriented basics. Object Class vs object Inheritance Overloading Interface

A Java Execution Simulator

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

Introduction to Object-Oriented Programming

Student Performance Q&A:

Chapter 6 Introduction to Defining Classes

Lecture 13: Design Patterns

Introducing Design Patterns

York University AK/ITEC INTRODUCTION TO DATA STRUCTURES. Final Sample II. Examiner: S. Chen Duration: Three hours

Pattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository

TO DO: Create a new class which adds statistics to the dice. NOTE: Don t forget to run regression tests

Objects and Classes Lecture 2

7. C++ Class and Object

Object-Oriented Design

Check out how to use the random number generator (introduced in section 4.11 of the text) to get a number between 1 and 6 to create the simulation.

Data Structures. BSc in Computer Science University of New York, Tirana. Assoc. Prof. Marenglen Biba 1-1

Design Patterns. Definition of a Design Pattern

Behavioral Design Patterns Used in Data Structures Implementation

Frameworks and Testing

INCORPORATING ADVANCED PROGRAMMING TECHNIQUES IN THE COMPUTER INFORMATION SYSTEMS CURRICULUM

Using Classes and Objects. Chapter

CS 1316 Exam 1 Summer 2009

Inheritance and Interfaces

Chapter 14 Abstract Classes and Interfaces

Copyright 2007 Pearson Addison-Wesley Copyright 2018 Aiman Hanna All rights reserved

An Introduction to Patterns

Idioms for Building Software Frameworks in AspectJ

Evictor. Prashant Jain Siemens AG, Corporate Technology Munich, Germany

26.1 Introduction Programming Preliminaries... 2

Chapter 3 Classes. Activity The class as a file drawer of methods. Activity Referencing static methods

Bugsquashing: Command - Pattern. Andreas Fetzer

Types and Expressions. Chapter 3

ENGLISH Page 1 of 6. EXAM IN COURSE TDT4100 Object-Oriented Programming / IT1104 Programming, Advanced Course. Tuesday 29. Mai

Outline. Logistics. Logistics. Principles of Software (CSCI 2600) Spring Logistics csci2600/

are most specifically concerned with

CS112 Lecture: Reuse, Packages, Patterns

Design Patterns Design patterns advantages:

Lecture: Simulation. of Manufacturing Systems. Sivakumar AI. Simulation. SMA6304 M2 ---Factory Planning and scheduling. Simulation - A Predictive Tool

ADAPTER. Topics. Presented By: Mallampati Bhava Chaitanya

Inheritance & Polymorphism Recap. Inheritance & Polymorphism 1

Subclassing for ADTs Implementation

Tackling Design Patterns Chapter 3: Template Method design pattern and Public Inheritance. 3.1 Introduction... 2

Parallel Task Executor in Java

2. The object-oriented paradigm!

Language-Shifting Objects from Java to Smalltalk

More About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000

Bluman & Mayer, Elementary Statistics, A Step by Step Approach, Canadian Edition

CPS122 Lecture: Design Patterns Last revised March 7, 2017

STATS PAD USER MANUAL

CPS122 Lecture: Design Patterns Last revised March 20, 2012

CSE 403: Software Engineering, Winter courses.cs.washington.edu/courses/cse403/16wi/ Design Patterns. Emina Torlak

Final Examination Semester 3 / Year 2012

Lab 9: Creating a Reusable Class

Coordinator. Example. Prashant Jain Corporate Technology, Siemens AG Munich, Germany

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. Object Oriented Programming

Design Patterns 2. Page 1. Software Requirements and Design CITS 4401 Lecture 10. Proxy Pattern: Motivation. Proxy Pattern.

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

Patterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides

Inheritance. Lecture 11 COP 3252 Summer May 25, 2017

Comp Intermediate Programming EXAM #1 February 16, 2004 Rice University - Instructors: Cox & Nguyen

CSE P 501 Compilers. Implementing ASTs (in Java) Hal Perkins Winter /22/ Hal Perkins & UW CSE H-1

Transcription:

SSJ User s Guide Package stat Tools for Collecting Statistics Version: December 21, 2006

CONTENTS 1 Contents Overview........................................ 2 StatProbe........................................ 3 Tally........................................... 5 TallyStore........................................ 7

CONTENTS 2 Overview This package provides elementary tools for collecting statistics and computing confidence intervals. The base class StatProbe implements common methods needed for all probes. Its extension class Tally collects data as a sequence of observations X 1, X 2,..., and computes sample averages, sample standard deviations and confidence intervals based on the normality assumption. The class TallyStore is similar, but it also stores the individual observations in a list implemented as a DoubleArrayList, a class imported from the COLT library. This permits one to compute more quantities and to use the methods provided by COLT for computing descriptive statistics. The class Accumulate, in package simevents, computes integrals and averages with respect to time. This class is in package simevents because its operation depends on the simulation clock. All classes in this package extend the Observable class of Java, which provides the basic support for the observer design pattern, well-known in software engineering [1]. This pattern facilitates the separation of data generation (by the simulation program) from data processing (for statistical reports and displays). This can be very helpful in particular in large simulation programs or libraries, where different objects may need to process the same data in different ways. An Observable object in Java maintains a list of registered Observer objects, and broadcasts information to all its registered observers whenever appropriate. For the StatProbe class, this happens whenever a new observation is given to the probe. Any object that implements the interface Observer can register as an observer.

3 StatProbe The objects of this class are statistical probes or collectors, which are elementary devices for collecting statistics. Each probe collects statistics on a given variable. The subclasses Tally, TallyStore, and Accumulate (from package simevents) implement two specific types of probes, for the case of successive observations X 1, X 2, X 3,..., and for the case of a variable whose value evolves in time, respectively. StatProbe extends Observable from package java.util, allowing statistical probes to register Observer objects. When a probe is updated, i.e., receives a new statistical observation, it broadcasts this new data to all registered observers. The broadcasting of observations to registered observers can be turned ON or OFF at any time. It is initially OFF by default and should stay OFF when there are no registered observers, to avoid unnecessary overhead. The data collection by the statistical probe itself can also be turned ON or OFF. By default, it is initially ON. We can turn it OFF, for example, if we want to use the statistical probe only to pass data to the observers, and do not need it to store any information. package umontreal.iro.lecuyer.stat; public abstract class StatProbe extends Observable Methods abstract public void init(); Initializes the statistical collector. public void setname (String name) Sets the name of this statistical collector to name. public String getname() Returns the name associated with this probe, or null if no name was specified upon construction. public double min() Returns the smallest value taken by the variable since the last initialization of this probe. public double max() Returns the largest value taken by the variable since the last initialization of this probe. public double sum() Returns the sum cumulated so far for this probe. The meaning of this sum depends on the subclass (e.g., Tally or Accumulate). abstract public double average(); Returns the average for this collector.

StatProbe 4 abstract public String report(); Returns a string containing a report for this statistical collector. public void setbroadcasting (boolean b) Instructs the probe to turn its broadcasting ON or OFF. The default value is OFF. Warning: To avoid useless overhead and performance degradation, broadcasting should never be turned ON when there are no registered observers. public void setcollecting (boolean b) Turns ON or OFF the statistical collection of statistical observations. The default value is ON. When statistical collection is turned OFF, observations added to the probe are passed to the registered observers if broadcasting is turned ON, but are not counted as observations by the probe itself.

5 Tally A subclass of StatProbe. This type of statistical collector takes a sequence of real-valued observations X 1, X 2, X 3,... and can return the average, the variance, a confidence interval for the theoretical mean, etc. Each call to add provides a new observation. When the broadcasting to observers is activated, the method add will also pass this new information to its registered observers. This type of collector does not memorize the individual observations, but only their number, sum, sum of squares, maximum, and minimum. The subclass TallyStore offers a collector that memorizes the observations. package umontreal.iro.lecuyer.stat; public class Tally extends StatProbe implements Cloneable Constructors public Tally() Constructs a new Tally statistical probe. public Tally (String name) Constructs a new Tally statistical probe with name name. Methods public void add (double x) Gives a new observation x to the statistical collector. If broadcasting to observers is activated for this object, this method will also transmit the new information to the registered observers by invoking the methods setchanged and notifyobservers (new Double (x)) inherited from Observable. public int numberobs() Returns the number of observations given to this probe since its last initialization. public double variance() Returns the variance of the observations since the last initialization. public double standarddeviation() Returns the standard deviation of the observations since the last initialization. public void confidenceintervalstudent (double level, double[] centerandradius) Returns, in elements 0 and 1 of the array object centerandradius[], the center and halflength (radius) of a confidence interval on the true mean of the random variable X, with

Tally 6 confidence level level, assuming that the observations given to this collector are independent and identically distributed (i.i.d.) copies of X, and that X has the normal distribution. This confidence interval is computed based on the statistic T = X n µ S n,x / n where n is the number of observations given to this collector since its last initialization, X n = average() is the average of these observations, S n,x = standarddeviation() is the empirical standard deviation. Under the assumption that the observations of X are i.i.d. and normally distributed, T has the Student distribution with n 1 degrees of freedom. The confidence interval given by this method is valid only if this assumption is approximately verified, or if n is large enough so that X n is approximately normally distributed. public String formatconfidenceintervalstudent (double level, int d) Similar to confidenceintervalstudent, but returns the confidence interval in a formatted string of the form 95% confidence interval for mean: (32.431, 32.487), using d decimal digits of accuracy. public String formatcistudent (double level, int d) An alias for formatconfidenceintervalstudent. public String formatcistudent (double level) An alias for formatconfidenceintervalstudent. public String report() Returns a formatted string that contains a report on this probe. public String reportandconfidenceintervalstudent (double level, int d) Returns a formatted string that contains a report on this probe (as in report), followed by a confidence interval (as in formatconfidenceintervalstudent), using d decimal digits of accuracy. public String reportandconfidenceintervalstudent (double level) Same as reportandconfidenceintervalstudent(level, 3). public String reportandcistudent (double level, int d) An alias for reportandconfidenceintervalstudent. public String reportandcistudent (double level) An alias for reportandconfidenceintervalstudent. public Object clone() Clone this object.

7 TallyStore This class is a variant of Tally, but for which the individual observations are stored in a list implemented as a DoubleArrayList. The class DoubleArrayList is imported from the COLT library and provides an efficient way of storing and manipulating a list of real-valued numbers in a dynamic array. The DoubleArrayList object used to store the values can be either passed to the constructor or created by the constructor, and can be accessed via the getarray method. The same counters as in Tally are maintained and are used by the inherited methods. To compute quantities not supported by the Tally methods, and/or to use methods provided by the COLT package, one must access the list. Never add or remove observations directly on the DoubleArrayList object, because this would put the counters of the TallyStore object in an inconsistent state. There are two potential reasons for using a TallyStore object instead of directly using a DoubleArrayList object: (a) it is an Observable object and (b) it maintains a few additional counters that may speed up some operations such as computing the average. package umontreal.iro.lecuyer.stat; public class TallyStore extends Tally Constructors public TallyStore() Construct a new TallyStore statistical probe. public TallyStore (int initialcapacity) Construct a new TallyStore statistical probe with given initial capacity for its associated array. public TallyStore (DoubleArrayList a) Construct a new TallyStore statistical probe with given associated array. This array must be empty. Methods public DoubleArrayList getarray() Returns the DoubleArrayList object that contains the observations for this probe. public double covariance (TallyStore t2) Returns the sample covariance of the observations contained in this tally, and the other tally t2. Both tallies must have the same number of observations. public Object clone() Clone this object.

REFERENCES 8 References [1] E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading, Mass., second edition, 1998.