- Timestamp:
- 11/11/10 14:13:19 (19 months ago)
- Files:
-
- 1 modified
-
trunk/src/random.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/random.py
r446 r475 19 19 import numpy, numpy.random 20 20 21 have_scipy = check_dependency('scipy') 22 23 21 24 22 class ParameterDist(object): 25 23 … … 67 65 either mean,var ('ms', the default) or a,b ('ab') 68 66 """ 67 68 if check_dependency('scipy'): 69 self.next = self._next_scipy 70 69 71 self.repr_mode = repr_mode 70 72 if 'm' in params and mean==None: … … 93 95 self.dist_name = 'GammaDist' 94 96 95 if have_scipy:97 def _next_scipy(self,n=1): 96 98 import scipy.stats 97 def next(self,n=1):98 return scipy.stats.gamma.rvs(self.params['a'],size=n)*self.params['b']99 else:100 def next(self,n=1): 101 raise Exception('Error scipy was not found at import time. GammaDist realization disabled.')102 99 return scipy.stats.gamma.rvs(self.params['a'],size=n)*self.params['b'] 100 def _next_no_scipy(self,n=1): 101 raise Exception('Error scipy was not found at import time. GammaDist realization disabled.') 102 103 next = _next_no_scipy 104 103 105 def mean(self): 104 106 return self.params['a']*self.params['b'] … … 119 121 mean + std 120 122 121 Generally the distribution is implemented122 by scipy.stats.gamma.pdf(x/b,a)/b123 124 For more info, in ipython type:125 >>> ? scipy.stats.gamma126 127 123 """ 128 124
