<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Ah, thanks Robert, that solved it. It was actually my second
suggestion how to solve it, but I missed the prepend-bit. Maybe
that could be added to the documentation. I appended it :)<br>
</p>
<p>Best,</p>
<p>Robert<br>
</p>
<br>
<div class="moz-cite-prefix">On 06/07/2018 07:44 AM, Robert Kern
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAF6FJit5TZ7UH77JzsePzOaGz1ym5zsfuWAiGJEQ3E+9tD9iUQ@mail.gmail.com">
<div dir="ltr">On Wed, Jun 6, 2018 at 10:26 PM Robert Rehammar
<<a href="mailto:robert.open@rehammar.se"
moz-do-not-send="true">robert.open@rehammar.se</a>> wrote:<br>
><br>
> Dear num-py developers,<br>
><br>
> For the methods in numpy.random, the distributions
typically have the<br>
> signature (a, b, ...[, size]). a, b, ... are parameters to
the<br>
> distributions and size is optional that can be used to
control how may<br>
> samples to draw and the shape of the returned structure.
The parameters<br>
> can also be array_like to draw from different
(parametrized) distributions.<br>
>
<div>> <span
style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">However,
it is not what I can see, possible to have the parameters<span> </span></span><br
style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">
<span
style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">>
array_like and at the same time use size!=None.</span></div>
<div><br>
Sure, you can! Let `shape` be `a.shape` (or the broadcasted
shape of all of those parameters. *Prepend* your desired
number (or shape) of draws to this `shape` to get the `size`
that you need to specify. So if I have two different `scale`
parameters for a normal distribution, and I want 12 draws from
each in a (3,4) shape (for whatever forsaken reason):
<div><br>
</div>
<div>
<div>[~]</div>
<div>|4> np.random.normal(0.0, [1.0, 2.0], size=(3, 4,
2))</div>
<div>array([[[ 1.72551057, 2.33545059],</div>
<div> [-1.45966289, 4.81820745],</div>
<div> [-0.13912257, 1.79127867],</div>
<div> [ 0.27693464, 1.45313416]],</div>
<div><br>
</div>
<div> [[ 1.41031607, 3.18113465],</div>
<div> [ 1.64033152, 1.47355763],</div>
<div> [ 1.18554024, -1.11605743],</div>
<div> [ 0.73556545, 2.44352574]],</div>
<div><br>
</div>
<div> [[-0.42889339, 3.88389374],</div>
<div> [-0.24146162, 0.54163374],</div>
<div> [ 0.53821574, 0.07862412],</div>
<div> [ 0.7418073 , -2.35439217]]])</div>
<div><br>
</div>
It's *not* a particularly intuitive API, obviously, but it
should let you do everything that you want to do.<br>
<br>
--<br>
Robert Kern</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SciPy-Dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:SciPy-Dev@python.org">SciPy-Dev@python.org</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/scipy-dev">https://mail.python.org/mailman/listinfo/scipy-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>