Changeset 687 for branches


Ignore:
Timestamp:
06/15/13 18:43:09 (3 years ago)
Author:
mmckerns
Message:

renaming of some of the measure methods, including dirac_measure to measure
moved dirac_measure.py to discrete.py, and paramtrans to distance
added isinstance to tools; added min, max, ess_min, ess_max to measures
moved dirac_measure.coords to dirac_measure.positions

Location:
branches
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • branches/UQ/math/examples2/TEST4d_OUQ_surrogate_diam.py

    r575 r687  
    6868 
    6969  from mystic.math.measures import split_param 
    70   from mystic.math.dirac_measure import product_measure 
     70  from mystic.math.discrete import product_measure 
    7171  from mystic.math import almostEqual 
    7272  from numpy import inf 
     
    114114    # impose expectation on product measure 
    115115    ##################### begin function-specific ##################### 
    116     E = float(c.get_expect(model)) 
     116    E = float(c.expect(model)) 
    117117    if not (E <= float(target[0] + error[0])) \ 
    118118    or not (float(target[0] - error[0]) <= E): 
     
    130130    #XXX: apply 'filters' to catch errors in constraints solver (necessary ?) 
    131131    ##################### begin function-specific ##################### 
    132     E = float(c.get_expect(model)) 
     132    E = float(c.expect(model)) 
    133133    if E > (target[0] + error[0]) or E < (target[0] - error[0]): 
    134134      if debug: print "skipping expect: %s" % E 
     
    238238 
    239239  from numpy import array 
    240   from mystic.math.dirac_measure import product_measure 
     240  from mystic.math.discrete import product_measure 
    241241  c = product_measure() 
    242242  c.load(solved,npts) 
     
    246246  
    247247  # XXX: 4D-expect 
    248   print "expect: %s" % str( c.get_expect(model) ) 
     248  print "expect: %s" % str( c.expect(model) ) 
    249249  print "var (x): %s" % str( c[0].var )   # var(h) 
    250250  print "mean(x): %s" % str( c[0].mean )  # mean(h) 
  • branches/UQ/math/examples2/TEST_OUQ_surrogate_diam.py

    r575 r687  
    6868 
    6969  from mystic.math.measures import split_param 
    70   from mystic.math.dirac_measure import product_measure 
     70  from mystic.math.discrete import product_measure 
    7171  from mystic.math import almostEqual 
    7272  from numpy import inf 
     
    9494    # impose expectation on product measure 
    9595    ##################### begin function-specific ##################### 
    96     E = float(c.get_expect(model)) 
     96    E = float(c.expect(model)) 
    9797    if not (E <= float(target[0] + error[0])) \ 
    9898    or not (float(target[0] - error[0]) <= E): 
     
    106106    c = product_measure() 
    107107    c.load(rv, npts) 
    108     E = float(c.get_expect(model)) 
     108    E = float(c.expect(model)) 
    109109    if E > (target[0] + error[0]) or E < (target[0] - error[0]): 
    110110      if debug: print "skipping expect: %s" % E 
     
    190190 
    191191  from numpy import array 
    192   from mystic.math.dirac_measure import product_measure 
     192  from mystic.math.discrete import product_measure 
    193193  c = product_measure() 
    194194  c.load(solved,npts) 
     
    197197  print "solved: [wz,z]\n%s" % array(zip(c[2].weights,c[2].coords)) 
    198198 
    199   print "expect: %s" % str( c.get_expect(model) ) 
     199  print "expect: %s" % str( c.expect(model) ) 
    200200 
    201201# EOF 
  • branches/UQ/math/legacy/MINMAX_StAlData.py

    r585 r687  
    6767def maximize(params,npts,bounds): 
    6868 
    69   from mystic.math.dirac_measure import scenario 
     69  from mystic.math.discrete import scenario 
    7070  from numpy import inf 
    7171  target,error = params 
     
    104104    ##################### begin function-specific ##################### 
    105105    # impose norm on the weights of the discrete measures 
    106     from mystic.math.dirac_measure import norm_wts_constraintsFactory as factory 
     106    from mystic.math.discrete import norm_wts_constraintsFactory as factory 
    107107    constrain = factory(npts) 
    108108 
     
    167167  nz = 1  #NOTE: SET THE NUMBER OF 'v' POINTS HERE! 
    168168  npts = (nx,ny,nz) 
    169   from mystic.math.paramtrans import _npts 
     169  from mystic.math.distance import _npts 
    170170  _n = _npts(npts) 
    171171 
     
    229229 
    230230  from numpy import array 
    231   from mystic.math.dirac_measure import scenario 
     231  from mystic.math.discrete import scenario 
    232232  c = scenario() 
    233233  c.load(solved,npts) 
  • branches/UQ/math/legacy/MM_OUQ_StAlData.py

    r675 r687  
    7575def maximize(params,npts,bounds): 
    7676 
    77   from mystic.math.dirac_measure import scenario 
     77  from mystic.math.discrete import scenario 
    7878  from numpy import inf 
    7979  target,error = params 
     
    112112    ##################### begin function-specific ##################### 
    113113    # impose mean on the values of the product measure 
    114     from mystic.math.dirac_measure import mean_y_norm_wts_constraintsFactory as factory 
     114    from mystic.math.discrete import mean_y_norm_wts_constraintsFactory as factory 
    115115    constrain = factory((target[0],error[0]), npts) 
    116116 
     
    196196  nz = 2  #NOTE: SET THE NUMBER OF 'v' POINTS HERE! 
    197197  npts = (nx,ny,nz) 
    198   from mystic.math.paramtrans import _npts 
     198  from mystic.math.distance import _npts 
    199199  _n = _npts(npts) 
    200200 
     
    260260 
    261261  from numpy import array 
    262   from mystic.math.dirac_measure import scenario 
     262  from mystic.math.discrete import scenario 
    263263  c = scenario() 
    264264  c.load(solved,npts) 
  • branches/UQ/math/legacy/TEST_OUQ_1dData.py

    r585 r687  
    7171def maximize(params,npts,bounds): 
    7272 
    73   from mystic.math.dirac_measure import scenario 
     73  from mystic.math.discrete import scenario 
    7474  from numpy import inf 
    7575  target,error = params 
     
    108108    ##################### begin function-specific ##################### 
    109109    # impose mean on the values of the product measure 
    110     from mystic.math.dirac_measure import mean_y_norm_wts_constraintsFactory as factory 
     110    from mystic.math.discrete import mean_y_norm_wts_constraintsFactory as factory 
    111111    constrain = factory((target[0],error[0]), npts) 
    112112 
     
    192192  nz = 1  #NOTE: SET THE NUMBER OF 'v' POINTS HERE! 
    193193  npts = (nx,ny,nz) 
    194   from mystic.math.paramtrans import _npts 
     194  from mystic.math.distance import _npts 
    195195  _n = _npts(npts) 
    196196 
     
    256256 
    257257  from numpy import array 
    258   from mystic.math.dirac_measure import scenario 
     258  from mystic.math.discrete import scenario 
    259259  c = scenario() 
    260260  c.load(solved,npts) 
  • branches/UQ/math/legacy/TEST_OUQ_1dSurr_CxCy.py

    r588 r687  
    7373def maximize(params,npts,bounds,printmon=None,**kwds): 
    7474 
    75   from mystic.math.dirac_measure import scenario 
     75  from mystic.math.discrete import scenario 
    7676  from numpy import inf 
    7777  target,error = params 
     
    110110    ##################### begin function-specific ##################### 
    111111    # impose mean on the values of the product measure 
    112     from mystic.math.dirac_measure import mean_y_norm_wts_constraintsFactory as factory 
     112    from mystic.math.discrete import mean_y_norm_wts_constraintsFactory as factory 
    113113    constrain = factory((target[0],error[0]), npts) 
    114114 
     
    203203  nz = 1  #NOTE: SET THE NUMBER OF 'v' POINTS HERE! 
    204204  npts = (nx,ny,nz) 
    205   from mystic.math.paramtrans import _npts 
     205  from mystic.math.distance import _npts 
    206206  _n = _npts(npts) 
    207207 
     
    271271 
    272272  from numpy import array 
    273   from mystic.math.dirac_measure import scenario 
     273  from mystic.math.discrete import scenario 
    274274  c = scenario() 
    275275  c.load(solved,npts) 
     
    294294  try: _Cx = max(Cx) 
    295295  except TypeError: _Cx = Cx 
    296   from mystic.math.paramtrans import graphical_distance 
     296  from mystic.math.distance import graphical_distance 
    297297  Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, 
    298298                          imax=0, hausdorff=hausdorff) 
  • branches/UQ/math/legacy/TEST_OUQ_1dSurr_Cy.py

    r586 r687  
    7373def maximize(params,npts,bounds,printmon=None,**kwds): 
    7474 
    75   from mystic.math.dirac_measure import scenario 
     75  from mystic.math.discrete import scenario 
    7676  from numpy import inf 
    7777  target,error = params 
     
    110110    ##################### begin function-specific ##################### 
    111111    # impose mean on the values of the product measure 
    112     from mystic.math.dirac_measure import mean_y_norm_wts_constraintsFactory as factory 
     112    from mystic.math.discrete import mean_y_norm_wts_constraintsFactory as factory 
    113113    constrain = factory((target[0],error[0]), npts) 
    114114 
     
    202202  nz = 1  #NOTE: SET THE NUMBER OF 'v' POINTS HERE! 
    203203  npts = (nx,ny,nz) 
    204   from mystic.math.paramtrans import _npts 
     204  from mystic.math.distance import _npts 
    205205  _n = _npts(npts) 
    206206 
     
    270270 
    271271  from numpy import array 
    272   from mystic.math.dirac_measure import scenario 
     272  from mystic.math.discrete import scenario 
    273273  c = scenario() 
    274274  c.load(solved,npts) 
     
    292292  try: _Cx = max(Cx) 
    293293  except TypeError: _Cx = Cx 
    294   from mystic.math.paramtrans import graphical_distance 
     294  from mystic.math.distance import graphical_distance 
    295295  Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=0) 
    296296  printmon.info("vertical_distance: %s <= %s" % (Ry, Cy + _Cx)) 
  • branches/UQ/math/legacy/TEST_OUQ_StAlData.py

    r585 r687  
    7171def maximize(params,npts,bounds): 
    7272 
    73   from mystic.math.dirac_measure import scenario 
     73  from mystic.math.discrete import scenario 
    7474  from numpy import inf 
    7575  target,error = params 
     
    108108    ##################### begin function-specific ##################### 
    109109    # impose mean on the values of the product measure 
    110     from mystic.math.dirac_measure import mean_y_norm_wts_constraintsFactory as factory 
     110    from mystic.math.discrete import mean_y_norm_wts_constraintsFactory as factory 
    111111    constrain = factory((target[0],error[0]), npts) 
    112112 
     
    193193  nz = 2  #NOTE: SET THE NUMBER OF 'v' POINTS HERE! 
    194194  npts = (nx,ny,nz) 
    195   from mystic.math.paramtrans import _npts 
     195  from mystic.math.distance import _npts 
    196196  _n = _npts(npts) 
    197197 
     
    257257 
    258258  from numpy import array 
    259   from mystic.math.dirac_measure import scenario 
     259  from mystic.math.discrete import scenario 
    260260  c = scenario() 
    261261  c.load(solved,npts) 
  • branches/UQ/math/legacy/TEST_OUQ_StStSurr_Cy.py

    r585 r687  
    7070def maximize(params,npts,bounds): 
    7171 
    72   from mystic.math.dirac_measure import scenario 
     72  from mystic.math.discrete import scenario 
    7373  from numpy import inf 
    7474  target,error = params 
     
    107107    ##################### begin function-specific ##################### 
    108108    # impose mean on the values of the product measure 
    109     from mystic.math.dirac_measure import mean_y_norm_wts_constraintsFactory as factory 
     109    from mystic.math.discrete import mean_y_norm_wts_constraintsFactory as factory 
    110110    constrain = factory((target[0],error[0]), npts) 
    111111 
     
    194194  nz = 1  #NOTE: SET THE NUMBER OF 'v' POINTS HERE! 
    195195  npts = (nx,ny,nz) 
    196   from mystic.math.paramtrans import _npts 
     196  from mystic.math.distance import _npts 
    197197  _n = _npts(npts) 
    198198 
     
    257257 
    258258  from numpy import array 
    259   from mystic.math.dirac_measure import scenario 
     259  from mystic.math.discrete import scenario 
    260260  c = scenario() 
    261261  c.load(solved,npts) 
     
    273273  try: _Cx = max(Cx) 
    274274  except TypeError: _Cx = Cx 
    275   from mystic.math.paramtrans import graphical_distance 
     275  from mystic.math.distance import graphical_distance 
    276276  Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, imax=0) 
    277277  print "vertical_distance: %s <= %s" % (Ry, Cy + _Cx) 
  • branches/UQ/math/legacy/envelope/Looper_BoLiSurr_Cy.py

    r675 r687  
    9898def maximize(params,npts,bounds,initial=None,job='',printmon=None): 
    9999 
    100   from mystic.math.dirac_measure import scenario 
     100  from mystic.math.discrete import scenario 
    101101  from numpy import inf 
    102102  target,error = params 
     
    140140    ##################### begin function-specific ##################### 
    141141    # impose mean on the values of the product measure 
    142     from mystic.math.dirac_measure import mean_y_norm_wts_constraintsFactory as factory 
     142    from mystic.math.discrete import mean_y_norm_wts_constraintsFactory as factory 
    143143    constrain = factory((target[0],error[0]), npts) 
    144144 
     
    250250 
    251251  npts = (nx,ny,nz) 
    252   from mystic.math.paramtrans import _npts 
     252  from mystic.math.distance import _npts 
    253253  _n = _npts(npts) 
    254254 
     
    316316 
    317317  from numpy import array 
    318   from mystic.math.dirac_measure import scenario 
     318  from mystic.math.discrete import scenario 
    319319  c = scenario() 
    320320  c.load(solved,npts) 
     
    333333# try: _Cx = max(Cx) 
    334334# except TypeError: _Cx = Cx 
    335   from mystic.math.paramtrans import graphical_distance 
     335  from mystic.math.distance import graphical_distance 
    336336  Ry = graphical_distance(model, c, ytol=Cy, xtol=Cx, cutoff=0.0, \ 
    337337                          imax=0, ipop=cde, hausdorff=hausdorff) 
  • branches/UQ/math/legacy/envelope/conf_hausd.py

    r592 r687  
    3636      
    3737# COMPUTING HAUSDORFF DISTANCES 
    38 from mystic.math.paramtrans import graphical_distance 
     38from mystic.math.distance import graphical_distance 
    3939d_hausdorff = graphical_distance(model, d, ytol=0, xtol=(2.5,2.5, 0.0), cutoff=0.0, imax=100, hausdorff=(5.0, 5.0, 0.0, 25.0)) 
    4040if debug: 
  • branches/UQ/math/legacy/envelope/envelope.py

    r675 r687  
    1515debug = False 
    1616 
    17 from mystic.math.paramtrans import infeasibility, _get_xy 
     17from mystic.math.distance import infeasibility, _get_xy 
    1818 
    1919def graphical_distance(model, points, **kwds): 
  • branches/UQ/math/legacy/envelope/hausdorff.py

    r621 r687  
    1919 
    2020# build a scenario 
    21 from mystic.math.dirac_measure import scenario 
     21from mystic.math.discrete import scenario 
    2222c = scenario() 
    2323c.load(solved, npts) 
     
    5353#""" 
    5454 
    55 #from mystic.math.paramtrans import graphical_distance 
     55#from mystic.math.distance import graphical_distance 
    5656from envelope import graphical_distance 
    5757from numpy import set_printoptions 
  • branches/UQ/math/legacy/envelope/sausage.py

    r601 r687  
    1818    exec("%s = %s" % (str(k),repr(v))) #XXX: HACK 
    1919 
    20   from mystic.math.dirac_measure import scenario 
     20  from mystic.math.discrete import scenario 
    2121  c = scenario() 
    2222  c.load(params, pts) 
     
    2828  yo = asarray(c.values) 
    2929 
    30   from mystic.math.dirac_measure import impose_valid 
     30  from mystic.math.discrete import impose_valid 
    3131 
    3232  # fixed x values as bounds 
  • branches/UQ/math/legacy/test_ExampleDataset.py

    r569 r687  
    3131 
    3232  # Check shortness 
    33   from mystic.math.paramtrans import lipschitz_distance, graphical_distance 
     33  from mystic.math.distance import lipschitz_distance, graphical_distance 
    3434  print("\nshort: %s" % ex1d_data.short()) 
    3535  L = ex1d_data.lipschitz; 
  • branches/UQ/math/legacy/test_StAlDataset.py

    r569 r687  
    2121 
    2222  # Check shortness 
    23   from mystic.math.paramtrans import lipschitz_distance, graphical_distance 
     23  from mystic.math.distance import lipschitz_distance, graphical_distance 
    2424  print("\nshort: %s" % st_al_data.short()) 
    2525  L = st_al_data.lipschitz; 
  • branches/UQ/math/legacy/test_graph_dist.py

    r588 r687  
    3333for i in d: print i 
    3434 
    35 from mystic.math.paramtrans import graphical_distance 
     35from mystic.math.distance import graphical_distance 
    3636from numpy import set_printoptions 
    3737set_printoptions(suppress=True) 
  • branches/UQ/math/sausage/TEST_OUQ_1dSurr_diam.py

    r588 r687  
    7272def maximize(params,npts,bounds): 
    7373 
    74   from mystic.math.dirac_measure import scenario 
     74  from mystic.math.discrete import scenario 
    7575  from mystic.math import almostEqual 
    7676  from numpy import inf 
     
    189189  nz = 1  #NOTE: SET THE NUMBER OF 'v' POINTS HERE! 
    190190  npts = (nx,ny,nz) 
    191   from mystic.math.paramtrans import _npts 
     191  from mystic.math.distance import _npts 
    192192  _n = _npts(npts) 
    193193 
     
    253253 
    254254  from numpy import array 
    255   from mystic.math.dirac_measure import scenario 
     255  from mystic.math.discrete import scenario 
    256256  c = scenario() 
    257257  c.load(solved,npts) 
  • branches/UQ/math/sausage/TEST_OUQ_StStSurr.py

    r588 r687  
    7171def maximize(params,npts,bounds): 
    7272 
    73   from mystic.math.dirac_measure import scenario 
     73  from mystic.math.discrete import scenario 
    7474  from mystic.math import almostEqual 
    7575  from numpy import inf 
     
    201201  nz = 1  #NOTE: SET THE NUMBER OF 'v' POINTS HERE! 
    202202  npts = (nx,ny,nz) 
    203   from mystic.math.paramtrans import _npts 
     203  from mystic.math.distance import _npts 
    204204  _n = _npts(npts) 
    205205 
     
    265265 
    266266  from numpy import array 
    267   from mystic.math.dirac_measure import scenario 
     267  from mystic.math.discrete import scenario 
    268268  c = scenario() 
    269269  c.load(solved,npts) 
  • branches/collapse/TEST_OUQ_surrogate_diam_collapse.py

    r576 r687  
    5858 
    5959  from mystic.math.measures import split_param 
    60   from mystic.math.dirac_measure import product_measure 
     60  from mystic.math.discrete import product_measure 
    6161  from mystic.math import almostEqual 
    6262  from numpy import inf 
     
    8484    # impose expectation on product measure 
    8585    ##################### begin function-specific ##################### 
    86     E = float(c.get_expect(model)) 
     86    E = float(c.expect(model)) 
    8787    if not (E <= float(target[0] + error[0])) \ 
    8888    or not (float(target[0] - error[0]) <= E): 
     
    9696    c = product_measure() 
    9797    c.load(rv, npts) 
    98     E = float(c.get_expect(model)) 
     98    E = float(c.expect(model)) 
    9999    if E > (target[0] + error[0]) or E < (target[0] - error[0]): 
    100100      if debug: print "skipping expect: %s" % E 
     
    188188 
    189189  from numpy import array 
    190   from mystic.math.dirac_measure import product_measure 
     190  from mystic.math.discrete import product_measure 
    191191  c = product_measure() 
    192192  c.load(solved,npts) 
     
    195195  print "solved: [wz,z]\n%s" % array(zip(c[2].weights,c[2].coords)) 
    196196 
    197   print "expect: %s" % str( c.get_expect(model) ) 
     197  print "expect: %s" % str( c.expect(model) ) 
    198198   
    199199  elapsed = (clock() - start) 
  • branches/collapse/collapse_code.py

    r576 r687  
    3737 
    3838def _set_weight_to_zero(rv, npts, axisW, indexW): 
    39     from mystic.math.dirac_measure import product_measure 
     39    from mystic.math.discrete import product_measure 
    4040    c = product_measure() 
    4141    c.load(rv, npts) 
     
    4444   
    4545def _set_same_positions(rv, npts, axisP, index1, index2): 
    46     from mystic.math.dirac_measure import product_measure 
     46    from mystic.math.discrete import product_measure 
    4747    c = product_measure() 
    4848    c.load(rv, npts) 
Note: See TracChangeset for help on using the changeset viewer.