Home /
Expert Answers /
Computer Science /
solve-for-java-first-assume-that-your-program-stores-the-wind-speed-data-in-a-data-structure-pa564
(Solved):
solve for java
First assume that your program stores the wind speed data in a data structure ...
solve for java
First assume that your program stores the wind speed data in a data structure which we'll call windValues. It will consist of N items, where N is the number of valid wind speeds obtained from the input file. You should define windValues as a data structure capable of storing 9000 floating point values.
Next, define a data structure to the store the range of values for each interval of the histogram that your program will construct. We will call each element in that data structure a Bin. Each Bin will store the interval (that is width or range) of an element of the histogram, the count of wind speeds that belong in that Bin's interval in the histogram, and, will eventually store the processed cumulative probability for each interval (in each Bin) in the histogram. An example of the data structure that you might use to store the information for each interval in the histogram is illustrated at the top of the next page. class Bin \{ Float interval; Integer count; Float cumProbability; \} Finally define a data structure to hold the data for each interval in the histogram your program will construct (each set of data for an interval will be in a Bin in your data structure) and name it: histogram.
So what is the reasonable width of an interval for (wind-speed) 2 values given that the values can range from 0mph to 10000mph ? This can vary, and should be one of the values users input to your program when you run it - store that value in a variable named: userDefinedInterval. For now, let's assume that the width of the interval for each Bin in the histogram will range between 50 and 100 (Your program should make sure that a user enters a number between 50 and 100 inclusive when it asks them the width of each interval they would like the program to use to compute the cumulative probability density. If the user enters a number out of that interval, your program should print out an error and re-prompt them until they enter a value in that interval). That means, given our range of possible wind speeds-squared, we will need between 100 and 200 bins (for example, 10000/50 =200 ). So, create your histogram data structure as follows Bin [] histogram = new Bin [200];
Based on the given information, we can define the windValues data structure as an array of 9000 floating point values.The Bin data structure should include the following elements:Float interval: the range of values for the intervalInteger count: the number of wind speeds that belong in that interval of the histogramFloat cumprobability: the processed cumulative probability for each interval in the histogram