Forum Discussion
Using Data Analysis tool pak to create histograms
Hello I am trying to create a histogram for the data on acorn size in mm for two collection sites. Site 1 is titled Creek, and site 2 is titled River.
RIVER Site data is:
5.8
5.2
5.7
4.2
4.1
4.7
4.1
4.4
5.1
4.8
4.8
4.7
4.2
4.3
5.5
4.1
3.8
4.1
5.3
3.9
4.2
3.9
2.9
4.1
4.7
3.1
3.1
5.0
3.6
3.2
CREEK Site data is:
3.6
3.0
2.9
3.0
2.6
3.1
3.2
3
3.2
2.9
3.1
3.1
3.2
2.9
3.1
3.1
4.9
5.1
3.2
3.1
3.3
2.8
2.9
2.8
2.9
2.4
2.9
3.7
3.3
3.2
My question is how do I use this data with the data analysis tool pak to create a histogram. What goes into the input, and what would the bin range be? Please help I'm so lost!
Thank you,
James
3 Replies
- m_tarlerSilver Contributor
Here is a screenshot with the Histogram tool from the Data Analysis :
I already did the "River" data as shown in the histogram in F2:G8 and the chart next to it and the current Histogram input window is set to repeat for the Creek data. The key is that you need to create the list of Bin values (see D2:D6) before launching that tool so you can point to that range.
- Patrick2788Silver Contributor
I can't speak to the analysis tool pak solution as I haven't used it in ages. I will offer a generalized Lambda solution - Histogramλ. This function will take care of the binning for you by inspecting the data and applying the binning rule which makes the most sense. You can also override this by supplying the bin_width (optional).
/* [GR13] ------------------------------------------------------------------------- Function: Histogramλ Category: Grid Analytics (Statistics) Author: Patrick H. Version: 1.1 Description: Generates a histogram using automatic binning rules (Sturges, Rice, Scott, Freedman) depending on sample size and skewness. Supports an optional fixed bin width and an optional Pareto (cumulative %) column. Parameters: array - Numeric array (1D or 2D). [bin_width] - Optional fixed bin width (0 < width ≤ 1000). [include_Pareto] - TRUE → include cumulative % column. Notes: • Returns #VALUE! if fewer than 2 values are supplied. • Caps total bins at 100. • If bin_width is supplied, automatic rules are bypassed. ------------------------------------------------------------------------------*/ Histogramλ = LAMBDA( array, [bin_width], [include_Pareto], IF(COUNT(array) <= 1,#VALUE!, IF(AND(NOT(ISOMITTED(bin_width)),OR(bin_width < 0, bin_width > 1000)),"#BIN-WIDTH!", LET( // Sample characteristics n, COUNT(array), SmallData?, n < 200, Add_Pareto?, NOT(ISOMITTED(include_Pareto)), min, MIN(array), max, MAX(array), range, max - min, iqr, QUARTILE(array, 3) - QUARTILE(array, 1), s, SKEW(array), IsSkewed?, IF(SmallData?, FALSE, ABS(s) > 0.2), // Optional fixed bin width IsFixed?, NOT(ISOMITTED(bin_width)), // Automatic binning rules Sturge, CEILING(LOG(n, 2) + 1, 1), SRR, CEILING(SQRT(n), 1), Rice, CEILING(2 * n^(1/3), 1), Scott, CEILING(3.5 * STDEV.P(array) / n^(1/3), 1), Freedman, CEILING(2 * iqr / n^(1/3), 1), fixed, CEILING(range / bin_width, 1 / bin_width), // Bin count selection k, IF(IsFixed?,fixed, IF(n <= 30,MAX(Sturge, Rice), IF(IsSkewed?,MIN(Freedman, 15), MIN(Scott, 15)))), // Avoid single-bin output; cap at 100 k_, MIN(IF(k = 1, 5, k), 100), // Bin interval interval, IF(range = 0, 1, MAX(range / k_, 0.1)), bin_upper, CEILING(max, interval), bin_lower, FLOOR(min, interval), bin_arr, SEQUENCE(1 + (bin_upper - bin_lower) / interval,,bin_lower,interval), // Bin labels bin_start, DROP(bin_arr, -1), bin_end, DROP(bin_arr, 1), bin_header, {"Start", "End", "Total"}, bin_labels, HSTACK(VSTACK("<", bin_start), VSTACK(TAKE(bin_start, 1), bin_end)), // Frequencies and Pareto freq, DROP(FREQUENCY(array, bin_arr), -1), Pareto, BYROW(freq, LAMBDA(v, PERCENTOF(v, freq))), // Final assembly stack, VSTACK(bin_header, HSTACK(bin_labels, freq)), deliver, IF(Add_Pareto?,SORT(HSTACK(stack,VSTACK("Cumulative %", Pareto)),3,-1), stack), deliver ))));- cadtriCopper Contributor
https://www.cadtri.com/helps contractors, developers, architects, and property owners keep projects moving with permit-ready construction drawings, coordinated documentation, and reliable drafting support services.