Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Q: What do you call a blind, deaf-mute, quadraplegic Virginian? A: Trustworthy.


comp / comp.os.linux.advocacy / Re: Need a Laugh? Watch DFS tear Feeb a new one.

Subject: Re: Need a Laugh? Watch DFS tear Feeb a new one.
From: DFS
Newsgroups: comp.os.linux.advocacy
Date: Sat, 13 Jul 2024 21:29 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.netnews.com!postmaster.netnews.com!us1.netnews.com!not-for-mail
X-Trace: DXC=XCbI2hoh?3;2Z65?TJZPK3HWonT5<]0T=Q;nb^V>PUf65[gZBW6J?L<b4Xlnec8Yj4T4cmOY[<WV0MEj?T1`1hb9Mba][>SC2C7f;]EoU=id56=R<hY6_C9T8
X-Complaints-To: support@blocknews.net
Date: Sat, 13 Jul 2024 17:29:32 -0400
MIME-Version: 1.0
User-Agent: Betterbird (Windows)
From: nospam@dfs.com (DFS)
Subject: Re: Need a Laugh? Watch DFS tear Feeb a new one.
Newsgroups: comp.os.linux.advocacy
References: <17e193b486847bee$317$2290655$802601b3@news.usenetexpress.com>
Content-Language: en-US
In-Reply-To: <17e193b486847bee$317$2290655$802601b3@news.usenetexpress.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 307
Message-ID: <6692f1bc$0$1895505$882e4bbb@reader.netnews.com>
NNTP-Posting-Host: 127.0.0.1
X-Trace: 1720906172 reader.netnews.com 1895505 127.0.0.1:40417
View all headers

On 7/12/2024 5:15 PM, Lameass Larry Piet wrote:

> The DooFuS wants to read a text file to determine its
> length and then rewind and process from the beginning.

wtf are you babbling about now, numbnut?

You might be referring to my clc post 'Whaddaya think?'

But it's clear you didn't understand it. I wasn't concerned with the
'length of the file' (whatever that means). I was counting the number
of data points in the file so I could allocate memory, then rewind the
file and read them in.

idiot

> Holy godzilla mutherfuckers!
>
> Hasn't this infinite idiot ever heard of GNU flex?

Why tf would anyone EVER waste their time and use such GuhNoo crapware
just to read a set of numbers from a file? It's a few lines of simple code.

AND, even though my original file format is integers separated by spaces
(shown for compactness in the post), my code works unchanged if they're
separated by line-feeds.

double idiot

> Even a C newbie would seriously consider pre-processing
> the input file to get it into proper shape. But not
> this insuperable dunce.

Who needs to "pre-process" a set of integers?

triple idiot

> Any moron so totally inept in programming cannot ever
> be admitted into a serious discussion of GNU/Linux.

You labeled this double-time shit-code of yours "wonderfully perfect and
highly efficient":

/* free all strarray elements */
for(i = 0; i < rec_count; i++) {
free(data[i]->field1);
free(data[i]->field2);
free(data[i]->field3);
free(data[i]);
i++;
}

Who are you to talk about 'inept programming', asshole? You were
clearly having another one of your "C Programmer Extraordinaire" moments.

http://al.howardknight.net/?STYPE=msgid&MSGI=%3Crnelct0tjg%40news3.newsguy.com%3E

Here's the full population descriptive stats program (of which the file
import is an option).

It's very entertaining.

compile
$ gcc -Wall prog.c -o prog -lm

use
$ ./prog -option N|F
where option is:
-r generates N random numbers
-c generates consecutive numbers 1 to N
-o generates random numbers with outliers
-f read in dataset from file
N is 2+, or F is the file containing the integers

===================================================================
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
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[])
{     if(argc < 3) {
printf("Missing argument:\n");
printf(" * enter an option -r -c -o or -f\n");
printf(" * enter a number greater than 2, or a file name\n");
exit(0);
    }
    int i = 0,N = 0;
    int *nums;
    if(strcmp(argv[1],"-f") != 0) {
N = atoi(argv[2]);
nums = malloc(N * sizeof(int));
    }
    if(strcmp(argv[1],"-r") == 0) {
srand(time(NULL));
for(i=0;i<N;i++) { nums[i] = randNbr(1,N*3); }

printf("%d Randoms between 1 and %d\n", N, 3*N);
printf("No commas : "); for(i=0;i<N;i++) { printf("%d ",
nums[i]); }
printf("\nWith commas: "); for(i=0;i<N;i++) { printf("%d,",
nums[i]); }
qsort(nums,N,sizeof(int),compareint);
printf("\nSorted : "); for(i=0;i<N;i++) { printf("%d ",
nums[i]); }
printf("\nSorted : "); for(i=0;i<N;i++) { printf("%d,",
nums[i]); }
    }
    if(strcmp(argv[1],"-o") == 0) {
srand(time(NULL));
nums[0] = 1; nums[1] = 3;
for(i=2;i<N-2;i++) { nums[i] = randNbr(100,N*30); }
nums[N-2] = 1000; nums[N-1] = 2000;

printf("%d Randoms with outliers\n", N);
printf("No commas : "); for(i=0;i<N;i++) { printf("%d ",
nums[i]); }
printf("\nWith commas: "); for(i=0;i<N;i++) { printf("%d,",
nums[i]); }
qsort(nums,N,sizeof(int),compareint);
printf("\nSorted : "); for(i=0;i<N;i++) { printf("%d ",
nums[i]); }
printf("\nSorted : "); for(i=0;i<N;i++) { printf("%d,",
nums[i]); }
    }
    if(strcmp(argv[1],"-c") == 0) {
for(i=0;i<N;i++) { nums[i] = i + 1; }

printf("%d Consecutive\n", N);
printf("No commas : "); for(i=0;i<N;i++) { printf("%d ",
nums[i]); }
printf("\nWith commas : "); for(i=0;i<N;i++) { printf("%d,",
nums[i]); }
    }
    if(strcmp(argv[1],"-f") == 0) {
nums = malloc(2 * sizeof(int));
FILE* datafile = fopen(argv[2], "r");
while(fscanf(datafile, "%d", &nums[N++]) == 1){
nums = realloc(nums, (N+1) * sizeof(int));
}
fclose (datafile);
N--;
printf("%d from file", N);
printf(" : "); for(i=0;i<N;i++) { printf("%d ", nums[i]); }
qsort(nums,N,sizeof(int),compareint);
printf("\nNo commas : "); for(i=0;i<N;i++) { printf("%d ",
nums[i]); }
printf("\nWith commas : "); for(i=0;i<N;i++) { printf("%d,",
nums[i]); }

    }
    double dmin = nums[0], dmax = nums[N-1];
    double sumN=0.0, median=0.0, Q1=0.0, Q2=0.0, Q3=0.0, IQR=0.0;
    double sqrdiffmean = 0.0, cubediffmean = 0.0, quaddiffmean = 0.0;
    double meanabsdev = 0.0, rootmeansqr = 0.0;
    char temp[15]="";
    for(i=0;i<N;i++) {sumN += nums[i];}
    double mean = sumN / (double)N;
    for(i = 0; i < N; i++)
    {
double diff = nums[i] - mean;
sqrdiffmean += diff * diff;
cubediffmean += diff * diff * diff;
quaddiffmean += diff * diff * diff * diff;
meanabsdev += fabs(diff);
rootmeansqr += nums[i] * nums[i];
    }
    double stddev = sqrt(sqrdiffmean/N);
    double kurtosis = quaddiffmean / (N * pow(sqrt(sqrdiffmean/N),4));
    if(N % 2 == 0) {
Q2 = median = (nums[(N/2)-1] + nums[N/2]) / 2.0;
i = N/2;
if(i % 2 == 0) {
Q1 = (nums[(i/2)-1] + nums[i/2]) / 2.0;
Q3 = (nums[i + ((i-1)/2)] + nums[i+(i/2)]) / 2.0;
}
else {
Q1 = nums[(i-1)/2];
Q3 = nums[i + ((i-1)/2)];
}
    }
    if(N % 2 != 0) {
Q2 = median = nums[(N-1)/2];
i = (N-1)/2;
if(i % 2 == 0) {
Q1 = (nums[(i/2)-1] + nums[i/2]) / 2.0;
Q3 = (nums[i + (i/2)] + nums[i + (i/2) + 1]) / 2.0;
}
else {
Q1 = nums[(i-1)/2];
Q3 = nums[i + ((i+1)/2)];
}
    }
    int occur = 0;
    char mode[250] = "";
    if(strcmp(argv[2],"-c") != 0) {
int *modecnt = calloc(dmax + 1, sizeof(int));
for(i = 0; i < N; i++) {
modecnt[nums[i]]++;
if(modecnt[nums[i]] > occur) {
occur = modecnt[nums[i]];
}
}
if (occur > 1) {
for(i = 0; i <= dmax; i++) {
if(modecnt[i] == occur) {
sprintf(temp,"%d ",i);
strncat(mode,temp,strlen(temp));
}
}
}
free(modecnt);
    }
    IQR = Q3 - Q1;
    char outliers[200]="";
    if (N > 3) {
double lo = Q1 - (1.5 * IQR);
double hi = Q3 + (1.5 * IQR);
if (dmin >= lo && dmax <= hi) {
strcat(outliers,"none (using IQR * 1.5 rule)");
}
if (dmin < lo || dmax > hi) {
for(i = 0; i < N; i++) {
double val = (double)nums[i];
if(val < lo || val > hi) {
sprintf(temp,"%.0f ",val);
printf("%d\n",(int)strlen(temp));
strncat(outliers, temp, strlen(temp));
}
}
strcat(outliers," (using IQR * 1.5 rule)");
}
outliers[strlen(outliers)] = '\0';
    }
    printf("\n--------------------------------------------------------------\n");
    printf("Minimum : %.0f\n", dmin);
    printf("Maximum : %.0f\n", dmax);
    printf("Range : %.0f\n", dmax - dmin);
    printf("Size N : %d\n" , N);
    printf("Sum N : %.0f\n", sumN);
    printf("Mean μ : %.2f\n", mean);
    printf("Median : %.1f\n", median);
    if(occur > 1) {
    printf("Mode(s) : %s (%d occurrences ea)\n", mode,occur);}
    else {
    printf("Mode(s) : na (no repeating values)\n");}
    printf("Std Dev σ : %.6f\n", stddev);
    printf("Variance σ^2 : %.6f\n", sqrdiffmean/N);
    printf("Mid Range : %.1f\n", (dmax + dmin)/2);
    printf("Quartiles");
    if(N > 3) {printf(" Q1: %.1f\n", Q1);}
    if(N < 4) {printf(" Q1: na\n");}
    printf(" Q2: %.1f (median)\n", Q2);
    if(N > 3) {printf(" Q3: %.1f\n", Q3);}
    if(N < 4) {printf(" Q3: na\n");}
    printf("IQR : %.1f (interquartile range)\n", IQR);
    if(N > 3) {printf("Outliers : %s\n", outliers);}
    if(N < 4) {printf("Outliers : na\n");}
    printf("Sum Squares SS : %.6f\n", sqrdiffmean);
    printf("MAD : %.6f (mean absolute deviation)\n",
meanabsdev / N);
    printf("Root Mean Sqr : %.6f\n", sqrt(rootmeansqr / N));
    printf("Std Error Mean : %.6f\n", stddev / sqrt(N));
    printf("Skewness γ1 : %.6f\n", cubediffmean / (N *
pow(sqrt(sqrdiffmean/N),3)));
    printf("Kurtosis β2 : %.6f\n", kurtosis);
    printf("Kurtosis Excess α4 : %.6f\n", kurtosis - 3);
    printf("CV : %.8f (coefficient of variation\n",
sqrt(sqrdiffmean/N) / mean);
    printf("RSD : %.6f%% (relative std deviation)\n",
100 * (sqrt(sqrdiffmean/N) / mean));
    printf("--------------------------------------------------------------\n");
    printf("Check results up to N=9999 against\n");
    printf("https://www.calculatorsoup.com/calculators/statistics/descriptivestatistics.php");
    printf("\n\n");
    free(nums);
    return 0;
} ===============================================================================

pwned

SubjectRepliesAuthor
o Need a Laugh? Check the DooFuS Posts on Comp.Lang.C

By: Lester Thorpe on Fri, 12 Jul 2024

27Lester Thorpe

rocksolid light 0.9.8
clearnet tor