Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

How to bin integral vs floating point correctly (precision issue and general question)

オープン
#336 コメント 37 件 リアクション 0 件 担当者 0 名 GitHub で見る

@ryanelandt がすでに取り組んでいます。

2023年6月15日 から。

  • #344 @HDembinski による — マージ済み
  • #387 @ryanelandt による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
cpp

調査の方向性

issue ではソースファイルもテストも指定されていないため、まず整数データ、[min, max+1] の境界、空の最後のビンを使って、浮動小数点精度のヒストグラムのケースを再現します。ヒストグラムのビニングのエントリポイントと、整数範囲に関する既存のガイダンスを確認します。精度の挙動と推奨される整数の境界が解決・文書化され、報告されたケースのカバレッジが追加されていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Dear @HDembinski and other authors, thanks for this awesome library. We have just started using it and the speed and versatility are impressive! We have a problem that manifests as a precision problem, but also shows a more general question.

The problem: We use the floating precision histogram to bin any kind of data. When we bin data (gray value camera images) of integer precision, we set lower and upper bound based on the data range to [min, max+1] and the number of bins to upper bound - lower bound. However there are sometimes cases where the numeric precision then leads to an empty last bin. This is due to rounding error, the values fall into max-1 instead of max. We checked and the bin index is then computed as (max-1).999... which finally resolves to max-1. Is there a good solution to this? It leads to confusion that the last bin is empty, and its also a bit problematic in writing tests.

The underlying question: We are not completely certain what is a "recommended" way to set histogram bounds for integral data space. Are there common guidelines? In floating point precision it is more understandable what data range is covered by each bin. But in integral space, it seems the value 0 could be best represented by bin [-0.5, 0.5) rather than the more obvious [0, 1). And help, links or pointers to documentation would be highly appreciated!

主要言語
C++
スター
334
フォーク
75
平均マージ
18時間 2分
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

boostorg/histogram のほかの issue

boostorg/histogram の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。