frequency

Getting the count of unique values in a column in bash

自作多情 提交于 2019-12-03 01:45:35
问题 I have tab delimited files with several columns. I want to count the frequency of occurrence of the different values in a column for all the files in a folder and sort them in decreasing order of count (highest count first). How would I accomplish this in a Linux command line environment? It can use any common command line language like awk, perl, python etc. 回答1: To see a frequency count for column two (for example): awk -F '\t' '{print $2}' * | sort | uniq -c | sort -nr fileA.txt z z a a b

Swift FFT - Complex split issue

心不动则不痛 提交于 2019-12-03 00:53:13
I am trying to perform FFT on an audio file to find frequency using the Accelerate framework. I have adapted code (probably wrong) from this question: Spectrogram from AVAudioPCMBuffer using Accelerate framework in Swift Although, the magnitudes from ' spectrum ' are either ' 0 ', ' inf ' or ' nan ', and the ' real ' and ' imag ' components of the complex split print similar results; indicating that this is the cause of the problem as: ' magnitude = sqrt(pow( real ,2)+pow( imag ,2) '. Correct me if i'm wrong, but I think the rest of the code is ok. Why am I receiving these results and how can

Given a string consisting of alphabets and digits, find the frequency of each digit in the given string

狂风中的少年 提交于 2019-12-02 22:54:48
问题 Please tell me whats wrong in code the output is 00000000. I know there is some mistake but cant find it. #include <stdio.h> #include <string.h> int main() { int c=0; char s[100]; fgets(s, 100, stdin); printf("%s", s); for(int i=0;i<=9;i++) { for(int j=0;j<strlen(s);j++) { if(s[j]==i){ c++; } } printf("%d", c); } return 0; } 回答1: Firstly, you are comparing a character with a int. Have a look at Char to int conversion in C for a solution. Then, I would remember you that "0" is index 48 in

An interesting Google interview algorithm I found online that requires linear time [closed]

时光总嘲笑我的痴心妄想 提交于 2019-12-02 20:52:12
So I found this Google interview algorithm question online. It's really interesting and I still have not come up with a good solution yet. Please have a look, and give me a hint/solution, it would be great if you can write the code in Java :). "Design an algorithm that, given a list of n elements in an array, finds all the elements that appear more than n/3 times in the list. The algorithm should run in linear time. (n >=0 ) You are expected to use comparisons and achieve linear time. No hashing/excessive space/ and don't use standard linear time deterministic selection algo" My solution was

Get RMS from FFT

可紊 提交于 2019-12-02 18:44:40
问题 I got an array of data voltages and I want to get the RMS value from the FFT that has been applied before to that data. I've seen that RMS in time domain should be equal to RMS(fft) / sqrt(nFFT) from Parseval's Theorem, but gives me different results. I'm using these functions: 1)FFT public static VectorDPoint FFT(double[] trama, double samplingFreq) { double fs = samplingFreq; // Sampling frequency double t1 = 1 / fs; // Sample time int l = trama.Length; // Length of signal // Time vector /

Using dplyr for frequency counts of interactions, must include zero counts

蓝咒 提交于 2019-12-02 17:45:43
My question involves writing code using the dplyr package in R I have a relatively large dataframe (approx 5 million rows) with 2 columns: the first with an individual identifier ( id ), and a second with a date ( date ). At present, each row indicates the occurrence of an action (taken by the individual in the id column) on the date in the date column. There are about 300,000 unique individuals, and about 2600 unique dates. For example, the beginning of the data look like this: id date John12 2006-08-03 Tom2993 2008-10-11 Lisa825 2009-07-03 Tom2993 2008-06-12 Andrew13 2007-09-11 I'd like to

java: Find integer's frequency in an array

馋奶兔 提交于 2019-12-02 13:40:15
I need to develop a java program that asks the user to enter some integers and find the largest, and smallest number, and the average of those numbers. Then, divides the set of array into a number of sub-intervals that the user specifies, then it generates a boundary points each has a length of sub-interval width.. The problem is that I need to create a frequency: ex: Interval: 14.5-16.5 Frequency: 1 (here it should shows how many integers belong to this boundaries) Interval: 16.5-18.5 Frequency: 4 and so on. Here is the code I have so far, almost done except finding the frequency of each

Count How many times a value appeared in a column(excel)

安稳与你 提交于 2019-12-02 11:27:17
问题 Ok, So I have an excel file that have a column that may contain duplicate value like this PO NUMBER PO COUNT P100293490 4 P100293490 P100293490 P100293490 P100293492 2 P100293492 P100293494 3 P100293494 P100293494 P100293497 4 P100293497 P100293497 P100293497 P100293499 1 P100293490 2 P100293490 P100293492 1 I need to count how many times it appeared on the column and place it beside the first occurrence of the word. The problem is that the PO NUMBER is not sorted so values may repeat on the

Accurate sleep/delay within Python while loop

℡╲_俬逩灬. 提交于 2019-12-02 09:53:34
I have a while True loop which sends variables to an external function, and then uses the returned values. This send/receive process has a user-configurable frequency, which is saved and read from an external .ini configuration file. I've tried time.sleep(1 / Frequency), but am not satisfied with the accuracy, given the number of threads being used elsewhere. E.g. a frequency of 60Hz (period of 0.0166667) is giving an 'actual' time.sleep() period of ~0.0311. My preference would be to use an additional while loop, which compares the current time to the start time plus the period, as follows:

Get RMS from FFT

落花浮王杯 提交于 2019-12-02 09:26:05
I got an array of data voltages and I want to get the RMS value from the FFT that has been applied before to that data. I've seen that RMS in time domain should be equal to RMS(fft) / sqrt(nFFT) from Parseval's Theorem, but gives me different results. I'm using these functions: 1)FFT public static VectorDPoint FFT(double[] trama, double samplingFreq) { double fs = samplingFreq; // Sampling frequency double t1 = 1 / fs; // Sample time int l = trama.Length; // Length of signal // Time vector //Vector t = Normal(0, l, 1) * t1; //// Values vector //Vector y = new Vector(trama); // We just use half