On 6/11/04 Rick Measham wrote:
>I said:
>>On the other hand, maybe these should be DateTime::Set methods:
>> my $mean   = $set->mean( $sunrise, $sunset ); my $median =
>> $set->median( $sunrise, $sunset );
>
>On Thu, 10 Jun 2004 18:04:36 -0700, Bruce Van Allen wrote
>> Huh? I'm confused by your usage of 'mean' and 'median'. In the case
>> in question, I think 'midpoint' is a much clearer term to use.
>
>I suggest placing mean and median in a module rather than just the FAQ
>because the current solution is just the midpoint of two datetimes.
>The mean can give this, but can also give results for more than two
>datetimes.

This doesn't change my mind that 'midpoint' is way better for what the
OP was asking than mean or median.

>As for my usage of 'mean' and 'median':
>'mean' and 'median' are mathematical constructs. The 'mean' is often
>called the 'average' while the 'median' would be the middle value.

Thanks. I didn't need the math lesson -- I was asking about _your_
usage of mean & median :-)

Your earlier post had the following:
>   use DateTime::Util::Stats qw/:all/;
>   # Solar Noon is the mean of sunrise and sunset:
>   my $mean   = mean_datetime( @dt_list )
>   # The mean is: round(scalar(@_) + 1 / 2) # IIRC
>   #   therefore $median == $sunset
>   my $median = median_datetime( @dt_list )

I think it's slightly obfuscatory to tell someone to calculate a
date/time midpoint using ideas of averaging. It's just a different goal.
 
Also, as Matt Sisk said:
>Midpoints are compelling, but also arbitrary. I'd like to see the
>general problem of portioning a span, or the delta between two
>arbitrary datetimes (expressed as a span or otherwise, transparently),
>solved in a general way...

This idea seems more relevant to the OP's question, and also more useful
than using mean or median.

"#   therefore $median == $sunset" demonstrates my point that this is a
mis-application of median. That outcome is an artifact of your algorithm
for median -- what practical use would it have?

My further concern, expressed several months ago, is that having a
catch-all module like DateTime::Utils just begs for code creep. What
Flavio posted could not be much more succinct:

>Matt Sisk wrote:
>> what is the midpoint of a span?
 
And [EMAIL PROTECTED] wrote:
>With DateTime::Span:
>
> $mid_point = 
>    $span->start->add_duration(
>        seconds => $span->duration->seconds / 2 
>    );
>
>With DateTime:
>
>  $mid_point = 
>    $start->add_duration(
>        seconds => $end->subtract_datetime_absolute( 
>            $start 
>        )->seconds / 2 
>    );


Best,


- Bruce

__bruce__van_allen__santa_cruz__ca__

Reply via email to