Histogram changes values #402
Replies: 2 comments 2 replies
-
I think there is a misunderstanding about the way histogram works. What you are supplying to the constructor are the boundaries between the histogram bins. What is plotted and returned by the e.G. For your use case I would suggest to just write your own DataSet class backed by two integer arrays for x-values and counts. Just extend AbstractDataSet and it should just be a few lines of code. You can also implement the Histogram interface or just make your own API for incrementing the individual bins. Please note that the JDK8 branch is not updated anymore. This means that it misses a lot of improvements that have been added between x.1.5 and x.2.5. There specifically have been some improvements for non equidistant Histograms, so there is a good chance, that the jdk8 version contains bugs that have already been fixed in current versions. If you can, update to JDK11 or later so you can use the current version. Even if you cannot use it in your main project, you can check against the current version to know if things have already been fixed and maybe determine workarounds for the jdk8 version. I have also two recommendations for future issues:
|
Beta Was this translation helpful? Give feedback.
-
Ah that makes more sense. To fix my problem I've gone back to using a DoubleDataSet and doing the counting on my own.
Sad to hear, as my project needs Java 8, and I wont be able to upgrade to the latest java anytime soon by the looks of it.
Definitely a good idea, I'll keep it in mind for the future |
Beta Was this translation helpful? Give feedback.
-
When using a Histogram the values inserted into the dataset is changed. Picture As can be seen in the picture the data point is 54.5, but all my data is ints converted to double, i.e. 54 -> 54.0, 55 -> 55.0 etc.
I should never be able to get 54.5, and I've checked the conversion from int to double (even though it should be without precision loss).
My data is not guaranteed to be equidistant so the Histogram is created with the
Histogram(String name, double[] xBins)
constructor, and filled with thefill(final double x)
method. I'm using anErrorDataSetRenderer()
.I've tried using the other constructors as well but in those equidistant is set to true so they are not ideal, and the result is way different i.e. points are close to original value e.g. 54 -> 53.95843957493, and as my data is not equidistant 0 values are used as fillers where I dont provide data to make it equidistant. See picture
The Histogram dataSet is nice to use as I dont have to count occurences in my data but simply insert it into the dataSet.
Environment:
Beta Was this translation helpful? Give feedback.
All reactions