Quote:
Originally Posted by sorrow
This looks wrong.
THRESHOLD is the minimum difference in seconds that we should use to establish sessions - you are literally adding 1801 to the end of the diffs array here.
Giving something like: [0, 10, 20, 15, 1801] - Effectively enforcing that another empty session exists because...
index = [5]
It is right and wrong. Wrong because numpy's ndarray doesn't have a method append. Tx to Eleatic for finding that out.
However the idea is correct. As per my later posting 2.1 should comprise:
Quote:
Originally Posted by Socratic
- replace line 36 with:
Code:
from numpy import diff, nonzero, sum, cumsum, max, min, append
- replace the original line 267 with:
Code:
diffs2 = append(diffs,THRESHOLD + 1)
index = nonzero(diffs2 > THRESHOLD)
Let me explain why my sollution is correct. suppose we have 5 hands with:
Code:
times = [t0=0, t1=t0+600, t2=t1+1900, t3=t2+400, t4=t3+100
In this case we should have 2 sessions: [t0,t1] and [t2,t3,t4].
However the original code will result in:
Code:
diffs = [600,1900,400,100]
index[0] = [1]
meaning that index will result in showing only the session [t0,t1], because range(len(index[0]))=[0].
My
updated code will result in:
Code:
diffs = [600,1900,400,100]
diffs2 = [600,1900,400,100,1801]
index[0] = [1,4]
meaning that index will result in showing sessions [t0,t1] and [t2,t3,t4], because range(len(index[0]))=[0,1]
Come to think of it "last_idx" is really a bad name for it's current use. It would be better to name it "first_idx". Because that's what it is: "the index to the first hand of a session."
Quote:
Originally Posted by sorrow
That gives you the right result, i'm not sure if its 'correct' though. Looking into it.
It gives the correct result, because it's correct. That's because how many numbers are between two number, n and m (n<=m), those two numbers included. Answer: m - n + 1. As an example how many number are between 1 and 10, (1 and 10 included). Answer: 10= 10-1 + 1 not 9= 10-1.
Quote:
Originally Posted by sorrow
Heh - hadn't payed attention to that yet.
I went with:
Code:
minutesplayed = (times[index[0][i]] - times[last_idx])/60
if minutesplayed == 0:
minutesplayed = 1
hph = hds*60/minutesplayed # Hands per hour
I've put together something thats working a little better now, but still printing mountains of debug.
That's another option. However, I don't really like it. Why? Because the last hand in the session took some time and you're ignoring it with your code. Come to think of it. Every session takes some additional time before and after actually playing ( before: starting up client, finding first table, sitting down, waiting for BB,...; after: checking stats, checking balance, closing client,... ) So with my code you could imagine even changing my 1 with a constant that signifies the number of minutes spend in the before, after and during final hand for an average session. So adding 1 minute to every session even seems conservative to me ( try starting a session from scratch, playing one hand and closing the session all within 1 minute if you don't believe me. Especially when using auxiliary software like fpdb to get a HUD and to analyse your session afterwords).
To conclude, I've test these changes myself in a git-tree on one of my Linux boxes and hands is
not off by one.
I'll stop my rant here.
Socratic.