Message Boards Message Boards

0
|
3450 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

[?] Create a loop to compute the minimum?

Posted 7 years ago

I have a long data (795,000 rows). For every 5000 rows I need the minimum and the position of this minimum. Then I will get 159 minima with their positions. I tried to create a loop to calculate these minima, but I didn't find a correct way. If my data is dd What should I do to correct this

mini[i_] := Min[dd[[i ;; i + 5000]]]
pos[i_] := Position[dd, mini[[i]]]

minima = {}
For[i = 1, i <= Length[dd], i + 5000,
 AppendTo[minima, {mini[[i]], pos[[i]]}]]

Thanks in advance.

POSTED BY: Ghady Almufleh
3 Replies
Posted 7 years ago

.

dd = {Insert Your 795000 Numbers Here};
part = -1;
Map[(part++; pos=Ordering[#,1]; Flatten[{#[[pos]], part*5000+pos}])&, Partition[dd,5000]]
POSTED BY: Bill Simpson
Posted 7 years ago

Thank you for your help! I tried to use your command, but my data has specific numbers. It is the result of another code that computes the differential cross sections, so do you think I can use RandomReal.? I should get stable values of the minima.

POSTED BY: Ghady Almufleh
Posted 7 years ago

I really appreciate it. I got what I need.Thanks a lot!

POSTED BY: Ghady Almufleh
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract