import java.util.Scanner;
public class EventFrequency {
/**
* main method:
* ask the user for the average number of events per time interval
* (lambda) and the number of time intervals to observe
* draw a horizontal and vertical histogram of the number of heads
*/
public static void main(String[] args) {
// set up to get user input
Scanner scan = new Scanner(System.in);
// ask user for the average number of events per time interval
System.out.println("What average number of events per time interval do you want?");
int lambda = scan.nextInt();
// ask user for the number of time intervals to observe
System.out.println("How many time intervals do you want to observe?");
int times = scan.nextInt();
// instantiate a Poisson object named myDist with average number of events
Poisson myDist = new Poisson(lambda);
// step 1:
// declare an int array named "counts" to count coin flip occurences
// make its size one larger than 3 * lambda
// step 2:
// initialize all of the values in the counts array to 0
// step 3:
// count the number of events occurring in each time interval observed
// step 4:
// print out the estimated probabilities of zero events and lambda events
// step 5:
// instantiate an object of the Histogram class with
// the array to be drawn, the indices of valid data,
// and the maximum length of the bars in the histogram
//
// call its draw methods to draw the two histograms
}
}
prog.java 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
Ezzaral commented: Indeed. +13
NormR1 563 Posting Sage Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.