
Does boost have a way to make a histogram of a vector? I want to be able to do queries such as: "Which numbers are in the 90th percentile?" Thanks, David

On Tue, Apr 27, 2010 at 4:19 PM, David Doria
Does boost have a way to make a histogram of a vector?
I want to be able to do queries such as:
"Which numbers are in the 90th percentile?"
Thanks,
David
Maybe a better explanation is I want a c++ function that will do what the Matlab hist() function does: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hist.html Thanks, David

Hi,
you can use http://www.codeproject.com/KB/recipes/zigurat.aspx example
or read the BOOST manual on accumulators.
typedef accumulator_set
On Tue, Apr 27, 2010 at 4:19 PM, David Doria
wrote: Does boost have a way to make a histogram of a vector?
I want to be able to do queries such as:
"Which numbers are in the 90th percentile?"
Thanks,
David
Maybe a better explanation is I want a c++ function that will do what the Matlab hist() function does: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hist.html
Thanks,
David _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- ------------------------------------------ Dr Arman Khalatyan, Observatoire Astronomique de Marseille-Provence Laboratoire d'Astrophysique de Marseille -----------------------------------------

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of David Doria Sent: Tuesday, April 27, 2010 9:19 PM To: boost-users@lists.boost.org Subject: [Boost-users] Histogram
Does boost have a way to make a histogram of a vector?
I want to be able to do queries such as:
"Which numbers are in the 90th percentile?"
When you have decided how to bin your values... You might like also to look at the example in the SVG Visualization 2007 GSoC project \boost-sandbox\SOC\2007\visualization\libs\svg_plot\example https://svn.boost.org/svn/boost/sandbox/SOC/2007/visualization/libs/svg_plot... and the svg plot it produces is attached. You will find a pdf version of the manual at https://svn.boost.org/svn/boost/sandbox/SOC/2007/visualization/libs/svg_plot... HTH Paul --- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow@hetp.u-net.com

Thanks Paul, I'll check it out. Arman helped me get to a working demo (below) but I am still a bit confused. 1) What is the "cache"/"cache size"? 2) Does this line: double tqueryP = quantile(acc0, quantile_probability = 0.50 ); tell you the percentage of the input values that fall in the top 50% of all input values? Here is the code: std::vector<double> data(100); std::generate(data.begin(), data.end(), data_filler<double>()); int c = data.size();//cache size for histogramm. //create a accumulator. accumulator_t_right acc0( boost::accumulators::tag::tail<right>::cache_size = c ); //fill accumulator for (int j = 0; j < c; ++j) { acc0(data[j]); } //ask some questions... double tqueryP = quantile(acc0, quantile_probability = 0.50 ); std::cout << tqueryP << std::endl; Also, with this code: 1) again, what is the cache_size? 2) Is there a way to get a list of the values that are in each bin? Or only the percentage of the input values that fall in the bin? //create some random data std::vector<double> data(100); std::generate(data.begin(), data.end(), data_filler<double>()); int c = data.size();//cache size for histogramm. //create a accumulator. acc myAccumulator( tag::density::num_bins = 20, tag::density::cache_size = 10); //fill accumulator for (int j = 0; j < c; ++j) { myAccumulator(data[j]); } //ask some questions... //double query = density(myAccumulator); histogram_type hist = density(myAccumulator); double total = 0.0; for( int i = 0; i < hist.size(); i++ ) { std::cout << "Bin lower bound: " << hist[i].first << ", Value: " << hist[i].second << std::endl; total += hist[i].second; } std::cout << "Total: " << total << std::endl; //should be 1 (and it is) Thanks! David

Paul,thanks for reminding SVG stl library, I did not knew that IE does not
support SVG:)
are there plans to add Latex formatting for the Greek/Math symbols for
titles and axises? that will be useful feature,at least for me:).
Thanks Arman.
On Wed, Apr 28, 2010 at 8:18 PM, Paul A. Bristow
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto: boost-users-bounces@lists.boost.org] On Behalf Of David Doria Sent: Tuesday, April 27, 2010 9:19 PM To: boost-users@lists.boost.org Subject: [Boost-users] Histogram
Does boost have a way to make a histogram of a vector?
I want to be able to do queries such as:
"Which numbers are in the 90th percentile?"
When you have decided how to bin your values...
You might like also to look at the example in the SVG Visualization 2007 GSoC project
\boost-sandbox\SOC\2007\visualization\libs\svg_plot\example
https://svn.boost.org/svn/boost/sandbox/SOC/2007/visualization/libs/svg_plot...
and the svg plot it produces is attached.
You will find a pdf version of the manual at
https://svn.boost.org/svn/boost/sandbox/SOC/2007/visualization/libs/svg_plot...
HTH
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow@hetp.u-net.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- ------------------------------------------ Dr Arman Khalatyan, Observatoire Astronomique de Marseille-Provence Laboratoire d'Astrophysique de Marseille -----------------------------------------

From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Arman Khalatyan Sent: Thursday, April 29, 2010 10:58 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] Histogram
Paul,thanks for reminding SVG stl library, I did not knew that IE does not support SVG:)
But with the Adobe addin (still widely available for download but not from Adobe), it does and IE9 promises full support at last (which means I might resume work on this). (And you can also easily use Inkscape to convert to png if you prefer that).
are there plans to add Latex formatting for the Greek/Math symbols for titles and axises? that will be useful feature,at least for me:)
You can already even more easily do this (at least for single line labels) using Unicode there are several examples of this in the sandbox. Finally sub and subscript support for Mozilla Firefox is promised soon. This is a must-have for units labels of course. Paul --- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow@hetp.u-net.com

On Thu, Apr 29, 2010 at 7:48 AM, Paul A. Bristow
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Arman Khalatyan Sent: Thursday, April 29, 2010 10:58 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] Histogram
Paul,thanks for reminding SVG stl library, I did not knew that IE does not support SVG:)
But with the Adobe addin (still widely available for download but not from Adobe), it does – and IE9 promises full support at last (which means I might resume work on this).
(And you can also easily use Inkscape to convert to png if you prefer that).
are there plans to add Latex formatting for the Greek/Math symbols for titles and axises? that will be useful feature,at least for me:)
You can already even more easily do this (at least for single line labels) using Unicode – there are several examples of this in the sandbox.
Finally sub and subscript support for Mozilla Firefox is promised soon. This is a must-have for units labels of course.
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow@hetp.u-net.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Thanks Arman, though I'm still a bit confused. If you can push as much data as you want into the acc: acc( 1.2, covariate1 = 12 ); acc( 2.3, covariate1 = -23 ); acc( 3.4, covariate1 = 34 ); acc( 4.5, covariate1 = -45 ); Here 4 entries were made even though the cache size was 2. If all of the statistics are updated on the fly, then why would you need to store ANY? Thanks, David
participants (3)
-
Arman Khalatyan
-
David Doria
-
Paul A. Bristow