HP Forums

Full Version: Project Euler Problem 39: Statistical Mode on the HP 48GX?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Problem 39 in effect seeks the (unique) statistical mode of 325 positive integers, each 1000 or smaller. I sorted the list, used 2 << minus >> DOSUBS to identify the positions of the boundaries at which values changed, used DeltaLIST to find the distances between those positions, and deduced the mode from the MAX of those distances.

That worked, but it's roundabout. Can anyone point me to a standard approach, on the 48GX, to finding the mode in such a case? Thanks.


As you, I am trying to solve most of the Euler's Problems by using only vintage system.

I see nothing wrong with your roundabout to found the most frequent value from a list (statistical mode).

What’s trigger me is why are you saying that you have to seek the most frequent perimeter value in a list of as much as 325 elements when 190 only is enough.

How are you building this list of 325 elements? Is there no way to detect the most frequent value (statistical mode) during the building process?

In my code, I use one array (counting array) to record occurrences of each perimeter. No need to record perimeter elsewhere, since the index of this counting array gives the perimeter value (since only integer values are valid for this exercise). I simply have to track the max value position in this counting array to get the answer immediately at the end of the list building process.

Edited: 29 July 2011, 3:33 a.m.

Is there no way to detect the most frequent value (statistical mode) during the building process?

In general no, there is no exact method.

There are several method for estimating the mode with one pass through the data. These are estimates only and not terribly precise. I referenced a few when I did my PhD thesis (which had a chapter on mode estimation) many many many years ago. I've no idea if the state of the art has moved along since then or not.

The mode is definitely the poor cousin of the three common measures of centrality.

- Pauli

Thanks C .Ret and Paul for helpful replies.

Given that my roundabout approach works, and given Paul's implication that once-through methods are likely to be good approximations only, I think that I'll go on to another Project Euler problem.

I will treat this as an application of a pauli exclusion principle.