Average Columns By Header Name - linux

I have files with columns like this. This sample input below is partial.
Please check below for main file link. Each file will have only two rows.
Gene 0.4% 0.7% 1.1% 1.4% 1.8% 2.2% 2.5% 2.9% 3.3% 3.6% 4.0% 4.3% 4.7% 5.1% 5.4% 5.8% 6.2% 6.5% 6.9% 7.2% 7.6% 8.0% 8.3% 8.7% 9.1% 9.4% 9.8% 10.1% 10.5% 10.9% 11.2% 11.6% 12.0% 12.3% 12.7% 13.0% 13.4% 13.8% 14.1% 14.5% 14.9% 15.2% 15.6% 15.9% 16.3% 16.7% 17.0% 17.4% 17.8% 18.1% 18.5% 18.8% 19.2% 19.6% 19.9% 20.3% 20.7% 21.0% 21.4% 21.7% 22.1% 22.5% 22.8% 23.2% 23.6% 23.9% 24.3% 24.6% 25.0% 25.4% 25.7% 26.1% 26.4% 26.8% 27.2% 27.5% 27.9% 28.3% 28.6% 29.0% 29.3% 29.7% 30.1% 30.4% 30.8% 31.2% 31.5% 31.9% 32.2% 32.6% 33.0% 33.3% 33.7% 34.1% 34.4% 34.8% 35.1% 35.5% 35.9% 36.2% 36.6% 37.0% 37.3% 37.7% 38.0% 38.4% 38.8% 39.1% 39.5% 39.9% 40.2% 40.6% 40.9% 41.3% 41.7% 42.0% 42.4% 42.8% 43.1% 43.5% 43.8% 44.2% 44.6% 44.9% 45.3% 45.7% 46.0% 46.4% 46.7% 47.1% 47.5% 47.8% 48.2% 48.6% 48.9% 49.3% 49.6% 50.0% 50.4% 50.7% 51.1% 51.4% 51.8% 52.2% 52.5% 52.9% 53.3% 53.6% 54.0% 54.3% 54.7% 55.1% 55.4% 55.8% 56.2% 56.5% 56.9% 57.2% 57.6% 58.0% 58.3% 58.7% 59.1% 59.4% 59.8% 60.1% 60.5% 60.9% 61.2% 61.6% 62.0% 62.3% 62.7% 63.0% 63.4% 63.8% 64.1% 64.5% 64.9% 65.2% 65.6% 65.9% 66.3% 66.7% 67.0% 67.4% 67.8% 68.1% 68.5% 68.8% 69.2% 69.6% 69.9% 70.3% 70.7% 71.0% 71.4% 71.7% 72.1% 72.5% 72.8% 73.2% 73.6% 73.9% 74.3% 74.6% 75.0% 75.4% 75.7% 76.1% 76.4% 76.8% 77.2% 77.5% 77.9% 78.3% 78.6% 79.0% 79.3% 79.7% 80.1% 80.4% 80.8% 81.2% 81.5% 81.9% 82.2% 82.6% 83.0% 83.3% 83.7% 84.1% 84.4% 84.8% 85.1% 85.5% 85.9% 86.2% 86.6% 87.0% 87.3% 87.7% 88.0% 88.4% 88.8% 89.1% 89.5% 89.9% 90.2% 90.6% 90.9% 91.3% 91.7% 92.0% 92.4% 92.8% 93.1% 93.5% 93.8% 94.2% 94.6% 94.9% 95.3% 95.7% 96.0% 96.4% 96.7% 97.1% 97.5% 97.8% 98.2% 98.6% 98.9% 99.3% 99.6% 100.0% 0.4% 0.7% 1.1% 1.4% 1.8% 2.2% 2.5% 2.9% 3.3% 3.6% 4.0% 4.3% 4.7% 5.1% 5.4% 5.8% 6.2% 6.5% 6.9% 7.2% 7.6% 8.0% 8.3% 8.7% 9.1% 9.4% 9.8% 10.1% 10.5% 10.9% 11.2% 11.6% 12.0% 12.3% 12.7% 13.0% 13.4% 13.8% 14.1% 14.5% 14.9% 15.2% 15.6% 15.9% 16.3% 16.7% 17.0% 17.4% 17.8% 18.1% 18.5% 18.8% 19.2% 19.6% 19.9% 20.3% 20.7% 21.0% 21.4% 21.7% 22.1% 22.5% 22.8% 23.2% 23.6% 23.9% 24.3% 24.6% 25.0% 25.4% 25.7% 26.1% 26.4% 26.8% 27.2% 27.5% 27.9% 28.3% 28.6% 29.0% 29.3% 29.7% 30.1% 30.4% 30.8% 31.2% 31.5% 31.9% 32.2% 32.6% 33.0% 33.3% 33.7% 34.1% 34.4% 34.8% 35.1% 35.5% 35.9% 36.2% 36.6% 37.0% 37.3% 37.7% 38.0% 38.4% 38.8% 39.1% 39.5% 39.9% 40.2% 40.6% 40.9% 41.3% 41.7% 42.0% 42.4% 42.8% 43.1% 43.5% 43.8% 44.2% 44.6% 44.9% 45.3% 45.7% 46.0% 46.4% 46.7% 47.1% 47.5% 47.8% 48.2% 48.6% 48.9% 49.3% 49.6% 50.0% 50.4% 50.7% 51.1% 51.4% 51.8% 52.2% 52.5% 52.9% 53.3% 53.6% 54.0% 54.3% 54.7% 55.1% 55.4% 55.8% 56.2% 56.5% 56.9% 57.2% 57.6% 58.0% 58.3% 58.7% 59.1% 59.4% 59.8% 60.1% 60.5% 60.9% 61.2% 61.6% 62.0% 62.3% 62.7% 63.0% 63.4% 63.8% 64.1% 64.5% 64.9% 65.2% 65.6% 65.9% 66.3% 66.7% 67.0% 67.4% 67.8% 68.1% 68.5% 68.8% 69.2% 69.6% 69.9% 70.3% 70.7% 71.0% 71.4% 71.7% 72.1% 72.5% 72.8% 73.2% 73.6% 73.9% 74.3% 74.6% 75.0% 75.4% 75.7% 76.1% 76.4% 76.8% 77.2% 77.5% 77.9% 78.3% 78.6% 79.0% 79.3% 79.7% 80.1% 80.4% 80.8% 81.2% 81.5% 81.9% 82.2% 82.6% 83.0% 83.3% 83.7% 84.1% 84.4% 84.8% 85.1% 85.5% 85.9% 86.2% 86.6% 87.0% 87.3% 87.7% 88.0% 88.4% 88.8% 89.1% 89.5% 89.9% 90.2% 90.6% 90.9% 91.3% 91.7% 92.0% 92.4% 92.8% 93.1% 93.5% 93.8% 94.2% 94.6% 94.9% 95.3% 95.7% 96.0% 96.4% 96.7% 97.1% 97.5% 97.8% 98.2% 98.6% 98.9% 99.3% 99.6% 100.0%
Basically, here is what I need to be done.
a. Start from second column which is 0.4% here.
b. Go until you hit "10" in the header name. If the header name is exactly 10.0%, then include that column too. If not, only include until the column before it. In this example, since we have 10.1% (29th column), we will be including columns starting from 0.4%(second) until 9.8% which is the 28th column. If the 29th column was to be 10.0%, then it would have been included too.
c. Average the values for these respective columns in the second row (data is not presented here - please click this link for total dataset - https://goo.gl/W8jND7). In this example, starting from 0.4%(second column) till 9.8%(28th column).
d. In the output, print first column which is "Gene", and this average value with column header being
Gene Average_10%
e. Then start from 10.1% (29th column) and check until you hit "20" in the header name. Repeat steps b through d. And print output as
Gene Average_10% Average_20%
Repeat this until you have
Gene Average_10% Average_20% Average_30% Average_40% Average_50% Average_60% Average_70% Average_80% Average_90% Average_100%
f. After you hit 100%, it means one dataset is done.
g. If you observe my column header carefully here, there is another 0.4%-100% columns after the first 100%. I will be having 13 of these 0.4%-100%s in the input file at the above link.
i. I have multiple files, the headers can be
1% 2% 3%....100%
1.5% 2.5% 3.5%....100%
It varies from file to file. But the logic of averaging(if you hit "10", "20", etc) is always the same. And the number of samples 13 is also same which means each file will have 100%s for 13 times.

I should say, it's a horrible format for this task. I don't expect anyone to come up with a final solution for you but this is how I would approach this
awk 'NR == 1 {
gsub("%","");
for (f=2; f<=NF; f++) {
for (i=1; i<10; i++)
if ($f<10*i && $(f+1)>=10*i) print f, $f
if ($f==100) print f, $f
}}' file
28 9.8
56 19.9
83 29.7
111 39.9
138 49.6
166 59.8
194 69.9
221 79.7
249 89.9
277 100.0
304 9.8
332 19.9
359 29.7
387 39.9
414 49.6
442 59.8
470 69.9
497 79.7
525 89.9
553 100.0
here printing the column index and the threshold used for verification purposes. Once you have the column boundaries extracted it should be straightforward to sum the respective columns. Note that by your logic 100% should be never included, however it seems wrong so I have special case for it.

Related

miniconda/pkgs taking up a lot of space

I have run out of disk space on my cluster machine. Doing
du -h --max-depth=20 | sort -hr > size_of_folders.txt
reveals that there is a directory called ./miniconda3/pkgs that is taking up 22Gbs.
Looking in this folder at the subfolders, I don't know what most of these . For example here are the top 50 entries:
804M ./qt-main-5.15.4-ha5833f6_2
769M ./qt-5.12.9-h1304e3e_6
629M ./qt-5.9.7-h5867ecd_1
629M ./cache
619M ./qt-5.9.7-h0c104cb_3
482M ./mkl-2020.2-256
481M ./mkl-2020.2-256/lib
360M ./qt-main-5.15.4-ha5833f6_2/include
359M ./qt-main-5.15.4-ha5833f6_2/include/qt
343M ./qt-5.12.9-h1304e3e_6/include/qt
343M ./qt-5.12.9-h1304e3e_6/include
321M ./qt-5.9.7-h5867ecd_1/include
321M ./qt-5.9.7-h0c104cb_3/include
320M ./qt-5.9.7-h5867ecd_1/include/qt
320M ./qt-5.9.7-h0c104cb_3/include/qt
307M ./libdb-6.2.32-h9c3ff4c_0
299M ./libdb-6.2.32-h9c3ff4c_0/docs
244M ./scipy-1.7.3-py310hea5193d_0
243M ./scipy-1.7.3-py310hea5193d_0/lib/python3.10
243M ./scipy-1.7.3-py310hea5193d_0/lib
242M ./scipy-1.7.3-py310hea5193d_0/lib/python3.10/site-packages/scipy
242M ./scipy-1.7.3-py310hea5193d_0/lib/python3.10/site-packages
221M ./pandas-1.3.4-py310hb5077e9_1
220M ./pandas-1.3.4-py310hb5077e9_1/lib/python3.10/site-packages
220M ./pandas-1.3.4-py310hb5077e9_1/lib/python3.10
220M ./pandas-1.3.4-py310hb5077e9_1/lib
219M ./python-3.8.3-cpython_he5300dc_0
219M ./pandas-1.3.4-py310hb5077e9_1/lib/python3.10/site-packages/pandas
199M ./python-3.8.3-cpython_he5300dc_0/lib
196M ./python-3.8.3-hcff3b4d_0
175M ./python-3.8.3-hcff3b4d_0/lib
172M ./pandas-1.4.1-py310hb5077e9_0
171M ./pandas-1.4.1-py310hb5077e9_0/lib/python3.10/site-packages
171M ./pandas-1.4.1-py310hb5077e9_0/lib/python3.10
171M ./pandas-1.4.1-py310hb5077e9_0/lib
170M ./pandas-1.4.3-py310h769672d_0
170M ./pandas-1.4.2-py310h769672d_2
170M ./pandas-1.4.1-py310hb5077e9_0/lib/python3.10/site-packages/pandas
169M ./pandas-1.4.3-py310h769672d_0/lib/python3.10/site-packages
169M ./pandas-1.4.3-py310h769672d_0/lib/python3.10
169M ./pandas-1.4.3-py310h769672d_0/lib
169M ./pandas-1.4.2-py310h769672d_2/lib/python3.10/site-packages
169M ./pandas-1.4.2-py310h769672d_2/lib/python3.10
169M ./pandas-1.4.2-py310h769672d_2/lib
168M ./perl-5.32.1-1_h7f98852_perl5
168M ./pandas-1.4.3-py310h769672d_0/lib/python3.10/site-packages/pandas
168M ./pandas-1.4.2-py310h769672d_2/lib/python3.10/site-packages/pandas
166M ./statsmodels-0.13.1-py310h96516ba_0
165M ./statsmodels-0.13.1-py310h96516ba_0/lib/python3.10/site-packages 165M ./statsmodels-0.13.1-py310h96516ba_0/lib/python3.10`
Can someone explain if these are deletable? These recognisable packages - such as pandas and scipy - have strange suffixes and I'm not sure if they're deletable.
I presume I can delete the cache but I'm not sure about the rest.

excel vba moving the offset to start of the range if exist (functional way of writing)

Goal is to identify the start of the region value and it will be used in offset.
Input will be dynamic
Row length is not fixed.
Only criteria is region begin and end, but it may exist or not (see the sample input below)
Criteria
Values
Sample Input
1 to 10
Region begin
4
Region end
7
I have written the following code in procedural way, is there a better functional way of writing the following code for better management and readability?
Sub findBorder()
Dim myrange As Range
Dim rCell As Range
' (1 2 3 4 5 6 7 8 9 10)
Set myrange = Range("D1:D10")
Dim mark_region_begin As Integer
Dim mark_region_end As Integer
Dim mark_region_after_begin As Integer
Dim mark_region_before_end As Integer
Range("F1").Value = ""
Range("F2").Value = ""
Range("F3").Value = ""
' Find in bewteen and including 4 & 7
For Each rCell In myrange:
If rCell.Value = 4 Then
mark_region_begin = rCell.Row
ElseIf rCell.Value > 4 And rCell.Value < 7 Then
If mark_region_after_begin = 0 Then
mark_region_after_begin = rCell.Row
End If
mark_region_end = rCell.Row
ElseIf rCell.Value = 7 Then
If mark_region_begin = 0 Then
mark_region_begin = rCell.Row
End If
mark_region_end = rCell.Row
End If
Next rCell
If mark_region_begin = 0 Then
mark_region_begin = mark_region_after_begin
End If
Range("F1").Value = mark_region_begin
Range("F2").Value = mark_region_after_begin
Range("F3").Value = mark_region_end
End Sub
Sample input:
In the following sample input, The column E is sorted, and the data in the range between -0.15 to +0.15 will be selected.
A
B
C
D
E
4190.65
4227.6
4332.717
19.79
-7.05
721.05
734.65
741.9
12.25
-6.80
4273.05
4303.5
4420.3
14.89
-6.60
1132.25
1150.3
1180.75
2.56
-6.54
1134.55
1140.6
1168.317
22.12
-6.47
4015.5
4030.4
4135.3
13.94
-6.34
597
608.6
617.8
4.19
-5.82
1355
1360.95
1385.317
2.95
-5.60
2104.1
2116.55
2158.483
6.93
-5.49
808.9
816.45
830.8167
1.54
-5.39
367.2
370
377.0667
7.87
-5.29
347.75
349.65
357.2167
3.28
-5.18
7045.1
7178.65
7178.633
11.76
-5.03
515.9
521.95
529.3
4.05
-4.91
2002.4
2026.3
2071.267
4.24
-4.88
100.5
101.2
102.7
2.36
-4.78
116.95
117.7
119.4833
17.83
-4.75
460.85
463.1
468.8
2.21
-4.69
2326.1
2343.6
2379.25
8.58
-4.49
193.8
196.25
198.85
0.71
-4.49
2277.7
2290.4
2327.683
6.18
-4.39
711.25
714.5
726.75
3.32
-4.34
14285.7
14354.5
14580.02
5.18
-4.33
6310.1
6365.15
6456.383
4.51
-4.31
119.2
120.65
122.6167
12.48
-4.31
80.8
81.3
82.96667
1.11
-4.29
1537.25
1549.45
1585.133
6.86
-4.23
778.05
785.75
797.9333
7.22
-4.18
459.85
461.55
468.8
-0.05
-4.15
2406.15
2413.75
2457.283
2.79
-4.15
243
244.7
249.05
0.55
-4.14
742.6
751.3
759.9167
7.98
-4.13
310.75
312.85
317.8167
0.81
-4.13
108.05
108.7
110.8167
5.24
-4.10
912.7
922
932.5667
3.01
-4.06
626.1
629.55
637.3666
8.14
-3.89
3767.4
3800.95
3871.116
11.39
-3.88
4333.15
4348.5
4406.033
6.91
-3.88
1444.55
1449.9
1469.15
4.14
-3.83
2303.15
2324.6
2347.9
8.44
-3.77
1036.05
1043.35
1058.967
1.72
-3.77
685.9
688.6
696.3499
1.75
-3.74
2242.95
2263.4
2292.116
1.84
-3.73
1492.35
1500.3
1527.467
10.11
-3.68
2436.5
2488.7
2506.85
6.64
-3.64
1795.85
1804.5
1821.783
2.37
-3.62
972.2
978.9
994.8667
2.7
-3.61
2686
2696.85
2728.3
4.57
-3.59
1620.15
1627.35
1649.75
2.06
-3.55
145.5
146.45
150.0667
2.77
-3.46
419.45
421.6
427.1
4.48
-3.31
196
203.8
204.1333
3.73
-3.29
266.5
268.25
271.6167
0.79
-3.28
3978.4
4003.5
4041.25
3.48
-3.27
338.5
339.55
343.5
1.63
-3.26
1899.3
1909.65
1934.583
0.23
-3.21
534.15
539.1
547.9167
1.77
-3.20
221.25
223.1
227.0167
1.07
-3.10
3371
3412.65
3443.45
2.25
-3.09
3083.1
3102.8
3128.1
5.42
-3.07
25129.5
25237.55
25722.35
3.99
-3.06
2687
2703.05
2728.333
2.2
-3.04
113
114.1
115.4833
0.59
-3.03
3484.1
3498.85
3548.533
1.29
-3.00
694.55
698.25
706.7333
3.17
-2.99
1962.45
1978.05
2000.167
4.74
-2.99
1339.55
1346.7
1359.667
3.89
-2.98
229.2
231.8
234.0333
1.22
-2.95
624.2
626.9
634.05
3.33
-2.93
7372.05
7416.9
7516.267
0.64
-2.92
367.7
369.35
373.6167
1.98
-2.88
109.45
109.95
111.1833
1.79
-2.87
1252.2
1258.3
1267.833
8.8
-2.81
392.65
395.65
399.9333
4.08
-2.79
323.75
326.95
330.4167
1.12
-2.77
8446.35
8582.25
8631.017
1.04
-2.76
706.25
709.95
718.1667
1.1
-2.76
1320.6
1331.85
1349.333
13.81
-2.76
476.6
479.3
484.4667
4.82
-2.75
761.3
767.35
779.0334
3.47
-2.75
2152.05
2173.95
2193.667
0.9
-2.75
716.3
718.95
727.75
0.29
-2.72
110.8
111.4
112.9333
2.11
-2.71
2405.95
2417.15
2451.2
2.72
-2.67
69892.8
70396.05
71025.88
3.6
-2.63
16210
16280.9
16376.4
13.1
-2.59
6507.75
6526.7
6585.333
3.54
-2.56
2197
2210.75
2229.35
5.88
-2.55
718.25
722.6
727.2333
1.12
-2.54
258.15
259.85
263.1833
2.28
-2.54
710.3
713.65
719.9333
3.07
-2.52
16600
16722.15
16797.17
-0.74
-2.51
366.1
369.55
373.1
5.47
-2.47
825
827.85
837.8167
-0.17
-2.47
113.95
114.3
115.45
3.82
-2.43
517.75
521.65
526.95
-0.04
-2.42
93.95
94.95
95.9
3.31
-2.42
35145.95
35308.15
35598.03
14.74
-2.38
123.2
123.7
125.0167
2.39
-2.37
894
899.85
906.1833
5.82
-2.36
3194.8
3203
3231.267
4.6
-2.35
156.4
157.05
158.6333
-0.87
-2.33
14110
14168.85
14268.67
6.25
-2.33
1631.9
1640.3
1653.017
3.86
-2.32
304
305.85
308.5333
-1.25
-2.32
896.2
901.6
907.6667
7.99
-2.31
2742
2791.2
2808.5
3.55
-2.30
433.75
438.5
443.45
-0.87
-2.24
572.85
578.9
583.2167
0.93
-2.21
2466.35
2493.85
2511.3
6.7
-2.20
2199.85
2204.25
2223.95
2.93
-2.20
2008.9
2022.05
2035.367
2.78
-2.19
442.2
448
451.7333
-1.46
-2.19
199.4
200.05
202.0333
4.69
-2.18
129.75
130.6
131.8667
4.3
-2.17
2666.05
2691.8
2711.833
3.22
-2.16
950.45
958.45
964.05
3.02
-2.15
16643.2
16702.5
16827.82
25.56
-2.15
254.85
257.85
260.7
-1.22
-2.15
724
727.05
733.55
2.57
-2.14
982
986
997.45
9.45
-2.12
750.2
757.7
764.95
0.06
-2.11
421.25
424.05
428.95
1.21
-2.11
3815.25
3842.65
3881.384
-1.83
-2.07
603.1
609.25
611.9667
0.52
-2.05
255.2
258.35
260.4667
2.8
-2.03
540.6
543.45
548.0167
2.05
-2.03
802.5
805.9
812.9333
4.24
-2.02
2420
2435.65
2454.883
4.32
-1.99
18000
18106.2
18219.4
4.03
-1.98
276.45
279
281.5334
2.91
-1.94
2007.65
2018.05
2031.683
3.32
-1.93
507.25
512.55
515.4167
2.74
-1.90
723
727.75
734.4
1.88
-1.88
1040.45
1049.45
1056.6
3.19
-1.85
566.2
569.4
572.4666
2.48
-1.84
2275
2300.25
2313.417
-0.77
-1.82
54.8
55.25
55.93333
0.2
-1.77
366
367.75
370.5333
1.82
-1.74
39067.45
39122.3
39462.92
5.62
-1.73
1776.35
1781.6
1793.317
3.87
-1.69
1205.25
1217.45
1224.033
3.62
-1.67
1248.4
1254.4
1265.267
0.87
-1.67
1595.25
1598.65
1611.25
4.68
-1.60
131.6
132.2
133.5333
-0.9
-1.56
1559.9
1566.7
1576.75
-2.17
-1.56
1258.8
1265.05
1282.95
7.18
-1.47
1010.6
1015
1022.533
0.25
-1.38
3471.25
3483.45
3507.783
3.35
-1.29
198.6
200.2
201.8667
5.44
-1.28
1620.7
1629.5
1640.817
2.78
-1.26
4034.2
4053.5
4088.75
-1.13
-1.25
178.05
179.95
182.95
12.54
-1.21
258.2
259.3
260.9
8.69
-1.18
834.4
838.8
842.7334
-2.55
-1.10
360.55
363.8
365.4666
0.93
-1.09
529.5
530.9
535.1334
4.22
-1.05
4102.2
4125.15
4159.05
0.64
-1.02
243.75
245.9
248.15
0.9
-0.90
93.9
94.55
95.56667
0.47
-0.84
668.5
674.3
680.2
-0.89
-0.81
2086.2
2099.35
2110.583
8.33
-0.81
338.85
343.95
344.25
2.12
-0.75
818
825.95
831.2834
3.78
-0.73
490.75
493.8
496.7
0.7
-0.71
898.2
911
912.0334
1.71
-0.68
823.1
829.9
834.7834
4.77
-0.62
45142.85
45377.95
45544.61
5.69
-0.61
1270.9
1279.05
1281.983
0.57
-0.53
516.25
519.8
524.5667
1.34
-0.52
3914.1
3943.4
3963.833
3.67
-0.52
125.6
126.4
127.0667
0.27
-0.51
764.15
768.5
771.2166
1.87
-0.47
3451.15
3480.1
3497.316
0.55
-0.30
1067.5
1080.7
1081.767
1.77
-0.28
638.2
642.85
644.65
1.74
-0.26
1536.45
1542.05
1550.75
2.02
-0.13
401
406.15
407.6167
2.21
-0.09
2267.2
2296.15
2313.85
5.95
-0.03
270.7
272.3
273.4833
0.48
-0.02
156.5
158.1
158.4167
0.87
0.00
186.9
187.9
188.65
0.89
0.03
1572.2
1585.25
1590.95
0.02
0.15
1206.15
1214.65
1219.1
1.75
0.23
1770.5
1783.5
1794.05
6.99
0.24
116.35
117.35
118.95
4.16
0.25
4690
4744.95
4754.633
0.35
0.29
1031
1039.4
1042.133
3.65
0.41
151.3
152.5
153.5667
1.62
0.63
157.6
158.8
159.5
2.88
0.92
486.2
497.4
495.3333
-9.39
1.67
233.65
237.9
237.0833
4.66
2.65
208.4
213.8
212.3833
1.64
2.66
158.45
162.75
161.5667
-1.41
3.69
3344.9
3395.5
3447.267
11.16
3.71
168.4
176.5
174.7667
19.57
5.77
Not directly answer to your question. But if I understand you correctly,
Sub test()
Dim rg As Range
Dim minVal As Integer
Dim maxVal As Integer
Dim oBegin As String
Dim oAfterBegin As String
Dim oEnd As String
With ActiveSheet
Set rg = .Range("E1:E20")
minVal = .Evaluate("min(if(" & rg.Address & ">=3.5," & rg.Address & "))")
maxVal = .Evaluate("max(if(" & rg.Address & "<=11.5," & rg.Address & "))")
oBegin = rg.Find(minVal).Address
oAfterBegin = Range(oBegin).Offset(1, 0).Address
oEnd = rg.Find(maxVal).Address
End With
End Sub
The code assumed that the data to be test is in cell E1 to E20 and already sorted.
Example data in column E from row 1 to 20 is a number from 1 to 20 on each row.
The goal is to find the cell address which contain :
the nearest bigger or equal number of 3.5 ---> this will be the row which contains number 4 in column E.
the nearest less or equal number of 11.5 ---> this will be the row which contains number 11 in column E.
To get point-1 result, the code using MIN function then keep it in minVal variable
To get point-2 result, the code using MAX function then keep it in maxVal variable
Then the code find the value of minVal/maxVal and get the address of the found cell.
So,
the oBegin variable value will be cell E4 ($E$4 which contains a number : 4)
the oEnd variable value will be cell E11 ($E$11 which contains a number : 11)
the oAfterBegin variable value will be $E$5

SVG that won't load in illustrator - saying "This SVG is invalid. Validate it before opening."

Here's the code - let me know if there's anything you see missing or unneeded. The file displays just fine in chrome :)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
<svg style="fill: rgb(62, 156, 205); width:15%; float:left; margin-right:5%;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 152.69 149.72"><path d="M151.37 81.59c-.88.15-1.76.3-2.55.27-.88-.03-1.61-.8-2.39-1.02-.83-.23-1.69-.21-2.43-.62-.74-.41-1.31-1.04-1.97-1.6-.64-.54-1.12-1.23-1.7-1.87-.57-.62-1.4-1.02-1.92-1.71-.53-.7-1.08-1.36-1.65-1.96-.6-.64-1.32-1.1-1.96-1.63-.67-.56-1.38-.97-2.08-1.42-.72-.46-1.35-1.05-2.12-1.39-.77-.35-1.47-.94-2.29-1.18-.8-.23-1.73.07-2.57-.05-.82-.13-1.63-.1-2.49-.13-.82-.03-1.65-.31-2.51-.26-.82.06-1.62.37-2.47.5-1.13.17-2.08.05-2.41-.31-.35-.38-.38-1.39.03-2.5.29-.8.73-1.55 1.16-2.17.47-.68 1.3-.99 1.91-1.47.61-.49 1.26-.87 1.99-1.19.7-.31 1.38-.76 2.16-.94.75-.17 1.55-.17 2.35-.25.91-.09 1.77-.58 2.67-.68.9-.09 1.84.13 2.74-.01.9-.14 1.82-.15 2.71-.37.79-.2 1.57-.42 2.28-.7.76-.3 1.24-1.07 1.91-1.46.7-.4 1.5-.57 2.1-1.07.61-.51 1.35-.91 1.87-1.51.51-.6.56-1.56.98-2.25.41-.67 1.07-1.19 1.4-1.94.32-.71.78-1.41 1.03-2.19.31-.99.68-2.66-.42-3.39-.94-.62-2.17.46-2.97.97-.76.48-1.74.35-2.51.64-.82.3-1.55.59-2.39.7-.85.11-1.66.47-2.53.41-.84-.06-1.63-.52-2.48-.71-.82-.19-1.6-.48-2.43-.77-.79-.28-1.63-.4-2.42-.66s-1.59-.58-2.39-.79c-.81-.21-1.7.05-2.53-.07-.82-.12-1.62-.39-2.46-.38-.79.01-1.58-.06-2.33.03-.78.1-1.5.45-2.23.66-.75.21-1.37.66-2.06 1-.69.34-1.35.64-1.97 1.13-.59.46-1.23.88-1.76 1.49-.64.75-1.03 2.43-2.12 2.01-.63-.24-1.05-.81-1.18-1.47-.12-.6.36-1.31.36-1.91 0-.83-.49-1.73-.26-2.49.23-.75.63-1.54 1.09-2.24.47-.71 1.19-1.23 1.78-1.8.6-.57 1.5-.73 2.18-1.22.67-.48 1.1-1.33 1.8-1.77.67-.42 1.16-1.04 1.76-1.53.61-.5 1.36-.8 1.91-1.36.55-.57 1.02-1.2 1.5-1.82.49-.63.83-1.33 1.24-2 .41-.68 1.11-1.19 1.44-1.91.33-.73.82-1.42 1.06-2.17.24-.77-.06-1.69.08-2.46.14-.8.3-1.56.32-2.35.02-.81-.08-1.58-.19-2.37-.11-.8-.22-1.57-.48-2.33-.27-.81-.33-2.11-1.34-2.19-.98-.07-1.23 1.08-1.54 1.71-.37.75-.68 1.45-1.11 2.1-.46.69-.44 1.76-.98 2.33-.56.59-1.6.59-2.26 1.04-.65.44-1.17 1.12-1.93 1.41-.72.28-1.56.08-2.38.21-.75.13-1.48.88-2.32.88-.68 0-1.35-.08-2.03-.03-.68.05-1.34.3-2.02.35-.79.07-1.61-.28-2.34-.11-.77.17-1.62.15-2.32.43-.73.29-1.12 1.26-1.78 1.66-.67.4-1.5.53-2.08 1.04-.58.51-.84 1.31-1.32 1.93-.47.61-1.48.88-1.85 1.58-.36.68-.65 1.48-.9 2.24-.24.73-.02 1.62-.15 2.42-.13.79.06 1.88-1.13 2-.95.1-1.69-.57-2.23-1.27-.57-.74-.63-1.73-.98-2.5-.39-.83-.64-1.6-.8-2.45-.17-.87-.56-1.71-.53-2.6.04-.87.58-1.66.78-2.53.19-.84.41-1.65.72-2.49.27-.74.3-1.57.56-2.31.26-.74.1-1.62.31-2.37.21-.76.97-1.38 1.11-2.15.14-.77-.31-1.62-.29-2.41.03-.79.33-1.56.28-2.32-.06-.79.09-1.62-.07-2.37-.17-.77-.64-1.47-.92-2.19s-.57-1.46-.98-2.13C85.77 3 83.7-.34 81.61.03c-.1.56.14.93.2 1.44.14 1.17-.2 2.28-.45 3.4-.19.87.1 1.89-.26 2.67-.35.79-1.39 1.18-1.87 1.91-.47.71-.52 1.76-1.08 2.43-.55.65-1.34 1.1-1.94 1.72-.59.62-.93 1.51-1.55 2.12-.48.47-1.1.79-1.59 1.24-.6.55-1.28.95-1.79 1.5-.56.59-1.11 1.15-1.56 1.75-.49.65-1.03 1.25-1.4 1.9-.4.71-.67 1.47-.92 2.19-.27.76 0 1.61-.11 2.38-.11.78-.33 1.5-.28 2.31.05.77 0 1.57.21 2.36.19.74.2 1.6.52 2.36.31.73 1.71 1.77.7 2.48-.76.53-1.97-.11-2.75-.51-.76-.39-1.65-.59-2.27-1.09-.66-.53-.85-1.54-1.34-2.18-.49-.66-.8-1.36-1.12-2.14-.3-.74-.51-1.48-.65-2.33-.12-.73-.78-1.39-.89-2.12-.11-.74.13-1.52.02-2.26-.11-.74-.19-1.48-.33-2.21s-.02-1.54-.21-2.26c-.22-.83-.58-1.62-.87-2.39-.3-.8-1.07-1.37-1.45-2.09-.39-.75-.71-1.51-1.19-2.18-.49-.68-.7-1.62-1.28-2.22-.57-.59-1.26-1.14-1.93-1.65-.65-.49-1.6-.55-2.33-.95-.7-.39-1.39-.83-2.18-1.15-.74-.29-1.49-.66-2.3-.88-.55-.15-1.23-.53-1.74-.06-.44.41-.3 1.12-.04 1.53.44.69 1.18 1.15 1.47 1.85.31.75.57 1.51.72 2.26.15.77-.06 1.58-.05 2.36.01.77.44 1.6.33 2.39-.11.76-.6 1.47-.8 2.23-.19.74-.61 1.41-.87 2.16-.28.79-.42 1.62-.64 2.41-.22.81-.37 1.63-.51 2.43-.14.82.12 1.68.07 2.5-.05.83-.29 1.63-.24 2.46.05.82.24 1.62.4 2.44.16.8.29 1.61.57 2.4.27.76.88 1.36 1.27 2.12.37.71.24 1.77.73 2.47.33.48 1.21.71 1.53 1.24.33.55.42 1.31.04 1.95-.39.66-1.14.6-1.84.68-.66.08-1.36.02-2.02.03-.75.01-1.5.27-2.2.07-.7-.2-1.38-.56-2.04-.9-.68-.36-1.38-.69-1.97-1.14-.61-.46-1-1.17-1.52-1.71-.53-.54-1.35-.84-1.82-1.43-.46-.6-.4-1.59-.82-2.23-.47-.7-1.38-1.03-1.92-1.64-.55-.63-.73-1.65-1.35-2.18-.63-.54-1.73-.41-2.41-.85-.7-.44-1.09-1.47-1.83-1.79-.75-.33-1.55-.68-2.34-.89-.79-.21-1.68-.02-2.49-.1-.8-.08-1.63-.18-2.44-.13-.8.05-1.67-.02-2.46.16-.66.15-2.11.41-2.32 1.19-.24.9.94 1.81 1.65 2.24.74.46 1.6.63 2.2 1.16.65.57.97 1.37 1.48 2.02.52.67 1.37 1.09 1.76 1.83.39.74.43 1.65.7 2.45.27.79.89 1.5 1.07 2.33.17.81.24 1.68.34 2.53.08.72-.11 1.47.07 2.17.18.69.13 1.49.41 2.17.31.75 1.04 1.29 1.43 1.95.41.69.75 1.42 1.23 2.02.5.61 1.25.96 1.83 1.49.57.53 1.23.9 1.87 1.35.63.45 1.24.89 1.93 1.27.67.37 1.33.75 2.05 1.06.7.31 1.46.43 2.21.69 1.14.4 1.96 1.07 2.12 1.59.17.58-.51 1.37-1.27 2.23-.5.56-.87 1.36-1.49 1.75-.62.39-1.57.09-2.29.29-.69.2-1.35.46-2.1.48-.71.02-1.47.23-2.22.09-.7-.14-1.31-.69-2.02-.98-.7-.28-1.36-.63-2.05-.93-.69-.3-1.55-.18-2.24-.48-.93-.39-1.91-.58-2.83-1.03-.36-.18-.74-.34-1.13-.39-.83-.11-1.54-.81-2.38-.94-.73-.11-1.5-.24-2.26-.25-.84-.01-1.64.41-2.43.49-.83.08-1.73-.28-2.51-.1-.81.19-1.47.84-2.23 1.14-.76.31-1.72.24-2.43.67-.69.42-.92 1.52-1.55 2.07-.61.52-1.5.75-2.06 1.39-.55.63-.91 1.33-.35 2.14.54.78 1.07.03 1.77-.17.78-.22 1.62-.12 2.37-.18.8-.06 1.53.34 2.28.48.76.14 1.5.18 2.21.54.67.34 1.58.44 2.2 1 .5.46 1.03.93 1.5 1.43.47.5.51 1.39.94 1.92.44.53 1.06.9 1.46 1.45.52.71 1.06 1.36 1.61 1.97.59.65 1 1.48 1.63 2.01.66.56 1.34 1.15 2.05 1.58.73.44 1.66.49 2.44.79.78.3 1.51.92 2.34 1.08.8.15 1.69.06 2.55.08.81.02 1.65-.13 2.51-.22.8-.08 1.54-.66 2.39-.83.96-.2 2.79-1.09 3.55.02.4.59.25 1.7.06 2.3-.19.58-.7 1.17-1.04 1.67-.49.73-1.34 1.15-2.02 1.69-.66.52-1.28 1.22-2.08 1.59-.69.31-1.45.48-2.17.71-.72.23-1.42.6-2.16.76-.74.15-1.52.11-2.27.21-.74.1-1.52-.05-2.27.01-.91.07-1.79.32-2.68.48-.9.15-1.87-.01-2.74.24-.87.25-1.49 1.2-2.33 1.56-.76.32-1.66.31-2.33.77-.68.46-1.11 1.22-1.68 1.8-.59.59-1.42.94-1.89 1.62-.53.67-.55 1.61-.87 2.37-.33.77-.52 1.52-.68 2.33-.16.82-.52 1.59-.49 2.42.02.54-.34 1.61.33 1.85.35.12 1.31-.19 1.62-.47.6-.54.96-1.28 1.57-1.67.67-.43 1.31-.88 1.98-1.14.72-.28 1.49-.44 2.23-.54.75-.1 1.53-.23 2.3-.17.74.06 1.53.16 2.29.36.71.19 1.25 1 1.98 1.3.68.28 1.41.46 2.11.83.7.37 1.49.52 2.18.82.72.31 1.42.64 2.14.88.75.24 1.48.51 2.22.66.76.15 1.53.34 2.29.39.77.05 1.56.04 2.32-.04.76-.08 1.48-.42 2.23-.62.72-.2 1.5-.32 2.21-.65.67-.31 1.26-.84 1.92-1.28.62-.41 1.23-.86 1.83-1.39.73-.64 1.23-1.61 2.52-.91 1.12.61 1.84 1.53 1.91 2.71.06.99-.68 1.85-.91 2.76-.23.89-.28 1.82-.89 2.62-.47.62-.94 1.22-1.47 1.77-.54.55-1.22.91-1.81 1.41-.58.49-1.16.97-1.78 1.42-.69.5-1.11 1.33-1.74 1.86-.65.55-1.48.87-2.06 1.46-.59.61-.82 1.52-1.33 2.18-.52.67-1.59.95-2 1.68-.42.73-.82 1.54-1.13 2.34-.3.78-.41 1.68-.59 2.54-.17.81.28 1.73.22 2.61-.05.74-.46 1.45-.41 2.18.05.74.13 1.49.35 2.2.21.69.61 1.32 1.02 1.97.31.49.65 1.38 1.3 1.38.94 0 .94-1.16 1.1-1.76.19-.69.21-1.43.4-2.11.19-.67.79-1.04 1.29-1.62.49-.56.53-1.57 1.07-2.02.56-.46 1.19-.95 1.82-1.28.63-.33 1.37-.62 2.07-.82.67-.19 1.47 0 2.22-.06.71-.06 1.46.24 2.17.16.71-.08 1.37-.52 2.08-.64.71-.11 1.47.04 2.16-.12.86-.2 1.66-.61 2.43-.91.82-.32 1.51-.87 2.21-1.31.74-.46 1.62-.73 2.24-1.31.62-.59.71-1.65 1.21-2.36.49-.69.95-1.34 1.33-2.15.35-.76.74-1.5.99-2.36.43-1.48 1.09-2.04 1.7-2.11.58-.07 1.43.22 2.4 1.37.59.7 1.11 1.42 1.46 2.14.39.8.22 1.74.35 2.56.14.84.61 1.69.51 2.53-.1.82-.7 1.55-.98 2.37-.26.78-.55 1.55-.95 2.32-.34.67-.31 1.5-.57 2.18-.27.69-.92 1.24-1.12 1.95-.2.71-.6 1.4-.74 2.13s.09 1.54.01 2.28c-.08.73-.36 1.47-.39 2.22-.04.89.65 1.7.79 2.5.14.86-.11 1.79.22 2.56.33.78.95 1.41 1.45 2.11.48.68.82 1.51 1.44 2.12.58.58 1.16 1.26 1.85 1.78.53.4 1.46 1.08 2.19.71.76-.38.46-1.55.33-2.17-.15-.74.02-1.41.05-2.1.03-.73-.37-1.52-.16-2.2.21-.68.96-1.1 1.32-1.73.35-.61.33-1.48.79-2.05.58-.72 1.53-1.1 2.15-1.78.61-.68 1.02-1.56 1.69-2.2.66-.62 1.35-1.23 2.09-1.79.69-.53 1.61-.78 2.17-1.36.59-.62.76-1.61 1.21-2.29.47-.71.93-1.4 1.26-2.17.34-.77.57-1.58.78-2.4.2-.81.33-1.64.43-2.49.09-.83.55-1.67.55-2.53 0-.84-.39-1.69-.47-2.55-.14-1.46-.12-2.38.36-2.79.47-.4 1.31-.11 2.71.31.96.28 2.06.19 2.78.7.78.56 1.36 1.46 1.86 2.27.47.77 1.03 1.67 1.25 2.65.18.82.29 1.67.44 2.49.15.83.02 1.7.17 2.53.15.83.02 1.71.19 2.53.17.82.33 1.66.55 2.47.23.84 1.06 1.43 1.39 2.18.35.79.58 1.57 1.04 2.26.46.71.84 1.47 1.4 2.08.56.61 1.21 1.14 1.87 1.67.64.52 1.12 1.34 1.84 1.78.7.43 1.72.27 2.48.63.74.35 1.4.89 2.19 1.19.87.33 2.27.95 2.95.16.73-.86-.68-1.66-1.17-2.28-.5-.64-.65-1.44-.97-2.1-.35-.72-.62-1.39-.78-2.12-.17-.76-.6-1.49-.58-2.26.02-.75.05-1.57.22-2.34.16-.73.3-1.53.57-2.27.27-.71 1.08-1.2 1.33-1.91s.48-1.45.68-2.17c.21-.73.39-1.48.53-2.23.14-.74.06-1.53.1-2.29.05-.86.16-1.71.07-2.52-.09-.85-.41-1.65-.62-2.45-.22-.81-.8-1.46-1.13-2.23-.32-.77-.24-1.73-.65-2.47-.4-.72-1.11-1.26-1.58-1.96-.46-.69-1.09-1.24-1.6-1.91-1.21-1.58-.49-2.52 1.12-2.94.9-.24 1.83.05 2.66.05.91 0 1.72.11 2.54.38.83.26 1.82.26 2.57.78.7.48.96 1.55 1.59 2.24.57.62 1.67.78 2.19 1.44.52.66.76 1.56 1.27 2.23.51.67 1.19 1.2 1.73 1.85.55.68 1.08 1.32 1.71 1.91.63.6 1.01 1.52 1.71 2.02.71.5 1.68.55 2.44.94.77.4 1.57.6 2.37.88.81.28 1.49 1.13 2.32 1.29.85.16 1.74.29 2.59.31.86.02 1.75-.16 2.58-.29.84-.13 1.51-.9 2.31-1.2.7-.26 1.67-.04 1.61-.99-.04-.8-.8-.99-1.41-1.22-.75-.3-1.41-.64-2.02-1.07-.64-.45-1.15-1.06-1.59-1.71-.47-.68-1.6-.94-2.04-1.71-.4-.71-.56-1.56-.81-2.3-.26-.75-.02-1.64-.2-2.41-.17-.77-.24-1.56-.39-2.34-.15-.78-.74-1.47-.93-2.24-.2-.8-.29-1.61-.54-2.36-.27-.78-.58-1.52-.92-2.24-.35-.74-.8-1.41-1.23-2.08-.43-.68-.61-1.59-1.13-2.2-.52-.6-1.46-.79-2.08-1.31-.6-.51-1.25-.91-1.94-1.34-.66-.4-1.3-.83-2.06-1.15-.71-.3-1.48-.37-2.28-.6-1.25-.36-1.45-1.14-1.53-1.66-.08-.51-.11-1.22.83-2.07.69-.63 1.61-.81 2.36-1.17.8-.38 1.62-.39 2.48-.52.85-.12 1.66-.54 2.55-.46.85.08 1.71.21 2.59.43.86.21 1.59.77 2.41 1.1.82.33 1.85.14 2.65.52.8.38 1.42 1.15 2.23 1.52.75.34 1.57.42 2.32.65.78.23 1.57.28 2.35.4.81.12 1.57.4 2.36.4.81 0 1.68.33 2.45.2.8-.14 1.59-.49 2.33-.75.75-.27 1.57-.54 2.26-.95.69-.41.92-1.47 1.52-2.01.6-.53 1.56-.69 2.06-1.34.51-.66 1.02-1.5.71-2.46-.19-.68-.77-.38-1.23-.3M74.11 60.82c.37-.58.56-1.29.95-1.86.39-.57.72-1.19 1.12-1.75.4-.56 1.33-.72 1.74-1.27.58-.77 1.01-1.86 2.15-2.49.6-.33 1.23-.34 1.79-.46.73-.16 1.36-.01 1.83-.02.82-.03 1.64-.44 2.47-.39.83.04 1.66.14 2.47.3.81.16 1.68.25 2.45.59.74.32 1.56.7 2.25 1.23.56.43.86 1.19 1.12 1.81.27.63.07 1.32 0 2.01-.07.67.15 1.49-.26 2.07-.61.87-1.65 1.6-2.61 1.74-.96.15-2.06-.39-2.9-1.04-.55-.42-1.36-.41-2.3-.5-1.91-.19-3.42.41-4.56 2.04-.54.77-1.07 1.55-1.58 2.34-.35.54-.64 1.1-1.15 1.39-.53.3-1.16.36-1.77.37-.76.01-1.73.14-2.41-.34-.58-.41-.84-1.24-1.13-1.84-.29-.62-.26-1.32-.22-2.01.06-.68.17-1.33.55-1.92M59.31 73c-1.07.04-1.78.16-2.32.53-.54.37-.92 1-1.31 2.02-.34.88-1.25 1.55-1.53 2.44-.25.8-.38 1.56-.98 2.03-.62.48-1.38.57-2.17.58-.42.01-.74-.2-1.16-.35-.66-.23-1.36-.27-1.79-.78-.44-.52-.75-1.17-.89-1.85-.13-.65-.26-1.42-.05-2.09.22-.7.38-1.44.62-2.13.25-.69.72-1.3.99-1.99.28-.68.85-1.23 1.15-1.89.21-.46.1-1.41.61-2.11.38-.52.86-1.18 1.49-1.62.59-.41 1.37-.42 1.94-.59.77-.23 1.45-.51 1.91-.55.69-.06 1.4-.12 2.1-.16.7-.04 1.4-.08 2.1-.09.7-.01 1.41.04 2.11.05 1.05.02 1.9.85 2.58 1.58.67.73 1.03 1.62 1.02 2.7-.01 1.08-.24 2.1-.93 2.8-.69.7-1.7 1.04-2.74 1.02-.93 0-1.84.42-2.75.45m40.12 7.46c-.19.78-.94 1.36-1.21 2.1-.28.75-.49 1.49-.85 2.2-.36.71-.46 1.56-.89 2.23-.43.67-1.15 1.1-1.65 1.72-.5.62-1.04 1.14-1.6 1.7s-1.01 1.2-1.62 1.7c-.61.5-1.27.9-1.92 1.33-.66.43-1.12 1.21-1.81 1.57-.7.36-1.51.5-2.24.78-.73.28-1.51.41-2.26.61-1.48.39-3.04.75-4.6.92-1.03.11-2.07.13-3.09.02-.86-.1-1.62-.88-2.45-1.03-.85-.15-1.75.03-2.58-.14-.72-.15-1.4-.48-2.1-.61-.73-.13-1.44-.41-2.14-.49-.74-.08-1.49.27-2.19.28-.74.02-1.44.09-2.13.26-1.02.26-2.16.19-2.99-.35-.82-.53-1.62-1.48-1.88-2.54-.17-.69.07-1.47.24-2.11.18-.66.76-1.06 1.23-1.54 1.96-1.98 3.63-1.76 6.26-1.69.8.02 1.62-.13 2.4-.04.8.1 1.6.21 2.37.35.8.15 1.59.28 2.35.44.7.14 1.37.33 2.04.45.7.13 1.33.64 2.01.73 2.74.34 4.26-.28 6.75-1.27.71-.28 1.52-.31 2.18-.71.66-.39 1.39-.7 1.99-1.19.6-.49 1.19-1.02 1.71-1.59.52-.58.61-1.48 1.04-2.13.43-.65 1.07-1.15 1.39-1.86.32-.71.8-1.39.99-2.15.42-1.69 1.55-2.97 3.2-3.56.72-.26 1.99-.32 2.73 0 2.09.9 1.76 3.85 1.32 5.61"/></svg>
<svg style="fill: rgb(62, 156, 205); width:80%; float:left; margin-top:3%;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1644 175.53">
<path d="M1639.81 87.56l-2.08.75 2.08-.75c-5.71-17.28-13.63-25.24-19.85-30.22-6.03-5.03-12.97-8.94-21.21-11.96-.6-.22-1.03-.76-1.1-1.41-.08-.65.2-1.28.73-1.64l15.27-10.47c2.26-1.55 3.65-4.14 3.72-6.94.08-2.8-1.18-5.47-3.35-7.15C1590.91 0 1568.69 0 1561.39 0c-26.6 0-40.38 9.43-46.23 15.06-4.91 4.7-7.3 7.92-8.82 11.88-.32.83-1.19 1.28-2.03 1.02-.83-.24-1.35-1.08-1.2-1.95l2.03-11.88c.43-2.52-.23-5.08-1.82-7.04-1.58-1.95-3.9-3.07-6.36-3.07h-37.92c-2.52 0-4.87 1.17-6.46 3.2-1.59 2.04-2.19 4.68-1.66 7.25 1.4 6.66 2.93 22.51-1.32 28.99-.92 1.41-1.95 2.1-3.55 2.38-.77.14-1.54.2-2.3.2-17.36 0-28.3-35.54-28.41-35.9-1.07-3.66-4.27-6.13-7.96-6.13h-27.08c-3.88 0-7.21 2.73-8.09 6.64l-27.99 123.13c-.2.89-1.03 1.47-1.9 1.31-.87-.14-1.49-.92-1.43-1.82l8.06-120.16c.16-2.37-.65-4.73-2.22-6.48-1.57-1.73-3.78-2.73-6.07-2.73h-70.88c-2.58 0-4.97 1.21-6.56 3.32-1.59 2.12-2.14 4.82-1.5 7.41l29.19 118.88c.22.89-.28 1.79-1.13 2.06-.84.28-1.78-.2-2.08-1.05l-44.86-125c-1.2-3.36-4.33-5.61-7.79-5.61h-19.1c-2.28 0-4.48.98-6.04 2.7-1.57 1.72-2.39 4.07-2.25 6.43 1.04 17.6-2.19 51.15-14.65 52.77-.59.08-1.19.11-1.77.11-17.46 0-34.43-34.33-41.01-55.98-1.09-3.61-4.28-6.04-7.93-6.04h-25.97c-4.2 0-7.74 3.25-8.25 7.57l-11.73 99.78c-.1.86-.82 1.51-1.67 1.52-.84 0-1.56-.64-1.67-1.5l-12.79-99.89c-.55-4.26-4.09-7.48-8.24-7.48h-25.85c-2.54 0-4.91 1.18-6.51 3.25l-28.45 36.99c-.51.67-1.41.85-2.13.45-.71-.39-1.05-1.25-.8-2.04l8.64-27.45c.82-2.62.38-5.51-1.18-7.74-1.56-2.22-4.07-3.54-6.72-3.54H868.69c-4.44 0-8.09 3.6-8.3 8.2l-1.22 26.43c-.04.88-.72 1.58-1.64 1.64-.8.09-1.56-.56-1.71-1.43l-4.71-27.72c-.7-4.12-4.14-7.12-8.19-7.12h-27.65c-3.2 0-6.17 2.65-7.76 6.93-.25.68-.94 1.14-1.65 1.11-.73-.03-1.35-.54-1.55-1.26-.24-.86-.48-1.57-.75-2.18-1.66-3.8-4.33-4.6-6.27-4.6h-48.21c-2.54 0-4.91 1.18-6.5 3.24-1.59 2.06-2.18 4.72-1.61 7.3 5.15 23.26 9.62 65.88-.33 81.2-1.94 2.99-4.24 4.63-7.24 5.14-15.29 2.61-28.19-20.54-36.33-40.43-9.92-24.26-14.98-49.37-15.03-49.63-.8-3.96-4.22-6.83-8.14-6.83h-16.08c-2.5 0-4.84 1.15-6.43 3.15-1.59 2.01-2.22 4.62-1.72 7.17l29.47 150.63c.78 4 4.21 6.9 8.15 6.9h63.9c3.64 0 6.82-2.41 7.92-6.01l41.09-134.3c.27-.87 1.16-1.37 2.01-1.16.86.22 1.41 1.08 1.26 1.97l-21.9 129.41c-.43 2.52.24 5.08 1.83 7.03 1.58 1.95 3.9 3.06 6.36 3.06h78.72c2.46 0 4.77-1.12 6.37-3.07.2-.25.37-.53.61-.95.67-1.15 2.45-1.04 2.97-.16l.24.42c1.53 2.36 4.1 3.77 6.87 3.77l92.59.07c3.01 0 5.79-1.7 7.27-4.44.06-.12 6.7-12.46 17.68-24.06 7.78-8.22 21.5-17.63 34.7-17.16 18.47.65 23.07 26.73 24.19 37.9.43 4.42 3.99 7.76 8.27 7.76h54.07c3.81 0 7.13-2.69 8.07-6.53.05-.21 5.23-20.63 16.87-22.27 8.22-1.31 18.06 15.6 21.26 23.49 1.3 3.23 4.31 5.32 7.68 5.32h29.94c2.28 0 4.49-.99 6.06-2.71 1.57-1.73 2.38-4.08 2.23-6.45-.62-9.85 1.19-31.78 10.53-32.76 8.93-.71 19.77 20.25 24.18 35.74 1.03 3.64 4.31 6.18 7.98 6.18h27.73c5.33 0 8.12-2.11 8.3-6.27.02-.61.02-1.24-.01-1.87-.04-.77.44-1.48 1.15-1.72.72-.24 1.53.04 1.94.69 1.41 2.21 2.07 4.19 2.6 5.78.34 1.02.6 1.77.89 2.27.43.72 1.17 1.11 1.95 1.08.2.02.48.04.84.04h26.02c3.7 0 4.14-1.58 5.31-5.8.23-.83.48-1.72.77-2.67.22-.72.87-1.2 1.61-1.2.74 0 1.38.49 1.6 1.21 1.8 5.96 4.66 8.73 8.99 8.73l26.67-.18c2.41 0 4.71-1.07 6.29-2.95 1.58-1.88 2.3-4.38 1.98-6.85-4.28-32.09-.13-61.95 8.87-63.91 8.95-1.92 25.49 30.16 34.61 67.21.94 3.82 4.25 6.48 8.06 6.48h35.89c4.04 0 7.48-2.99 8.18-7.11l3.99-23.35c.12-.68.62-1.22 1.28-1.38.66-.15 1.36.12 1.75.67 16.21 23.11 41.94 34.83 76.47 34.83 41.3 0 61.89-18.17 71.89-33.42 0 0 .16-.22.16-.23 10.21-15.71 11.8-33.47 4.92-54.27zm-760.76 64.68c-.25.65-.9 1.09-1.73 1.07-.74-.08-1.35-.65-1.49-1.4l-13.47-74.73c-.76-4.46.63-9.02 3.69-12.21 2.02-2.1 4.57-3.45 7.38-3.92 8.6-1.43 14.74-1.95 19.14-1.95 9.81 0 10.98 2.62 11.49 3.78 3.03 8.25-6.32 41.65-25.01 89.36zM995.27 64.8l-63.37 82.38c-.47.61-1.33.83-2.03.5-.7-.33-1.09-1.1-.95-1.88 4.2-23.1 12.89-63.96 23.96-78.07 4.53-5.76 14.6-7.38 23.97-7.38 7.13 0 13.86.94 17.41 1.7.52.11.97.46 1.19.94.29.6.22 1.29-.18 1.81zm62.58 18.69c-1.83 1.58-4.85 2.44-8.51 2.44h-.01c-5.79 0-12.39-2.12-17.67-5.68-6.62-4.46-9.33-9.67-9.64-12.77-.17-1.67.25-2.95 1.3-4.03 1.77-1.83 5.08-2.88 9.09-2.88 5.98 0 12.6 2.26 18.16 6.21 5.37 3.82 8.82 8.67 9 12.67.08 1.69-.47 2.97-1.72 4.04zm492.68-49.18c1.99-1.07 5.3-2.46 9.87-3.06 9.05-1.17 16.71 1.56 23.4 8.38.52.53.65 1.34.31 2.01-.33.65-.94 1.07-1.8.91-1.36-.25-1.81-.32-2.52-.42l-17.1-2.59c-3.64-.53-8.17-1.2-11.74-2.02-.69-.16-1.21-.74-1.3-1.46-.09-.72.26-1.42.88-1.75zm28.92 76.16c-.02.01-.04.01-.06.02l-.3.08c-1.61.47-5.22 1.27-11.4 1.27-22.82 0-37.53-8.2-44.97-25.06-.99-2.26-2.88-3.96-5.19-4.68-.78-.24-1.58-.36-2.37-.36-1.55 0-3.08.45-4.42 1.31l-16.33 10.6c-.57.37-1.29.36-1.86-.04-.55-.38-.82-1.06-.7-1.73l8.47-47.22c.15-.87.92-1.42 1.78-1.41.85.06 1.53.77 1.56 1.65.42 10.52 6.21 18.12 18.8 24.67 6.8 3.66 15.1 5.44 22.41 7.01l19.19 4.22c1.09.24 2.3.49 3.61.76 8.06 1.64 16.94 3.72 20.41 7.61 1.87 2.09 2.55 4.94 2.76 6.07 1.35 7.46-2.91 13.15-11.39 15.23zM593.04 3.78h-63.48c-4.79 0-9.62 1.65-11.73 5.6 0 0-8.39 15.63-19.79 36.86-.72 1.35-3.01.88-3-.61.01-4.57-1.12-9.3-3.45-14.53-1.86-4.17-14.59-27.32-58.28-27.32h-51.83c-3.89 0-7.42 1.08-8.59 4.2-1.32 5.52-2.63 11.04-3.94 16.56l-3.51 14.76c-.33 1.4-2.18 13.02-5.36 8.63-1.19-1.63-.37-17.41-.37-22.56V8.01c0-2.87-3.44-4.24-7.68-4.24H195.52c-2.57 0-5.02.85-6.75 2.35-1.74 1.5-2.59 3.5-2.36 5.51 1.06 9.16 1.17 23.14-8.05 23.14s-14.55-11.82-19.59-26.45c-1-2.9-4.74-4.54-8.5-4.54H10.6C5.22 3.78.52 7.17.58 10.55L0 167.43c.04 2.43 3.16 4.49 7.26 4.49h163.17c4.83 0 8.83-3.11 9.12-6.91.9-11.61 7.96-25.05 16.86-25.05 9.7 0 19.12 14.49 23.14 26.53 1.05 3.15 4.68 5.44 8.81 5.44h96.1c2.18 0 4.26-.93 5.72-2.03 1.45-1.1 2.15-2.57 1.92-4.04l-14.96-93.03c-.11-.73.24-1.47.96-2.02.73-.55 1.77-.86 2.86-.86h18.2c4.59 0 11.23-.42 15.21 1.95 3.17 1.88 1.8 6.44 1.14 9.21-2.49 10.49-13.31 67.01-17.54 84.79-.08.36-.16.71-.25 1.07-.93 2.55 1.94 4.98 5.83 4.98h36.73c2.05 0 4.04-.65 5.33-1.74 1.29-1.09 1.73-2.5 1.16-3.77-3.83-8.49-9.59-17.9-9.58-27.5.01-8.56 7.58-11.88 14.73-7.67 11.76 6.92 18.95 24 20.72 36.84.3 2.15 3.11 3.83 6.41 3.83 0 0 53.48.02 60.86.03 3.54.01 6.83-1.57 8.68-4.21 2.93-4.16 7.49-10.24 10.61-12.64 9.26-7.11 21.32-8.66 32.3-5.78 4.13 1.09 8.12 2.99 11.58 5.61 3.69 2.79 5.15 5.85 7.49 9.73 3.57 5.92 5.64 7.13 11.3 7.26 2.3.05 26.26 0 30.89 0 7.35 0 7.35-6.37 7.35-6.37V8.23c-.04-3.38-2.81-4.45-7.07-4.45zM137.71 112.12c-2.42 6.68-5.26 13.24-8.38 19.69-1.78 3.68-3.49 9.05-7.77 11.14-1.04.51-2.22.82-3.6.87-19.65.45-52.51-2.12-50.68-13.43 1.36-8.41 10.28-13.17 44.13-14.97 4.29-.23 7.53-2.35 7.53-4.94l-4.07-17.2c0-2.67-3.62-4.89-8.07-4.96-18.17-.27-51.67-3.95-51.62-13.64.06-11.51 30.98-15.23 45.44-15.63 4.43-.13 7.9-2.3 7.9-4.96l-4.07-20.24c0-2 3.23-2.84 4.73-1.23 15 16.11 30.2 39.77 33.6 51.23 2.61 8.81-2.07 19.99-5.07 28.27zm127.51 28.35c-.38 2.3-4.12 3.08-5.85 1.21-23.12-25.09-39.47-55.58-41.7-65.68-2.16-9.79-.67-29.63 6.69-46.11 1.77-3.96 8.1-2.86 8.1 1.42v33.4c0 2.87 3.56 5.21 7.94 5.21h32.12c1.12 0 2.2.32 2.95.86.75.55 1.11 1.29 1 2.02l-11.25 67.67zm148.9-68.34c-3.09.47-5.86.48-8.2.05-1.37-.25-2.6-.66-3.66-1.22-2.25-1.17-3.67-2.98-4.09-5.22-1.14-6 4.97-13.22 15.8-18.39 8.34-3.97 17.26-5.26 22.68-3.35 2.96 1.05 4.93 3.03 5.54 5.55.46 1.93.36 5.06-2.75 9.02-5.06 6.46-15.69 12.11-25.32 13.56zm67.28 4.25c-6.27 11.98-18.68 35.65-25.58 48.5-1.42 2.63-5.7 2.64-7.15.03-1.49-2.69-10.98-17.07-11.57-21.14-1.29-9.05 14.94-13.07 21.92-16.14 7.85-3.45 15-8.74 19.84-12.79 1.27-1.07 3.26.16 2.54 1.54zm71.46 41.54c-1.34 1.86-3.61 3.12-6.54 3.63-.68.12-1.38.2-2.12.24-6.01.33-13.89-1.93-20.75-6.06-10.2-6.13-15-13.95-11.96-19.45 2.45-4.44 9.12-5.77 17.87-3.53 10.59 2.71 20.88 10.04 23.94 17.05 1.68 3.88.69 6.56-.44 8.12z"/></svg>
</body>
</html>

Find local maximum of data files in gnuplot

I have a list of data (two columns) and I want to plot in gnuplot only the value for which my second column has a local maximum.
To do so I would like to see if the second column of the ith row is bigger than the (i-1) and (i+1)th rows.
It can be done and I was bored enough to do it. I generated the following set of random data:
5191
29375
23222
32118
3185
32355
17173
8734
28850
20811
5956
6950
28560
25770
4630
28272
10035
7209
19428
26187
30784
20326
12865
23288
20924
Plotting the values against their position in the list looks like this:
You can spot the local maxima right away from the graph above. Now I can process the data points storing the two previous values (both x and y coordinates) in temporary variables, when I identify a maximum, I plot the data point:
# Select the columns of your data file that contain x and y data
# (usually 1 and 2 respectively)
xcolumn=0
ycolumn=1
plot "data" u (column(xcolumn)):(column(ycolumn)) w l, \
"data" u (column(0)==0 ? (last2y=column(ycolumn), \
last2x=column(xcolumn), 1/0) : column(0)==1 ? (lasty=column(ycolumn), \
lastx=column(xcolumn), 1/0) : lastx) \
: \
( column(0) < 2 ? 1/0 : (last2y < lasty && \
column(ycolumn) < lasty) ? (value=lasty, last2y=lasty, last2x=lastx, \
lasty=column(ycolumn), lastx=column(xcolumn), value) : (last2y=lasty, \
last2x=lastx, lasty=column(ycolumn), lastx=column(xcolumn), 1/0)) pt 7
A simple gnuplot peak finder
Comparing 3 consecutive data points is a simple way to look for maxima/peaks.
if y(i-1) < y(i) > y(i+1) then you have a maximum/peak at x(i).
However, if you have noisy curves (like experimental spectra typically are) you will get too many "peaks".
The script below basically calculates for each peak a specific number which is a measure for the "independence" of a peak (see Topographic prominence). Note that a high peak intensity does not necessarily mean high prominence. For the script gnuplot>=5.2 is required since it uses datablocks and plot ... with table. With some adaptions, it can maybe run with older versions.
You can give "threshold" to show only a certain number of peaks. Unfortunately, gnuplot does not have an easy internal feature for sorting datablocks, with this one could have easily shown the first N most prominent peaks. Hence, here it is done differently:
Threshold=100 means show all peaks, Threshold=0 means show only the global maximum. Note that the threshold values and number of shown peaks are not linear between 0 and 100 since it depends on the spectral shape.
Comments and improvements are welcome.
Data: SO28173128.dat
# x y
6.02 3.33
9.59 4.03
9.59 4.03
9.59 4.03
9.83 3.66
10.58 3.22
10.62 3.85
11.32 2.33
11.53 3.67
11.88 3.27
13.28 3.97
13.42 4.35
14.56 2.99
14.75 3.50
15.23 3.91
15.59 3.58
16.56 3.85
16.70 4.49
16.97 3.98
17.23 4.49
17.37 3.73
17.90 4.24
17.93 4.91
18.80 4.23
18.83 4.64
20.37 3.59
20.48 3.99
21.70 3.19
22.29 4.36
22.41 3.38
23.34 5.04
23.41 5.38
24.38 4.71
24.58 4.96
25.40 5.13
25.41 4.70
26.20 4.21
26.36 4.84
26.55 4.11
26.79 4.73
27.02 4.13
27.54 4.51
27.55 5.17
28.08 5.42
28.33 4.97
28.61 5.17
29.06 5.10
29.12 4.26
29.61 3.61
30.03 4.84
30.58 5.30
30.68 4.72
31.21 5.82
31.99 5.83
32.58 6.56
33.03 6.23
33.51 6.79
33.73 8.88
34.00 7.85
34.17 9.82
34.32 11.24
34.55 10.78
34.85 12.58
35.14 13.84
35.50 18.07
35.85 18.40
36.55 30.70
36.75 29.27
37.16 28.78
38.15 18.93
38.29 20.52
38.83 14.96
39.63 11.39
40.17 8.67
40.48 9.22
40.88 9.75
40.95 8.77
41.45 10.86
41.58 10.33
41.84 11.12
42.51 12.83
43.33 15.09
43.43 14.20
43.63 14.56
44.22 14.76
44.92 12.58
45.71 9.40
45.98 9.84
47.03 7.01
47.53 7.15
47.95 5.48
48.08 6.21
48.56 4.51
48.64 5.11
49.14 3.69
49.31 4.27
49.86 4.71
50.14 4.13
50.33 5.83
50.37 5.36
51.00 4.60
51.37 4.75
52.00 4.91
52.01 4.34
54.28 3.83
54.46 4.33
54.83 3.19
55.58 5.30
55.86 4.95
55.92 6.48
56.40 5.89
56.59 5.16
57.56 5.96
57.64 5.21
58.31 5.36
58.38 6.08
58.92 5.84
59.00 5.28
59.57 5.96
59.94 5.37
61.31 6.07
61.32 6.78
61.96 7.34
62.37 6.89
63.14 9.45
63.54 9.51
63.80 11.03
63.93 11.56
64.17 11.12
64.84 12.38
65.14 16.28
65.64 18.07
66.22 19.06
66.42 17.70
66.56 18.40
67.10 17.20
67.24 18.00
67.77 16.82
68.04 15.80
68.15 16.88
68.43 14.98
68.86 16.28
69.33 16.55
70.43 29.11
70.93 48.16
71.62 58.09
72.01 66.42
72.43 73.37
72.79 76.74
72.84 81.24
73.07 79.85
73.15 72.04
73.32 74.49
73.58 61.26
73.71 65.36
73.98 51.60
73.98 58.75
74.25 52.93
74.53 39.70
74.90 34.01
75.18 34.80
76.67 23.29
77.05 23.82
77.15 20.94
77.27 27.13
77.52 25.20
77.70 29.76
78.17 29.96
78.36 33.33
78.73 37.05
78.86 34.67
79.03 39.90
79.38 39.70
79.59 40.62
79.88 39.17
80.59 36.52
80.60 33.61
81.26 27.53
81.67 23.69
82.07 23.69
82.90 15.37
83.94 14.04
84.25 14.42
85.01 11.26
85.22 12.18
85.77 11.19
85.89 9.97
86.46 10.72
86.56 11.78
87.06 10.56
87.19 11.53
87.74 9.60
87.89 10.64
88.30 8.74
88.56 9.27
88.98 8.08
89.25 8.70
90.12 9.15
90.14 8.34
90.99 9.59
91.06 8.86
91.72 9.01
91.74 8.48
92.43 7.68
92.48 8.34
93.15 7.68
93.54 8.34
93.72 7.61
94.20 8.00
94.39 8.64
94.82 7.83
95.00 8.40
95.43 6.77
95.66 7.39
95.81 5.44
95.84 6.25
96.53 7.70
96.55 6.70
97.22 9.14
97.47 8.13
97.53 6.75
98.57 7.83
98.85 7.40
98.92 8.45
99.35 8.25
99.40 7.77
100.04 8.33
100.14 7.91
101.00 8.30
101.04 7.80
101.94 7.48
102.02 8.20
102.53 6.56
102.58 7.84
103.23 7.75
103.38 6.82
103.39 8.93
103.75 8.60
104.05 9.26
104.30 8.14
104.55 8.56
104.85 7.15
105.17 10.09
105.21 8.41
105.52 11.78
105.80 10.00
105.92 10.86
106.11 9.54
106.31 9.93
106.86 10.99
107.20 10.88
107.42 12.05
107.62 10.33
107.80 11.16
108.39 9.90
108.79 12.25
109.08 11.85
109.46 13.77
109.73 13.42
109.96 15.16
111.02 20.08
111.30 23.56
111.69 23.56
112.35 30.08
112.61 39.04
112.89 43.53
113.28 43.67
113.81 60.73
113.94 56.63
114.20 63.11
114.46 69.60
115.00 80.44
115.12 86.95
115.27 84.68
115.78 88.78
116.11 89.57
116.40 88.51
116.43 89.90
117.90 80.31
118.18 71.32
118.42 72.51
118.70 67.48
118.83 61.13
119.25 60.34
119.37 54.51
119.65 55.18
120.08 50.28
120.12 48.96
120.84 54.18
120.95 51.87
121.24 56.49
121.50 53.01
121.64 54.44
121.73 51.74
121.84 52.53
122.14 53.72
122.19 52.40
122.44 53.59
122.45 54.91
122.64 51.61
122.76 53.17
123.08 50.79
123.10 50.15
123.34 49.51
123.39 50.81
123.88 50.28
124.25 46.58
124.26 44.06
124.53 43.67
125.18 38.77
125.81 32.16
126.10 32.55
127.32 21.71
127.70 21.18
127.96 18.27
128.22 18.66
128.62 15.71
128.89 16.24
129.30 13.94
129.56 14.47
129.96 12.22
130.21 12.72
130.53 10.83
130.93 10.61
131.15 11.24
131.84 10.06
131.93 11.12
132.71 9.87
133.06 13.17
133.38 12.73
134.17 16.97
134.31 22.37
134.85 30.83
135.38 43.01
135.62 40.09
135.64 50.81
135.75 54.05
136.16 56.10
136.80 50.22
137.21 49.36
138.29 25.41
138.56 26.73
139.98 13.09
140.03 11.92
140.32 14.53
140.55 13.80
140.85 16.25
141.24 15.81
141.45 17.92
141.59 16.51
141.99 20.65
142.25 20.19
142.76 27.79
142.91 24.95
143.72 37.66
143.79 35.37
144.65 29.11
144.91 30.32
145.71 25.74
145.84 24.80
146.54 27.73
146.74 30.57
147.30 31.11
147.42 30.30
148.33 31.23
148.38 30.68
148.93 31.19
149.09 31.74
149.24 28.43
149.49 29.03
149.96 24.55
150.69 23.48
151.83 18.06
151.89 19.39
152.41 18.27
152.96 19.45
153.02 18.53
153.47 19.42
153.71 18.78
153.91 19.44
154.08 17.74
154.54 18.92
154.65 18.20
155.61 18.79
156.78 15.75
157.06 16.08
157.54 12.68
157.84 13.40
158.51 12.73
158.57 11.85
159.45 11.27
159.57 10.33
160.11 8.81
160.24 9.81
160.90 9.27
160.90 8.08
161.17 8.48
161.43 8.10
161.59 8.72
161.83 7.91
162.44 8.48
162.61 7.94
163.41 8.75
163.43 8.19
163.94 8.99
163.96 8.33
164.60 8.23
164.87 8.74
165.81 8.50
166.10 8.08
166.74 8.91
167.02 8.48
167.67 9.68
167.96 9.28
168.90 9.81
168.96 10.34
169.57 9.77
169.76 11.28
170.00 10.75
171.01 13.77
171.12 13.13
171.79 13.71
172.83 19.14
173.19 19.13
173.52 21.06
173.73 20.38
173.87 21.65
174.27 21.90
174.41 25.94
174.94 27.39
175.20 33.48
175.71 35.07
175.84 40.49
176.48 43.27
176.51 46.84
177.34 51.47
177.62 57.30
177.69 55.18
177.87 53.26
178.08 54.46
178.45 49.43
178.76 49.62
179.02 43.53
179.43 42.08
179.96 28.98
180.21 26.40
180.56 26.57
180.57 26.20
181.14 26.43
181.24 25.51
181.68 24.93
181.74 27.13
181.97 28.85
182.05 26.93
182.14 29.78
182.30 27.53
182.59 28.72
182.72 26.93
183.04 27.67
183.21 28.76
183.33 27.92
183.75 29.99
184.06 29.78
184.28 32.07
184.71 32.49
185.40 37.78
185.61 34.01
186.02 33.86
186.20 30.07
186.79 28.72
186.97 25.44
187.34 25.15
188.45 17.65
188.84 16.25
189.08 16.77
189.50 14.08
189.90 13.69
189.92 11.67
190.37 12.04
190.41 12.90
190.90 11.40
190.93 12.58
192.29 9.27
192.33 8.79
193.23 10.21
193.34 9.73
193.78 11.15
194.07 10.20
194.54 10.43
194.93 9.64
195.39 9.82
195.98 10.86
196.08 10.05
196.45 11.78
197.00 8.90
197.03 9.95
197.70 7.15
198.07 10.13
198.10 8.48
198.83 9.67
198.85 10.46
199.27 9.80
199.46 9.46
200.46 11.78
200.73 11.38
201.38 12.37
201.92 9.72
202.06 10.52
203.14 7.67
203.52 7.95
203.93 7.02
204.13 7.55
204.39 6.66
204.63 7.15
206.35 5.53
206.57 6.00
207.21 6.57
207.33 5.76
208.23 7.93
208.52 7.68
208.92 7.15
209.21 7.56
209.41 6.62
209.88 6.89
211.48 4.50
211.70 5.00
212.39 5.37
212.51 4.53
212.84 4.31
212.92 5.17
213.26 4.38
213.44 5.24
213.70 4.57
214.15 4.97
214.24 5.71
215.55 5.20
215.65 6.01
216.28 6.16
216.55 6.87
216.73 5.56
216.95 6.23
217.25 6.03
217.47 5.46
217.93 5.50
218.26 5.83
218.56 5.04
219.31 4.73
219.97 4.72
220.10 5.61
220.79 4.23
220.87 4.94
221.87 4.64
222.07 4.12
222.58 4.47
222.69 5.02
223.21 4.51
223.24 5.22
223.86 4.54
223.90 5.22
224.48 4.29
224.54 5.04
225.22 4.73
225.28 3.86
225.54 4.13
225.76 4.72
225.84 3.93
226.52 4.23
226.60 4.94
226.98 4.02
227.78 3.89
228.29 4.67
228.62 4.29
229.12 4.90
229.46 4.16
229.83 4.48
230.28 3.54
230.50 4.06
230.91 3.03
231.18 3.63
231.79 3.99
231.97 3.45
232.70 4.86
Edit: revised and simplified
Script: (works with gnuplot>=5.2.0)
### a simple gnuplot peak finder
reset session
FILE = "SO28173128.dat"
colX = 1
colY = 2
# extract all peaks
set table $Temp
plot y2=y1=x2=x1=NaN FILE u (x0=x1,x1=x2,x2=column(colX), \
y0=y1,y1=y2,y2=column(colY), \
y0<y1 && y1>=y2 ? sprintf("%g %g",x1,y1) : '') w table
set table $Peaks # remove empty lines and store first values in x0,y0 for later use
plot $Temp u (column(-2)==0 && $0==0?x0=$1:$1):(column(-2)==0 && $0==0?y0=$2:$2) w table
unset table
isNaN(v) = v!=v # check if value is NaN
min(a,b) = isNaN(a) && isNaN(b) ? NaN : isNaN(a) ? b : isNaN(b) ? a : a<b ? a : b # get minimum incl. NaN
# create prominence table
set print $Prominence
do for [n0=0:|$Peaks|-1] {
xn = yn = xp = yp = NaN
stats $Peaks u ($0<n0 && $2>y0 ? (xn=$1,yn=$2) : 0, \
$0>n0 && $2>y0 && yp!=yp ? (xp=$1,yp=$2) : 0, \
$0==n0+1 ? (x1=$1, y1=$2) : 0 ) nooutput
print sprintf("%g %g %g",x0,y0, min(x0-xn,xp-x0))
x0=x1
y0=y1
}
set print
set key noautotitle
set offsets 0,0,1,0
set grid y
# filter Peaks
stats $Prominence u 3 name "P" nooutput # get min, max
Filter(col,t) = (!valid(col) ? 0 : (1-(column(col)-P_min)/(P_max-P_min))*99+1)<=t ? $2 : NaN
Threshold = 100
set label 1 at graph 0.02,0.95 sprintf("Threshold: %g",Threshold)
plot FILE u colX:colY w l lc rgb "blue" ti "Spectrum", \
$Prominence u 1:(Filter(3,Threshold)) w impulses lc rgb "red", \
$Prominence u 1:(Filter(3,Threshold)):1 w labels offset 0,1
### end of script
Results: (for different thresholds)

Correlation analysis between stock prices

Let us consider following stock prices taken from yahoo.finance.com:
Date Open High Low Close Volume Adj Close
3/4/2013 23.15 23.84 23.03 23.67 30908300 23.3
2/25/2013 23.5 23.53 22.81 23.19 40710800 22.83
2/19/2013 23.42 23.75 23.12 23.39 38743400 23.03
2/11/2013 22.49 23.55 22.35 23.29 46448500 22.74
2/4/2013 22.41 22.62 22.27 22.5 34498100 21.97
1/28/2013 22.44 22.64 22.18 22.62 39634900 22.09
1/22/2013 22.18 22.31 21.75 22.29 47826300 21.77
1/14/2013 21.18 22.19 21.01 22.04 54826000 21.52
1/7/2013 21.16 21.24 20.68 21.13 35304100 20.63
12/31/2012 20.29 21.54 20.26 21.2 45796500 20.7
12/24/2012 20.79 20.96 20.42 20.44 28597100 19.96
12/17/2012 21.69 21.95 20.56 20.88 70719700 20.39
12/10/2012 21.43 21.95 21.36 21.62 39455500 20.92
12/3/2012 21.18 21.48 20.71 21.46 35913000 20.77
11/26/2012 20.88 21.36 20.5 21.13 36203100 20.45
11/19/2012 20.41 21.04 20.37 21.04 35401500 20.36
11/12/2012 21.04 21.14 19.87 20.15 45095400 19.5
11/5/2012 21.2 21.78 20.7 21 37812800 20.32
11/2/2012 21.53 21.68 21.26 21.31 47475200 20.62
And i want to do correlation matrix between for example Volume and Low Close variable. I used correlation function from data analysis toolbox from excel, but I got only one side matrix, like this:
Close Volume
Close 1
Volume -0.117267345 1
It does not show me correlation coefficients up side of main diagonal, why? Maybe it is symmetric and because of this?
The correlation matrix is necessarily symmetric, so the above the diagonal element in your case is -0.117257345. If you check the documentation on the correl function, and look at the defining equation, you can see that it is symmetric with respect to exchanging X<->Y

Resources