question archive (a) Briefly describe ASCII and Unicode and draw attention to any relationship between them
Subject:Computer SciencePrice:9.82 Bought4
(a) Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A novice programmer has written the following copying program which is intended simply to read characters from data one at a time and to wr them out. public class Copying { public static void main(String[] args) { int ch; while ((ch = System.in.read()) != -1) { System.out.printf("%c", (char) ch); } } } (c) Unfortunately this program causes a compile-time error. Explain what the problem is and modify the code so that the program compiles. [3 marks] (d) The amended program correctly copies data in simple cases but is found to fail when exotic characters are encountered. Why is this? [3 marks] (e) By exploiting a Reader, rewrite the program so that exotic characters no longer cause any problems.
(a) Outline the use of enum in Java programs and explain any similarities to and any differences from a Java class. [6 marks] The following fragment of code shows an early attempt to write and test a Java program to simulate the paper-scissors-stone game. In the method main() each of the identifiers a and b is assigned one of the items, paper, scissors or stone and the printf() method then says whether the first beats, draws with or loses against the second. [The rule is that paper beats stone, scissors beat paper and stone beats scissors.] public class Game { public static void main(String[] args) { Item a = allocateItem(); Item b = allocateItem(); int res = a.versus(b); System.out.printf("%s %s %s%n", a, res>0 ? "beats" : res==0 ? "draws with" : "loses against", b); } private static Item allocateItem() { ... } } enum Item { PAPER... The three possibilities PAPER, SCISSORS and STONE are declared in enum Item along with a constructor, the method versus() and any necessary additional data fields. (b) Using the method Math.random() or otherwise, provide a body for the method allocateItem() such that the method returns an Item PAPER, SCISSORS or STONE equiprobably. [6 marks] (c) Complete the enum Item so that the statements in the method main() operate as intended.(a) Wr a function in a programming language of your choice that takes a (32-bit IEEE format) float and returns a float with the property that: given zero, infinity or a positive normalised floating-point number then its result is the smallest normalised floating-point number (or infinity if this is not possible) greater than its argument. You may assume functions f2irep and irep2f which map between a float and the same bit pattern held in a 32-bit integer. [6 marks] (b) Briefly explain how this routine can be extended also to deal with negative floating-point values, remembering that the result should always be greater than the argument. [2 marks] (c) Define the notions of rounding error and truncation error of a floating-point computation involving a parameter h that mathematically should tend to zero. [2 marks] (d) Given a function f implementing a differentiable function that takes a floatingpoint argument and gives a floating-point result, a programmer implements a function f 0 (x) ≈ f(x + h) − f(x − h) 2h to compute its derivative. Using a Taylor expansion or otherwise, estimate how rounding and truncation errors depend on h. You may assume that all mathematical derivatives of f are within an order of magnitude of 1.0. [8 marks] (e) Suggest a good value for h given a double-precision floating-point format that represents approximately 15 significant decimal figures.
What to submit:
For this section of the project, you will be submitting
? a .Rmd file (LastName_FirstName.Rmd) that will contain all the code and written answers for the steps
mentioned below.
? a knitted file (LastName_FirstName.pdf ) from the .Rmd file.
Details:
The R portion of the project will test your ability to wrangle, graph, analyze, and understand a complicated, real-world
data set using R. This portion of the project utilizes the tidy version of the data (LastName_FirstName.csv) you
generated during the SQL portion of the project.
In a .Rmd file, write the code and include written answers to the following steps:
Qus 1 - [50 PTS]
1a. Read the data. Tell R to treat admission_type_id, discharge_disposition_id, and admission_source_id as categorical.
1b. Clean the variables `diag_1`, `diag_2`, and `diag_3` using the code you wrote in the Lesson 11 Homework. You
should end up with 3 new variables, `diagnosis1`, `diagnosis2`, and `diagnosis3`, containing human-readable
interpretations of the ICD-9 billing codes.
1c. Remove the old variables `diag_1`, `diag_2`, `diag_3`. If you created any intermediate variables (such as
`injury_cause1`), remove those also.
1d. Use code to determine which columns have no variability (i.e., all rows contain the same value). Print the names of
the columns, and remove those columns.
Q]
2a. Count the number of missing values that are denoted by NA. Count the number of missing values that are denoted
by "?". (In a factor/character variable, R will not automatically ignore rows containing "?".) Which column has the most
missing values?
2b. Replace the "?" in the `race` column with NAs. Then use mode imputation to impute the NAs in the data. (Leave the
"?" in other columns alone.)
Setup and Explore
1. Calculate mean IsCorrect by gender and premiumpupil. comment
2. Make a variable for the absolute deviation between correct answer and answer value. histogram + comment
3. Add answer date into the merged table (from answers metadata). don't forget to check for typos, outliers, etc.
4. Make an age variable using DOB and and answer date. histogram + comment
5. Replicate [this overlaid histogram](https://www.r-graph-gallery.com/histogram_several_group.html) for distribution of age across genders. comment
6. Make bins for the age variable and find mean of IsCorrect for each bin. Comment
7. Scatter plot: x = age, y = mean of IsCorrect. color based on gender or premiumpupil (either is fine)
Model Building
1. Comment on what relevant features/variables you can get using the metadata tables and how
2. Add some of those variables into your merged dataset
3. Build a linear probability model for IsCorrect
4. Build a logistic probability model
5. Make a grid for lambda
6. Build Ridge for each lambda and find the best using CV
7. Build Lasso for each lambda and find the best using CV
8. Which variables your Lasso models tend to choose?
9. Build an elasticnet model (similar code just alpha = 0.5) and find the best lambda using CV
* Check the review session folder and ISLR book for sample code
Test and Compare
1. Build a test dataset using test_private_answers_task_1.csv
* you can merge the same characteristics from the metadata tables and make test_merged have the same variables as train_merged
2. Calculate out of sample MSE for each of the models you have built
3. Report them in a table and comment on their performance
https://eedi.com/projects/neurips-education-challenge
The data can be downloaded here at Download Eedi Dataset.
test_private_answers_task_1.csv
Why is my program returning 0 for the area of a triangle? public class GeometricObjects{ private String color = " white "; private boolean filled; private java.util.Date dateCreated; public GeometricObjects0 { dateCreated = new java.util.Date0; public GeometricObjects(String color, boolean filled) dateCreated = new java.util.Date 0: this.color = color; this.filled = filled; public String getColor00 return color; public void setColor(String color) { this.color = color public boolean isFilled 0 { return filled;public void setColor(String color) { this.color = color public boolean isFilled0 { return filled; public void setFilled(boolean filled) { this.filled = filled; public java.util.Date getDateCreated0 { return dateCreated; public String toString0 return "Created on" + dateCreated+ "n color"color+"and filled" Below is the class containing the formula for the area of a triangle: import java.lang.Math; public class Triangle extends GeometricObjects { private double side1, side2, side3 1.0; public Trianale0Below is the class containing the formula for the area of a triangle import java.lang.Math; public class Triangle extends GeometricObjects{ private double side1, side2, side3 = 1.0; public Triangle0 { public Triangle(double side1, double side2, double side3) { this.side1 = side1; this.side2 side2; this.side3 = side3; public double setSide10 { return side1; public double setSide20 return side2; public double setSide30 return side3;public double setSide10 { return side1; public double setSide20 return side2; public double setSide30 return side3; public void getSide1(double side1) { this.side1 = side1; public void getSide2(double side2){ this.side2 = side2; public void getSide3(double side3) { this.side3 = side3; public double getPerimeter0 return side1 + side2 +side3;And finally, beloW Is my code for the test class: import java.util.Scanne public class TestGeometricObjects{ private double side1, side2, side3, length, width = 1.0; public static void main(String | args){ Scanner input = new Scanner(System.in); System.out.println("Enter three sides of the triangle: "); double side1 = input.nextDouble0: double side2 = input.nextDouble0: double side3 = input.nextDouble0: System.out.println("'Enter the color of the triangle: "); String triangleColor = input.next0; System.out.printin("ls the triangle filled? Reply with True or False' "); boolean triangleFilled = inputnextBoolean0; Triangle triangle = new Triangle(side1, side2, side3); triangle.setFilled(triangleFilled) triangle.setColor(triangleColor); System.out.println("The triangle's 3 sides are " +side1"," + side2+ ". side3): Cuctom.out nrintln/"Tha trianalo'c oroa ic" trianals cotAroa)):
Purchased 4 times