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
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment