We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
 vonmises
numpy.random.vonmises function implementation

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ivy/functional/frontends/numpy/random/functions.py`
Content:
```
1 # local
2 
3 import ivy
4 from ivy.functional.frontends.numpy.func_wrapper import (
5     to_ivy_arrays_and_back,
6     from_zero_dim_arrays_to_scalar,
7 )
8 
9 
10 @to_ivy_arrays_and_back
11 @from_zero_dim_arrays_to_scalar
12 def beta(a, b, size=None):
13     return ivy.beta(a, b, shape=size)
14 
15 
16 @to_ivy_arrays_and_back
17 @from_zero_dim_arrays_to_scalar
18 def binomial(n, p, size=None):
19     if p < 0 or p > 1:
20         raise ValueError("p must be in the interval (0, 1)")
21     if n < 0:
22         raise ValueError("n must be strictly positive")
23     if size is None:
24         size = 1
25     else:
26         size = size
27     if isinstance(size, int):
28         size = (size,)
29     lambda_ = ivy.multiply(n, p)
30     return ivy.poisson(lambda_, shape=size)
31 
32 
33 @to_ivy_arrays_and_back
34 @from_zero_dim_arrays_to_scalar
35 def chisquare(df, size=None):
36     df = ivy.array(df)  # scalar ints and floats are also array_like
37     if ivy.any(df <= 0):
38         raise ValueError("df <= 0")
39 
40     # ivy.gamma() throws an error if both alpha is an array and a shape is passed
41     # so this part broadcasts df into the shape of `size`` first to keep it happy.
42     if size is not None:
43         df = df * ivy.ones(size)
44 
45     return ivy.gamma(df / 2, 2, dtype="float64")
46 
47 
48 @to_ivy_arrays_and_back
49 @from_zero_dim_arrays_to_scalar
50 def choice(a, size=None, replace=True, p=None):
51     sc_size = 1
52     if isinstance(size, int):
53         sc_size = size
54     elif size is not None:
55         #  If the given shape is, e.g., (m, n, k)
56         #  then m * n * k samples are drawn. As per numpy docs
57         sc_size = 1
58         for s in size:
59             if s is not None:
60                 sc_size *= s
61     if isinstance(a, int):
62         a = ivy.arange(a)
63     index = ivy.multinomial(len(a), sc_size, replace=replace, probs=p)
64     return a[index]
65 
66 
67 @to_ivy_arrays_and_back
68 @from_zero_dim_arrays_to_scalar
69 def dirichlet(alpha, size=None):
70     return ivy.dirichlet(alpha, size=size)
71 
72 
73 @to_ivy_arrays_and_back
74 @from_zero_dim_arrays_to_scalar
75 def f(dfn, dfd, size=None):
76     # Generate samples from the uniform distribution
77     x1 = ivy.gamma(ivy.to_scalar(ivy.divide(dfn, 2)), 2.0, shape=size, dtype="float64")
78     x2 = ivy.gamma(ivy.to_scalar(ivy.divide(dfd, 2)), 2.0, shape=size, dtype="float64")
79     # Calculate the F-distributed samples
80     samples = ivy.divide(ivy.divide(x1, ivy.array(dfn)), ivy.divide(x2, ivy.array(dfd)))
81     return samples
82 
83 
84 @to_ivy_arrays_and_back
85 @from_zero_dim_arrays_to_scalar
86 def gamma(shape, scale=1.0, size=None):
87     return ivy.gamma(shape, scale, shape=size, dtype="float64")
88 
89 
90 @to_ivy_arrays_and_back
91 @from_zero_dim_arrays_to_scalar
92 def geometric(p, size=None):
93     if p < 0 or p > 1:
94         raise ValueError("p must be in the interval [0, 1]")
95     oneMinusP = ivy.subtract(1, p)
96     sizeMinusOne = ivy.subtract(size, 1)
97 
98     return ivy.multiply(ivy.pow(oneMinusP, sizeMinusOne), p)
99 
100 
101 @to_ivy_arrays_and_back
102 @from_zero_dim_arrays_to_scalar
103 def gumbel(loc=0.0, scale=1.0, size=None):
104     u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype="float64")
105     x = loc - scale * ivy.log(-ivy.log(u))
106     return x
107 
108 
109 @to_ivy_arrays_and_back
110 @from_zero_dim_arrays_to_scalar
111 def laplace(loc=0.0, scale=1.0, size=None):
112     u = ivy.random_uniform(low=0.0, high=0.0, shape=size, dtype="float64")
113     u = loc - scale * ivy.sign(u - 0.5) * ivy.log(1 - 2 * ivy.abs(u - 0.5))
114     return u
115 
116 
117 @to_ivy_arrays_and_back
118 @from_zero_dim_arrays_to_scalar
119 def logistic(loc=0.0, scale=1.0, size=None):
120     u = ivy.random_uniform(low=0.0, high=0.0, shape=size, dtype="float64")
121     x = loc + scale * ivy.log(u / (1 - u))
122     return x
123 
124 
125 @to_ivy_arrays_and_back
126 @from_zero_dim_arrays_to_scalar
127 def lognormal(mean=0.0, sigma=1.0, size=None):
128     ret = ivy.exp(ivy.random_normal(mean=mean, std=sigma, shape=size, dtype="float64"))
129     return ret
130 
131 
132 @to_ivy_arrays_and_back
133 @from_zero_dim_arrays_to_scalar
134 def logseries(p=0, size=None):
135     if p < 0 or p >= 1:
136         raise ValueError("p value must be in the open interval (0, 1)")
137     r = ivy.log(1 - p)
138     u = ivy.random_uniform(low=0.0, high=1.0, shape=size)
139     v = ivy.random_uniform(low=0.0, high=1.0, shape=size)
140     q = 1 - ivy.exp(r * u)
141     ret = 1 + ivy.log(v) / ivy.log(q)
142     return ret
143 
144 
145 @to_ivy_arrays_and_back
146 @from_zero_dim_arrays_to_scalar
147 def multinomial(n, pvals, size=None):
148     assert not ivy.exists(size) or (len(size) > 0 and len(size) < 3)
149     batch_size = 1
150     if ivy.exists(size):
151         if len(size) == 2:
152             batch_size = size[0]
153             num_samples = size[1]
154         else:
155             num_samples = size[0]
156     else:
157         num_samples = len(pvals)
158     return ivy.multinomial(n, num_samples, batch_size=batch_size, probs=pvals)
159 
160 
161 @to_ivy_arrays_and_back
162 @from_zero_dim_arrays_to_scalar
163 def negative_binomial(n, p, size=None):
164     if p <= 0 or p >= 1:
165         raise ValueError("p must be in the interval (0, 1)")
166     if n <= 0:
167         raise ValueError("n must be strictly positive")
168     # numpy implementation uses scale = (1 - p) / p
169     scale = (1 - p) / p
170     # poisson requires shape to be a tuple
171     if isinstance(size, int):
172         size = (size,)
173     lambda_ = ivy.gamma(n, scale, shape=size)
174     return ivy.poisson(lam=lambda_, shape=size)
175 
176 
177 @to_ivy_arrays_and_back
178 @from_zero_dim_arrays_to_scalar
179 def normal(loc=0.0, scale=1.0, size=None):
180     return ivy.random_normal(mean=loc, std=scale, shape=size, dtype="float64")
181 
182 
183 @to_ivy_arrays_and_back
184 @from_zero_dim_arrays_to_scalar
185 def pareto(a, size=None):
186     if a < 0:
187         return 0
188     u = ivy.random_uniform(low=0.0, high=0.0, shape=size, dtype="float64")
189     return ivy.pow(1 / (1 - u), 1 / a)
190 
191 
192 @to_ivy_arrays_and_back
193 @from_zero_dim_arrays_to_scalar
194 def permutation(x, /):
195     if isinstance(x, int):
196         x = ivy.arange(x)
197     return ivy.shuffle(x)
198 
199 
200 @to_ivy_arrays_and_back
201 @from_zero_dim_arrays_to_scalar
202 def poisson(lam=1.0, size=None):
203     return ivy.poisson(lam=lam, shape=size)
204 
205 
206 @to_ivy_arrays_and_back
207 @from_zero_dim_arrays_to_scalar
208 def random_sample(size=None):
209     return ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype="float64")
210 
211 
212 @to_ivy_arrays_and_back
213 @from_zero_dim_arrays_to_scalar
214 def rayleigh(scale, size=None):
215     u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype="float64")
216     log_u = ivy.log(u)
217     x = ivy.multiply(scale, ivy.sqrt(ivy.multiply(-2, log_u)))
218     return x
219 
220 
221 @to_ivy_arrays_and_back
222 @from_zero_dim_arrays_to_scalar
223 def shuffle(x, axis=0, /):
224     if isinstance(x, int):
225         x = ivy.arange(x)
226     return ivy.shuffle(x, axis)
227 
228 
229 @to_ivy_arrays_and_back
230 @from_zero_dim_arrays_to_scalar
231 def standard_cauchy(size=None):
232     u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype="float64")
233     return ivy.tan(ivy.pi * (u - 0.5))
234 
235 
236 @to_ivy_arrays_and_back
237 @from_zero_dim_arrays_to_scalar
238 def standard_gamma(shape, size=None):
239     return ivy.gamma(shape, 1.0, shape=size, dtype="float64")
240 
241 
242 @to_ivy_arrays_and_back
243 @from_zero_dim_arrays_to_scalar
244 def standard_normal(size=None):
245     return ivy.random_normal(mean=0.0, std=1.0, shape=size, dtype="float64")
246 
247 
248 @to_ivy_arrays_and_back
249 @from_zero_dim_arrays_to_scalar
250 def standard_t(df, size=None):
251     numerator = ivy.random_normal(mean=0.0, std=1.0, shape=size, dtype="float64")
252     denominator = ivy.gamma(df / 2, 1.0, shape=size, dtype="float64")
253     return ivy.sqrt(df / 2) * ivy.divide(numerator, ivy.sqrt(denominator))
254 
255 
256 @to_ivy_arrays_and_back
257 @from_zero_dim_arrays_to_scalar
258 def triangular(left, mode, right, size=None):
259     if left > mode or mode > right or left == right:
260         raise ivy.utils.exceptions.IvyValueError(
261             "left < mode < right is not being followed"
262         )
263     u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype="float64")
264     condition = u <= (mode - left) / (right - left)
265     values1 = left + (right - left) * (u * (mode - left) / (right - left)) ** 0.5
266     values2 = (
267         right - (right - mode) * ((1 - u) * (right - mode) / (right - left)) ** 0.5
268     )
269     return ivy.where(condition, values1, values2)
270 
271 
272 @to_ivy_arrays_and_back
273 @from_zero_dim_arrays_to_scalar
274 def uniform(low=0.0, high=1.0, size=None):
275     return ivy.random_uniform(low=low, high=high, shape=size, dtype="float64")
276 
277 
278 @to_ivy_arrays_and_back
279 @from_zero_dim_arrays_to_scalar
280 def wald(mean, scale, size=None):
281     if size is None:
282         size = 1
283     mu_2l = mean / (2 * scale)
284     Y = ivy.random_normal(mean=0, std=1, shape=size, dtype="float64")
285     U = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype="float64")
286 
287     Y = mean * ivy.square(Y)
288     X = mean + mu_2l * (Y - ivy.sqrt(((4 * scale) * Y) + ivy.square(Y)))
289 
290     condition = U <= mean / (mean + X)
291     value1 = X
292     value2 = mean * mean / X
293 
294     return ivy.where(condition, value1, value2)
295 
296 
297 @to_ivy_arrays_and_back
298 @from_zero_dim_arrays_to_scalar
299 def weibull(a, size=None):
300     if a < 0:
301         return 0
302     u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype="float64")
303     return ivy.pow(-ivy.log(1 - u), 1 / a)
304 
305 
306 @to_ivy_arrays_and_back
307 @from_zero_dim_arrays_to_scalar
308 def zipf(a, size=None):
309     if a <= 1:
310         return 0
311     u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype="float64")
312     return ivy.floor(ivy.pow(1 / (1 - u), 1 / a))
313
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/ivy/functional/frontends/numpy/random/functions.py b/ivy/functional/frontends/numpy/random/functions.py
--- a/ivy/functional/frontends/numpy/random/functions.py
+++ b/ivy/functional/frontends/numpy/random/functions.py
@@ -275,6 +275,33 @@
     return ivy.random_uniform(low=low, high=high, shape=size, dtype="float64")
 
 
+@to_ivy_arrays_and_back
+@from_zero_dim_arrays_to_scalar
+def vonmises(mu, kappa, size=None):
+    t_size = 0
+    # Output shape. If the given shape is, e.g., (m, n, k),
+    # then m * n * k samples are drawn.
+    if size is None or len(size) == 0:
+        t_size = 1
+    else:
+        for x in size:
+            t_size = t_size * x
+    size = t_size
+    li = []
+    while len(li) < size:
+        # Generate samples from the von Mises distribution using numpy
+        u = ivy.random_uniform(low=-ivy.pi, high=ivy.pi, shape=size)
+        v = ivy.random_uniform(low=0, high=1, shape=size)
+
+        condition = v < (1 + ivy.exp(kappa * ivy.cos(u - mu))) / (
+            2 * ivy.pi * ivy.i0(kappa)
+        )
+        selected_samples = u[condition]
+        li.extend(ivy.to_list(selected_samples))
+
+    return ivy.array(li[:size])
+
+
 @to_ivy_arrays_and_back
 @from_zero_dim_arrays_to_scalar
 def wald(mean, scale, size=None):

{"golden_diff": "diff --git a/ivy/functional/frontends/numpy/random/functions.py b/ivy/functional/frontends/numpy/random/functions.py\n--- a/ivy/functional/frontends/numpy/random/functions.py\n+++ b/ivy/functional/frontends/numpy/random/functions.py\n@@ -275,6 +275,33 @@\n     return ivy.random_uniform(low=low, high=high, shape=size, dtype=\"float64\")\n \n \n+@to_ivy_arrays_and_back\n+@from_zero_dim_arrays_to_scalar\n+def vonmises(mu, kappa, size=None):\n+    t_size = 0\n+    # Output shape. If the given shape is, e.g., (m, n, k),\n+    # then m * n * k samples are drawn.\n+    if size is None or len(size) == 0:\n+        t_size = 1\n+    else:\n+        for x in size:\n+            t_size = t_size * x\n+    size = t_size\n+    li = []\n+    while len(li) < size:\n+        # Generate samples from the von Mises distribution using numpy\n+        u = ivy.random_uniform(low=-ivy.pi, high=ivy.pi, shape=size)\n+        v = ivy.random_uniform(low=0, high=1, shape=size)\n+\n+        condition = v < (1 + ivy.exp(kappa * ivy.cos(u - mu))) / (\n+            2 * ivy.pi * ivy.i0(kappa)\n+        )\n+        selected_samples = u[condition]\n+        li.extend(ivy.to_list(selected_samples))\n+\n+    return ivy.array(li[:size])\n+\n+\n @to_ivy_arrays_and_back\n @from_zero_dim_arrays_to_scalar\n def wald(mean, scale, size=None):\n", "issue": " vonmises\nnumpy.random.vonmises function implementation\n", "before_files": [{"content": "# local\n\nimport ivy\nfrom ivy.functional.frontends.numpy.func_wrapper import (\n    to_ivy_arrays_and_back,\n    from_zero_dim_arrays_to_scalar,\n)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef beta(a, b, size=None):\n    return ivy.beta(a, b, shape=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef binomial(n, p, size=None):\n    if p < 0 or p > 1:\n        raise ValueError(\"p must be in the interval (0, 1)\")\n    if n < 0:\n        raise ValueError(\"n must be strictly positive\")\n    if size is None:\n        size = 1\n    else:\n        size = size\n    if isinstance(size, int):\n        size = (size,)\n    lambda_ = ivy.multiply(n, p)\n    return ivy.poisson(lambda_, shape=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef chisquare(df, size=None):\n    df = ivy.array(df)  # scalar ints and floats are also array_like\n    if ivy.any(df <= 0):\n        raise ValueError(\"df <= 0\")\n\n    # ivy.gamma() throws an error if both alpha is an array and a shape is passed\n    # so this part broadcasts df into the shape of `size`` first to keep it happy.\n    if size is not None:\n        df = df * ivy.ones(size)\n\n    return ivy.gamma(df / 2, 2, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef choice(a, size=None, replace=True, p=None):\n    sc_size = 1\n    if isinstance(size, int):\n        sc_size = size\n    elif size is not None:\n        #  If the given shape is, e.g., (m, n, k)\n        #  then m * n * k samples are drawn. As per numpy docs\n        sc_size = 1\n        for s in size:\n            if s is not None:\n                sc_size *= s\n    if isinstance(a, int):\n        a = ivy.arange(a)\n    index = ivy.multinomial(len(a), sc_size, replace=replace, probs=p)\n    return a[index]\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef dirichlet(alpha, size=None):\n    return ivy.dirichlet(alpha, size=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef f(dfn, dfd, size=None):\n    # Generate samples from the uniform distribution\n    x1 = ivy.gamma(ivy.to_scalar(ivy.divide(dfn, 2)), 2.0, shape=size, dtype=\"float64\")\n    x2 = ivy.gamma(ivy.to_scalar(ivy.divide(dfd, 2)), 2.0, shape=size, dtype=\"float64\")\n    # Calculate the F-distributed samples\n    samples = ivy.divide(ivy.divide(x1, ivy.array(dfn)), ivy.divide(x2, ivy.array(dfd)))\n    return samples\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef gamma(shape, scale=1.0, size=None):\n    return ivy.gamma(shape, scale, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef geometric(p, size=None):\n    if p < 0 or p > 1:\n        raise ValueError(\"p must be in the interval [0, 1]\")\n    oneMinusP = ivy.subtract(1, p)\n    sizeMinusOne = ivy.subtract(size, 1)\n\n    return ivy.multiply(ivy.pow(oneMinusP, sizeMinusOne), p)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef gumbel(loc=0.0, scale=1.0, size=None):\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    x = loc - scale * ivy.log(-ivy.log(u))\n    return x\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef laplace(loc=0.0, scale=1.0, size=None):\n    u = ivy.random_uniform(low=0.0, high=0.0, shape=size, dtype=\"float64\")\n    u = loc - scale * ivy.sign(u - 0.5) * ivy.log(1 - 2 * ivy.abs(u - 0.5))\n    return u\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef logistic(loc=0.0, scale=1.0, size=None):\n    u = ivy.random_uniform(low=0.0, high=0.0, shape=size, dtype=\"float64\")\n    x = loc + scale * ivy.log(u / (1 - u))\n    return x\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef lognormal(mean=0.0, sigma=1.0, size=None):\n    ret = ivy.exp(ivy.random_normal(mean=mean, std=sigma, shape=size, dtype=\"float64\"))\n    return ret\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef logseries(p=0, size=None):\n    if p < 0 or p >= 1:\n        raise ValueError(\"p value must be in the open interval (0, 1)\")\n    r = ivy.log(1 - p)\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size)\n    v = ivy.random_uniform(low=0.0, high=1.0, shape=size)\n    q = 1 - ivy.exp(r * u)\n    ret = 1 + ivy.log(v) / ivy.log(q)\n    return ret\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef multinomial(n, pvals, size=None):\n    assert not ivy.exists(size) or (len(size) > 0 and len(size) < 3)\n    batch_size = 1\n    if ivy.exists(size):\n        if len(size) == 2:\n            batch_size = size[0]\n            num_samples = size[1]\n        else:\n            num_samples = size[0]\n    else:\n        num_samples = len(pvals)\n    return ivy.multinomial(n, num_samples, batch_size=batch_size, probs=pvals)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef negative_binomial(n, p, size=None):\n    if p <= 0 or p >= 1:\n        raise ValueError(\"p must be in the interval (0, 1)\")\n    if n <= 0:\n        raise ValueError(\"n must be strictly positive\")\n    # numpy implementation uses scale = (1 - p) / p\n    scale = (1 - p) / p\n    # poisson requires shape to be a tuple\n    if isinstance(size, int):\n        size = (size,)\n    lambda_ = ivy.gamma(n, scale, shape=size)\n    return ivy.poisson(lam=lambda_, shape=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef normal(loc=0.0, scale=1.0, size=None):\n    return ivy.random_normal(mean=loc, std=scale, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef pareto(a, size=None):\n    if a < 0:\n        return 0\n    u = ivy.random_uniform(low=0.0, high=0.0, shape=size, dtype=\"float64\")\n    return ivy.pow(1 / (1 - u), 1 / a)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef permutation(x, /):\n    if isinstance(x, int):\n        x = ivy.arange(x)\n    return ivy.shuffle(x)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef poisson(lam=1.0, size=None):\n    return ivy.poisson(lam=lam, shape=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef random_sample(size=None):\n    return ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef rayleigh(scale, size=None):\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    log_u = ivy.log(u)\n    x = ivy.multiply(scale, ivy.sqrt(ivy.multiply(-2, log_u)))\n    return x\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef shuffle(x, axis=0, /):\n    if isinstance(x, int):\n        x = ivy.arange(x)\n    return ivy.shuffle(x, axis)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef standard_cauchy(size=None):\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    return ivy.tan(ivy.pi * (u - 0.5))\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef standard_gamma(shape, size=None):\n    return ivy.gamma(shape, 1.0, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef standard_normal(size=None):\n    return ivy.random_normal(mean=0.0, std=1.0, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef standard_t(df, size=None):\n    numerator = ivy.random_normal(mean=0.0, std=1.0, shape=size, dtype=\"float64\")\n    denominator = ivy.gamma(df / 2, 1.0, shape=size, dtype=\"float64\")\n    return ivy.sqrt(df / 2) * ivy.divide(numerator, ivy.sqrt(denominator))\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef triangular(left, mode, right, size=None):\n    if left > mode or mode > right or left == right:\n        raise ivy.utils.exceptions.IvyValueError(\n            \"left < mode < right is not being followed\"\n        )\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    condition = u <= (mode - left) / (right - left)\n    values1 = left + (right - left) * (u * (mode - left) / (right - left)) ** 0.5\n    values2 = (\n        right - (right - mode) * ((1 - u) * (right - mode) / (right - left)) ** 0.5\n    )\n    return ivy.where(condition, values1, values2)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef uniform(low=0.0, high=1.0, size=None):\n    return ivy.random_uniform(low=low, high=high, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef wald(mean, scale, size=None):\n    if size is None:\n        size = 1\n    mu_2l = mean / (2 * scale)\n    Y = ivy.random_normal(mean=0, std=1, shape=size, dtype=\"float64\")\n    U = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n\n    Y = mean * ivy.square(Y)\n    X = mean + mu_2l * (Y - ivy.sqrt(((4 * scale) * Y) + ivy.square(Y)))\n\n    condition = U <= mean / (mean + X)\n    value1 = X\n    value2 = mean * mean / X\n\n    return ivy.where(condition, value1, value2)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef weibull(a, size=None):\n    if a < 0:\n        return 0\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    return ivy.pow(-ivy.log(1 - u), 1 / a)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef zipf(a, size=None):\n    if a <= 1:\n        return 0\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    return ivy.floor(ivy.pow(1 / (1 - u), 1 / a))\n", "path": "ivy/functional/frontends/numpy/random/functions.py"}], "after_files": [{"content": "# local\n\nimport ivy\nfrom ivy.functional.frontends.numpy.func_wrapper import (\n    to_ivy_arrays_and_back,\n    from_zero_dim_arrays_to_scalar,\n)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef beta(a, b, size=None):\n    return ivy.beta(a, b, shape=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef binomial(n, p, size=None):\n    if p < 0 or p > 1:\n        raise ValueError(\"p must be in the interval (0, 1)\")\n    if n < 0:\n        raise ValueError(\"n must be strictly positive\")\n    if size is None:\n        size = 1\n    else:\n        size = size\n    if isinstance(size, int):\n        size = (size,)\n    lambda_ = ivy.multiply(n, p)\n    return ivy.poisson(lambda_, shape=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef chisquare(df, size=None):\n    df = ivy.array(df)  # scalar ints and floats are also array_like\n    if ivy.any(df <= 0):\n        raise ValueError(\"df <= 0\")\n\n    # ivy.gamma() throws an error if both alpha is an array and a shape is passed\n    # so this part broadcasts df into the shape of `size`` first to keep it happy.\n    if size is not None:\n        df = df * ivy.ones(size)\n\n    return ivy.gamma(df / 2, 2, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef choice(a, size=None, replace=True, p=None):\n    sc_size = 1\n    if isinstance(size, int):\n        sc_size = size\n    elif size is not None:\n        #  If the given shape is, e.g., (m, n, k)\n        #  then m * n * k samples are drawn. As per numpy docs\n        sc_size = 1\n        for s in size:\n            if s is not None:\n                sc_size *= s\n    if isinstance(a, int):\n        a = ivy.arange(a)\n    index = ivy.multinomial(len(a), sc_size, replace=replace, probs=p)\n    return a[index]\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef dirichlet(alpha, size=None):\n    return ivy.dirichlet(alpha, size=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef f(dfn, dfd, size=None):\n    # Generate samples from the uniform distribution\n    x1 = ivy.gamma(ivy.to_scalar(ivy.divide(dfn, 2)), 2.0, shape=size, dtype=\"float64\")\n    x2 = ivy.gamma(ivy.to_scalar(ivy.divide(dfd, 2)), 2.0, shape=size, dtype=\"float64\")\n    # Calculate the F-distributed samples\n    samples = ivy.divide(ivy.divide(x1, ivy.array(dfn)), ivy.divide(x2, ivy.array(dfd)))\n    return samples\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef gamma(shape, scale=1.0, size=None):\n    return ivy.gamma(shape, scale, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef geometric(p, size=None):\n    if p < 0 or p > 1:\n        raise ValueError(\"p must be in the interval [0, 1]\")\n    oneMinusP = ivy.subtract(1, p)\n    sizeMinusOne = ivy.subtract(size, 1)\n\n    return ivy.multiply(ivy.pow(oneMinusP, sizeMinusOne), p)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef gumbel(loc=0.0, scale=1.0, size=None):\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    x = loc - scale * ivy.log(-ivy.log(u))\n    return x\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef laplace(loc=0.0, scale=1.0, size=None):\n    u = ivy.random_uniform(low=0.0, high=0.0, shape=size, dtype=\"float64\")\n    u = loc - scale * ivy.sign(u - 0.5) * ivy.log(1 - 2 * ivy.abs(u - 0.5))\n    return u\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef logistic(loc=0.0, scale=1.0, size=None):\n    u = ivy.random_uniform(low=0.0, high=0.0, shape=size, dtype=\"float64\")\n    x = loc + scale * ivy.log(u / (1 - u))\n    return x\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef lognormal(mean=0.0, sigma=1.0, size=None):\n    ret = ivy.exp(ivy.random_normal(mean=mean, std=sigma, shape=size, dtype=\"float64\"))\n    return ret\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef logseries(p=0, size=None):\n    if p < 0 or p >= 1:\n        raise ValueError(\"p value must be in the open interval (0, 1)\")\n    r = ivy.log(1 - p)\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size)\n    v = ivy.random_uniform(low=0.0, high=1.0, shape=size)\n    q = 1 - ivy.exp(r * u)\n    ret = 1 + ivy.log(v) / ivy.log(q)\n    return ret\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef multinomial(n, pvals, size=None):\n    assert not ivy.exists(size) or (len(size) > 0 and len(size) < 3)\n    batch_size = 1\n    if ivy.exists(size):\n        if len(size) == 2:\n            batch_size = size[0]\n            num_samples = size[1]\n        else:\n            num_samples = size[0]\n    else:\n        num_samples = len(pvals)\n    return ivy.multinomial(n, num_samples, batch_size=batch_size, probs=pvals)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef negative_binomial(n, p, size=None):\n    if p <= 0 or p >= 1:\n        raise ValueError(\"p must be in the interval (0, 1)\")\n    if n <= 0:\n        raise ValueError(\"n must be strictly positive\")\n    # numpy implementation uses scale = (1 - p) / p\n    scale = (1 - p) / p\n    # poisson requires shape to be a tuple\n    if isinstance(size, int):\n        size = (size,)\n    lambda_ = ivy.gamma(n, scale, shape=size)\n    return ivy.poisson(lam=lambda_, shape=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef normal(loc=0.0, scale=1.0, size=None):\n    return ivy.random_normal(mean=loc, std=scale, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef pareto(a, size=None):\n    if a < 0:\n        return 0\n    u = ivy.random_uniform(low=0.0, high=0.0, shape=size, dtype=\"float64\")\n    return ivy.pow(1 / (1 - u), 1 / a)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef permutation(x, /):\n    if isinstance(x, int):\n        x = ivy.arange(x)\n    return ivy.shuffle(x)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef poisson(lam=1.0, size=None):\n    return ivy.poisson(lam=lam, shape=size)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef random_sample(size=None):\n    return ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef rayleigh(scale, size=None):\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    log_u = ivy.log(u)\n    x = ivy.multiply(scale, ivy.sqrt(ivy.multiply(-2, log_u)))\n    return x\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef shuffle(x, axis=0, /):\n    if isinstance(x, int):\n        x = ivy.arange(x)\n    return ivy.shuffle(x, axis)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef standard_cauchy(size=None):\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    return ivy.tan(ivy.pi * (u - 0.5))\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef standard_gamma(shape, size=None):\n    return ivy.gamma(shape, 1.0, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef standard_normal(size=None):\n    return ivy.random_normal(mean=0.0, std=1.0, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef standard_t(df, size=None):\n    numerator = ivy.random_normal(mean=0.0, std=1.0, shape=size, dtype=\"float64\")\n    denominator = ivy.gamma(df / 2, 1.0, shape=size, dtype=\"float64\")\n    return ivy.sqrt(df / 2) * ivy.divide(numerator, ivy.sqrt(denominator))\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef triangular(left, mode, right, size=None):\n    if left > mode or mode > right or left == right:\n        raise ivy.utils.exceptions.IvyValueError(\n            \"left < mode < right is not being followed\"\n        )\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    condition = u <= (mode - left) / (right - left)\n    values1 = left + (right - left) * (u * (mode - left) / (right - left)) ** 0.5\n    values2 = (\n        right - (right - mode) * ((1 - u) * (right - mode) / (right - left)) ** 0.5\n    )\n    return ivy.where(condition, values1, values2)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef uniform(low=0.0, high=1.0, size=None):\n    return ivy.random_uniform(low=low, high=high, shape=size, dtype=\"float64\")\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef vonmises(mu, kappa, size=None):\n    t_size = 0\n    # Output shape. If the given shape is, e.g., (m, n, k),\n    # then m * n * k samples are drawn.\n    if size is None or len(size) == 0:\n        t_size = 1\n    else:\n        for x in size:\n            t_size = t_size * x\n    size = t_size\n    li = []\n    while len(li) < size:\n        # Generate samples from the von Mises distribution using numpy\n        u = ivy.random_uniform(low=-ivy.pi, high=ivy.pi, shape=size)\n        v = ivy.random_uniform(low=0, high=1, shape=size)\n\n        condition = v < (1 + ivy.exp(kappa * ivy.cos(u - mu))) / (\n            2 * ivy.pi * ivy.i0(kappa)\n        )\n        selected_samples = u[condition]\n        li.extend(ivy.to_list(selected_samples))\n\n    return ivy.array(li[:size])\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef wald(mean, scale, size=None):\n    if size is None:\n        size = 1\n    mu_2l = mean / (2 * scale)\n    Y = ivy.random_normal(mean=0, std=1, shape=size, dtype=\"float64\")\n    U = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n\n    Y = mean * ivy.square(Y)\n    X = mean + mu_2l * (Y - ivy.sqrt(((4 * scale) * Y) + ivy.square(Y)))\n\n    condition = U <= mean / (mean + X)\n    value1 = X\n    value2 = mean * mean / X\n\n    return ivy.where(condition, value1, value2)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef weibull(a, size=None):\n    if a < 0:\n        return 0\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    return ivy.pow(-ivy.log(1 - u), 1 / a)\n\n\n@to_ivy_arrays_and_back\n@from_zero_dim_arrays_to_scalar\ndef zipf(a, size=None):\n    if a <= 1:\n        return 0\n    u = ivy.random_uniform(low=0.0, high=1.0, shape=size, dtype=\"float64\")\n    return ivy.floor(ivy.pow(1 / (1 - u), 1 / a))\n", "path": "ivy/functional/frontends/numpy/random/functions.py"}]}