{"id":20221658,"url":"https://github.com/phcerdan/histogram","last_synced_at":"2025-04-10T16:23:10.951Z","repository":{"id":27922671,"uuid":"31414884","full_name":"phcerdan/histogram","owner":"phcerdan","description":"Histogram in C++11, 1D, simple header-only, inspired by R, calculate and optimize breaks automatically. Accepts different precissions.","archived":false,"fork":false,"pushed_at":"2020-08-05T11:00:09.000Z","size":725,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T14:11:16.545Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phcerdan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-27T10:40:16.000Z","updated_at":"2022-10-09T03:50:46.000Z","dependencies_parsed_at":"2022-08-02T10:52:05.748Z","dependency_job_id":null,"html_url":"https://github.com/phcerdan/histogram","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phcerdan%2Fhistogram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phcerdan%2Fhistogram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phcerdan%2Fhistogram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phcerdan%2Fhistogram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phcerdan","download_url":"https://codeload.github.com/phcerdan/histogram/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248252658,"owners_count":21072699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T06:53:57.724Z","updated_at":"2025-04-10T16:23:10.933Z","avatar_url":"https://github.com/phcerdan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"You might be interested in the modern and more mature [boost::histogram](https://github.com/boostorg/histogram) header only library.\n\n# Histogram\nHistogram in C++11, 1D, simple header-only, inspired by R, calculate and optimize breaks automatically. Accepts different precissions.\n# Documentation\n\n\u003c!-- [Doxygen generated Docs](http://phcerdan.github.io/histo-header/docs/html/index.html) --\u003e\n[Doxygen generated Docs](http://phcerdan.github.io/histogram/docs/html/index.html)\n\nWarning, docs are not generated automatically and might be outdated.\n\n# Downloading\nYou can use the header as is, just download it, and include it in your project.\nMIT License, but please contribute back if you add any extra feature!\n\n# Using it.\nYou should read the test file as a sample for usage.\n```cpp\nvector\u003cdouble\u003e data{1.0, 1.0, 2.0, 3.0, 19.0, 0.5, 14.0};\nhisto::Histo\u003cdouble\u003e h_scott(data); // Default method to calculate Breaks.\nsize_t bins = 10;\nauto breaks_with_bins = histo::GenerateBreaksFromRangeAndBins\u003cdouble\u003e(0.0, 20.0, bins);\ndouble width = 1.0;\nauto breaks_with_fixed_width = histo::GenerateBreaksFromRangeAndWidth\u003cdouble\u003e(0.0, 20.0, width);\nhisto::Histo\u003cdouble\u003e h_with_bins(data, breaks_with_bins);\nhisto::Histo\u003cdouble\u003e h_with_width(data, breaks_with_width);\n```\n\nEach histogram has public members: `bins`, `breaks`, `counts` and `range`.\nWe can fill the histogram with `FillCounts(data)`, called at constructor.\nThe data is not stored in the histogram.\n\nWe can fill the bins with more data to an existing histogram.\n```cpp\nvector\u003cdouble\u003e extra_data{7.0, 13.0};\nh_with_bins.FillCounts(extra_data);\n```\n\nWe can also normalize the histogram to get a probability density function from it.\n\n```cpp\nhisto::Histo\u003cdouble, unsigned int\u003e regular_histo(data);\nhisto::Histo\u003cdouble, double\u003e normalized_histogram = histo::NormalizeByArea(regular_histo);\n```\n\nOptionally, we can use VTK (vtkChartXY) to visualize the histogram.\n\n```cpp\nvector\u003cdouble\u003e data{0.0, 1.0, 1.0,1.0, 2.0, 3.0, 5.0, 5.0, 8.0, 8.0,  12.0};\nHisto\u003cdouble\u003e h(data, histo::GenerateBreaksFromRangeAndBins\u003cdouble\u003e(0.0,15.0, 5));\nh.PrintBreaksAndCounts(std::cout);\nh.name = \"withJustData\";\nvisualize_histo(h, vtkChart::LINE);\nvisualize_histo(h, vtkChart::BAR);\n```\n\n\n\u003cimg src=\"https://github.com/phcerdan/histogram/blob/gh-pages/readme_images/just_data_line.png\" alt=\"Line\" width=\"640\" height=\"480\"\u003e\n\u003cimg src=\"https://github.com/phcerdan/histogram/blob/gh-pages/readme_images/bar_just_data.png\" alt=\"Bar\" width=\"640\" height=\"480\"\u003e\n\n# Test\nAll the features are tested using gtest.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphcerdan%2Fhistogram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphcerdan%2Fhistogram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphcerdan%2Fhistogram/lists"}