HISTOGRAM and string data [message #53810] |
Wed, 02 May 2007 17:55 |
MarioIncandenza
Messages: 231 Registered: February 2005
|
Senior Member |
|
|
Hello IDL Wizards,
I did a search on the group for this, and found a post whose _subject_
was my problem exactly, but the poster actually wanted something
completely different (and was instantly satisfied).
I have an application where I have an array of STRING_DATA, and I need
to calculate stats of FLOAT_DATA based on the value of STRING_DATA. If
HISTOGRAM worked on strings, this would be as simple as:
hstr=histogram(STRING_DATA,reverse_indices=ristr)
answer=hstr * 0.0
for i=0l,n_elements(hstr) do if(hstr[i] gt 0) then answer[i] =
f(FLOAT_DATA[ristr[ristr[i]:(ristr[i+1]-1)]])
I thought UNIQ might help me, but it depends on doing a SORT, and
sorting DATA is something I'd like to avoid if possible.
One approach is to convert the STRING_DATA into some form of number,
like longword integers. Any suggestions on how to do that without
creating a very sparse field (if the resulting histogram has 1e8
elements, that isn't necessarily going to work)?
Oh, and feel free to bring on the slow solutions, this is not a time-
dependent problem ;)
--Edward H.
|
|
|