Project Euler Problem 39: Statistical Mode on the HP 48GX?


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.

Possibly Related Threads...
Thread Author Replies Views Last Post
  Integration question and "RPN" mode comment Craig Thomas 16 3,047 12-05-2013, 02:32 AM
Last Post: Nick_S
  FRAM71 Project aj04062 1 633 11-25-2013, 01:59 PM
Last Post: Hans Brueggemann
  HP Prime: Recommendation for future RPN Program Mode BruceTTT 3 936 11-13-2013, 10:03 PM
Last Post: BruceTTT
  Best statistical fit Richard Berler 8 1,420 10-30-2013, 11:25 PM
Last Post: Walter B
  Program to change entry mode on Prime Michael de Estrada 3 920 10-28-2013, 10:13 AM
Last Post: Han
  Prime: Exam mode (possible duplicate after funny response first time) Paul Townsend (UK) 1 697 10-24-2013, 03:09 PM
Last Post: Tim Wessman
  Does RPN entry mode cause the Prime keyboard to lock up ? Michael de Estrada 14 2,253 10-22-2013, 06:27 PM
Last Post: John Colvin
  Euler's Constant Approximation Namir 0 466 10-19-2013, 11:32 AM
Last Post: Namir
  HP Prime: Edit integer in RPN mode plivesey 15 2,246 10-18-2013, 04:34 PM
Last Post: kris223
  Temporary User Mode Key Programs not working in RPN BruceTTT 7 1,402 10-14-2013, 01:46 PM
Last Post: BruceTTT

Forum Jump: