1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mario62 [17]
3 years ago
8

Write a test client for Randomthat checks that two methods, namely, nextGaussian()and nextLong()in the library operate as expect

ed. Take a command-line argument N, generate Nrandom numbers using each of the methods in Random, and print out their mean, and standard deviation.
Part 2: Implement a class that extends Random with a static method maxwellBoltzmann() that returns a random value drawn from a Maxwell-Boltzmann distribution with parameter s. To produce such a value, return the square root of the sum of the squares of three Gaussian random variables with mean 0 and standard deviation s. The speeds of molecules in an ideal gas have a Maxwell-Boltzmann distribution. Write a test client to test this new method, taking as command-line arguments N and sand prints N random numbers from the Maxwell Boltzmann distribution with parameter s.
Computers and Technology
1 answer:
xenn [34]3 years ago
5 0

Answer:

/ TestRandom.java

import java.util.Random;

public class TestRandom {

   // method to find the mean value of set of numbers

   // using Number as data type, so that it can represent both Double and Long

   // types needed for this program

   static double calculateMean(Number array[]) {

        double sum = 0;

        // summing values

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

            sum += array[i].doubleValue();

        }

        // finding average and returning it

        double avg = (double) sum / array.length;

        return avg;

   }

   // method to find the standard deviation value of set of numbers

   // using Number as data type, so that it can represent both Double and Long

   // types needed for this program

   static double calculateSD(Number array[], double mean) {

        // initializing sum of squared difference between each number and mean

        // to 0

        double sumSquaredDiff = 0;

        // looping

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

            // finding difference between current number and mean, squaring the

            // result, adding to sumSquaredDiff

            sumSquaredDiff += Math.pow(array[i].doubleValue() - mean, 2);

        }

        // finding variance

        double variance = (double) sumSquaredDiff / array.length;

        // finding square root of variance as standard deviation

        double sd = Math.sqrt(variance);

        return sd;

   }

   public static void main(String[] args) {

        // if no command line arguments given, displaying usage and quit

        if (args.length == 0) {

            System.out.println("Usage: java TestRandom <n>");

            System.exit(0);

        }

        // parsing first argument as integer N

        int N = Integer.parseInt(args[0]);

        // declaring a Double array and a Long array of size N

        Double gaussian[] = new Double[N];

        Long lng[] = new Long[N];

        // Random number generator

        Random random = new Random();

        // looping for N times

        for (int i = 0; i < N; i++) {

            // generating a guassian number, adding to array

            gaussian[i] = random.nextGaussian();

            // generating a long number, adding to array

            lng[i] = random.nextLong();

        }

        // finding average and standard deviation of both array values, we can

        // use the same functions for both types

        double avgGaussian = calculateMean(gaussian);

        double sdGaussian = calculateSD(gaussian, avgGaussian);

        double avgLong = calculateMean(lng);

        double sdLong = calculateSD(lng, avgLong);

        // displaying mean and standard deviation of both, formatted to 2 digits

        // after decimal point. the gaussian values will yeild a mean value

        // close to 0 and a standard deviation close to 1

        System.out.printf("Mean of %d gaussian values: %.2f\n", N, avgGaussian);

        System.out.printf("Standard deviation: %.2f\n", sdGaussian);

        System.out.printf("Mean of %d long values: %.2f\n", N, avgLong);

        System.out.printf("Standard deviation: %.2f\n", sdLong);

   }

}

Explanation:

You might be interested in
Which term is used to mean the methods of a predator uses to befriend youth online?
sammy [17]
Pretty sure its called the grooming process

6 0
2 years ago
Read 2 more answers
The processor in Q1 above is converted into an 8-stage pipeline, similar to the one discussed on slide 8 of lecture 16. It takes
Nadusha1986 [10]

Answer:

1000/125 billion instructions per second.

Explanation:

All the stages take 125ps and latch time was outlooked.

The clock speed would be the highest stage time in all 5 stages. Here all are same clock speed it would be 125ps only.

throughput = 1/cycle time so ⇒ 1/125 instructions/ps

Since we want it in billion instructions per second so we have to multiply with 10⁻⁹ /10⁻¹² then the result is 1000/125 billion instructions per second.

3 0
2 years ago
Which version of Windows was considered an operating environment rather than an operating system?
maksim [4K]
The answer is A. Windows 1.O
4 0
3 years ago
Users report that the database on the main server cannot be accessed. A database administrator verifies the issue and notices th
navik [9.2K]

Answer: (C) Ransomware

Explanation:

The ransomware is one of the type of malware software design which is used for blocking the user accessing unauthorized and also without paying money.

The most of the ransomware software encrypt the computer accessing and the files as they demand for the payment dues for again restoring the access.  

It also encrypt the user account and the information until the correct decrypt key are get entered into the system. So, according to the given situation, the ransomware attack are experienced in an organization.  

Therefore, Option (C) is correct.

4 0
3 years ago
If a device is determined to have an out-of-date virus signature file, then Network Access Control (NAC) can redirect that devic
GalinKa [24]

Answer:

C. Address Resolution Protocol (ARP) poisoning.

Explanation:

An antivirus signature file is a program written to describe and remedy a group of identified malware attacks, to prevent future attacks from the described malicious softwares. It is constantly updated to identify more malicious softwares.

A network access protocol (NAC) is used to implement access control on a network, collaborating with other protocols like ARP and unifying antiviruses, intrusion detection and vulnerability assessment.

When the virus signature file is out of date, the NAC allows a new malware, the antivirus can not identify, to access the network through ARP poisoning.

4 0
2 years ago
Other questions:
  • What should you do if ads keep popping up on your computer when using Google Chrome?
    14·1 answer
  • What are you guys doing?
    13·2 answers
  • K. What are the types of page orientation?​
    7·1 answer
  • A(n) ______ system is a set of programs that coordinates all the activities among computer or mobile device hardware. a. managem
    10·1 answer
  • What are the layers in the internet protocol stack? what are the principle responsibilities of each of these layers?
    11·1 answer
  • In which of the following situations should you expect to provide your Social Security number?
    13·1 answer
  • When you first open a word processor, you’ll find a ? document. A. filled B. blank C. edited
    9·2 answers
  • Discuss All control statements supported by Go
    13·1 answer
  • How can I download music and films at home without breaking the law?
    11·2 answers
  • Current flow is the same through all the elements of a series circuit.<br><br> true or false?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!