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
irga5000 [103]
1 year ago
6

Variance for accumulator. Validate that the following code, which adds the

Computers and Technology
1 answer:
Art [367]1 year ago
3 0

Using the knowledge of computational language in JAVA it is possible to write a code that Validate that the following code, which adds the methods var() and stddev() to Accumulator, computes both the mean and variance of the numbers presented as arguments to addDataValue()

<h3>Writting the code:</h3>

<em>import java.util.*;</em>

<em>public class </em><em>Accumulator </em><em>{  </em>

<em>private static double m;   </em>

<em>private static double v;   </em>

<em>private static double st;   </em>

<em>private static  double s[]=new double[5]; </em>

<em>private static int N;</em>

<em>private static int count =0;</em>

<em>public static void main(String[] args) {</em>

<em>// TODO Auto-</em><em>generated </em><em>method stub</em>

<em>Random r = new Random();</em>

<em>System.out.println("hello world");</em>

<em>for(int i=0;i<5;i++) {</em>

<em>    double randomvalue = r.nextDouble();</em>

<em>addDataValue(randomvalue);</em>

<em>}</em>

<em>for(int i=0;i<s.length;i++) {</em>

<em>    System.out.println("dataValue:"+s[i]);</em>

<em>}   </em>

<em>mean();</em>

<em>System.out.println("mean:"+m);</em>

<em>var();</em>

<em>System.out.println("variance:"+v);</em>

<em>stddev();</em>

<em>System.out.println("standard deviation:"+st);</em>

<em>}</em>

<em>public  static void </em><em>addDataValue</em><em>(double value) {     // addes data values to array</em>

<em>  s[count]=value;</em>

<em>  count++;</em>

<em> }</em>

<em>public static double mean() {        // returns mean</em>

<em>double sum=0.0;</em>

<em>for(int i=0;i<s.length;i++) {</em>

<em>    sum+=s[i];</em>

<em>}</em>

<em>m = sum/s.length;</em>

<em> return m;</em>

<em>}   </em>

<em>public </em><em>static </em><em>double var() {    //returns variance</em>

<em>double mm = mean();</em>

<em>     double t = 0;</em>

<em>     for(int i=0;i<s.length;i++) {</em>

<em>         t+= (s[i]-mm)*(s[i]-mm);</em>

<em>} </em>

<em>     v= t/(s.length-1);</em>

<em>      return v;  </em>

<em>}</em>

<em>public static  double </em><em>stddev</em><em>() {        // returnsn the stardard deviation </em>

<em>st= Math.sqrt(var());</em>

<em>return st;</em>

<em>}</em>

<em>}</em>

See more about JAVA at brainly.com/question/12975450

#SPJ1

You might be interested in
Most users find settings between ____ to be the most convenient option for how long the computer sits idle before the screen sav
Sphinxa [80]
I would say about 5 to 10 minutes
3 0
4 years ago
What is set of instructions executed by the computer?​
alexdok [17]

Answer:

code

Explanation:

code are set of instruction executed by the computer.

7 0
3 years ago
A significant and powerful aspect of the java language is the: (points : 1)
Elodia [21]
 <span>A significant and powerful aspect of the Java language is the: D. Object program. Java is inherently object-oriented, which means that Java programs are made up of programming elements called objects. [ [ Simply put, an object is a programming entity that represents either some real-world object or an abstract concept.</span>
7 0
4 years ago
Convert (520)10 into base 16​
kakasveta [241]
The base-10 value of 52010 is equal to base-16 value of 20816.
3 0
3 years ago
Read 2 more answers
What are the four principal services provided by S/MIME?
konstantin123 [22]

Answer:

Explanation:

Secure/Multipurpose Internet Mail Extensions, is a technology that permits you to encrypt your emails. S/MIME is based on asymmetric cryptography to protect your emails from unauthorized access. It also allows you to digitally sign your emails to verify you as the legitimate sender of the message, making it an effective weapon against many phishing attacks.

The four principal services presented by S/mime includes ;

Authentication, Non-repudiation of origin utilizing digital signatures, Message Integrity and message Privacy.

3 0
3 years ago
Other questions:
  • I need to know the answer to this question
    15·1 answer
  • Mrs. Dunn shows her students a data range, which has been named "Goals,” covering cells A14 to A25. She tells her students that
    9·1 answer
  • Which of the following is a regional accreditation agency?
    7·1 answer
  • What is the definition of delimited text?
    14·2 answers
  • One acre of land is equivalent to 43,560 square feet. Write a program that asks the user to enter the total square feet in a tra
    11·1 answer
  • Because it allows their files to be accessed from any device on the Internet, many users like to back-up their files using ___ s
    14·1 answer
  • . Explain the notions of WAN, LAN, MAN and PAN.
    15·1 answer
  • Universal Containers uses a custom object within the product development team. Product development, executives, and System Admin
    11·1 answer
  • Assume a system has a TLB hit ratio of 90%. It requires 15 nanoseconds to access the TLB, and 85 nanoseconds to access main memo
    5·2 answers
  • 3. Coaxial/telephone cable sends<br> during the data transmission<br> signal
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!