- Hands-On Data Science with R
- Vitor Bianchi Lanzetta Nataraj Dasgupta Ricardo Anjoleto Farias
- 313字
- 2021-06-10 19:12:31
Measures of central tendency
What if you had to describe the center of a distribution within a single number? Most people would appeal to one of these three estimators: mean, median, or mode. Those are probably the most popular measures of central tendency. Let's begin by sampling data from an arbitrary distribution. Get into your R console and try the following code:
set.seed(10)
small_sample <- rnorm(n = 10, mean = 10, sd = 5)
big_sample <- rnorm(n = 10^5, mean = 10, sd = 5)
The first line is setting the seed number to work with our random number generator (RNG). Every time there's a need to rely on a pseudo-random process, the set.seed() function will make sure your code is reproducible (at least at some level). By setting it to 10 you will get the same numbers that I'm getting from the preceding code lines.
The two last lines are sorting pseudo-random numbers from a normally distributed variable. Call the rnom() function to sort variables from a normal distribution. Choose the number of observations sorted by adjusting the n parameter. Modify the mean and sd parameters if you want a mean and standard deviation different from 0 and 1 respectively.
In the real world, you will hardly know for sure what underlying process is ruling your data, but here we do know beforehand that our numbers come from a normally distributed variable with a mean of 10 and a standard deviation of 5 units. We gathered two samples. The one called small_sample has only 10 observations, while big_sample sums up to 100,000 observations. Even though both come from similar distributions we will see how estimates behave with respect to sample sizes.
- Creo Parametric 1.0中文版從入門到精通
- Ceph:Designing and Implementing Scalable Storage Systems
- 工業機器人應用案例集錦
- LAMP網站開發黃金組合Linux+Apache+MySQL+PHP
- 中國戰略性新興產業研究與發展·智能制造裝備
- Microsoft System Center Confi guration Manager
- 計算機組網技術
- 從零開始學SQL Server
- 青少年VEX IQ機器人實訓課程(初級)
- 重估:人工智能與賦能社會
- Hands-On SAS for Data Analysis
- 簡明學中文版Flash動畫制作
- Visual Basic項目開發案例精粹
- Hands-On Geospatial Analysis with R and QGIS
- 軟件測試管理