Changeset 768


Ignore:
Timestamp:
11/12/14 07:37:47 (18 months ago)
Author:
mmckerns
Message:

fix: impose_product should also work when prod is negative

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mystic/_math/measures.py

    r763 r768  
    511511    return list(weights * inf)  # protect against ZeroDivision 
    512512  if float(mass): 
    513     return list(weights / (w/mass)**(1./n))  #FIXME: not "mean-preserving" 
     513    if w/mass < 0.0: 
     514      return list(-weights / (-w/mass)**(1./n))  #FIXME: not "mean-preserving" 
     515    return list(weights / (w/mass)**(1./n))      #FIXME: not "mean-preserving" 
    514516  # force selected member to satisfy product = 0.0 
    515517  if not zsum: 
     
    520522  n = n-1 
    521523  mass = zmass 
    522   return list(weights[:-1]/(w/mass)**(1./n))+[0.] #FIXME: not "mean-preserving" 
     524  if w/mass >= 0.0: 
     525    return list(weights[:-1]/(w/mass)**(1./n))+[0.]#FIXME: not "mean-preserving" 
     526  return list(-weights[:-1]/(-w/mass)**(1./n))+[0.]#FIXME: not "mean-preserving" 
    523527 
    524528 
Note: See TracChangeset for help on using the changeset viewer.