mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	GH-100234: Set a default value for random.expovariate() (GH-100235)
This commit is contained in:
		
							parent
							
								
									8356c14b4f
								
							
						
					
					
						commit
						b430399d41
					
				
					 4 changed files with 8 additions and 2 deletions
				
			
		|  | @ -320,7 +320,7 @@ be found in any statistics text. | |||
|    ``beta > 0``. Returned values range between 0 and 1. | ||||
| 
 | ||||
| 
 | ||||
| .. function:: expovariate(lambd) | ||||
| .. function:: expovariate(lambd = 1.0) | ||||
| 
 | ||||
|    Exponential distribution.  *lambd* is 1.0 divided by the desired | ||||
|    mean.  It should be nonzero.  (The parameter would be called | ||||
|  | @ -328,6 +328,9 @@ be found in any statistics text. | |||
|    range from 0 to positive infinity if *lambd* is positive, and from | ||||
|    negative infinity to 0 if *lambd* is negative. | ||||
| 
 | ||||
|    .. versionchanged:: 3.12 | ||||
|       Added the default value for ``lambd``. | ||||
| 
 | ||||
| 
 | ||||
| .. function:: gammavariate(alpha, beta) | ||||
| 
 | ||||
|  |  | |||
|  | @ -577,7 +577,7 @@ def lognormvariate(self, mu, sigma): | |||
|         """ | ||||
|         return _exp(self.normalvariate(mu, sigma)) | ||||
| 
 | ||||
|     def expovariate(self, lambd): | ||||
|     def expovariate(self, lambd=1.0): | ||||
|         """Exponential distribution. | ||||
| 
 | ||||
|         lambd is 1.0 divided by the desired mean.  It should be | ||||
|  |  | |||
|  | @ -988,6 +988,7 @@ def test_zeroinputs(self): | |||
|         g.random = x[:].pop; g.uniform(1,10) | ||||
|         g.random = x[:].pop; g.paretovariate(1.0) | ||||
|         g.random = x[:].pop; g.expovariate(1.0) | ||||
|         g.random = x[:].pop; g.expovariate() | ||||
|         g.random = x[:].pop; g.weibullvariate(1.0, 1.0) | ||||
|         g.random = x[:].pop; g.vonmisesvariate(1.0, 1.0) | ||||
|         g.random = x[:].pop; g.normalvariate(0.0, 1.0) | ||||
|  |  | |||
|  | @ -0,0 +1,2 @@ | |||
| Set a default value of 1.0 for the ``lambd`` parameter in | ||||
| random.expovariate(). | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Raymond Hettinger
						Raymond Hettinger