Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Whip me. Beat me. Make me maintain AIX." (By Stephan Zielinski)


devel / comp.lang.c / Std Deviation Formula

SubjectAuthor
* Std Deviation FormulaManu Raju
+* Re: Std Deviation FormulaBart
|+* Re: Std Deviation FormulaMalcolm McLean
||`- Re: Std Deviation FormulaManfred
|`- Re: Std Deviation FormulaManu Raju
+* Re: Std Deviation FormulaMeredith Montgomery
|`* Re: Std Deviation FormulaLew Pitcher
| `- Re: Std Deviation FormulaAnton Shepelev
`- Re: Std Deviation FormulaDFS

1
Std Deviation Formula

<t03938$lsd$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20852&group=comp.lang.c#20852

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: MR...@invalid.invalid (Manu Raju)
Newsgroups: comp.lang.c
Subject: Std Deviation Formula
Date: Sun, 6 Mar 2022 21:27:16 +0000
Organization: Aioe.org NNTP Server
Lines: 5
Message-ID: <t03938$lsd$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 6 Mar 2022 21:29:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2f3d1f57643a6a879b105b3308138537";
logging-data="22413"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gM+2pLBUHweByP6T5QeU5cjXsiWkKI7M="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.2
Cancel-Lock: sha1:EcN5bJC5O14P3MneMwxWhRtnnDg=
Content-Language: en-US
 by: Manu Raju - Sun, 6 Mar 2022 21:27 UTC

The formula:

<https://i.imgur.com/qLwVFtQ.png>

Re: Std Deviation Formula

<t03a95$ufg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20854&group=comp.lang.c#20854

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Std Deviation Formula
Date: Sun, 6 Mar 2022 21:49:25 +0000
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <t03a95$ufg$1@dont-email.me>
References: <t03938$lsd$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 6 Mar 2022 21:49:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8980970af4ff0eac474a7e725117ab98";
logging-data="31216"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/M5R+hd5vm77TAlQyVD0IIYy/4Z7BClI8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:YcEszvsVeJ45TilTVit5GqwTOyo=
In-Reply-To: <t03938$lsd$1@dont-email.me>
 by: Bart - Sun, 6 Mar 2022 21:49 UTC

On 06/03/2022 21:27, Manu Raju wrote:
> The formula:
>
> <https://i.imgur.com/qLwVFtQ.png>
>
>

OK, according to this:

https://www.calculator.net/standard-deviation-calculator.html

There are two slightly different ways of getting the SD. One divides by
N, the other by N-1.

(I had no idea myself, I just copied the method in the OP of the other
thread.)

This suggests that there could be another parameter to the SD function
to select which formula is used.

Re: Std Deviation Formula

<93add7bd-f9b2-4310-a893-a494b9362a22n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20855&group=comp.lang.c#20855

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:2293:b0:600:2b7b:2a19 with SMTP id o19-20020a05620a229300b006002b7b2a19mr5155665qkh.408.1646603690515;
Sun, 06 Mar 2022 13:54:50 -0800 (PST)
X-Received: by 2002:ad4:5be1:0:b0:430:c99:8a87 with SMTP id
k1-20020ad45be1000000b004300c998a87mr6450234qvc.82.1646603690331; Sun, 06 Mar
2022 13:54:50 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 6 Mar 2022 13:54:50 -0800 (PST)
In-Reply-To: <t03a95$ufg$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:a191:f9e2:b08a:add8;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:a191:f9e2:b08a:add8
References: <t03938$lsd$1@dont-email.me> <t03a95$ufg$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <93add7bd-f9b2-4310-a893-a494b9362a22n@googlegroups.com>
Subject: Re: Std Deviation Formula
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sun, 06 Mar 2022 21:54:50 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 23
 by: Malcolm McLean - Sun, 6 Mar 2022 21:54 UTC

On Sunday, 6 March 2022 at 21:49:58 UTC, Bart wrote:
> On 06/03/2022 21:27, Manu Raju wrote:
> > The formula:
> >
> > <https://i.imgur.com/qLwVFtQ.png>
> >
> >
>
> OK, according to this:
>
> https://www.calculator.net/standard-deviation-calculator.html
>
> There are two slightly different ways of getting the SD. One divides by
> N, the other by N-1.
>
> (I had no idea myself, I just copied the method in the OP of the other
> thread.)
>
> This suggests that there could be another parameter to the SD function
> to select which formula is used.
>
Yes, to be strictly accurate you should pass in a flag to say whether it is
sample or population deviation. Or have two functions to avoid passing a
confusing boolean.

Re: Std Deviation Formula

<t03b0h$4ak$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20856&group=comp.lang.c#20856

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: MR...@invalid.invalid (Manu Raju)
Newsgroups: comp.lang.c
Subject: Re: Std Deviation Formula
Date: Sun, 6 Mar 2022 21:58:29 +0000
Organization: Aioe.org NNTP Server
Lines: 33
Message-ID: <t03b0h$4ak$1@dont-email.me>
References: <t03938$lsd$1@dont-email.me> <t03a95$ufg$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 6 Mar 2022 22:01:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2f3d1f57643a6a879b105b3308138537";
logging-data="4436"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gbvCrZHyek8rNZQVtjsfhgpVj5LInPG0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:4NAZXD2JScRDfIRVPgHxnVzhZqg=
In-Reply-To: <t03a95$ufg$1@dont-email.me>
Content-Language: en-US
 by: Manu Raju - Sun, 6 Mar 2022 21:58 UTC

On 06/03/2022 21:49, Bart wrote:
> On 06/03/2022 21:27, Manu Raju wrote:
>> The formula:
>>
>> <https://i.imgur.com/qLwVFtQ.png>
>>
>>
>
> OK, according to this:
>
> https://www.calculator.net/standard-deviation-calculator.html
>
> There are two slightly different ways of getting the SD. One divides
> by N, the other by N-1.
>
> (I had no idea myself, I just copied the method in the OP of the other
> thread.)
>
> This suggests that there could be another parameter to the SD function
> to select which formula is used.

The full article is at this link:

<https://en.wikipedia.org/wiki/Standard_deviation>

(N - 1) is when you want to apply Bessel's correction factor:
<https://en.wikipedia.org/wiki/Bessel%27s_correction>

I just used a quick method to write a C program because I got bored of
watching Russia Invasion on TV.

Re: Std Deviation Formula

<t03tqs$mnp$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20862&group=comp.lang.c#20862

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: Re: Std Deviation Formula
Date: Mon, 7 Mar 2022 04:23:08 +0100
Organization: Aioe.org NNTP Server
Message-ID: <t03tqs$mnp$1@gioia.aioe.org>
References: <t03938$lsd$1@dont-email.me> <t03a95$ufg$1@dont-email.me>
<93add7bd-f9b2-4310-a893-a494b9362a22n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="23289"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Manfred - Mon, 7 Mar 2022 03:23 UTC

On 3/6/2022 10:54 PM, Malcolm McLean wrote:
> On Sunday, 6 March 2022 at 21:49:58 UTC, Bart wrote:
>> On 06/03/2022 21:27, Manu Raju wrote:
>>> The formula:
>>>
>>> <https://i.imgur.com/qLwVFtQ.png>
>>>
>>>
>>
>> OK, according to this:
>>
>> https://www.calculator.net/standard-deviation-calculator.html
>>
>> There are two slightly different ways of getting the SD. One divides by
>> N, the other by N-1.
>>
>> (I had no idea myself, I just copied the method in the OP of the other
>> thread.)
>>
>> This suggests that there could be another parameter to the SD function
>> to select which formula is used.
>>
> Yes, to be strictly accurate you should pass in a flag to say whether it is
> sample or population deviation. Or have two functions to avoid passing a
> confusing boolean.

Well, if all you have is a sequence of samples, then the correct
function to use is what is called the "Sample Standard Deviation" in the
article posted by Bart - i.e. the one that divides by (N-1).

In order to use what is called the "Population standard deviation" (the
one that divides by N) you need to know the exact expected value, which
you can't calculate from a sample, so you can use that formula only if
you pass in the expected value as an extra parameter, which would be
your "flag".

Re: Std Deviation Formula

<86lexfnsb0.fsf@levado.to>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20898&group=comp.lang.c#20898

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!K0Mf9xWdzF+RvqYo8Wn9fw.user.46.165.242.91.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.c
Subject: Re: Std Deviation Formula
Date: Sat, 12 Mar 2022 11:45:07 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86lexfnsb0.fsf@levado.to>
References: <t03938$lsd$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="32624"; posting-host="K0Mf9xWdzF+RvqYo8Wn9fw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:OaWOX2+N8Gv4unuGbY4+jugRNGE=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Meredith Montgomery - Sat, 12 Mar 2022 14:45 UTC

Manu Raju <MR@invalid.invalid> writes:

> The formula:
>
> <https://i.imgur.com/qLwVFtQ.png>

This entire thread so far is weird. The OP --- as far as I can see ---
did not even write a sentence, but somehow everyone seems to have
understood exactly what was being said or discussed or ask and a whole
conversation seems to have taken place.

Not to mention how off-topic it is.

No complaints, no hard feelings. Just weird.

Perhaps sometimes the USENET is used as private chat.

Re: Std Deviation Formula

<t0igod$iot$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20899&group=comp.lang.c#20899

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.lang.c
Subject: Re: Std Deviation Formula
Date: Sat, 12 Mar 2022 16:11:57 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <t0igod$iot$1@dont-email.me>
References: <t03938$lsd$1@dont-email.me> <86lexfnsb0.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 12 Mar 2022 16:11:57 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d744c3dd037b2f84c7136267c8e0c876";
logging-data="19229"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sD5hHMM9+xuo6rKAYKQ3bU8+hln5Jgu4="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:bELILZTMssOB6fVPhuMu4rEz5/Q=
 by: Lew Pitcher - Sat, 12 Mar 2022 16:11 UTC

On Sat, 12 Mar 2022 11:45:07 -0300, Meredith Montgomery wrote:

> Manu Raju <MR@invalid.invalid> writes:
>
>> The formula:
>>
>> <https://i.imgur.com/qLwVFtQ.png>
>
> This entire thread so far is weird. The OP --- as far as I can see ---
> did not even write a sentence, but somehow everyone seems to have
> understood exactly what was being said or discussed or ask and a whole
> conversation seems to have taken place.
>
> Not to mention how off-topic it is.
>
> No complaints, no hard feelings. Just weird.
>
> Perhaps sometimes the USENET is used as private chat.

First off, I suspect that Manu Raju started /this/ thread
to relate directly to the wider conversation started by
Malcolm McLean in the "C vis C++ standard deviation function"
thread.

As for the topic, standard deviation is one of those concepts that
- is often taught in high-school and university math programs,
- crops up a lot in scientific and financial computing, and
- is easily implemented in C

Knowing the calibre of the audience in comp.lang.c, I would expect
this sort of discussion around a three-word topic like this :-)

--
Lew Pitcher
"In Skills, We Trust"

Re: Std Deviation Formula

<20220314111612.da6448420ecf8081f1f333dc@g{oogle}mail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20900&group=comp.lang.c#20900

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: anton....@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: Std Deviation Formula
Date: Mon, 14 Mar 2022 11:16:12 +0300
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <20220314111612.da6448420ecf8081f1f333dc@g{oogle}mail.com>
References: <t03938$lsd$1@dont-email.me>
<86lexfnsb0.fsf@levado.to>
<t0igod$iot$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="65d23a1e4b97c81685bbe16984e04742";
logging-data="13852"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4q51jtaybS/Pi+lqpLFfNq/Jq+XY9PNs="
Cancel-Lock: sha1:4osRvcco9HDpj7WLZqEFRfUSKN0=
X-Newsreader: Sylpheed 3.5.0 (GTK+ 2.24.23; i686-pc-mingw32)
 by: Anton Shepelev - Mon, 14 Mar 2022 08:16 UTC

Lew Pitcher:

> Knowing the calibre of the audience in comp.lang.c, I
> would expect this sort of discussion around a three-word
> topic like this :-)

I can make a single shot from a small arm: a more
interesting way to calculate standard deviation is via a
numerically stable single-pass algorithm:

https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm

--
() ascii ribbon campaign - against html e-mail
/\ http://preview.tinyurl.com/qcy6mjc [archived]

Re: Std Deviation Formula

<aKZ_J.458885$oF2.266647@fx10.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20962&group=comp.lang.c#20962

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Subject: Re: Std Deviation Formula
Content-Language: en-US
Newsgroups: comp.lang.c
References: <t03938$lsd$1@dont-email.me>
From: nos...@dfs.com (DFS)
In-Reply-To: <t03938$lsd$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 103
Message-ID: <aKZ_J.458885$oF2.266647@fx10.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Thu, 24 Mar 2022 12:45:58 UTC
Organization: blocknews - www.blocknews.net
Date: Thu, 24 Mar 2022 08:45:56 -0400
X-Received-Bytes: 3742
 by: DFS - Thu, 24 Mar 2022 12:45 UTC

On 3/6/2022 4:27 PM, Manu Raju wrote:
> The formula:
>
> <https://i.imgur.com/qLwVFtQ.png>

Last year I wrote a short routine to calc the moments of a randomly
generated set of ints. It makes one pass thru the data to calc the
mean, then another pass to determine the other stats.

$ progname N

=======================================================================
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>

// this program computes the mean, median, mode, variance, std
deviation, skewness and kurtosis
// of a randomly generated set of int numbers

// used the population skewness and Kurtosis formulas from:
//
https://www.calculatorsoup.com/calculators/statistics/descriptivestatistics.php

int randNbr(int low, int high) {
return (low + rand() / (RAND_MAX / (high - low + 1) + 1));
}

int compareint (const void * a, const void * b)
{ if (*(int*)a > *(int*)b) return 1;
else if (*(int*)a < *(int*)b) return -1;
else return 0;
}

int main(int argc, char *argv[])
{ int i=0, lastmode=0;
int N = atoi(argv[1]);
int nums[N];
double sumN=0, median = 0.0;
double sqrdiffmean = 0.0, cubediffmean = 0.0, quaddiffmean = 0.0;
char mode[1000], tmp[12];
srand(time(NULL));
printf("%d Randoms:\nNo commas : ", N);
i=0; while(i<N){nums[i] = randNbr(1,N*2);printf("%d
",nums[i]);sumN+=nums[i];i++;}
i=0; printf("\nWith commas: "); while(i<N){printf("%d,",nums[i++]);}
qsort(nums,N,sizeof(int),compareint);
printf("\nSorted : "); for(i=0;i<N;i++){printf("%d,",nums[i]);}
double mean = sumN/(double)N;
int ucnt = 1, umaxcnt=1;
for(i=0;i<N;i++)
{

sqrdiffmean += pow(nums[i]-mean,2); // for variance
cubediffmean += pow(nums[i]-mean,3); // for skewness
quaddiffmean += pow(nums[i]-mean,4); // for Kurtosis


if(ucnt == umaxcnt && lastmode != nums[i])
{
sprintf(tmp,"%d ",nums[i]);
strcat(mode,tmp);
}

if(nums[i]-nums[i+1]!=0) {ucnt=1;} else {ucnt++;}

if(ucnt>umaxcnt)
{
umaxcnt=ucnt;
memset(mode,'\0',sizeof(mode));
sprintf(tmp,"%d ",nums[i]);
strcat(mode,tmp);
lastmode=nums[i];
}
}

if(N%2==0) {median = (nums[(N/2)-1] + nums[(N/2)]) / 2.0;}
else {median = nums[(N-1)/2];}
printf("\n\nN = %d\n", N);
printf("Sum N = %.0f\n", sumN);
printf("Mean = %.1f\n", mean);
printf("Median = %.1f\n", median);
if(umaxcnt > 1) {printf("Mode(s) = %s (%d occurrences)\n", mode,umaxcnt);}
else {printf("Mode(s) = na (no repeating values)\n");}
printf("Variance = %.2f\n", sqrdiffmean/N);
printf("Std Dev = %.2f\n", sqrt(sqrdiffmean/N));
printf("Skewness P = %.4f\n", cubediffmean / (N *
pow(sqrt(sqrdiffmean/N),3)));
printf("Kurtosis P = %.4f\n", quaddiffmean / (N *
pow(sqrt(sqrdiffmean/N),4)));
return(0);
} =======================================================================

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor