pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSelect random lines of a table using a probability distribution
2+ messages / 2 participants
[nested] [flat]
* Select random lines of a table using a probability distribution
@ 2011-07-13 13:27 Jira, Marcel <Marcel.Jira@wu.ac.at>
0 siblings, 1 reply; 2+ messages in thread
From: Jira, Marcel @ 2011-07-13 13:27 UTC (permalink / raw)
To: pgsql-sql
Hi!
Let's consider I have a table like this
id qualification gender age income
I'd like to select (for example 100) lines of this table by random, but the random mechanism has to follow a certain probability distribution.
I want to use this procedure to construct a test group for another selection.
Example:
I filter all lines having the qualification "plumber".
I get 50 different ids consisting of 40 males, 10 females and a certain age distribution.
I also get some information concerning the income of the plumbers.
Now I want to know if the income is more influenced by the gender and age distribution or by the qualification "plumber".
Therefore I would like to select a test group (of 50 or more) without any plumbers. This test group has to follow the same age and gender distribution.
Then I would be able to compare this groups income statistics with the plumbers income statistics.
Is this possible (and doable with reasonable effort) in PostgreSQL?
Thank you in advance.
Best regards,
Marcel Jira
????? ~~~ * ~~~
? Mag. Marcel Jira
? Institut für Sozialpolitik, Wirtschaftsuniversität Wien
? +43 1 313 36-5890
? UZA IV, D 317
? http://www.wu.ac.at/sozialpolitik/team/wimi/jira
????? ~~~ * ~~~
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Select random lines of a table using a probability distribution
@ 2011-07-13 13:58 ktm@rice.edu <ktm@rice.edu>
parent: Jira, Marcel <Marcel.Jira@wu.ac.at>
0 siblings, 0 replies; 2+ messages in thread
From: ktm@rice.edu @ 2011-07-13 13:58 UTC (permalink / raw)
To: Jira, Marcel <Marcel.Jira@wu.ac.at>; +Cc: pgsql-sql
On Wed, Jul 13, 2011 at 03:27:10PM +0200, Jira, Marcel wrote:
> Hi!
>
> Let's consider I have a table like this
>
> id qualification gender age income
>
> I'd like to select (for example 100) lines of this table by random, but the random mechanism has to follow a certain probability distribution.
>
> I want to use this procedure to construct a test group for another selection.
>
> Example:
>
> I filter all lines having the qualification "plumber".
> I get 50 different ids consisting of 40 males, 10 females and a certain age distribution.
>
> I also get some information concerning the income of the plumbers.
>
> Now I want to know if the income is more influenced by the gender and age distribution or by the qualification "plumber".
>
> Therefore I would like to select a test group (of 50 or more) without any plumbers. This test group has to follow the same age and gender distribution.
>
> Then I would be able to compare this groups income statistics with the plumbers income statistics.
>
> Is this possible (and doable with reasonable effort) in PostgreSQL?
>
> Thank you in advance.
>
> Best regards,
>
> Marcel Jira
>
You may want to take a look at pl/R which make the R system available to
PostgreSQL as a function language.
Regards,
Ken
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-07-13 13:58 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13 13:27 Select random lines of a table using a probability distribution Jira, Marcel <Marcel.Jira@wu.ac.at>
2011-07-13 13:58 ` ktm@rice.edu <ktm@rice.edu>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox