Question

Write a function that determines standart deviation of float array. The function takes dataset as a...

Write a function that determines standart deviation of float array. The function takes dataset as a float array parameter!! And it also return result as a float. (Clue: calculate average first) Definations: σ=√1N Σi =1 N ( xi− x ) σ = standard deviation xi = each value of dataset x (with a bar over it) = the arithmetic mean of the data (This symbol will be indicated as average of dataset) N = the total number of data points (if you need square root of some number you can use sqrt function in math.h library. Usage example: a=sqrt(b); which means “a” is equal to square root of “b”)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  1. #include <math.h>
  2. #include <stdio.h>
  3. float calculateSD(float data[]) {
  4. float sum = 0.0, mean, SD = 0.0;
  5. int i;
  6. for (i = 0; i < 10; ++i) { // loop to calculate sum
  7. sum += data[i];
  8. }
  9. mean = sum / 10; // mean calculation
  10. for (i = 0; i < 10; ++i)
  11. SD += pow(data[i] - mean, 2); // (xi - mean(x))2
  12. return sqrt(SD / 10);
  13. }
Add a comment
Know the answer?
Add Answer to:
Write a function that determines standart deviation of float array. The function takes dataset as a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ ONLY!!! NOT JAVA. The standard deviation is calculated from an array X size n with...

    C++ ONLY!!! NOT JAVA. The standard deviation is calculated from an array X size n with the equation std=sqrt(sum((xi-mean)2/(n-1))) Sum the square of difference of each value with the mean. Divide that sum by n-1. Take the square root and you have the standard deviation. //System Libraries #include <iostream> //Input/Output Library #include <cstdlib> //Srand #include <ctime> //Time to set random number seed #include <cmath> //Math Library #include <iomanip> //Format Library using namespace std; //User Libraries //Global Constants, no Global Variables...

  • Fix the following program (C++). #include <iostream> #include <cmath> #include <vector> #include <limits> using namespace std;...

    Fix the following program (C++). #include <iostream> #include <cmath> #include <vector> #include <limits> using namespace std; /* * Calculate the square of a number */ float square (float x) { return x*x; } /* * Calculate the average from a list of floating point numbers */ float average(vector<float>& values) { float sum = 0.0f; float average; for (float x : values) sum += x; average = sum / values.size(); return average; } /** Calculate the standard deviation from a vector...

  • 1.) Write a function called canMakeSum() that takes a sorted array of n integers and determines...

    1.) Write a function called canMakeSum() that takes a sorted array of n integers and determines whether two distinct elements of the array add up to some specified value, "key". If so, return 1. Otherwise, return 0. The function signature is: int canMakeSum(int *array, int n, int key);

  • Do the following: - Write and test a function that takes an array of doubles and...

    Do the following: - Write and test a function that takes an array of doubles and returns the average of the values in the array - Write and test a function that takes an array of doubles and returns number of values in the array that are above the average of the values in the array - Write and test a function that takes an array of Strings and returns number of values in the array that start with an...

  • Write a method called stdev that returns the standard deviation of an array of integers. Standard...

    Write a method called stdev that returns the standard deviation of an array of integers. Standard deviation is computed by taking the square root of the sum of the squares of the differences between each element and the mean, divided by one less than the number of elements. (It's just that simple!) More concisely and mathematically, the standard deviation of an array a is written as follows: stdev(a)=∑i=0a.length−1(a[ i ]−average(a)2)a.length−1 For example, if the array passed contains the values [1,...

  • for this assignment you will be creating a series of functions for manipulating an array of...

    for this assignment you will be creating a series of functions for manipulating an array of data. The data will consist of randomly generated doubles. You should make the following functions: generate() - This function fills an array with random doubles in a specified range. This function takes four inputs: an array of doubles, an integer representing the size of the array, and two doubles representing the lower an upper bounds of the range random values. For example, the function...

  • Write a function shuffle that takes an array of 20 integers and then shuffles the integers...

    Write a function shuffle that takes an array of 20 integers and then shuffles the integers using the following algorithm. For each element X of the array, generate a random number N between 0 and 19, inclusive. swap X with the element that corresponds to N.

  • a) Write a function called print_doubles that prints the first n elements of an array of...

    a) Write a function called print_doubles that prints the first n elements of an array of doubles. Assume the array is long enough. Example: double v[5] = {1,2,3,4,5}; print_doubles(v, 5); // prints [1,2,3,4,5] b) Write a function with the following signature: void get_min_max(const double values[], int n, double *pmin, double *pmax); that returns in output parameters *pmin the value of the minimum element in array values and in *pmax the maximum element. Parameter n represents the size of array values....

  • Write a program that computes the average and standard deviation of four scores. The standard deviation...

    Write a program that computes the average and standard deviation of four scores. The standard deviation is defined to be the square root of the average of the four values. Use two functions. One function to calculate the average, this function should be with Return Type "double". Second Function should be to calculate standard deviation, this function should be with Return Type "void". Allow the program to continue until the user tells the program he/she is finished. This is for...

  • Column A contains a generic dataset. Column C is a list of questions that correspond to...

    Column A contains a generic dataset. Column C is a list of questions that correspond to the questions below. Column D indicates which Excel function(s) that question is designed to teach. Column E is where you will work with the function(s) to generate the answer to each question. And finally Column F displays the formula you used to generate your answer in Column E. To place your answers from Column E into the blanks below, use the copy/paste keyboard shortcut:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT