Geometric and weighted mean

12222017, 10:13 PM
(This post was last modified: 12222017 10:16 PM by salvomic.)
Post: #1




Geometric and weighted mean
I was asked about this question: are there in the Prime direct command to get geometric mean and weighted mean?
For example extracting data from Statistics: Statistics_1Var.D1 as a list and to calculate from that list. Or is better to write a little program? Sorry, but my memory fails (and I can't find those command in the Catalog)... Salvo ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

12222017, 11:32 PM
(This post was last modified: 12232017 05:24 PM by Carlos295pz.)
Post: #2




RE: Geometric and weighted mean
I think there is no geometric mean.
Viga C  TD  FB 

12232017, 07:46 AM
Post: #3




RE: Geometric and weighted mean
(12222017 11:32 PM)Carlos295pz Wrote: I think there is no geometric mean. thank you Carlos, I'll adivise to whom asked me your suggestions. So I didn't remember bad... (size(D1)√(πList(D1)) is ok per geometric mean. Wmean was in old HP calculators, like HP42s and others. Salvo ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

12232017, 08:05 AM
Post: #4




RE: Geometric and weighted mean
You might also be able to abuse the regression functionality to get (some of) those values out.
The HP/Free/DM 42 is nice enough to calculate the required sums for both types of average/regression all the time; I don't think the Prime does that too. 

12232017, 08:57 AM
Post: #5




RE: Geometric and weighted mean
(12232017 07:46 AM)salvomic Wrote:(12222017 11:32 PM)Carlos295pz Wrote: I think there is no geometric mean. Your "arithmetic mean" is not correct, it is the median and should be 6.625. This is what mean() produces. Arno 

12232017, 09:20 AM
(This post was last modified: 12232017 09:29 AM by salvomic.)
Post: #6




RE: Geometric and weighted mean
(12232017 08:05 AM)AlexFekken Wrote: You might also be able to abuse the regression functionality to get (some of) those values out.ok Quote:The HP/Free/DM 42 is nice enough to calculate the required sums for both types of average/regression all the time; I don't think the Prime does that too.it should have those functions, as they are useful with simple statistics. (12232017 08:57 AM)Arno K Wrote: Your "arithmetic mean" is not correct, it is the median and should be 6.625. This is what mean() produces. Seeing in Wikipedia, we can add also the harmonic mean to the list... For geometric mean better than use the product maybe it's better to consider the alternative definition with logarithms, to avoid the multiply by zero (defining what it should do ln(0)!): I think to write a little program for my friend to offer geometric, weighted and harmonic means. Salvo ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

12232017, 09:29 AM
Post: #7




RE: Geometric and weighted mean  
12232017, 09:31 AM
(This post was last modified: 12232017 09:53 AM by salvomic.)
Post: #8




RE: Geometric and weighted mean
(12232017 09:29 AM)Arno K Wrote:(12232017 09:20 AM)salvomic Wrote: For geometric mean better than use the product maybe it's better to consider the alternative definition with logarithms, to avoid the multiply by zero: no... and I corrected my post (see now), as also ln(0) returns error, obviously... Rigorously, geometric mean with zeros doesn't mean anything. And then the geometric mean is calculable only for positive numbers (for the root)... ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

12232017, 10:33 AM
(This post was last modified: 12232017 07:35 PM by salvomic.)
Post: #9




RE: Geometric and weighted mean
Could this code be good?
No error correction (for 0, negative numbers) in it. Code:
With the Carlos' lists list1={5.2, 8.2,7.4,5.7}, wlist={3,1,2,4}: mean(list1) = 6.625 median(list1) = 6.55 gmean(list1) = 6.51224817722 wmean(list1, wlist) = 6.14 hmean(list1) = 6.40171419012 Question for Bernard: are there those means in XCAS? EDIT:: thanks to Carlos29pz for info: I didn't remember that we can use the already present command mean(list1, list2) to get weighted mean, so please, use my program only for geometric and harmonic means, since those command won't be builtin the Prime. ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

12232017, 11:42 AM
(This post was last modified: 12232017 11:56 AM by DrD.)
Post: #10




RE: Geometric and weighted mean
Salvo,
After reading your original post, I found a website that had some useful information. Did you happen to see this one, also? http://buzzardsbay.org/specialtopics/ca...tricmean/ (Particularly, near the bottom where it has suggestions for handling negative values, or zero values). Dale 

12232017, 11:51 AM
Post: #11




RE: Geometric and weighted mean
(12232017 11:42 AM)DrD Wrote: Salvo, hi Dale, interesting link, thanks. I've not seen it first. I'm bookmarking it to read in the local afternoon; there is also a discussion how to calculate geometric mean with 0 and negative values... Salvo ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

12232017, 05:21 PM
Post: #12




RE: Geometric and weighted mean
Oh true, I chose wrong in the catalog, median instead of mean, they were very close xD
Corrected. Viga C  TD  FB 

12232017, 05:25 PM
Post: #13




RE: Geometric and weighted mean
(12232017 05:21 PM)Carlos295pz Wrote: Oh true, I chose wrong in the catalog, median instead of mean, they were very close xD Well! ;) in most cases mean and median are close, very close. Geometric mean is lesser than arithmetic mean. Salvo ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

12242017, 03:01 AM
Post: #14




RE: Geometric and weighted mean
Perhaps it is worth pointing out that *an* average is a relatively arbitrary way of "summarising" a bunch of numbers into a single number. The abstract definition that I learnt at uni even covers the two extreme cases of min() and max().
It is very common not to justifiy a particular choice of average (e.g. the arithmetic mean), other than by its ubiqitous implementation. If you want to get really serious and properly justify why you "should" use a certain choice of average, you are typically lead to consider cost functions. For example: minimize sum of squares (arithmetic mean), miminize expected walking distance to the first lift that arrives in the office (median), ... In terms of relative size, these hold in general: min <= harmonic <= geometric <= arithmogeometric <= arithmetic <= max I think not much can be said about the relative sizes of other common types as it depends heavily on the (skewness of the) distribution of the numbers. In fact, their size relative to the arithmetic mean may be used as an indicator of skewness. 

12242017, 08:33 AM
Post: #15




RE: Geometric and weighted mean
(12242017 03:01 AM)AlexFekken Wrote: Perhaps it is worth pointing out that *an* average is a relatively arbitrary way of "summarising" a bunch of numbers into a single number. The abstract definition that I learnt at uni even covers the two extreme cases of min() and max(). yes Alex, definitely all depends after the data we want treat and after the problem type. That said, the Prime has already good instruments to handle Statistics. Perhaps it is missed only geometric mean, that in some cases is more adequate than other types or of the median. It is not a great problem as we can make it with a little program; my friend would like only to have it as a command; I tried to help him with a program that acts like a command, so he can experiment among the various types and I'll suggest him also your right considerations about the correct use of means. Thank you, Salvo ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

01042018, 03:55 PM
(This post was last modified: 01042018 04:04 PM by StephenG1CMZ.)
Post: #16




RE: Geometric and weighted mean
(12242017 03:01 AM)AlexFekken Wrote: Perhaps it is worth pointing out that *an* average is a relatively arbitrary way of "summarising" a bunch of numbers into a single number. The abstract definition that I learnt at uni even covers the two extreme cases of min() and max(). I was intruiged by your mention of max and min as extreme examples of means. I realised that I really was not sure what "a mean" was. To try to understand the concept, I looked up several example means  and implemented many of them here. http://www.hpmuseum.org/forum/thread9852.html I admit I still would not like to have to explain what "a mean" is. As for justifying which mean to use for a given data set, I thought my IsMean procedure might be useful. Used properly, it can show which mean a tabloid newspaper has used in its headline. Used improperly, given the number you would like as your answer, it can identify which average you need to use (regardless of appropriateness). By the way, if you have weighted data but your mean procedure does not implement weights, you can use my InvOCCUR procedure to turn Valuelist,Weightlist into Valuelistwithrepeatedvalues (I'm sure there must be a better name). Obviously, weights must be integer. http://www.hpmuseum.org/forum/thread9411.html Stephen Lewkowicz (G1CMZ) 

01042018, 05:24 PM
Post: #17




RE: Geometric and weighted mean
thank a lot, Stephen!
∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

01052018, 01:22 AM
Post: #18




RE: Geometric and weighted mean
(01042018 03:55 PM)StephenG1CMZ Wrote: I admit I still would not like to have to explain what "a mean" is. Nice to see someone taking my feedback seriously and expanding on it. From memory, the abstract definition of a mean (that I learned in a "captia selecta" math lecture) is that of any function of a "finite sequence" (i.e. a list) of numbers satifying: 1  the mean is not less than all of the numbers 2  the mean is not more than all of the numbers 3  the mean is scaleinvariant Presumably the numbers had to be real (or at least from a totally ordered set) for 1 and 2 to make sense. I am not sure if there were further domain restrictions, e.g. all numbers > 0, in this abstract context, but since we covered the arithmeticogeometric mean I suppose there must have been. And "weights" apparently weren't in scope at all :) The 3rd condition means that if you multiply all numbers in the seqence by a fixed constant then you can get the new mean by multiplying the original by the same constant. This ensures that if the number represent physical quantities on an absolute scale (e.g. NOT degrees Celsius, Fahrenheit), then you will get the same mean regardless of the units used. So other than "staying within range" that was the only functional restriction on the definition of a "mean". But of course abstract definitions are not intended to explain but to distil the essence of a concept (my favourite being that of a "topology" to represent "closeness" without talking about distance). I would say using cost functions is probably the best way to justify/explain the different types of means (as "best estimates" that mimimize them). For example (and in addition to the ones I already mentioned), if the cost of underestimating is much very bigger than that of overestimating, then max would be your best "mean". 

« Next Oldest  Next Newest »

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