[Numpy-discussion] another indexing question
Bago
mrbago at gmail.com
Mon May 20 22:45:06 EDT 2013
You could also try using bincount, (np.bincount(x, y.real) +
1j*np.bincount(x, y.imag)) / np.bincount(x)
Bago
On Mon, May 20, 2013 at 9:03 AM, Robert Kern <robert.kern at gmail.com> wrote:
> On Mon, May 20, 2013 at 5:00 PM, Neal Becker <ndbecker2 at gmail.com> wrote:
> > I have a system that transmits signals for an alphabet of M symbols
> > over and additive Gaussian noise channel. The receiver has a
> > 1-d array of complex received values. I'd like to find the means
> > of the received values according to the symbol that was transmitted.
> >
> > So transmit symbol indexes might be:
> >
> > x = [0, 1, 2, 1, 3, ...]
> >
> > and receive output might be:
> >
> > y = [(1+1j), (1-1j), ...]
> >
> > Suppose the alphabet was M=4. Then I'd like to get an array of means
> >
> > m[0...3] that correspond to the values of y for each of the corresponding
> > values of x.
> >
> > I can't think of a better way than manually using loops. Any tricks
> here?
>
> All you need is a single loop over the alphabet, which is usually not
> problematic.
>
>
> means = np.empty([M])
> for i in range(M):
> means[i] = y[x == i].mean()
>
> --
> Robert Kern
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130520/8e5b1b9e/attachment.html>
More information about the NumPy-Discussion
mailing list