[29184] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 428 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 11 14:14:21 2007

Date: Fri, 11 May 2007 11:14:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 11 May 2007     Volume: 11 Number: 428

Today's topics:
    Re: Solve a statistics problem <brundlefly76@hotmail.com>
    Re: Solve a statistics problem xhoster@gmail.com
    Re: Solve a statistics problem <brundlefly76@hotmail.com>
    Re: Solve a statistics problem <brundlefly76@hotmail.com>
    Re: Solve a statistics problem <ignoramus6365@NOSPAM.6365.invalid>
    Re: Solve a statistics problem <ignoramus6365@NOSPAM.6365.invalid>
    Re: Solve a statistics problem xhoster@gmail.com
    Re: Solve a statistics problem <bik.mido@tiscalinet.it>
    Re: Solve a statistics problem <brundlefly76@hotmail.com>
    Re: Solve a statistics problem <brundlefly76@hotmail.com>
    Re: Solve a statistics problem <brundlefly76@hotmail.com>
    Re: Solve a statistics problem <bik.mido@tiscalinet.it>
    Re: Solve a statistics problem xhoster@gmail.com
        Why does this cookie set? <edMbj@aes-intl.com>
    Re: Why does this cookie set? <thepoet_nospam@arcor.de>
    Re: Why does this cookie set? <edMbj@aes-intl.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 11 May 2007 11:15:03 -0400
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: Re: Solve a statistics problem
Message-Id: <4644887b$0$24279$8d2e0cab@news.usenetbinaries.com>

thanks for the spamcop spam.
heres your cookie.


"Paul Lalli" <mritty@gmail.com> wrote in message 
news:1178895654.115586.182150@e65g2000hsc.googlegroups.com...
> On May 11, 10:47 am, "Seth Brundle" <brundlefl...@hotmail.com> wrote:
>> Say I have a hash with peoples names and a quality score, like their free
>> throw percentage.
>>
>> Mathematically what is the most accurate way to divide the list into the 
>> two
>> most balanced teams?
>
> This question has nothing to do with Perl.  It would be the same
> question regardless of what language you're using to implment your
> solution.  You're asking a mathematics question.  You're more likely
> to get good answers in a group that discusses mathematics.
>
> Paul Lalli
> 




------------------------------

Date: 11 May 2007 15:16:03 GMT
From: xhoster@gmail.com
Subject: Re: Solve a statistics problem
Message-Id: <20070511111606.486$5y@newsreader.com>

"Seth Brundle" <brundlefly76@hotmail.com> wrote:
> Say I have a hash with peoples names and a quality score, like their free
> throw percentage.
>
> Mathematically what is the most accurate way to divide the list into the
> two most balanced teams?

Mathematically, enumerate all possible sets of teams, compute the
balancedness of each, and take the one with the most balancedness.  There
are various combinatoric modules and sample-code for Perl, but which one
you want probably depends on what exactly constitutes a legal pair of
teams.1

> Obviously you could do something simple like alternate in descending
> order, but this isnt guaranteed to produce the most accurate result.

It is not guaranteed to produce the *optimal* result.  Accuracy probably
doesn't enter into it.

>
> Ideally, I would like to be able to balance based on the mean, median, or
> both.

Do both teams have to be the same size?  If so, then balancing on mean is
the same as balancing on sum, right?  That sounds like a variant of the
well-known bin-packing or knap-sack problems.  For the median, that depends
strongly on whether the teams have to be divided equally, and also on
whether the number on each team is going to be odd or even, and on how you
define median in the case of even-membered teams.

>
> Code isnt necessary but of course appreciated - but if you have a link to
> the fundementals of solving such a problem thats fine to - I want to
> learn to do it for myself.

knap-sack and bin-packing are very widely discussed fundamentals.  Google
on those terms, you will find more than you care for on them.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Fri, 11 May 2007 11:20:53 -0400
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: Re: Solve a statistics problem
Message-Id: <464489d8$0$24189$8d2e0cab@news.usenetbinaries.com>

> Unless you have gross outliers, you will probably do well by sorting
> the list by score, then you would take (unshift) pairs of people with
> close scores (that is, take pair of persons 1 and 2 (two worst

thanks for the reply, but that solution is the one I referred to (basically 
a phys-ed style draft pick)  that I dont believe to be the most accurate.

Yes, the outcome I seek is that after the sort the two teams will have the 
closest average (mean) mathematically possible.

However, it would be cool if I could do it by median as well, or both, just 
for comparison. 




------------------------------

Date: Fri, 11 May 2007 11:24:13 -0400
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: Re: Solve a statistics problem
Message-Id: <46448aa1$0$24192$8d2e0cab@news.usenetbinaries.com>


> knap-sack and bin-packing are very widely discussed fundamentals.  Google
> on those terms, you will find more than you care for on them.

Excellent thanks!
I see there is actually a perl-Algorithm-Knapsack module.

Nothing better then a unique keyword to help you find what your looking 
for - thanks!




------------------------------

Date: Fri, 11 May 2007 10:26:39 -0500
From: Ignoramus6365 <ignoramus6365@NOSPAM.6365.invalid>
Subject: Re: Solve a statistics problem
Message-Id: <weadnZQPHoeyFtnbnZ2dnUVZ_gudnZ2d@giganews.com>

On Fri, 11 May 2007 11:20:53 -0400, Seth Brundle <brundlefly76@hotmail.com> wrote:
>> Unless you have gross outliers, you will probably do well by sorting
>> the list by score, then you would take (unshift) pairs of people with
>> close scores (that is, take pair of persons 1 and 2 (two worst
>
> thanks for the reply, but that solution is the one I referred to (basically 
> a phys-ed style draft pick)  that I dont believe to be the most accurate.

No it is not. Re-read again what you said in your original post: 

``Obviously you could do something simple like alternate in descending
order, but this isnt guaranteed to produce the most accurate result.''

My suggestion does not merely alternate in descending order, it
randomizes the pairs. Yours guarantees that one team will be always
better than another. Whereas mine does not. 

i


------------------------------

Date: Fri, 11 May 2007 10:27:51 -0500
From: Ignoramus6365 <ignoramus6365@NOSPAM.6365.invalid>
Subject: Re: Solve a statistics problem
Message-Id: <weadnZcPHofqFtnbnZ2dnUVZ_gudnZ2d@giganews.com>

On 11 May 2007 15:16:03 GMT, xhoster@gmail.com <xhoster@gmail.com> wrote:
> "Seth Brundle" <brundlefly76@hotmail.com> wrote:
>> Say I have a hash with peoples names and a quality score, like their free
>> throw percentage.
>>
>> Mathematically what is the most accurate way to divide the list into the
>> two most balanced teams?
>
> Mathematically, enumerate all possible sets of teams, compute the
> balancedness of each, and take the one with the most balancedness.  There
> are various combinatoric modules and sample-code for Perl, but which one
> you want probably depends on what exactly constitutes a legal pair of
> teams.1

Try enumerating all possibilities for two teams of 20 people each. 

That would be 2^40 possibilities. 1 trillion of them or so. 

i


------------------------------

Date: 11 May 2007 15:44:17 GMT
From: xhoster@gmail.com
Subject: Re: Solve a statistics problem
Message-Id: <20070511114421.362$Q6@newsreader.com>

Ignoramus6365 <ignoramus6365@NOSPAM.6365.invalid> wrote:
> On 11 May 2007 15:16:03 GMT, xhoster@gmail.com <xhoster@gmail.com> wrote:
> > "Seth Brundle" <brundlefly76@hotmail.com> wrote:
> >> Say I have a hash with peoples names and a quality score, like their
> >> free throw percentage.
> >>
> >> Mathematically what is the most accurate way to divide the list into
> >> the two most balanced teams?
> >
> > Mathematically, enumerate all possible sets of teams, compute the
> > balancedness of each, and take the one with the most balancedness.
> > There are various combinatoric modules and sample-code for Perl, but
> > which one you want probably depends on what exactly constitutes a legal
> > pair of teams.1
>
> Try enumerating all possibilities for two teams of 20 people each.
>
> That would be 2^40 possibilities.

Well, more like 2^39.  But even less if the teams have to be balanced in
size as well as in <whatever> score.

> 1 trillion of them or so.

He said "mathematically", not "algorithmically".  Since when are
mathematicians concerned about run time?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Fri, 11 May 2007 17:45:38 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Solve a statistics problem
Message-Id: <kr3943dh00lh5lqao9b9hermor248c4sgg@4ax.com>

On 11 May 2007 08:00:54 -0700, Paul Lalli <mritty@gmail.com> wrote:

>solution.  You're asking a mathematics question.  You're more likely
>to get good answers in a group that discusses mathematics.

Along with some answers from crackpots who claim to have a simple FLT
proof, that is!  ;-)


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Fri, 11 May 2007 11:47:35 -0400
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: Re: Solve a statistics problem
Message-Id: <4644901c$0$24201$8d2e0cab@news.usenetbinaries.com>

>> 1 trillion of them or so.
>
> He said "mathematically", not "algorithmically".  Since when are
> mathematicians concerned about run time?

hehe I think you will find a lot of them are just as efficiency-obsessed any 
programmer.




------------------------------

Date: Fri, 11 May 2007 11:49:12 -0400
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: Re: Solve a statistics problem
Message-Id: <4644907a$0$24203$8d2e0cab@news.usenetbinaries.com>

> ``Obviously you could do something simple like alternate in descending
> order, but this isnt guaranteed to produce the most accurate result.''
>
> My suggestion does not merely alternate in descending order, it
> randomizes the pairs. Yours guarantees that one team will be always
> better than another. Whereas mine does not.

Sorry I misunderstood - interesting option! 




------------------------------

Date: Fri, 11 May 2007 11:54:50 -0400
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: Re: Solve a statistics problem
Message-Id: <464491cc$0$24207$8d2e0cab@news.usenetbinaries.com>

> knap-sack and bin-packing are very widely discussed fundamentals.  Google
> on those terms, you will find more than you care for on them.

Interesting, the knapsack and binpack solutions  (which as I understand it 
from reviewing these modules), seem to both be the exact same problem 
domain, but that domain seems significantly different from my problem.

Basically, they are solving the problems of how to fill x number of y-sized 
bins so there is the least amount of space left in the containers.

However, I dont think it necessarily guarantees the bins are filled equally, 
as the last bin may be just the leftovers from the last-efficiently-filled 
bin.

But I will play with them.





------------------------------

Date: Fri, 11 May 2007 18:03:38 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Solve a statistics problem
Message-Id: <kv39439bcgigagg4t0jgp1fi5s3a170snq@4ax.com>

On Fri, 11 May 2007 11:20:53 -0400, "Seth Brundle"
<brundlefly76@hotmail.com> wrote:

>thanks for the reply, but that solution is the one I referred to (basically 
>a phys-ed style draft pick)  that I dont believe to be the most accurate.
>
>Yes, the outcome I seek is that after the sort the two teams will have the 
>closest average (mean) mathematically possible.

Yours is still a mathematical, and admittedly interesting, question.
Like Paul Lalli rightly pointed out, you'd better ask in a
mathematics, statistics or algorithm newsgroup or forum. Personally,
since I have no idea how to specifically help you with this particular
problem, I can only keep the discussion moderately on topic by
pointing you to a suitable CPAN search:

http://search.cpan.org/search?mode=module&query=statistics

See if any module can help you. Other than this, I could only write
some brute force approach for your, which I suppose is not what you're
after.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: 11 May 2007 17:25:05 GMT
From: xhoster@gmail.com
Subject: Re: Solve a statistics problem
Message-Id: <20070511132509.707$ss@newsreader.com>

"Seth Brundle" <brundlefly76@hotmail.com> wrote:
> > knap-sack and bin-packing are very widely discussed fundamentals.
> > Google on those terms, you will find more than you care for on them.
>
> Interesting, the knapsack and binpack solutions  (which as I understand
> it from reviewing these modules), seem to both be the exact same problem
> domain, but that domain seems significantly different from my problem.

Depending on the exact nature of your problem, there may be ways to map it
into knapsack or bin-packing.  There are several small-seeming
clarifications you haven't yet provided which have a very big impact on how
and whether this can be done.

> Basically, they are solving the problems of how to fill x number of
> y-sized bins so there is the least amount of space left in the
> containers.

If you pack your objects into a bin whose capacity is one half of the total
score of all the objects, then the arrangement what maximizes the score
of the bin without going over the capacity will be the same arrangement
that makes the total of two bins closest to each other.

Anyway, when you make off-topic posts and then insult the regulars who
point this out to you, I'm less inclined to go much more out of my way to
help out.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Fri, 11 May 2007 08:35:02 -0700
From: Ed Jay <edMbj@aes-intl.com>
Subject: Why does this cookie set?
Message-Id: <a839435t5upkhoq0ipve84ip6mg98d778e@4ax.com>

My code to set a cookie is:

$cookie = $query->cookie(-name=>$username,
			-value=>$c_value,
			-domain=>'http://www.mydomainname.com'
			-path=>'/');

It works, but notice the missing comma after the domain name. If I add the
comma, i.e.:  -domain=>'http://www.mydomainname.com', the script fails.

Additionally, if I define the variable 
$myDomain = 'http://www.mydomainname.com' and use it in place of the full
domain name, the script crashes, with or without the trailing comma. 

Can someone offer me some insight, please. Thanks,
-- 
Ed Jay (remove 'M' to respond by email)


------------------------------

Date: Fri, 11 May 2007 18:28:09 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Why does this cookie set?
Message-Id: <46449999$0$6392$9b4e6d93@newsspool2.arcor-online.net>

Ed Jay wrote:
> My code to set a cookie is:
> 
> $cookie = $query->cookie(-name=>$username,
> 			-value=>$c_value,
> 			-domain=>'http://www.mydomainname.com'
> 			-path=>'/');
> 
> It works, but notice the missing comma after the domain name. If I add the
> comma, i.e.:  -domain=>'http://www.mydomainname.com', the script fails.
> 
> Additionally, if I define the variable 
> $myDomain = 'http://www.mydomainname.com' and use it in place of the full
> domain name, the script crashes, with or without the trailing comma. 
> 
> Can someone offer me some insight, please. Thanks,

Without a runnable piece of code that can reproduce the problem
this would be more a matter of guesswork. Though seeing the
strange behaviour, it might well be that the error is further up
in the script (like e.g. unbalanced quoting). Did you run the script
with "strict" and "warnings" enabled and
use CGI::Carp qw(fatalsToBrowser);
to get a more verbose error description than "crashes" or "fails"?

Btw., the "domain" field of the cookie should contain that, a domain
name, not a complete URL. In your example this should simply be
"www.mydomainname.com".

-Chris


------------------------------

Date: Fri, 11 May 2007 10:46:40 -0700
From: Ed Jay <edMbj@aes-intl.com>
Subject: Re: Why does this cookie set?
Message-Id: <bua9439h85o790uhrjt9b58g1bvbu7o9fg@4ax.com>

Christian Winter scribed:

>Ed Jay wrote:
>> My code to set a cookie is:
>> 
>> $cookie = $query->cookie(-name=>$username,
>> 			-value=>$c_value,
>> 			-domain=>'http://www.mydomainname.com'
>> 			-path=>'/');
>> 
>> It works, but notice the missing comma after the domain name. If I add the
>> comma, i.e.:  -domain=>'http://www.mydomainname.com', the script fails.
>> 
>> Additionally, if I define the variable 
>> $myDomain = 'http://www.mydomainname.com' and use it in place of the full
>> domain name, the script crashes, with or without the trailing comma. 
>> 
>> Can someone offer me some insight, please. Thanks,
>
>Without a runnable piece of code that can reproduce the problem
>this would be more a matter of guesswork. Though seeing the
>strange behaviour, it might well be that the error is further up
>in the script (like e.g. unbalanced quoting). Did you run the script
>with "strict" and "warnings" enabled and
>use CGI::Carp qw(fatalsToBrowser);
>to get a more verbose error description than "crashes" or "fails"?
>
>Btw., the "domain" field of the cookie should contain that, a domain
>name, not a complete URL. In your example this should simply be
>"www.mydomainname.com".
>
Thanks, Chris. Your 'btw' comment was the issue! When I removed 'http://www'
it worked fine.
-- 
Ed Jay (remove 'M' to respond by email)


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 428
**************************************


home help back first fref pref prev next nref lref last post