Add files via upload
bulk data dump
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
## build Histogram
|
||||
## jbs - paragonsoft
|
||||
## 06 Apr 2024 15:55
|
||||
|
||||
all: histo
|
||||
|
||||
histo: histogram.c
|
||||
cc -o histo histogram.c -lm
|
||||
clean:
|
||||
rm histo
|
||||
@@ -0,0 +1,29 @@
|
||||
# Histogram
|
||||
|
||||
what is a histogram?
|
||||
The visual representation that charts the frequency distribution of variables in a data set.
|
||||
A frequency distribution shows the regularity of an occurrence of a value in a set of data.
|
||||
Often confused with a bar chart, although there are certain defining characteristics of differentiation.
|
||||
* The x-axis consists of equal width bars without space in between, known as bins or buckets that represent a range of classes.
|
||||
* x axis is the class interval and is labelled with a number rather than a description.
|
||||
* The y axis represents the frequency of occurrence of a value.
|
||||
* Bar graphs represents data that is discrete or categorical in nature
|
||||
|
||||
Uses
|
||||
In statistics to show the frequency of a specific value within a certain range.
|
||||
Used to analyse large amounts of data easily to detect trends and patterns.
|
||||
|
||||
## Change-log:
|
||||
|
||||
* 06/04/2023 - Initial release
|
||||
* 04/04/2023 - Foundation code
|
||||
|
||||
## Compilation
|
||||
type `make` or `cc -o histo histogram.c -lm` on the command line
|
||||
|
||||
## Todo
|
||||
* Need to use SDL2 to plot a graph of the output
|
||||
|
||||
## Author(s)
|
||||
Jason Bou-Samra
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
10.000000000000000000 89.000000000000000000
|
||||
20.000000000000000000 108.000000000000000000
|
||||
30.000000000000000000 120.000000000000000000
|
||||
40.000000000000000000 109.000000000000000000
|
||||
50.000000000000000000 111.000000000000000000
|
||||
60.000000000000000000 127.000000000000000000
|
||||
70.000000000000000000 88.000000000000000000
|
||||
80.000000000000000000 117.000000000000000000
|
||||
90.000000000000000000 87.000000000000000000
|
||||
100.000000000000000000 83.000000000000000000
|
||||
110.000000000000000000 109.000000000000000000
|
||||
120.000000000000000000 96.000000000000000000
|
||||
130.000000000000000000 85.000000000000000000
|
||||
140.000000000000000000 102.000000000000000000
|
||||
150.000000000000000000 121.000000000000000000
|
||||
160.000000000000000000 97.000000000000000000
|
||||
170.000000000000000000 97.000000000000000000
|
||||
180.000000000000000000 96.000000000000000000
|
||||
190.000000000000000000 109.000000000000000000
|
||||
200.000000000000000000 104.000000000000000000
|
||||
210.000000000000000000 99.000000000000000000
|
||||
220.000000000000000000 104.000000000000000000
|
||||
230.000000000000000000 94.000000000000000000
|
||||
240.000000000000000000 90.000000000000000000
|
||||
250.000000000000000000 97.000000000000000000
|
||||
260.000000000000000000 99.000000000000000000
|
||||
270.000000000000000000 100.000000000000000000
|
||||
280.000000000000000000 80.000000000000000000
|
||||
290.000000000000000000 95.000000000000000000
|
||||
300.000000000000000000 111.000000000000000000
|
||||
310.000000000000000000 97.000000000000000000
|
||||
320.000000000000000000 86.000000000000000000
|
||||
330.000000000000000000 88.000000000000000000
|
||||
340.000000000000000000 100.000000000000000000
|
||||
350.000000000000000000 86.000000000000000000
|
||||
360.000000000000000000 98.000000000000000000
|
||||
370.000000000000000000 98.000000000000000000
|
||||
380.000000000000000000 91.000000000000000000
|
||||
390.000000000000000000 101.000000000000000000
|
||||
400.000000000000000000 93.000000000000000000
|
||||
410.000000000000000000 106.000000000000000000
|
||||
420.000000000000000000 97.000000000000000000
|
||||
430.000000000000000000 85.000000000000000000
|
||||
440.000000000000000000 103.000000000000000000
|
||||
450.000000000000000000 107.000000000000000000
|
||||
460.000000000000000000 98.000000000000000000
|
||||
470.000000000000000000 125.000000000000000000
|
||||
480.000000000000000000 96.000000000000000000
|
||||
490.000000000000000000 105.000000000000000000
|
||||
500.000000000000000000 98.000000000000000000
|
||||
510.000000000000000000 100.000000000000000000
|
||||
520.000000000000000000 114.000000000000000000
|
||||
530.000000000000000000 82.000000000000000000
|
||||
540.000000000000000000 99.000000000000000000
|
||||
550.000000000000000000 93.000000000000000000
|
||||
560.000000000000000000 105.000000000000000000
|
||||
570.000000000000000000 107.000000000000000000
|
||||
580.000000000000000000 83.000000000000000000
|
||||
590.000000000000000000 119.000000000000000000
|
||||
600.000000000000000000 81.000000000000000000
|
||||
610.000000000000000000 102.000000000000000000
|
||||
620.000000000000000000 103.000000000000000000
|
||||
630.000000000000000000 110.000000000000000000
|
||||
640.000000000000000000 100.000000000000000000
|
||||
650.000000000000000000 89.000000000000000000
|
||||
660.000000000000000000 77.000000000000000000
|
||||
670.000000000000000000 96.000000000000000000
|
||||
680.000000000000000000 115.000000000000000000
|
||||
690.000000000000000000 104.000000000000000000
|
||||
700.000000000000000000 104.000000000000000000
|
||||
710.000000000000000000 107.000000000000000000
|
||||
720.000000000000000000 99.000000000000000000
|
||||
730.000000000000000000 99.000000000000000000
|
||||
740.000000000000000000 96.000000000000000000
|
||||
750.000000000000000000 100.000000000000000000
|
||||
760.000000000000000000 85.000000000000000000
|
||||
770.000000000000000000 106.000000000000000000
|
||||
780.000000000000000000 111.000000000000000000
|
||||
790.000000000000000000 95.000000000000000000
|
||||
800.000000000000000000 97.000000000000000000
|
||||
810.000000000000000000 105.000000000000000000
|
||||
820.000000000000000000 102.000000000000000000
|
||||
830.000000000000000000 112.000000000000000000
|
||||
840.000000000000000000 104.000000000000000000
|
||||
850.000000000000000000 121.000000000000000000
|
||||
860.000000000000000000 111.000000000000000000
|
||||
870.000000000000000000 94.000000000000000000
|
||||
880.000000000000000000 88.000000000000000000
|
||||
890.000000000000000000 110.000000000000000000
|
||||
900.000000000000000000 125.000000000000000000
|
||||
910.000000000000000000 105.000000000000000000
|
||||
920.000000000000000000 84.000000000000000000
|
||||
930.000000000000000000 93.000000000000000000
|
||||
940.000000000000000000 94.000000000000000000
|
||||
950.000000000000000000 101.000000000000000000
|
||||
960.000000000000000000 78.000000000000000000
|
||||
970.000000000000000000 107.000000000000000000
|
||||
980.000000000000000000 98.000000000000000000
|
||||
990.000000000000000000 113.000000000000000000
|
||||
1000.000000000000000000 91.000000000000000000
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/************************************
|
||||
** Display data file as Histogram **
|
||||
** Jason Bou-Samra 06/04/2024 **
|
||||
** Paragon Software **
|
||||
************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
int N = 10000; // number of samples (data points)
|
||||
int nbin = round(sqrt(N)); // number of bins ~ sqrt(N) (or nearest integer value if not perfect square)
|
||||
float hist[nbin]; // histogram array
|
||||
float x[N]; // array of data points
|
||||
float xmax, xmin; // minimum & maximum x data point values
|
||||
float summ; // used to normalise data
|
||||
float dx; // dx = (xmax - xmin) / nbin (delta value)
|
||||
int i,j; // index variables
|
||||
|
||||
FILE *fptr_r, *fptr_w; // read and write file pointers
|
||||
|
||||
fptr_r = fopen("uniform.dat", "r"); // data points (read in)
|
||||
fptr_w = fopen("dist3.dat", "w"); // the histogram output file (write out)
|
||||
|
||||
if(fptr_r == NULL || fptr_w == NULL) {
|
||||
perror("Error opening file");
|
||||
return(-1);} // handle fopen error, if any
|
||||
|
||||
for (i = 0; i < N+1; i++)
|
||||
{
|
||||
fscanf(fptr_r, "%G", &x[i]);
|
||||
}
|
||||
|
||||
xmin = x[1]; // search for xmin
|
||||
for (i = 1 ; i < N+1 ; i++)
|
||||
{
|
||||
if (x[i] < xmin) {
|
||||
xmin = x[i];
|
||||
}
|
||||
}
|
||||
|
||||
xmax = x[1]; // search for xmax
|
||||
for (i = 1 ; i < N+1 ; i++)
|
||||
{
|
||||
if (x[i] > xmax) {
|
||||
xmax = x[i];
|
||||
}
|
||||
}
|
||||
dx = (xmax - xmin) / (float)(nbin); // calculate dx
|
||||
|
||||
for (j = 0 ; j < nbin+1 ; j++) // compute histogram
|
||||
{
|
||||
hist[j] = 0.0f;
|
||||
for (i = 0 ; i < N+1 ; i++)
|
||||
{
|
||||
if ((x[i] >= (xmin + (j - 1) * dx) && x[i] < xmin + j * dx))
|
||||
hist[j] = hist[j] + 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
//summ = 0.0f; // normalize
|
||||
//for (i = 1 ; i < nbin ; i++) summ = summ + hist[i];
|
||||
//for (i = 1 ; i < nbin ; i++) hist[i] = hist[i] / summ;
|
||||
|
||||
for (i = 1; i < nbin+1; i++)
|
||||
{
|
||||
fprintf(fptr_w, " %3.18f %3.18f\n", xmin+i*dx, hist[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+10000
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user