Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class H4_Q3 { public static void main(String args[]) { //Part a double [] values; //Part b double sum = 0; double sample_average = 0;
public class H4_Q3 { public static void main(String args[]) { //Part a double[] values; //Part b double sum = 0; double sample_average = 0; double sample_variance = 0; //Add code to implement the formula given in part b. here System.out.println("Sample Variance (Part b formula): "+ sample_variance); //Part c //Add code to implement the formula given in part c. here double sum_squared = 0; double sum_values=0; System.out.println("Sample Variance (Part c formula): "+ sample_variance); //Part d sample_variance = 0; //Uncomment code below and use as a starting point for implementing argument in part d. /* double [] M = new double [values.length]; double [] S = new double [values.length]; M[0]=values[0]; S[0] = 0; */ System.out.println("Sample Variance (Part d formula): "+ sample_variance); } }Question 3 This questions requires you to examine computational differences for methods used to calculate sample variation. You will implement three approaches. You should find that two of these approaches calculate the sample variation more accurately than the other approach. Note that the values provided in part a coincide with a large mean and a small variance. This scenario can be particularly problematic computationally when calculating sample variance. 3. Add code to H4_Q3 that declares an array of doubles named values initialized with the following {100000000.6,99999999.8,100000002.8,99999998.5,100000001.3 ). b. Add code to H4_Q3 that determines the sample variance using the following equation: S- (2-1) where The individual values are given as {10,000.6, 9,999.8, 10,002.8, 9,998.5, 10,001.3 ) so that n = 5 with indexed as i = 0,...,4. c. Add code to H4_Q3 that determines the sample variance using the following equation: s-(4-(*:-))--- with r, given in b. d. Add code to H Q3 that calculates the sample variance using the following method: Algorithm 1: Sample Variance Algorithm: Part d Result: Sample Variance: initialization: Set Mo = to; So = 0 and i = 1; while i sn-1 do M - M -1 + M 1 , S = S-1 + (x - M -1)*(** - MA) end with a given in b. This approach to calculating sample variance is known as the Welford method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started