Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Passing values from structure arrays to a generic geometrical mean function Date: Mon, 30 Jan 2017 12:19:29 -0800 Organization: None to speak of Lines: 54 Message-ID: References: <8abfc054-e7c3-498c-a7b4-8e7471f57ac6@googlegroups.com> <0a48658d-968a-4ddf-8c3e-5a856e298ec1@googlegroups.com> <87lgtwxxjp.fsf@bsb.me.uk> <50df88d5-9db9-401b-bf2d-bf1846d68b7b@googlegroups.com> <87wpdgvzmp.fsf@bsb.me.uk> <522dd411-1a86-49fb-8df7-a1384f3c5da8@googlegroups.com> <4f8b2e49-6a8b-fb05-e35b-d21fb00f6779@verizon.net> <899963c8-4716-422b-93c9-59e98c91a160@googlegroups.com> <43aa17b1-6286-8ec5-c9d7-fe59d88c1688@verizon.net> <39f310e9-691c-4a27-9d9f-bc9114854af8@googlegroups.com> <816ac4fc-3e93-cd1b-e4b9-ce0eac72da7e@verizon.net> <7af44069-dfe1-48ce-8c6e-33aed7131a02@googlegroups.com> <54ce71f7-5db5-0d83-c2f6-bc37acf070c1@verizon.net> <2be1c4a8-64ed-4e33-86fc-00ae8dee873b@googlegroups.com> <87sho1plyn.fsf@bsb.me.uk> <8d0708ec-7ccf-e349-b973-f53869988664@verizon.net> <496c32c2-a962-44f3-94eb-6ac84b3ed9b6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="a9fae22b5f567322e337da4e19df7ab9"; logging-data="25319"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DwcDkI0bxdUbVgRybR8tT" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:NLQSPxp/uLhFOeh12GK7xI472Xk= sha1:MlEB7PfTmPY+XX7IUiLydCgEkyQ= Xref: csiph.com comp.lang.c:102794 Alla _ writes: [...] > And, to Keith, I am a girl :) I'm aware. If I've used an incorrect pronoun, I apologize, but I'm not aware that I have, nor do I see anything from me in this post or the few of its direct ancestors I bothered to check. [...] > double mean_twonums(double number1, double number2) > { > // if both abs values of numbers are between 1 and 0 > if( (fabs(number1) < 1 && fabs(number1) > 0) > && (fabs(number2) < 1 && fabs(number2) > 0) ) > { > number1 += 1.0; > number2 += 1.0; > > return pow((number1*number2), 1.0/2) - 1; > } > // if any number is negative return simple arithm average > if(number1 < 0 || number2 < 0) > return (number1+number2)/2; > //compute geo mean for any other cases > return pow((number1*number2), 1.0/2); > } I can't comment on whether this function is meaningful in financial terms, but I find the name "mean_twonums" misleading at best. The name strongly implies that it computes the mean of two numbers, which should be as simple as return (number1 + number2) / 2.0; for an arithmetic mean, or return sqrt(number1 * number2); for a geometric mean. There are other kinds of means, such as the harmonic mean, but the value computed by this function doesn't resemble any of them. What this function actually does strikes me as quite arbitrary, but that's merely a statement about my misunderstanding. If this mathematical function is actually called a "mean" in the field of finance, then I suppose my objection is with financial terminology. If it's not called a "mean", then I would hope that there's some coherent name for it. I seem to recall you also had a function called something like "geomean()" that computed something other than a geometic mean. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"