TRIANGLE_HISTOGRAM
Histograms of Triangle Data
TRIANGLE_HISTOGRAM
is a C++ program which
creates a histogram of data in the unit triangle.
The unit triangle has the vertices (1,0), (0,1), (0,0).
"Data" in the unit triangle is assumed to take the form of a file,
containing a list of points that lie in the triangle.
The sides of the triangle can each be
divided into N subintervals, and by connecting them, the result is
N*N subtriangles of the same area.
The program then determines the number of points that lie within
each subtriangle, and prints this list.
This program is particularly suitable for investigating whether
a set of points in the unit triangle are close to a uniformly
sampling, or if there is some bias in the selection.
Usage:
triangle_histogram data_file n
where
-
data_file is the file containing the sample points;
-
n is the number of subintervals into which each side
of the unit triangle is to be divided.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
TRIANGLE_HISTOGRAM is available in
a C++ version and
a FORTRAN90 version and
a MATLAB version.
Related Data and Programs:
RANDOM_DATA,
a C++ program which
produces random samples from a number of regions, including triangles.
TRIANGLE_MONTE_CARLO,
a C++ program which
uses the Monte Carlo method to estimate integrals over a triangle.
TRIANGLE_SAMPLES,
a dataset directory which
contains sets of sample points drawn from the unit triangle.
Reference:
-
Reuven Rubinstein,
Monte Carlo Optimization, Simulation and Sensitivity of
Queueing Networks,
Krieger, 1992,
ISBN: 0894647644,
LC: QA298.R79.
-
Greg Turk,
Generating Random Points in a Triangle,
in Graphics Gems I,
edited by Andrew Glassner,
AP Professional, 1990,
ISBN: 0122861663,
LC: T385.G697
Source Code:
Examples and Tests:
B10000 is a "bad" set of sample points.
G10000 is a "good" set of sample points.
List of Routines:
-
MAIN is the main program for TRIANGLE_HISTOGRAM.
-
CH_CAP capitalizes a single character.
-
CH_EQI is true if two characters are equal, disregarding case.
-
CH_TO_DIGIT returns the integer value of a base 10 digit.
-
FILE_COLUMN_COUNT counts the columns in the first line of a file.
-
FILE_ROW_COUNT counts the number of row records in a file.
-
I4_MAX returns the maximum of two I4's.
-
I4_MIN returns the minimum of two I4's.
-
I4VEC_MAX returns the value of the maximum element in an I4VEC.
-
I4VEC_MEAN returns the mean of an I4VEC.
-
I4VEC_MIN returns the value of the minimum element in an I4VEC.
-
I4VEC_STD returns the standard deviation of an I4VEC.
-
R8MAT_DATA_READ reads the data from an R8MAT file.
-
R8MAT_HEADER_READ reads the header from an R8MAT file.
-
R8MAT_TRANSPOSE_PRINT_SOME prints some of an R8MAT, transposed.
-
S_LEN_TRIM returns the length of a string to the last nonblank.
-
S_TO_I4 reads an I4 from a string.
-
S_TO_R8 reads an R8 from a string.
-
S_TO_R8VEC reads an R8VEC from a string.
-
S_WORD_COUNT counts the number of "words" in a string.
-
TIMESTAMP prints the current YMDHMS date as a time stamp.
You can go up one level to
the C++ source codes.
Last revised on 14 August 2009.