Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Prime (at least Express, where I'm stuck) doesn't have that feature. Being bored to tears with the pandemic, I set out this morning the be able to take a vector of data (of random length) and develop a histogram of that data. (A histogram, for those not familiar, divides a range of values into a set of discrete "bins" and returns the count of values in each bin.)
I was partially successful. The attached Prime 4.0 file demonstrates the technique. It also demonstrates several issues that I'm hoping someone smarter than I can help me with.
Solved! Go to Solution.
Fred,
The Prime express file with additional functions contains the histogram function. I remember working on that to make it work.
Check https://community.ptc.com/t5/PTC-Mathcad/Prime-Express-A-joke/m-p/604216.
For your example:
Success!
Luc
Would this help:
That looks like a great fix!
but nn and rows(M) are both simply a count. If we have a vector of measurements with units, then dn has those units too . . .
Still works, but how do we justify the units in the graph?
Its the necessary unit to get an area of (unitless) 1 under the curve.
You get the same unit when you use pnorm with units, too.
Doesn't pay to argue with Werner!
My rough tool works and makes sense, but it doesn't compare with Luc's effort!
Fred,
The Prime express file with additional functions contains the histogram function. I remember working on that to make it work.
Check https://community.ptc.com/t5/PTC-Mathcad/Prime-Express-A-joke/m-p/604216.
For your example:
Success!
Luc
Luc,
WOW!!
I had forgotten your magnum opus.
One small addendum: there are expressions to assist in defining how many bins you should have, seem to help.
Hi Fred,
You're right, but choosing the optimum number of bins is outside of the scope of the histogram function. I tried to mimic the functionality of the Premium function.
And I see now there's work to be done. Prime's built in histogram function accepts units (according to the help). Mine doesn't ☹️ unless the first argument is an array with the intervals specified, and also has a unit attached (the same unit as the second argument).
Regards,
Luc
You're right, but choosing the optimum number of bins is outside of the scope of the histogram function. I tried to mimic the functionality of the Premium function.
True, but my simple tool fails if it trips over a bin with no values inside. And, surprisingly, you don't need a huge number of bins to get a good representation.
And I see now there's work to be done. Prime's built in histogram function accepts units (according to the help). Mine doesn't unless the first argument is an array with the intervals specified, and also has a unit attached (the same unit as the second argument).
I suspect that the "UnitsOf" function would be very useful here, used as I have to strip units from differential equations for solving, then restoring them.
Attached one final iteration on a simple effort.
Yep, I need to use UnitsOf(), not to strip off, but to add units.
The updated file is attached to the other thread.
Luc