mean

Getting mean and standard deviation from groups in a data.frame

痴心易碎 提交于 2019-12-02 07:36:37
I have heart rate data in the form of a list with the four categories 1AS, 1CS, 1AI, 1CI each of variable size. I would like to output mean and standard deviations for each category in the list. I have the data in this format to calculate ANOVA and Tukey which I have done successfully but the mean has me stumped! Group HR 1 1AS 300 2 1AS 280 3 1AS 260 4 1AS 250 5 1AS 300 6 1AS 272 7 1AS 250 8 1AS 198 9 1AS 200 10 1AS 195 11 1AS 214 12 1AS 249 13 1AS 240 14 1CS 250 15 1CS 236 16 1CS 200 17 1CS 272 18 1CS 206 19 1CS 203 20 1CS 237 21 1CS 214 22 1AI 218 23 1AI 276 24 1AI 240 25 1AI 264 26 1AI 300

How to calculate the mean of specific rows in R?

十年热恋 提交于 2019-12-02 07:18:49
I have a data file as following example but much more larger names num Y1 Y2 William 1 4.71 7.4 William 2 3.75 8 William 3 4.71 7.9 Katja 1 5.83 8.5 Katja 2 5.17 7.1 Katja 3 6.08 7.4 Aroma 1 4.04 7.5 Aroma 2 5 6.9 Aroma 3 4.3 7.9 ... I have to calculate the mean for each 3 of the same names (first column) for Y1 and Y2. And then make a bar chart by the average of each name with Y1 and Y2, separately. So on the x axis I will have the names and on the y axis the mean. Could anybody help me with this? Jilber Urbina You can also use aggregate . See ?aggregate for further details. > aggregate(.

Calculate mean of each column ignoring missing data with awk

心已入冬 提交于 2019-12-02 07:13:39
问题 I have a large tab-separated data table with thousands of rows and dozens of columns and it has missing data marked as "na". For example, na 0.93 na 0 na 0.51 1 1 na 1 na 1 1 1 na 0.97 na 1 0.92 1 na 1 0.01 0.34 I would like to calculate the mean of each column, but making sure that the missing data are ignored in the calculation. For example, the mean of column 1 should be 0.97. I believe I could use awk but I am not sure how to construct the command to do this for all columns and account

calcuate the mean of trials for each subject in R

*爱你&永不变心* 提交于 2019-12-02 07:06:17
This is my first time on stack. I have tried searching for an answer but i can't seem to find anything relevant. I hope someone can help. I have a dataframe here: each subject does 6 trials, there are 105 subjects. I want to find the mean of 'skip' for 6 trials for each subj. Please can someone give me a hint as to how to start. > subj entropy n_gambles trial choice 1 0 high 2 0 skip 2 0 high 2 1 skip 3 0 high 2 2 skip 4 0 high 2 3 skip 5 0 high 2 4 skip 6 0 high 2 5 skip 7 1 high 32 0 buy 8 1 high 32 1 buy 9 1 high 32 2 buy 10 1 high 32 3 buy 11 1 high 32 4 buy 12 1 high 32 5 buy If I have to

Pandas: Calculate mean leaving out own row's value

大憨熊 提交于 2019-12-02 04:18:30
I want to calculate means by group, leaving out the value of the row itself. import pandas as pd d = {'col1': ["a", "a", "b", "a", "b", "a"], 'col2': [0, 4, 3, -5, 3, 4]} df = pd.DataFrame(data=d) I know how to return means by group: df.groupby('col1').agg({'col2': 'mean'}) Which returns: Out[247]: col1 col2 1 a 4 3 a -5 5 a 4 But what I want is mean by group, leaving out the row's value. E.g. for the first row: df.query('col1 == "a"')[1:4].mean() which returns: Out[251]: col2 1.0 dtype: float64 Edit: Expected output is a dataframe of the same format as df above, with a column mean_excl_own

Calculate mean of each column ignoring missing data with awk

自古美人都是妖i 提交于 2019-12-02 04:15:47
I have a large tab-separated data table with thousands of rows and dozens of columns and it has missing data marked as "na". For example, na 0.93 na 0 na 0.51 1 1 na 1 na 1 1 1 na 0.97 na 1 0.92 1 na 1 0.01 0.34 I would like to calculate the mean of each column, but making sure that the missing data are ignored in the calculation. For example, the mean of column 1 should be 0.97. I believe I could use awk but I am not sure how to construct the command to do this for all columns and account for missing data. All I know how to do is to calculate the mean of a single column but it treats the

Divide column of data by mean of the group

為{幸葍}努か 提交于 2019-12-02 03:37:19
问题 If I have a data frame, such as: group=rep(1:4,each=10) data=c(seq(1,10,1),seq(5,50,5),seq(20,11,-1),seq(0.3,3,0.3)) DF=data.frame(group,data) Now, I would like to divide each data element by the mean of its group. For example: group=rep(1:4,each=10) data=c(seq(1,10,1),seq(5,50,5),seq(20,11,-1),seq(0.3,3,0.3)) DF=data.frame(group,data) aggregate(DF,by=list(DF$group),FUN=mean) #Group.1 group data #1 1 1 5.50 #2 2 2 27.50 #3 3 3 15.50 #4 4 4 1.65 data1=c(seq(1,10,1)/5.5,seq(5,50,5)/27.5,seq(20

Harmonic mean in a python function?

爱⌒轻易说出口 提交于 2019-12-02 02:44:13
问题 I have 2 functions that give out precision and recall scores, I need to make a harmonic mean function defined in the same library that uses these two scores. The functions looks like this: here are the functions: def precision(ref, hyp): """Calculates precision. Args: - ref: a list of 0's and 1's extracted from a reference file - hyp: a list of 0's and 1's extracted from a hypothesis file Returns: - A floating point number indicating the precision of the hypothesis """ (n, np, ntp) = (len(ref

Harmonic mean in a python function?

偶尔善良 提交于 2019-12-02 02:43:05
I have 2 functions that give out precision and recall scores, I need to make a harmonic mean function defined in the same library that uses these two scores. The functions looks like this: here are the functions: def precision(ref, hyp): """Calculates precision. Args: - ref: a list of 0's and 1's extracted from a reference file - hyp: a list of 0's and 1's extracted from a hypothesis file Returns: - A floating point number indicating the precision of the hypothesis """ (n, np, ntp) = (len(ref), 0.0, 0.0) for i in range(n): if bool(hyp[i]): np += 1 if bool(ref[i]): ntp += 1 return ntp/np def

caffe中batch norm源码阅读

只谈情不闲聊 提交于 2019-12-02 02:39:07
1. batch norm 输入batch norm层的数据为[N, C, H, W], 该层计算得到均值为C个,方差为C个,输出数据为[N, C, H, W]. <1> 形象点说,均值的计算过程为: (1) 即对batch中相同索引的通道数取平均值,所以最终计算得到的均值为C个,方差的计算过程与此相同。 <2> batch norm层的作用: a. 均值: (2) b. 方差: (3) c. 归一化: (4) 2. caffe中batch_norm_layer.cpp中的LayerSetUp函数: 1 template <typename Dtype> 2 void BatchNormLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom, 3 const vector<Blob<Dtype>*>& top) { 4 BatchNormParameter param = this->layer_param_.batch_norm_param(); //读取deploy中moving_average_fraction参数值 5 moving_average_fraction_ = param.moving_average_fraction(); //改变量在batch_norm_layer.hpp中的定义为bool