subject

Now it’s time to generate some weather! Imagine you are a farmer. Does knowing the number of wet or dry days tell the whole story? Would the pattern
be important? If so, what pattern would you like to see? How would you measure this pattern?

The transition probabilities that we have used for Norman, OK are based on historical data, and you might
use them to get a sense for the likelihood certain weather phenomena in the near future. For instance, a
farmer might want to run many, many simulations to get an idea of the likelihood of going 20 or more days
without rain, and the results might influence the crops that he or she plants.

Just as we can base the transition probabilities on historical data, we can also base them on future predictions.
For instance, the National Center for Atmospheric Research (NCAR) simulates weather as it responds to assumptions
about how various “forcings” (e. g, greenhouse gasses) will evolve in the future. Typically, these models couple
an atmospheric model with an ocean model, but more recent versions, the so-called Earth system models, incorporate
more components including land use, sea and land ice, etc. The models can be used to predict future precipitation
patterns and transition probabilities that are based on these forecasts, rather than past data.

The weather generator methods you will be writing for this assignment will:

predict future precipitation pattern for one month: oneMonthGenerator
find the number of wet or dry days in a given month’s forecast: numberOfWetDryDays
find the longest wet or dry spell in a given month’s forecast:

Future transition probability table as a 2D array

The oneMonthGenerator method receives as arguments the transition probability tables (dry to wet, and wet to wet) as 2D arrays.
Each table row corresponds to a location (longitude, latitude) in the USA and contains the transition probabilities
for each month of the year.

Longitude Latitude January February March April May June July August September October November December
-97.58 26.02 0.76 0.75 0.77 0.74 0.80 0.86 0.94 0.97 0.89 0.77 0.74 0.77

Following are the methods to be completed in WeatherGenerator. java:

public class WeatherGenerator {

/* Given a location (longitude, latitude) in the USA and a month of the year, the method
* returns the forecast for the month based on the drywet and wetwet transition
* probabilities tables.
*
* month will be a value between 2 and 13: 2 corresponds to January, 3 corresponds to February
* and so on. These are the column indexes of each month in the transition probabilities tables.
*
* The first day of the month has a 50% chance to be a wet day, 0-0.49 (wet), 0.50-0.99 (dry)
*
* Use StdRandom. uniform() to generate a real number uniformly in [0,1)
*/
int[] oneMonthGenerator(double longitute, double latitude, int month, double[][] drywet, double[][] wetwet)

// Returns the longest number of consecutive mode (WET or DRY) days in forecast.
int numberOfWetDryDays (int[] forecast, int mode)

/*
* Analyzes the forecast array and returns the longest number of
* consecutive mode (which can be WET or DRY) days in forecast.
*/
int (int[] forecast, int mode)
}

Use the main method as a driver to test your methods. To generate the weather for location at longitude -98.76 and latitude 26.70 for the month of February do:

java WeatherGenerator111 -98.76 26.70 3

public static void main (String[] args) {

int numberOfRows = 4001; // Total number of locations
int numberOfColumns = 14; // Total number of 14 columns in file
// File format: longitude, latitude, 12 months of transition probabilities

// Allocate and populate arrays that hold the transition probabilities
double[][] drywet = new double[numberOfRows][numberOfColumn s];
double[][] wetwet = new double[numberOfRows][numberOfColumn s];
(drywet, wetwet, numberOfRows);

/*** WRITE YOUR CODE BELLOW THIS LINE. DO NOT erase any of the lines above. ***/

// Read command line inputs
double longitute = Double. parseDouble(args[0]);
double latitude = Double. parseDouble(args[1]);
int month = Integer. parseInt(args[2]);

int[] forecast = oneMonthGenerator(longitute, latitude, month, drywet, wetwet);
int drySpell = lengthOfLongestSpell(forecast, DRY);
int wetSpell = lengthOfLongestSpell(forecast, WET);

StdOut. println("There are " + forecast. length + " days in the forecast for month " + month);
StdOut. println(drySpell + " days of dry spell.");

for ( int i = 0; i < forecast. length; i++ ) {

// This is the ternary operator. (conditional) ? executed if true : executed if false
String weather = (forecast[i] == WET) ? "Wet" : "Dry";
StdOut. println("Day " + (i+1) + " is forecasted to be " + weather);
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
Problems: 1. using textbooks, reference books, and internet as your source of research, draw the following microprocessor microarchitectures i. intel 8086 ii. motorola 68000 i atmel atmega32 iv. mips single cycle v. arm cortex-m3 write an hdl module for a hexadecimal seven-segment display decoder. the input is 4-bit binary representing a hex number (0-f), and the output is 8-bit seven segment display bits (a-h). thus, the decoder must handle the digits 10 - 15 to display a-f respectively, in addition to 0-9 numbers. 2. design a 4-bit left and right rotator (both outputs). first sketch schematic diagrams of your design. then implement your design using hdl coding. 3. 4. design a modified priority encoder that receives an 8-bit input, a7: 0 and produces a 3-bit output, y2o. y indicates the most significant bit of the input that is true. y should be 0 if none of the inputs are true. give a simplified boolean equation, sketch a schematic, and write an hdl code. 5.write an 8: 1 multiplexer module called mux8 with selection inputs s, data input d, and data output y. data input (d) and data output (v) are 32-bit wide
Answers: 3
question
Computers and Technology, 22.06.2019 09:00
Howard is designing a chair swing ride. the swing ropes are 5 meters long, and in full swing they tilt in an angle of 29° outside chairs to be 2.75 m above the ground in full swing.
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Jake really works well with numbers and is skilled with computers but doesn't work well with others. which of the jobs discussed in this unit might be best for jake? why?
Answers: 3
question
Computers and Technology, 24.06.2019 10:20
Multiple choice project create a program with two multiple choice questions. 1. users have two attempts only, show attempt number each time. hint: while loop with break control. (20%) 2. only one correct answer for each question, use switch case for each question. (20%) 3. show total score after the two questions are answered. hint: . (20%) 4. user have options to answer the two questions again if first attempt score is not 100%. hint: if statment. (20%) 5. use string method .toupper() to allow users to enter with lowercase or uppercase letters. (20%) 1. where is the capital of the state of florida? a. orlando b. tallahassee c. miami d. tampa b 2. where is walt disney world park located in florida? a. orlando b. tallahassee c. miami d. tampa a
Answers: 1
You know the right answer?
Now it’s time to generate some weather! Imagine you are a farmer. Does knowing the number of wet or...
Questions
question
Mathematics, 04.02.2022 14:00
question
Mathematics, 04.02.2022 14:00
Questions on the website: 13722363