frequency

Setting a relative frequency in a matplotlib histogram

丶灬走出姿态 提交于 2019-11-28 19:19:13
I have data as a list of floats and I want to plot it as a histogram. Hist() function does the job perfectly for plotting the absolute histogram. However, I cannot figure out how to represent it in a relative frequency format - I would like to have it as a fraction or ideally as a percentage on the y-axis. Here is the code: fig = plt.figure() ax = fig.add_subplot(111) n, bins, patches = ax.hist(mydata, bins=100, normed=1, cumulative=0) ax.set_xlabel('Bins', size=20) ax.set_ylabel('Frequency', size=20) ax.legend plt.show() I thought normed=1 argument would do it, but it gives fractions that are

python equivalent of R table

雨燕双飞 提交于 2019-11-28 18:31:36
I have a list [[12, 6], [12, 0], [0, 6], [12, 0], [12, 0], [6, 0], [12, 6], [0, 6], [12, 0], [0, 6], [0, 6], [12, 0], [0, 6], [6, 0], [6, 0], [12, 0], [6, 0], [12, 0], [12, 0], [0, 6], [0, 6], [12, 6], [6, 0], [6, 0], [12, 6], [12, 0], [12, 0], [0, 6], [6, 0], [12, 6], [12, 6], [12, 6], [12, 0], [12, 0], [12, 0], [12, 0], [12, 6], [12, 0], [12, 0], [12, 6], [0, 6], [0, 6], [6, 0], [12, 6], [12, 6], [12, 6], [12, 6], [12, 6], [12, 0], [0, 6], [6, 0], [12, 0], [0, 6], [12, 6], [12, 6], [0, 6], [12, 0], [6, 0], [6, 0], [12, 6], [12, 0], [0, 6], [12, 0], [12, 0], [12, 0], [6, 0], [12, 6], [12, 6],

Python library for playing fixed-frequency sound

橙三吉。 提交于 2019-11-28 17:14:01
I have a mosquito problem in my house. This wouldn't usually concern a programmers' community; However, I've seen some devices that claim to deter these nasty creatures by playing a 17Khz tone. I would like to do this using my laptop. One method would be creating an MP3 with a a single, fixed-frequency tone ( This can easily done by audacity ), opening it with a python library and playing it repeatedly. The second would be playing a sound using the computer built-in speaker. I'm looking for something similar to QBasic Sound : SOUND 17000, 100 Is there a python library for that? jfs PyAudiere

Getting frequency values from histogram in R

落花浮王杯 提交于 2019-11-28 16:59:57
I know how to draw histograms or other frequency/percentage related tables. But now I want to know, how can I get those frequency values in a table to use after the fact. I have a massive dataset, now I draw a histogram with a set binwidth. I want to extract the frequency value (i.e. value on y-axis) that corresponds to each binwidth and save it somewhere. Can someone please help me with this? Thank you! The hist function has a return value (an object of class histogram ): R> res <- hist(rnorm(100)) R> res $breaks [1] -4 -3 -2 -1 0 1 2 3 4 $counts [1] 1 2 17 27 34 16 2 1 $intensities [1] 0.01

How to generate a frequency table in R with with cumulative frequency and relative frequency

寵の児 提交于 2019-11-28 16:33:16
I'm new with R. I need to generate a simple Frequency Table (as in books) with cumulative frequency and relative frequency. So I want to generate from some simple data like > x [1] 17 17 17 17 17 17 17 17 16 16 16 16 16 18 18 18 10 12 17 17 17 17 17 17 17 17 16 16 16 16 16 18 18 18 10 [36] 12 15 19 20 22 20 19 19 19 a table like: frequency cumulative relative (9.99,11.7] 2 2 0.04545455 (11.7,13.4] 2 4 0.04545455 (13.4,15.1] 1 5 0.02272727 (15.1,16.9] 10 15 0.22727273 (16.9,18.6] 22 37 0.50000000 (18.6,20.3] 6 43 0.13636364 (20.3,22] 1 44 0.02272727 I know it should be simple, but I don't know

Where is the documentation on Pandas 'Freq' tags? [closed]

南笙酒味 提交于 2019-11-28 15:57:05
I am new to Pandas, and am trying to use date_range . I came across all kinds of good things for freq , like BME and BMS and I would like to be able to quickly look up the proper strings to get what I want. Yesterday I found a nicely formatted table somewhere in the documentation, but the title of the table was so obtuse that I can not use search to find it again today. jezrael You can find it called Offset Aliases : A number of string aliases are given to useful common time series frequencies. We will refer to these aliases as offset aliases (referred to as time rules prior to v0.8.0). Alias

How to get the most frequent level of a categorical variable in R

試著忘記壹切 提交于 2019-11-28 14:43:57
I can get the levels and frequencies of a categorical variable using table() function. But I need to feed the most frequent level into calculations later. How can I do that? for example, I want to get "191" from categorical variable a. > table(a) a 19 71 98 139 146 185 191 305 75 179 744 1 1980 6760 a <- sample(x = c(19, 71, 98, 139, 146, 185, 191), size = 1000, replace = TRUE) tt <- table(a) names(tt[which.max(tt)]) ll<-data.frame(table(a)) ll[which.max(ll$Freq),] Example from mtcars data: ll<-data.frame(table(mtcars$cyl)) ll Var1 Freq 1 4 11 2 6 7 3 8 14 ll[which.max(ll$Freq),] Var1 Freq 3 8

How to count the frequency of bundle of number using c#?

≡放荡痞女 提交于 2019-11-28 14:42:25
Can somebody help me to run this program using c#. This program is to calculate the frequency of the number, for example 12 appear 10x. Before this I try to sort all list number in a horizontal line. Then I compare the same number, then count++, but until know I can’t get the output. Thanks for helping. INPUT 46 31 46 9 25 12 45 33 25 12 12 12 28 36 38 28 25 12 12 9 36 38 36 36 12 9 36 12 12 25 28 34 36 36 9 12 16 25 28 44 OUTPUT 9 – 4 12 -10 16 – 1 25 – 5 28 - 4 31 – 1 33 – 1 34 - 1 36 – 7 38 – 2 44 – 1 45 – 1 46 – 2 Well, you could do this manually using a Dictionary<int, int> : var

PHP - count frequency of array values

十年热恋 提交于 2019-11-28 14:27:52
Is there a way in php to count how often a value exists in a large array? So if I have an array like this: $array = "1,2,3,4,joe,1,2,3,joe,joe,4,5,1,6,7,8,9,joe"; is there a way to output a new array that tells me (and sorts) which is used most and how many for each? $result = array( [joe] => 4 [1] => 3 [2] =>2 etc... ) I've seen the php array_count_values, but can this be sorted by most -> least? or is there an easier way? Thanks everyone! Michael Berkowski Sort them after counting them with arsort() $result = array_count_values(explode(',', $array)); arsort($result); Array ( [joe] => 4 [1] =

subset() a factor by its number of observation

久未见 提交于 2019-11-28 11:40:57
I have a problem with subset()function. How can I subset a factor of my dataframe by its number of observation? NAME CLASS COLOR VALUE antonio B YELLOW 5 antonio B BLUE 8 antonio B BLUE 7 antonio B BLUE 12 luca C YELLOW 99 luca B YELLOW 87 luca B YELLOW 98 giovanni A BLUE 48 I would like to obtain data where the three factors "NAME","CLASS" and "COLOR" compare at least three times in order to make a mean of VALUE. in this case I'll obtain: NAME CLASS COLOR VALUE antonio B BLUE mean because antonio is the only with three observations for each factor thank you so much Nik You can use the table