subsampling hands

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

subsampling hands

Postby timooo » Mon May 18, 2009 9:47 am

Hello, I've searched the forum but couldnt find anything

I need to subsample hands for a specific player (that i have e.g. 20k hands) and get the stats for these subsamples. For example get the stats of his first 1k hands than of his second and so on.
If you wonder why I need it: I want to do some cross validation on a weighted winrate...

Im not so experienced in sql, so the only thing i thought could work was to filter in the where clause, but i cannot use aggregate fcts (to count the hands) and limiting the id_hand to a treshold wont produce samples of same size, i presume?!?

The last thing that comes to my mind is export every HH for a player to matlab and devide it and calculate stats in there.
timooo
 
Posts: 6
Joined: Sat May 09, 2009 3:20 pm

Re: subsampling hands

Postby kraada » Mon May 18, 2009 10:03 am

I think you should be able to do this in the SQL directly; you would need to create a for loop, then iterate until you have however many hands you want and add up whatever stats you're interested in from those hands.

In pseudocode, assuming you just want to find winrate:

win = 0
j = 1
for (i = 0, i < 1000, i++) {
if (player is in id_hand(j)){
i++
win = win + amt_won from id_hand(j)
}
j++
}

Then after that's run, run the query again with the loop starting with i = 1000, and i < 2000, etc. Unfortunately I'm not well versed enough in PostgreSQL specifically to tell you exactly how to write this loop, but this section of documentation from PostgreSQL.org should help you get started.
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: subsampling hands

Postby timooo » Mon May 18, 2009 11:47 am

thats exactly what i was looking for, thx a lot!
timooo
 
Posts: 6
Joined: Sat May 09, 2009 3:20 pm


Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 0 guests