Changeset 789


Ignore:
Timestamp:
05/08/15 10:48:37 (13 months ago)
Author:
mmckerns
Message:

impose_reweighted_* should only return weights

Location:
mystic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mystic/_math/measures.py

    r777 r789  
    414414 
    415415def impose_reweighted_mean(m, samples, weights=None, solver=None): 
    416     """impose a mean on a list of points, using reweighting""" 
     416    """impose a mean on a list of points by reweighting weights""" 
    417417    ndim = len(samples) 
    418418    if weights is None: 
     
    451451    if warn or not almostEqual(_norm, norm): 
    452452        print "Warning: could not impose mean through reweighting" 
    453         return impose_mean(m, samples, weights), weights 
    454  
    455     return samples, wts 
     453        return None #impose_mean(m, samples, weights), weights 
     454 
     455    return wts #samples, wts 
    456456 
    457457 
    458458def impose_reweighted_variance(v, samples, weights=None, solver=None): 
    459     """impose a variance on a list of points, using reweighting""" 
     459    """impose a variance on a list of points by reweighting weights""" 
    460460    ndim = len(samples) 
    461461    if weights is None: 
     
    498498    if warn or not almostEqual(_norm, norm): 
    499499        print "Warning: could not impose mean through reweighting" 
    500         return impose_variance(v, samples, weights), weights 
    501  
    502     return samples, wts  # "mean-preserving" 
     500        return None #impose_variance(v, samples, weights), weights 
     501 
     502    return wts #samples, wts  # "mean-preserving" 
    503503 
    504504def impose_reweighted_std(s, samples, weights=None, solver=None): 
    505     """impose a standard deviation on a list of points, using reweighting""" 
     505    """impose a standard deviation on a list of points by reweighting weights""" 
    506506    return impose_reweighted_variance(s**2, samples, weights, solver) 
    507507 
  • mystic/tests/test_impose.py

    r776 r789  
    1515  m = 3.5 
    1616 
    17   x, w = impose_reweighted_mean(m, x0, w0) 
    18   assert x0 == x 
    19   assert almostEqual(mean(x,w), m) 
     17  w = impose_reweighted_mean(m, x0, w0) 
     18  assert almostEqual(mean(x0,w), m) 
    2019 
    2120 
     
    2625  v = 1.0 
    2726 
    28   x, w = impose_reweighted_variance(v, x0, w0) 
    29   assert x0 == x 
    30   assert almostEqual(variance(x,w), v) 
    31   assert almostEqual(mean(x0,w0), mean(x,w)) 
     27  w = impose_reweighted_variance(v, x0, w0) 
     28  assert almostEqual(variance(x0,w), v) 
     29  assert almostEqual(mean(x0,w0), mean(x0,w)) 
    3230 
    3331 
Note: See TracChangeset for help on using the changeset viewer.