'; var adpushup = adpushup || {}; adpushup.que = adpushup.que || []; adpushup.que.push(function() { adpushup.triggerAd(ad_id); });
To find the mean and standard deviation from frequency table, we would need to apply the formula for mean and standard deviation for frequency data. For example, if we have a data frame called df that contains a column x for units and frequency for counts then the mean and standard deviation can be calculated as −
Mean = sum(df$x*df$frequency)/sum(df$frequency)SD = sqrt(sum((df$x−Mean)**2*df$frequency)/(sum(df$frequency)−1)) respectively.
Example1
x<−rpois(20,5)frequency<−sample(1:100,20)df1<−data.frame(x,frequency)df1
Output
x frequency1 6 42 7 263 1 864 2 65 4 526 4 617 1 558 4 239 8 3810 3 4011 8 5412 10 5613 7 7414 9 7015 7 5916 16 9517 4 2018 5 919 4 8220 9 45
Example
Mean=sum(df1$x*df1$frequency)/sum(df1$frequency)Mean
Output
[1] 6.55288
Example
SD=sqrt(sum((df1$x−Mean)**2*df1$frequency)/(sum(df1$frequency)−1))SD
Output
[1] 4.172396
Example2
y<−rnorm(20,25,3.24)frequency<−rpois(20,10)df2<−data.frame(y,frequency)df2
Output
y frequency1 27.44960 72 25.80343 53 22.64088 84 22.39061 75 24.55087 76 24.41826 167 23.24647 118 25.61511 99 22.42244 1110 26.77522 1411 21.89209 1112 22.95852 813 25.79808 1614 22.39654 615 21.20728 1216 28.25911 1717 26.67983 818 25.24964 1219 20.92070 820 28.25806 7
Example
Mean=sum(df2$y*df2$frequency)/sum(df2$frequency)Mean
Output
[1] 24.58724
Example
SD=sqrt(sum((df2$y−Mean)**2*df2$frequency)/(sum(df2$frequency)−1))SD
Output
[1] 2.284964
Updated on: 09-Feb-2021
4K+ Views
Related Articles
- How to create boxplot using mean and standard deviation in R?
- Plot mean and standard deviation in Matplotlib
- How to create a line chart with mean and standard deviation using ggplot2 in R?
- How to find the moving standard deviation in an R matrix?
- PyTorch – How to normalize an image with mean and standard deviation?
- How to find the moving standard deviation in an R data frame?
- How to compute the mean and standard deviation of a tensor in PyTorch?
- How to find the standard error of mean in R?
- How to find the standard deviation for rows in an R data frame?
- Generate random numbers by giving certain mean and standard deviation in Excel
- How to find the row standard deviation of columns having same name in R matrix?
- How to divide the matrix rows by row standard deviation in R?
- Variance and Standard Deviation
- How to calculate standard deviation in Excel?
- How To Calculate Standard Deviation in MATLAB?
Advertisem*nts