Changeset 789
- Timestamp:
- 05/08/15 10:48:37 (13 months ago)
- Location:
- mystic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/_math/measures.py
r777 r789 414 414 415 415 def 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""" 417 417 ndim = len(samples) 418 418 if weights is None: … … 451 451 if warn or not almostEqual(_norm, norm): 452 452 print "Warning: could not impose mean through reweighting" 453 return impose_mean(m, samples, weights), weights454 455 return samples, wts453 return None #impose_mean(m, samples, weights), weights 454 455 return wts #samples, wts 456 456 457 457 458 458 def 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""" 460 460 ndim = len(samples) 461 461 if weights is None: … … 498 498 if warn or not almostEqual(_norm, norm): 499 499 print "Warning: could not impose mean through reweighting" 500 return impose_variance(v, samples, weights), weights501 502 return samples, wts # "mean-preserving"500 return None #impose_variance(v, samples, weights), weights 501 502 return wts #samples, wts # "mean-preserving" 503 503 504 504 def 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""" 506 506 return impose_reweighted_variance(s**2, samples, weights, solver) 507 507 -
mystic/tests/test_impose.py
r776 r789 15 15 m = 3.5 16 16 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) 20 19 21 20 … … 26 25 v = 1.0 27 26 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)) 32 30 33 31
Note: See TracChangeset
for help on using the changeset viewer.