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
erma4kov [3.2K]
3 years ago
10

(Statistics) Write a program that includes two functions named calcavg() and variance(). The calcavg() function should calculate

and return the average of values stored in an array named testvals. The array should be declared in main() and include the values 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, and 73. The variance() function should calculate and return the variance of the data. The variance is obtained by subtracting the average from each value in testvals, squaring the values obtained, adding them, and dividing by the number of elements in testvals. The values returned from calcavg() and variance() should be displayed by using cout statements in main().
Computers and Technology
1 answer:
Gwar [14]3 years ago
7 0

Answer:

Following are the program in the C++ Programming Language.

#include<iostream>   //set header file

using namespace std;  //namespace

//set method for sum and average

double calcavg(int a[])  

{

double t=0;  

double average ;

  cout<<"Arraylist is : "<<endl;

for(int i=0;i<14;i++) //set for loop

{ cout<<a[i]<<" ";

  t = t+a[i];

}

cout<<endl<<endl;

  average = t/14;

  cout<<"total : "<<t<<endl; //print message with output

return average; //return the average

}

//set method for the variance

double variance(int a[],double average)  

{

  double t=0;

for(int i=0;i<14;i++) //set the for loop

{

      a[i] = (a[i]-average) * (a[i]-average);

  t = t+a[i];

}

  double variance = t/14;

  return variance; // return variance

}

int main() //define main method

{

  double average;

  double variances ;

  //set array data type declaration

  int testvals[]={89,95,72,83,99,54,86,75,92,73,79,75,82,73};  

  average = calcavg(testvals); //call the methods

  variances = variance(testvals,average); //call the methods

  cout<<"average is : "<<average<<endl; //print output

  cout<<"variance is : "<<variances<<endl;//print output

  return 0;

}

<u>Output</u>:

Arraylist is :

89 95 72 83 99 54 86 75 92 73 79 75 82 73

total : 1127

average is : 80.5

variance is : 124.429

Explanation:

Here, we set the function "calcavg()" in which we pass integer data type array argument "a[]" in its parameter.

  • inside it, we set two double type variable "t" and assign its value to 0 and "average"
  • we set the variable "t" to find the total sum of the array
  • we set the variable "average" to find the average of the array.

Then, we set the function "variance()" in which we pass two argument, integer array type argument "a[]" and double type argument "average" in its parameter.

  • inside it, we find the variance of the array.

Finally, we define the "main()" function in which we call both the functions and pass values in its argument and then print the output.

You might be interested in
You’ve just finished training an ensemble tree method for spam classification, and it is getting abnormally bad performance on y
inn [45]

Answer:

The various reasons that could be a major problem for the implementation are it involves a large number of parameters also, having a noisy data

Explanation:

Solution

The various reasons that could be causing the problem is given as follows :

1. A wide number of parameters :

  • In the ensemble tree method, the number of parameters which are needed to be trained is very large in numbers.
  • When the training is performed in this tree, then the model files the data too well.
  • When the model has tested against the new data point form the validation set, then this causes a large error because the model is trained completely according to the training data.

2. Noisy Data:

  • The data used to train the model is taken from the real world . The real world's data set is often noisy i.e. contains the missing filed or the wrong values.
  • When the tree is trained on this noisy data, then it sets its parameters according to the training data.
  • As regards to testing the model by applying the validate set, the model gives a large error of high in accuracy y.

8 0
3 years ago
If you want to tune into a radio station that is carried by a signal with wavelength 3.0 meters, what channel would you choose?
Over [174]

Answer:  The radio should be tuned to 100. 0 Mhz.

Explanation:

As radio waves are electromagnetic waves, like x-rays, UV rays, and all the wavelengths of visible light, they propagate in the free space at the speed of light: 3. 10⁸ m/s.

At any wave, there is a fixed relationship between the distance travelled by the wave along one cycle (which is called wavelength ) and the speed at which the wave oscillates (which is called the frequency of the wave), with the speed at which the wave propagates, as follows:

λ (wavelength) =  v (speed) / f (frequency)

Replacing by the values, and solving for frequency, we have:

f = 3. 10⁸ m/seg / 3 m = 10⁸ 1/sec = 10⁸ Hz = 100. 0 Mhz

This is the radio channel to which must be tuned in order to listen the station with a wavelength of 3 m, in the FM band.

6 0
3 years ago
Complete the code to finish this program to analyze the inventory for a store that sells purses and backpacks. Each record is co
Volgvan
Import csv
fileIn = open("data/bags.txt","r")
countPurse = 0
textFile= csv.reader(fileIn)
for bag in textFile:
if bag[ 1 ] == 'purse':
countPurse = countPurse + int(bag[6])
fileIn.close()
print("Number of purses:",countPurse)
5 0
2 years ago
Analytical processing uses multi-levelaggregates, instead of record level access.? True? False
Dominik [7]

Answer:

True.

Explanation:

Analytical processing uses multi-levelaggregates, instead of record level access.

8 0
3 years ago
If you have two folders open on your desktop and you want to move a file from one folder to the other, simply ________ the file
Daniel [21]

Answer:

copy

Explanation:

3 0
2 years ago
Other questions:
  • Privileged instructions 1) generate an interrupt so they can execute before non-privileged instructions. 2) are valid only when
    5·1 answer
  • Anna always has a hard time finding files on her computer because she does not know where she saved them. This also affects her
    12·2 answers
  • Two of the major sources used today for obtaining information to create computer maps are satellites and _____________.
    11·2 answers
  • Pleasee help. How do you fix this problem in discord?
    10·1 answer
  • Impaired drivers are one of the many risks drivers face on the Highway Transportation System. List 3 signs that a driver could b
    10·2 answers
  • I dont understand this at all! PLZ help me
    14·1 answer
  • What is the plan to make optimum usage of available spaces?
    15·1 answer
  • Why do we need operating systems?
    7·1 answer
  • Can somebody please help me with these few questions?
    11·1 answer
  • What are backup storage devices of computer? Why are they necessary in the computer system?​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!