> -----Original Message-----
> From: Joe Discenza [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, October 17, 2006 4:32 AM
> To: Su, Yu (Eugene); perl-win32-users@listserv.ActiveState.com
> Subject: RE: how to initialize an array
> 
> 
> Su, Yu (Eugene) wrote, on Monday, October 16, 2006 8:52 PM
> : How to initialize an array? I want to get a median by using 
> : Statistics::Descriptive.
> : I enter (12, 13, 14), (15, 16, 17), (16, 17, 18) I expect 
> : 13,16,17. Instead, I get 13.00, 14.50, 16.00.
> : 
> : I thought my @temp_array=(); in the median sub (see code 
> : snippet below) will get me new array. But I am wrong. How do 
> : I initialize an array in my example?
> 
> Your array looks fine. To me, the suspicious line is this:
> 
> :     $stat->add_data(@temp_array); 
> 
> I've never used Statistics::Descriptive, but I bet it keeps all the
> previous data. There should be a "clear" method somewhere; if not,
> you'll need a new object each time.

You are right. It is the $stat object keeps all the previous data. Moving 
my $stat = Statistics::Descriptive::Full->new() inside median() (as Bill's 
suggestion) fixed the problem.

Thank you all for helps.

-Eugene

> 
> Joe
> 
> Joseph Discenza, Senior Programmer/Analyst
> mailto:[EMAIL PROTECTED]
> 
> Carleton Inc. http://www.carletoninc.com
> 574.243.6040 ext. 300
> Fax: 574.243.6060
> 
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to