[SciPy-User] [SciPy-user] Avoiding inner for loops??

eat e.antero.tammi at gmail.com
Wed Aug 22 05:04:09 EDT 2012


Hi,

On Wed, Aug 22, 2012 at 3:52 AM, mdekauwe <mdekauwe at gmail.com> wrote:

>
> Actually one more thing I can't figure out, is I want to use the smallest
> difference, ie. from ss2 to get the relevant paramater values.
>
> e.g.
>
> ss2= ((obs[:, n_, n_, n_]- ans).sum(0)** 2).reshape(grid_size** 3)
> index = np.argmin(ss2, 0)
>
> but this index will be from the full grid (shape=8000) and not give me
> something I can pull the values from the param1, param2, param3 arrays
> (shape=20)?
>
Perhaps
In []: ss= ((obs[:, n_, n_, n_]- ans).sum(0)** 2)
In []: ndx= where(ss.min()== ss)
In []: ndx
Out[]: (array([0]), array([0]), array([0]))
In []: ss[ndx]
Out[]: array([ 2500.])

Regards,
-eat

>
> thanks again.
> --
> View this message in context:
> http://old.nabble.com/Avoiding-inner-for-loops---tp34319763p34332296.html
> Sent from the Scipy-User mailing list archive at Nabble.com.
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120822/5acbca2c/attachment.html>


More information about the SciPy-User mailing list