Auto correlation of a row vector - signal-processing

I want to take auto correlation of a row vector of length 1x2080, as i want to take first 52 numbers(from 0 to 52) and then correlate with this row then i want to take from next 52 from (1 to 53) and then so on for example next i will take next 52 (2 to 54) and the correlate this with row so at the end of the day i can check where the auto correlation is high.I am trying to implement a for loop for that for example for i = 1:52:2080
autocorr(i+51,a)
end
where a contains the row vector of containing numbers for autocorrelation

Related

Random select in with a bias towards certain outcomes (ie 60/40)

Lets say I have 2 lists and I would like to randomly select a winner between the lists but I would like to select the winner from list A 60% of the time and from list B 40% of the time, how can that be done in Google Sheets?
You can randomly select names from a list using this formula
INDEX(A2:A, RANDBETWEEN(1, COUNTA(A2:A)))
Without knowing some more information on your setup here is a general formula that does what you're describing:
=IF(RAND()<=0.6,INDEX(A2:A, RANDBETWEEN(1, COUNTA(A2:A))),INDEX(B2:B, RANDBETWEEN(1, COUNTA(B2:B))))
Essentially it is rolling a random number between 0 and 1. If it is equal to or less than .6 (simulating 60%, since there is a 60% chance it will be less than or equal to .6) it then selects a random name from Column A, otherwise (bottom 40%) it selects from column B.
You can also replace the "0.6" with A1 in my example to have the weight be a dynamic number. Changing A1 to 75% for example will then compare the random value against less than or equal to .75.
EDIT: Image shows the wrong condition, I was corrected in the sense you want less than or equal to .6 and not greater than, I had the weights flipped.

Calculate the average of the top 80% of values in a column Google Sheets

How can I get the top 80% of an unsorted column of values that includes 0s?
values
1
1
0.3333333333
1
1
1
1
1
0
0
If the top 80% of values to average is not a rational number, I need it to average both above and below the rational number:
(e.g. 11 values * 0.8 = 8.8 values to consider, so it should average the top 8 and the top 9 values)
so far I've this: =AVERAGEIF(A1:A12,">"&PERCENTILE(A1:A12,80%))
do it like this:
=IFERROR(AVERAGE(INDIRECT("A1:A"&COUNTA(A1:A)*80%)),
{AVERAGE(INDIRECT("A1:A"&ROUNDDOWN(COUNTA(A1:A)*80%)));
AVERAGE(INDIRECT("A1:A"&ROUNDUP(COUNTA(A1:A)*80%)))})
If by 'top 80%' you mean the largest 80%, I would use sortn:
=average(sortn(A:A,rounddown(count(A:A)*0.8),,1,false))
and
=average(sortn(A:A,ROUNDUP(count(A:A)*0.8),,1,false))
The average of the top 8 numbers is 7.5 and the average of the top 9 numbers is 7.

How to eliminate highlighting duplicates in google sheets conditional formatting

I have a spreadsheet where I need to conditional format/highlight the lowest 3 scores in a row to reflect dropped scores that are part of a Total calculation. I'm using the SMALL function to successfully calculate the Total..=SUM(A2:I2)-SMALL(A2:I2,1)-SMALL(A2:I2,2)-SMALL(A2:I2,3) but when I try to use the SMALL function in the Custom Formula field of the Conditional Format it highlights 0,60,60,60 and not 0,60,60
119 101 60 100 0 109 60 60 112 TOTAL:601
If four of the values are 0, it will highlight all for 0's.. if 60 is the lowest score and there are 4 or more scores of 60, it will highlight all and not reflect that only 3 of the scores are actually dropped.
Is there another way (custom formula) that can only highlight the lowest 3 scores in the row even when the 3rd lowest may have duplicates in the row?
I've come up with this formula (assuming values start in A1) which unfortunately is a bit long
=OR(A1<SMALL($A1:$I1,3),AND(A1=SMALL($A1:$I1,3),COUNTIF($A1:A1,SMALL($A1:$I1,3))<=(3-COUNTIF($A1:$I1,"<"&SMALL($A1:$I1,3)))))
or
=OR(A1<SMALL($A1:$I1,3),AND(A1=SMALL($A1:$I1,3),(COUNTIF($A1:A1,SMALL($A1:$I1,3))+COUNTIF($A1:$I1,"<"&SMALL($A1:$I1,3))<=3)))
The logic is that it highlights all cells which are less than the third smallest value, then any values (starting from the left) which are equal to the third smallest value until the total equals three.
I've changed the second row to show that it selects the second zero instead of the second 60.

Nested Average(Small(offset)) in Sheets isn't producing correct result

I want to calculate the average of the smallest 20 numbers in a range (using offset), then multiply it by 0.96 using a Google sheet.
This is the formula we have:
=AVERAGE(SMALL(OFFSET(B13,2,0,20),{1;2;3;4;5;6;7;8;9;10}))*0.96
(See below for pictures)
The function should output 24, but instead it's outputting 14. I think it has something to do with the range of numbers for 'n' in the nested 'small' function, but for the life of me I can't figure out what it is. I've linked some pictures:
Thank you!
Since the data in your image only has 20 rows, i am assuming you mean to calculate average of smallest 10 numbers from the 20 rows. Try this formula
=AVERAGE(SMALL(OFFSET(B13,0,0,20,1),{1,2,3,4,5,6,7,8,9,10}))
Please note the the formula should be entered as an array i,.e. type the formula and press Ctrl + shift + enter

How to create (number) series with custom intervals in LibreOffice

Imagine you have the following table, see down below. Now, I would like to tell LibreOffice to create out of all three columns a series with custom intervals each. Is this possible?
The series shall be like this:
Increase number by 1 every 112 rows and insert current number inbetween.
Increase number by 1 every 28 rows and insert current number inbetween.
Increase number by 1 every 7 rows and insert current number inbetween.
You can use formula =INT((ROW()-1)/period)+startingNumber and drag it down (with black square at the bottom right of selected cell) to copy it to number of rows.
Or you can use simple macro (where period equals 7, 28 or 112):
Option Explicit
Sub Main
Dim numberOfRows, n, period, startingNumber As Integer
Dim destinationCell As Variant
period = 7
numberOfRows = 30
startingNumber = 1
For n = 0 To numberOfRows-1
destinationCell=ThisComponent.Sheets.getByIndex(0).getCellByPosition(0,n)
destinationCell.setValue(Int(n/period)+startingNumber)
Next n
End Sub

Resources