Changeset 861


Ignore:
Timestamp:
04/02/16 13:44:19 (7 weeks ago)
Author:
mmckerns
Message:

enable SetDistributionPoints? to take a numpy.random distribution method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mystic/mystic/abstract_solver.py

    r858 r861  
    426426        return 
    427427 
    428     def SetDistributionInitialPoints(self, dist): 
     428    def SetDistributionInitialPoints(self, dist, *args): 
    429429        """Generate Random Initial Points from Distribution (dist) 
    430430 
    431431input:: 
    432     - dist: a scipy.stats distribution instance""" 
     432    - dist: a scipy.stats distribution instance (or a numpy.random method) 
     433 
     434note:: 
     435    this method only accepts numpy.random methods with the keyword 'size'""" 
    433436        from mystic.tools import random_state 
    434437        prng = random_state(module='numpy.random') 
    435         for i in range(self.nPop): 
    436             self.population[i] = dist.rvs(self.nDim, random_state=prng).tolist() 
     438        if not args and type(dist).__name__ is 'rv_frozen': #from scipy.stats 
     439            for i in range(self.nPop): 
     440                self.population[i] = dist.rvs(self.nDim, random_state=prng).tolist() 
     441        else: #from numpy.random with *args and size in kwds 
     442            for i in range(self.nPop):  
     443                self.population[i] = dist(*args, size=self.nDim).tolist() 
    437444        return 
    438445 
Note: See TracChangeset for help on using the changeset viewer.