Post Reply 
[VA] SRC#005- April, 1st Mean Minichallenge
04-01-2019, 08:09 PM
Post: #1
[VA] SRC#005- April, 1st Mean Minichallenge
 
Hi all, welcome to my meaningless but well-meaning  SRC#005 - April, 1st  Mean Minichallenge.
      
Given a set of data consisting of positive real numbers  x1, x2, ..., xn,  consider these four well-known means Mk for k = 1, 2, 3, 4:

      M1 = the Harmonic Mean = \(\frac{n}{\frac{1}{x_1} + \frac{1}{x_2} + ... + \frac{1}{x_n}} \)

      M2 = the Geometric Mean = \(\sqrt[n]{ x_1 x_2 ... x_n} \)

      M3 = the Arithmetic Mean = \(\frac{x_1 + x_2 + ... + x_n}{n} \)

      M4 = the Quadratic Mean = \(\sqrt{\frac{{x_1}^2 + {x_2}^2 + ... + {x_n}^2}{n}} \)

The Minichallenge:

Write code that accepts as input a dataset and the parameter k and returns the value of the corresponding mean Mk. For instance, for the sample dataset  4, 1, 20.19  your code should return:

      k = 1:   M1 = 2.3085
... (Harmonic mean)

      k = 2:   M2 = 4.3224
... (Geometric mean)

      k = 3:   M3 = 8.3966
... (Arithmetic mean)

      k = 4:   M4 = 11.8972
... (Quadratic mean)

Now, with the same sample dataset, use your code to return the values of the means  M5/2 , MPi , M-2.019  and  M0.61. Also, find the value of k which makes  Mk = Pi.

In a day or so I'll post my original solution which is a 3-line (138 bytes) subprogram for the HP-71B, but in the meantime see what you can do with any HP calc (not Excel, Python, etc.) of your choice and please post both code and results, not just math expressions or text explanations and such. Enjoy ! Smile

V.
 

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[VA] SRC#005- April, 1st Mean Minichallenge - Valentin Albillo - 04-01-2019 08:09 PM



User(s) browsing this thread: 1 Guest(s)