Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- building a histogram

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
09:36 AM

11-24-2020
09:36 AM

- One of the features from Mathcad 15 that I miss (occasionally) is the ability to display a histogram of a vector of data--the ability to display the general shape of a distributed variable is valuable.

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.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
10:41 AM

11-24-2020
10:41 AM

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

9 REPLIES 9

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
10:04 AM

11-24-2020
10:04 AM

Re: building a histogram

Would this help:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
10:51 AM

11-24-2020
10:51 AM

Re: building a histogram

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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
02:38 PM

11-24-2020
02:38 PM

Re: building a histogram

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-25-2020
02:51 PM

11-25-2020
02:51 PM

Re: building a histogram

Doesn't pay to argue with Werner!

My rough tool works and makes sense, but it doesn't compare with Luc's effort!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
10:41 AM

11-24-2020
10:41 AM

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
12:00 PM

11-24-2020
12:00 PM

Re: building a histogram

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
01:53 PM

11-24-2020
01:53 PM

Re: building a histogram

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
03:25 PM

11-24-2020
03:25 PM

Re: building a histogram

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2020
05:00 PM

11-24-2020
05:00 PM

Re: building a histogram

Yep, I need to use UnitsOf(), not to strip off, but to add units.

The updated file is attached to the other thread.

Luc