Hi Wolfgang,<div><br></div><div>I thought maybe there is a trick for your specific operation. </div><div>Your array stacking is a simple case of the group-by operation and normalization is aggregation followed by update. </div>
<div>I believe group-by and aggregation are on the NumPy todo-list. </div><div>You may have to write a small extension module to speed up your operations. <br>Val</div><div><br><div class="gmail_quote">On Thu, May 31, 2012 at 8:27 AM, Wolfgang Kerzendorf <span dir="ltr"><<a href="mailto:wkerzendorf@gmail.com" target="_blank">wkerzendorf@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hey Val,<div><br></div><div>Well it doesn't matter what I do, but specifically I do factor = sum(data_array[start_point:start_point+length_data]) and then</div>
<div>data[array[start_point:start_point+length_data]) /= factor. and that for every star_point and length data.</div><div><br></div><div>How to do this fast?</div><div><br></div><div>Cheers</div><span class="HOEnZb"><font color="#888888"><div>
   Wolfgang</div></font></span><div><div class="h5"><div><div><div>On 2012-05-31, at 1:43 AM, Val Kalatsky wrote:</div><br><blockquote type="cite">What do you mean by "normalized it"?<div>Could you give the output of your procedure for the sample input data.</div>
<div>Val<br><br><div class="gmail_quote">On Thu, May 31, 2012 at 12:36 AM, Wolfgang Kerzendorf <span dir="ltr"><<a href="mailto:wkerzendorf@gmail.com" target="_blank">wkerzendorf@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<br>
<br>
I have an ndarray which consists of many arrays stacked behind each other (only conceptually, in truth it's a normal 1d float64 array).<br>
I have a second array which tells me the start of the individual data sets in the 1d float64 array and another one which tells me the length.<br>
Example:<br>
<br>
data_array = (conceptually) [[1,2], [1,2,3,4], [1,2,3]] = in reality [1,2,1,2,3,4,1,2,3, dtype=float64]<br>
start_pointer = [0, 2, 6]<br>
length_data = [2, 4, 3]<br>
<br>
I now want to normalize each of the individual data sets. I wrote a simple for loop over the start_pointer and length data grabbed the data and normalized it and wrote it back to the big array. That's slow. Is there an elegant numpy way to do that? Do I have to go the cython way?<br>


<br>
Cheers<br>
   Wolfgang<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br></div>
_______________________________________________<br>NumPy-Discussion mailing list<br><a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br><a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br></div></div></div></div><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>