Skip to content

Commit

Permalink
Updated rv_continuous so that .rvs method can handle scale==0 and ret…
Browse files Browse the repository at this point in the history
…urns location parameter.
  • Loading branch information
teoliphant committed Apr 9, 2004
1 parent 49a2b0a commit d1aed45
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Lib/stats/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def rvs(self,*args,**kwds):
"""
loc,scale,size=map(kwds.get,['loc','scale','size'])
args, loc, scale = self.__fix_loc_scale(args, loc, scale)
cond = logical_and(self._argcheck(*args),(scale > 0))
cond = logical_and(self._argcheck(*args),(scale >= 0))
if not all(cond):
raise ValueError, "Domain error in arguments."

Expand All @@ -438,7 +438,10 @@ def rvs(self,*args,**kwds):
size = (size,)

vals = reshape(self._rvs(*args),size)
return vals * scale + loc
if scale == 0:
return loc*ones(size,'d')
else:
return vals * scale + loc

def pdf(self,x,*args,**kwds):
"""Probability density function at x of the given RV.
Expand Down

0 comments on commit d1aed45

Please sign in to comment.