• Post Reply Bookmark Topic Watch Topic
  • New Topic

one for the mathematicians  RSS feed

 
Robin Heard
Greenhorn
Posts: 18
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is more of a maths question rather than pure java.

I need to have my application calculate the impact of something. Every time an error has occurred at a location it is counted. So for example:

Location A:1
Location B:1
Location C:1
Location D:3

Locations A-C have had one error each and location D has had 3.

Calculating the sum is easy but what I need is an algorithm that takes into account the fact that a location has had the error several times and therefore see this as a bigger issue.

An error can only be reported up to 100 times in one location. In the case of the above example, rather than the result being 6 it should be more due to location D. If each location only has 1 reported errors the result would be 4.

What would be the best way to calculate this?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to define your rules much more thoroughly.

rather than the result being 6 it should be more due to location D
How much more? What if the values were:
Location A: 0
Location B: 0
Location C: 0
Location D: 3

In this scenario, there is less than 1 incident per location, but because there is more than 1 incident at location D, how do you want that reflected in the result?
 
Robin Heard
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be honest I'm not sure. I've not really thought that part through and I'm open to ideas. The final result should be a percentage between 0-100. A single location doesn't have more than 100 errors.

Location A: 0
Location B: 0
Location C: 0
Location D: 3

That scenario would be the same as:

Location A:1
Location B:1
Location C:1
Location D:3

but minus 3. So if the algorithm were to decide that 3 is weighted as 5 then the final sum would be 5 for the first one and 7 for the second one.

Based on the fact that a single location will not have more than 100 errors and there are 300 locations, what would you say would be a sensible weighting of a location that has more than one error?
 
Andy Jack
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I may ask, what is the purpose of doing all this ? What are your requirements exactly ?

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robin Heard wrote:To be honest I'm not sure. I've not really thought that part through


Well, that's what you will have to do. It will be really hard for anyone to come up with a good answer without the full spec. Since you know what the application is and what it is supposed to do, you are the one that needs to come up with that spec. The forums is not really a great place for hammering out ideas based on partial specs because only one side of the conversation knows what they are talking about (you) and the other side (us) will have to guess.

For example:
That scenario would be the same as [the first one] but minus 3. So if the algorithm were to decide that 3 is weighted as 5 then the final sum would be 5 for the first one and 7 for the second one.

What that means is hard for me to decipher. Why is 3 a 5, and why is it 5 in one scenario and 7 in another (when one is supposed to be the other minus 3).

Not knowing anything about your situation: I would report an average value. I would set 'thresholds' for what is considered OK (example average < 0.5) what is Code Red (average > 1), and a record of all sites with > 1 incident. But that is a naive attempt at something I don't know anything about.
 
Paul Clapham
Sheriff
Posts: 22817
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if I were making up the requirements I would start out by weighting Location X to be the square of the number of errors at that location. That makes more errors look much worse (e.g. 50 errors is weighted as 2,500). You might find that too aggressive, in which case you could use some other function which grows more slowly such as N log N or N ^ 1.5 for example. (Remember, you did ask for advice from the mathematicians.) However if you had to explain it to upper management types who couldn't be put off by hand-waving you might get into trouble doing something like that.

But I have no idea where your percentage between 0 and 100 comes into the picture. What would constitute 100%? 50%?
 
Robin Heard
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've done some test cases and N log N seems like a good idea.

Thanks for the help
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robin Heard wrote:I've done some test cases and N log N seems like a good idea...

OK, but like Steve, I'm still totally in the dark as to what you're trying to achieve, nor how you arrived at the fact that N log N is a good idea (as opposed to any of the other possibilities suggested).

Design is about WHAT, not HOW; and you seem to have leapt to an implementation (the latter) without being able to describe to us WHAT you're trying to do - and I hate to say, but that's almost invariably a bad way to proceed.

Winston
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!