[VA] SRC#005 April, 1st Mean Minichallenge

04012019, 08:09 PM
Post: #1




[VA] SRC#005 April, 1st Mean Minichallenge
Hi all, welcome to my meaningless but wellmeaning SRC#005  April, 1st Mean Minichallenge. Given a set of data consisting of positive real numbers x_{1}, x_{2}, ..., x_{n}, consider these four wellknown means M_{k} for k = 1, 2, 3, 4: M_{1} = the Harmonic Mean = \(\frac{n}{\frac{1}{x_1} + \frac{1}{x_2} + ... + \frac{1}{x_n}} \) M_{2} = the Geometric Mean = \(\sqrt[n]{ x_1 x_2 ... x_n} \) M_{3} = the Arithmetic Mean = \(\frac{x_1 + x_2 + ... + x_n}{n} \) M_{4} = 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 M_{k}. For instance, for the sample dataset 4, 1, 20.19 your code should return: k = 1: M_{1} = 2.3085... (Harmonic mean) k = 2: M_{2} = 4.3224... (Geometric mean) k = 3: M_{3} = 8.3966... (Arithmetic mean) k = 4: M_{4} = 11.8972... (Quadratic mean) Now, with the same sample dataset, use your code to return the values of the means M_{5/2} , M_{Pi} , M_{2.019} and M_{0.61}. Also, find the value of k which makes M_{k} = Pi. In a day or so I'll post my original solution which is a 3line (138 bytes) subprogram for the HP71B, 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 ! V. Find All My HPrelated Materials here: Valentin Albillo's HP Collection 

« Next Oldest  Next Newest »

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