Skip to content

Commit

Permalink
furtehr fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Mar 29, 2024
1 parent 4e2743d commit cb1f7c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 153 deletions.
132 changes: 3 additions & 129 deletions ostap/stats/moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,92 +196,28 @@ def _om_u5th ( obj ) :
# v = m.moment()
# @endcode
if ( 6 , 22 ) <= root_info :
## if ( 6 , 31 ) <= root_info :
##
def _om_cm2 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
'central_moment: invalid order %s/%d' % ( order , obj.order )
if 2 <= order and obj.empty() : return neg_infinity
return obj.moment_[order]()
##
elif ( 6 , 22 ) <= root_info :
##
def _om_cm2 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
'central_moment: invalid order %s/%d' % ( order , obj.order )
if 2 <= order and obj.empty() : return neg_infinity
T = Ostap.Math.Moments._central_moment_2 [ order , obj.order ]
return T ( obj )
##
elif ( 6 , 20 ) <= root_info :
else :
##
def _om_cm2 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
'central_moment: invalid order %s/%d' % ( order , obj.order )
if 2 <= order and obj.empty() : return neg_infinity
return obj.moment ( order )
## T = Ostap.Math.Moments._central_moment_2 [ order , obj.order ]
## M = Ostap.Math.Moments()
## return T ( M , obj )
##
elif ( 6 , 18 ) <= root_info :
##
def _om_cm2 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
'central_moment: invalid order %s/%d' % ( order , obj.order )
if 2 <= order and obj.empty() : return neg_infinity
T = Ostap.Math.Moments._central_moment_2 ( order , obj.order )
M = Ostap.Math.Moments()
return T ( M , obj )
##
else :
##
def _om_cm2 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
'central_moment: invalid order %s/%d' % ( order , obj.order )
if 2 <= order and obj.empty() : return neg_infinity
T = Ostap.Math.Moments._central_moment_2 ( order , obj.order )
return T ( obj )


_om_cm2.__doc__ = \
"""Get a central moment fro the moment-counter
>>> m = ...
>>> v = m.central_moment ( 3 ) ## ditto
>>> v = m.cmoment ( 3 ) ## ditto
"""



## def _om_cm2 ( obj , order ) :
## """Get a central moment fro the moment-counter
## >>> m = ...
## >>> v = m.central_moment ( 3 ) ## ditto
## >>> v = m.cmoment ( 3 ) ## ditto
## """
## assert isinstance ( order , integer_types ) and 2<= order , 'Invalid order %s'% order
## assert order <= obj.order , 'central_moment: invalid order cmbiarions %s/%s' % ( order , obj.order )

## if order * 2 <= obj.order :
## ##

## if root_info < ( 6 , 18 ) : ## well, actually 6.14
## T = Ostap.Math.Moments._central_moment_2 ( order , obj.order )
## return T ( obj )
## elif root_info < ( 6 , 20 ) :
## T = Ostap.Math.Moments._central_moment_2 ( order , obj.order )
## M = Ostap.Math.Moments()
## return T ( M , obj )
## elif root_info < ( 6 , 22 ) :
## T = Ostap.Math.Moments._central_moment_2 [ order , obj.order ]
## M = Ostap.Math.Moments()
## return T ( M , obj )

## T = Ostap.Math.Moments._central_moment_2 [ order , obj.order ]
## return T ( obj )

## return obj.moment ( order )


# =============================================================================
## get central moment
# @code
Expand All @@ -290,7 +226,6 @@ def _om_cm2 ( obj , order ) :
# v = m.moment()
# @endcode
if ( 6 , 22 ) <= root_info :
## if ( 6 , 31 ) <= root_info :
##
def _om_cm3 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
Expand All @@ -299,48 +234,13 @@ def _om_cm3 ( obj , order ) :
##
return obj.moment_[order]()
##
elif ( 6 , 22 ) <= root_info :
##
def _om_cm3 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
'central_moment: invalid order %s/%d' % ( order , obj.order )
if 2 <= order and not obj.ok () : return neg_infinity
##
T = Ostap.Math.Moments._central_moment_3 [ order , obj.order ]
return T ( obj )
##
elif ( 6 , 20 ) <= root_info :
else :
##
def _om_cm3 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
'central_moment: invalid order %s/%d' % ( order , obj.order )
if 2 <= order and not obj.ok () : return neg_infinity
return obj.moment ( order )
##
## T = Ostap.Math.Moments._central_moment_3 [ order , obj.order ]
## M = Ostap.Math.Moments ()
## return T ( M , obj )
##
elif ( 6 , 18 ) <= root_info :
##
def _om_cm3 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
'central_moment: invalid order %s/%d' % ( order , obj.order )
if 2 <= order and not obj.ok () : return neg_infinity
##
T = Ostap.Math.Moments._central_moment_3 ( order , obj.order )
M = Ostap.Math.Moments ()
return T ( M , obj )
else:
##
def _om_cm3 ( obj , order ) :
assert isinstance ( order , integer_types ) and order <= obj.order ,\
'central_moment: invalid order %s/%d' % ( order , obj.order )
if 2 <= order and not obj.ok () : return neg_infinity
##
T = Ostap.Math.Moments._central_moment_3 ( order , obj.order )
return T ( obj )


_om_cm3.__doc__ = \
""" Get a central moment fro the moment-counter
Expand All @@ -350,32 +250,6 @@ def _om_cm3 ( obj , order ) :
"""


## def _om_cm3 ( obj , order ) :
## """Get a central moment fro the moment-counter
## >>> m = ...
## >>> v = m.central_moment ( 3 ) ## ditto
## >>> v = m.cmoment ( 3 ) ## ditto
## """
## assert isinstance ( order , integer_types ) and 2<= order , 'Invalid order %s'% order
## assert order <= obj.order , 'central_moment: invalid order cmbiarions %s/%s' % ( order , obj.order )

## if order * 2 <= obj.order :
## ##
## if root_info < ( 6 , 18 ) : ## well, actaully 6.14
## T = Ostap.Math.Moments._central_moment_3 ( order , obj.order )
## return T ( obj )
## elif root_info < ( 6 , 20 ) : ## well, actaully 6.14
## T = Ostap.Math.Moments._central_moment_3 ( order , obj.order )
## M = Ostap.Math.Moments ()
## return T ( M , obj )
## elif root_info < ( 6 , 22 ) :
## T = Ostap.Math.Moments._central_moment_3 [ order , obj.order ]
## M = Ostap.Math.Moments ()
## return T ( M , obj )


## return obj.moment ( order )

# =============================================================================
## get a RMS
# @code
Expand Down
24 changes: 0 additions & 24 deletions source/include/Ostap/Moments.h
Original file line number Diff line number Diff line change
Expand Up @@ -1416,18 +1416,6 @@ namespace Ostap
return VE ( muo , cov2 ) ;
}
// ======================================================================
/** get the central moment of order \f$ N \f$ with
* the estimate of the uncertainty (with \f$O(n^{-2})\f$~precision
* - the error estimate is possible only when \f$ 2N \le K \f$!
* @aparam m counter
* @return moment with uncertainty for non-empty counter
* <code>s_INVALID_MOMENT</code> for empty counters
*/
template <unsigned short N, unsigned short K,
typename std::enable_if<(1<N)&&(2*N<=K),int>::type = 0 >
static inline VE _central_moment_2 ( const Moment_<K>& m )
{ return central_moment<N> ( m ) ; }
// ======================================================================
/** get the standartized moment of order 1
*/
template <unsigned short N, unsigned short K,
Expand Down Expand Up @@ -1559,18 +1547,6 @@ namespace Ostap
return VE ( muo , cov2 ) ;
}
// ======================================================================
/** get the central moment of order \f$ N \f$ with
* the estimate of the uncertainty (with \f$O(n^{-2})\f$~precision
* - the error estimaet is possible only when \f$ 2N \le K \f$!
* @aparam m counter
* @return moment with uncertainty for non-empty counter
* <code>s_INVALID_MOMENT</code> for empty counters
*/
template <unsigned short N, unsigned short K,
typename std::enable_if<(1<N)&&(2*N<=K),int>::type = 0 >
static inline VE _central_moment_3 ( const WMoment_<K>& m )
{ return central_moment<N> ( m ) ; }
// ======================================================================
/** get the standartized moment of order 1
*/
template <unsigned short N, unsigned short K,
Expand Down

0 comments on commit cb1f7c1

Please sign in to comment.