Question #45300

Write a script averages which take two values xlow and xhigh and generate 10000 random numbers in the range [xlow…xhigh], and calls the appropriate functions to compute arithmetic mean (average), rms
average, geometric mean and harmonic mean.
1

Expert's answer

2014-09-02T01:46:48-0400

Answer on Question #45300, Programming, Mat LAB | Mathematica | MathCAD | Maple

Question:

Write a script averages which take two values xlow and xhigh and generate 10000 random numbers in the range [xlow...xhigh], and calls the appropriate functions to compute arithmetic mean (average), rms average, geometric mean and harmonic mean.

Answer:


function [average_value, rms_value, geometric_mean, harmonic_mean] = averages(xlow, xhigh)
    random_array = random('unif', xlow, xhigh, 10000, 1);
    average_value = mean(random_array);
    rms_value = rms(random_array);
    geometric_mean = geomean(random_array);
    harmonic_mean = harmmean(random_array);
end


http://www.AssignmentExpert.com/

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS