@@ -163,60 +163,13 @@ def binomial(n, p, size=None):
163
163
164
164
Draw samples from a binomial distribution.
165
165
166
- Samples are drawn from a binomial distribution with specified
167
- parameters, n trials and p probability of success where
168
- n an integer >= 0 and p is in the interval [0,1]. (n may be
169
- input as a float, but it is truncated to an integer in use)
166
+ For full documentation refer to :obj:`numpy.random.binomial`.
170
167
171
- Parameters
172
- ----------
173
- n : int
174
- Parameter of the distribution, >= 0. Floats are also accepted,
175
- but they will be truncated to integers.
176
- p : float
177
- Parameter of the distribution, >= 0 and <=1.
178
- size : int or tuple of ints, optional
179
- Output shape. If the given shape is, e.g., ``(m, n, k)``, then
180
- ``m * n * k`` samples are drawn. If size is ``None`` (default),
181
- a single value is returned if ``n`` and ``p`` are both scalars.
182
- Otherwise, ``np.broadcast(n, p).size`` samples are drawn.
183
-
184
- Returns
185
- -------
186
- out : dparray, int32
187
- Drawn samples from the parameterized binomial distribution, where
188
- each sample is equal to the number of successes over the n trials.
189
-
190
- Notes
191
- -----
192
- The probability density for the binomial distribution is
193
-
194
- .. math:: P(N) = \\ binom{n}{N}p^N(1-p)^{n-N},
195
-
196
- where :math:`n` is the number of trials, :math:`p` is the probability
197
- of success, and :math:`N` is the number of successes.
198
-
199
- When estimating the standard error of a proportion in a population by
200
- using a random sample, the normal distribution works well unless the
201
- product p*n <=5, where p = population proportion estimate, and n =
202
- number of samples, in which case the binomial distribution is used
203
- instead. For example, a sample of 15 people shows 4 who are left
204
- handed, and 11 who are right handed. Then p = 4/15 = 27%. 0.27*15 = 4,
205
- so the binomial distribution should be used in this case.
206
-
207
- References
208
- ----------
209
- .. [1] Dalgaard, Peter, "Introductory Statistics with R",
210
- Springer-Verlag, 2002.
211
- .. [2] Glantz, Stanton A. "Primer of Biostatistics.", McGraw-Hill,
212
- Fifth Edition, 2002.
213
- .. [3] Lentner, Marvin, "Elementary Applied Statistics", Bogden
214
- and Quigley, 1972.
215
- .. [4] Weisstein, Eric W. "Binomial Distribution." From MathWorld--A
216
- Wolfram Web Resource.
217
- http://mathworld.wolfram.com/BinomialDistribution.html
218
- .. [5] Wikipedia, "Binomial distribution",
219
- https://en.wikipedia.org/wiki/Binomial_distribution
168
+ Limitations
169
+ -----------
170
+ Output array data type is :obj:`dpnp.int32`.
171
+ Parameters ``n`` and ``p`` are supported as scalar.
172
+ Otherwise, :obj:`numpy.random.binomial(n, p, size)` samples are drawn.
220
173
221
174
Examples
222
175
--------
@@ -235,23 +188,20 @@ def binomial(n, p, size=None):
235
188
"""
236
189
237
190
if not use_origin_backend (n ) and dpnp_queue_is_cpu ():
238
- if size is None :
239
- size = 1
240
- elif isinstance (size , tuple ):
241
- for dim in size :
242
- if not isinstance (dim , int ):
243
- checker_throw_value_error ("binomial" , "type(dim)" , type (dim ), int )
244
- elif not isinstance (size , int ):
245
- checker_throw_value_error ("binomial" , "type(size)" , type (size ), int )
246
-
247
191
# TODO:
248
192
# array_like of floats for `p` param
249
- if p > 1 or p < 0 :
250
- checker_throw_value_error ("binomial" , "p" , p , "in [0, 1]" )
251
- if n < 0 :
252
- checker_throw_value_error ("binomial" , "n" , n , "non-negative" )
253
-
254
- return dpnp_binomial (int (n ), p , size )
193
+ if not dpnp .isscalar (n ):
194
+ pass
195
+ elif not dpnp .isscalar (p ):
196
+ pass
197
+ elif p > 1 or p < 0 :
198
+ pass
199
+ elif n < 0 :
200
+ pass
201
+ else :
202
+ if size is None :
203
+ size = 1
204
+ return dpnp_binomial (int (n ), p , size )
255
205
256
206
return call_origin (numpy .random .binomial , n , p , size )
257
207
0 commit comments