Deutsch   English   Français   Italiano  
<vlu58c$mdjf$3@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: DFS <guhnoo-basher@linux.advocaca>
Newsgroups: comp.os.linux.advocacy
Subject: Re: Why GIMP Is Better Than Photoshop
Date: Sat, 11 Jan 2025 11:12:00 -0500
Organization: A noiseless patient Spider
Lines: 312
Message-ID: <vlu58c$mdjf$3@dont-email.me>
References: <pan$12f0c$b8055f7b$e138cd3a$8c4aa277@linux.rocks>
 <vle9tl$13eiv$3@dont-email.me> <vlerd7$13ci0$4@dont-email.me>
 <vlfbcv$19rah$1@dont-email.me> <vlhdf5$1mvfl$1@dont-email.me>
 <vlhdrg$1pgeu$2@dont-email.me> <vlhg72$1mrpk$3@dont-email.me>
 <vlhlnf$1r4fb$1@dont-email.me> <vlhtmb$1shoo$1@dont-email.me>
 <1818649790e0bb2f$109336$891815$802601b3@news.usenetexpress.com>
 <vlkdm1$1vekp$1@solani.org> <pan$bcfa$35279e17$8c30f97b$96d7b78d@linux.rocks>
 <vlmoai$20prf$4@solani.org>
 <pan$d5d0b$12fc6de0$3676d124$ef46004b@linux.rocks>
 <vlmt5k$20tmg$1@solani.org> <pan$3a3b$85056c6e$911fe2eb$3ea1376@linux.rocks>
 <lu8l63Fj3pqU3@mid.individual.net> <vlq146$3kfpo$1@dont-email.me>
 <pan$1dd3e$cd2f970$63112fc0$f871af9a@linux.rocks>
 <vlt4hm$goeg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 11 Jan 2025 17:11:57 +0100 (CET)
Injection-Info: dont-email.me; posting-host="239423d1bee743aa2dddf7e3888ce357";
	logging-data="734831"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/5+p+0NO7vAcoAzEUCbm1q"
User-Agent: Betterbird (Windows)
Cancel-Lock: sha1:4GJePL6rdvJv4acFXMS+OJZ2zLE=
In-Reply-To: <vlt4hm$goeg$1@dont-email.me>
Content-Language: en-US

On 1/11/2025 1:53 AM, Physfitfreak wrote:


> Score of 85 might be a bit too harsh in his case, but I have no doubt 
> that he's around the average IQ but on the dumb side of that average; 
> never on the other side. That, I'm sure.

Get ready Maleki.

========================================================================================
//this code is hereby released to the public domain

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


/*
  this program computes the descriptive statistics of sets of integers

  1.0 release Dec 2020
  2.0 release Jun 2024

  used the population skewness and Kurtosis formulas from:

https://www.calculatorsoup.com/calculators/statistics/descriptivestatistics.php
  also test the results of this code against that site

  compile:
  $ gcc -Wall prog.c -o prog -lm
  or
  $ gcc -Wall -Wextra -O2 prog.c -o prog -lm
  or
  $ gcc -Wall -Wextra -O2 -fsanitize=undefined prog.c -o prog
  -lm

  usage  : ./prog -option N
            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
		   and N is 2+ or the file name
*/


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

//comparator function used with qsort
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 a number greater than 2\n");
		printf(" * enter an option -r -c -o or -f\n");
		exit(0);
	}	
	
	
	//=================================================================================================
	//generate datasets
	//=================================================================================================
	
	int i = 0, N = 0;
	int *nums;
	if(strcmp(argv[1],"-f") != 0) {
		N = atoi(argv[2]);
		nums  = malloc(N * sizeof(int));
	}
	
	//random
	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);
		for(i=0;i<N;i++) { printf("%d ", nums[i]); }
		qsort(nums,N,sizeof(int),compareint);
		printf("\nSorted:\n"); for(i=0;i<N;i++) { printf("%d ", nums[i]); }
	}	
	
	//random with outliers
	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);
		for(i=0;i<N;i++) { printf("%d ", nums[i]); }
		qsort(nums,N,sizeof(int),compareint);
		printf("\nSorted:\n"); for(i=0;i<N;i++) { printf("%d ", nums[i]); }
	}	
	
	
	//consecutive numbers 1 to N
	if(strcmp(argv[1],"-c") == 0) {
		printf("%d Consecutive\n", N);
		for(i=0;i<N;i++) {
			nums[i] = i + 1;
			printf("%d ", nums[i]);	
		}
	}
	
	
	//read dataset from file
	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", N);
		for(i=0;i<N;i++) { printf("%d ", nums[i]); }
		qsort(nums,N,sizeof(int),compareint);
		printf("\nSorted:\n"); for(i=0;i<N;i++) { printf("%d ", nums[i]); }
	}
	
	
	//=================================================================================================
	//calc descriptive stats
	//=================================================================================================
	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 diff = 0.0, 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++)
	{
		diff          = nums[i] - mean;
		sqrdiffmean  += diff * diff					;  // for variance and sum squares
		cubediffmean += diff * diff * diff			;  // for skewness
		quaddiffmean += diff * diff * diff * diff	;  // for Kurtosis
		meanabsdev   += fabs(diff)					;  // for mean absolute deviation
		rootmeansqr  += nums[i] * nums[i]			;  // for root mean square
	}
		
	double stddev   = sqrt(sqrdiffmean/N);
	double skewness = cubediffmean / (N * pow(stddev,3));
	double kurtosis = quaddiffmean / (N * pow(stddev,4));	
	
	// median and quartiles
	// quartiles divide sorted dataset into four sections
	// Q1 = median of values less than Q2
	// Q2 = median of the data set
	// Q3 = median of values greater than Q2
	if(N % 2 == 0) {
		Q2 = median = (nums[(N/2)-1] + nums[N/2]) / 2.0;
		i = N/2;
========== REMAINDER OF ARTICLE TRUNCATED ==========