Answer to Question #6103 in Ruby | Ruby on Rails for FIona

Question #6103
Implementing four statistic calculation methods for mean, median, variance, and standard deviation within a script named stats.rb. Generate an array of random integers and process this array using the methods you defined.
The following arrays will be used
a = [ 70, 65, 80, 85, 23]
b = [ 70, 65, 80, 85, 23, 45]
Mean: puts "mean a: #{mean(a)} & mean b: #{mean(b)}"
Outputs: mean a: 64.6 & mean b: 61.3333333333333
Median: puts "median a: #{median(a)} & median b: #{median(b)}"
Outputs: median a: 70 & median b: 67.5
Variance: puts "variance a: #{variance(a)} & variance b: #{variance(b)}"
Outputs: variance a: 482.64 & variance b: 455.555555555556
Standard Deviation: puts "std_dev a: #{std_dev(a)} & std_dev b: #{std_dev(b)}"
Outputs: std_dev a: 21.9690691655336 & std_dev b: 21.3437474581095
0
Expert's answer

Answer in progress...

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!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS