histc problem in counting in particular bin

1 回表示 (過去 30 日間)
Dammar Badu
Dammar Badu 2021 年 10 月 20 日
編集済み: Dammar Badu 2021 年 10 月 20 日
Hello
For data = 0.1:0.02:0.3 and bins = 0.1:0.04:0.3. When I use histc(data, bins), I get histogram frequency = 2 2 2 2 2 1. which is correct.
But when I change bins upto 0.4, I mean bins = 0.1:0.04:0.4, then the histogram frequency = 2 2 3 1 2 1 0 0, which is not correct. It incorrectly counting upper bound in 3rd bin and missing lower bound in 4th bin.
I appreciate any help.

採用された回答

Matt J
Matt J 2021 年 10 月 20 日
編集済み: Matt J 2021 年 10 月 20 日
You are assuming that the bin boundaries are calculated with infinite precision, which is impossible. Likewise your data is also not computed in perfect increments of 0.04.
  6 件のコメント
Walter Roberson
Walter Roberson 2021 年 10 月 20 日
The process is not actually random, but it is complicated . If you have two different ways of calculating the same mathematical quantity, then if there are any differences, you might not get the same result for the two ways.
Dammar Badu
Dammar Badu 2021 年 10 月 20 日
編集済み: Dammar Badu 2021 年 10 月 20 日
Thank you Matt, Walter and Image Analyst for clarification. It is very helpful.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by