Вы можете использовать curve
. Установите freq=FALSE
в гистограмме, чтобы получить согласованные плотности на обоих графиках.
hist(Datadiff, breaks=40, freq=FALSE)
curve(dnorm(x, mean=mean(Datadiff), sd=sd(Datadiff)),
add=TRUE, col=2, lty=2)
legend("topright", c("empirical", "theoretical normal"), cex=.8, lty=1:2, col=1:2)
(Если вы хотите сравнить со стандартным нормальным, не используйте mean=mean(Datadiff), sd=sd(Datadiff)
, позвольте вашему dnorm(.)
по умолчанию mean=0, sd=1
.)
Производит
Данные
Datadiff <- c(-1.36785, -0.8615, 11.15045, -6.67, -20.52355, 8.738, -10.7468,
5.3824, -1.8901, 3.35195, 1.17, 7.3426, 2.81535, -0.9266, -9.56,
-3.72, 1.4636, 0.8247, 9.708, 7.332, -1.36575, 2.78635, 6.6637,
-1.15, -2.8612, 16.458, -0.05225, -3.0934, 1.9593, -3.87005,
0.44745, -6.62, -0.21815, -3.518, -1.0033, -0.03625, -4.64435,
0.06035, -11.48, -0.8453, 7.046, -2.46555, 2.7182, -1.52, -2.82975,
10.546, 5.00345, 2.1405, -2.21505, 1.5721, -3.3, 0.1231, 2.52765,
1.992, 0.6746, 1.98135, -5.9399, -2.1133, -2.63, -1.00055, 10.746,
3.4821, 5.57785, -5.86435, -4.4314, -2.19, 1.26305, 13.226, -0.01415,
-1.97, -2.1243, -8.4482, 6.576, 0.6822, 5.1788, -13.1987, -15.50855,
-3.46, -2.63695, 0.7464, -8.99235, -0.9024, -1.53, -1.79115,
18.142, -1.55485, -0.6195, -2.0266, -5.9687, -1.3856, -15.19,
0.89995, 6.794, -1.30305, 3.01845, -1.79065, -9.6228, -9.38075,
-4.41, -12.8267, 11.03, -5.538, -2.05115, -0.7859, 0.64765, 0.59,
0.66905, 22.618, -4.8083, -9.70915, 0.05, 14.3027, 12.16, 2.6874,
-6.7665, -5.7918, -0.4582, -2.1, 0.7593, 5.786, -0.1, -0.46655,
0.9485, -3.13245, -1.5221, -0.98, -3.1284, 5.59, 0.71075, 0.0399,
-10.7903, 1.46695, -2.84, 3.4016, 11.816, -1.17585, 0.8819, 2.6835,
6.622, 2.20255, -9.4959, -4.48095, 3.64315, -8.20225, 4.32, -0.65105,
-2.29, 0.83655, -0.1267, -3.63, -2.6286, 10.514, -14.12515, -2.22105,
-5.3065, 0.5826, -0.83785, -0.93, -5.0779, -1.368, -3.76125,
-3.98745, -2.09495, 1.72375, -3.24, -6.96, -1.4646, 14.172, 5.65645,
-0.1642, 0.89805, 4.756, -3.09, -0.8877, 7.708, 2.09225, -2.8971,
2.38945, 5.0624, -1.16, -14.36495, -1.9661, -11.1264, -1.3959,
-0.41, -2.64025, 7.174, -1.84085, -3.72375, 0.85585, -1.2126,
-0.11665, -10.58, -2.0293, 8.148, 7.2625, 0.04545, -8.20515,
-1.48135, 1.01, -5.7903, 8.228, 0.42545, 0.91175, -6.7525, -4.2698,
-0.8247, 2.0385, 0.13885, 0.05825, -0.46, -1.6177, -3.456, 6.84655,
4.6918, -12.01, 2.26105, 4.558, -3.69285, -3.33635, 14.49105,
-5.472, -3.08, -8.7, 1.145, 2.036, 5.9448, 16.65735, -10.8584,
-1.463, -2.23, -3.42175, 6.898, 10.17, -5.29375, 5.0088, -1.60595,
4.6765, 0.84, 1.64015, 16.99, 4.3742, 0.13515, -8.90405, -21.47555,
0.68, -4.42255, -0.2678, -2.3864, 8.04025, -3.71, 2.19665, 3.712,
1.64115, 4.2804, -1.3764, -0.40445, -3.19015, -1.33, -1.32835,
11.04, -1.1805, 0.68375, -9.1053, 2.03685, -2.34, 1.15855, 10.824,
1.21475, 0.06675, -4.02465, -4.0694, -4.32, -2.28975, -1.9953,
-0.19295, -1.06, 3.35215, 4.088, 23.66225, 0.2967, -9.3897, 1.2021,
11.164, 0.04115, 5.0418, 0.61605, -4.5202, -6.9, -1.7435, 9.59,
16.496, -1.46245, 5.7376, -10.584, -3.12405, -3.51, 2.38375,
11.448, -2.29725, -2.88615, 1.0015, -1.2928, -1.75035, -4.19,
2.1016, -3.798, -2.93645, -1.7545, -3.41025, -3.63075, 2.9, 4.6095,
6.408, -4.30895, 2.3146, -4.52, 10.50445, -2.098, -2.4021, 1.10155,
-2.6391, -3.6665, -3.31, 2.4025, 2.50105, 7.19, 3.87565, 4.677,
-6.2623, -1.57665, -7.88, 5.2101, 8.04, -2.66635, -2.2253, -4.58515,
-0.60955, -4.39, -3.7346, 11.272, -1.27, 1.84275, 1.83205, 3.858,
5.94525, 5.76705, -16.2386, 2.22515, 1.7, -0.95415, 9.18425,
-2.31855, -5.3029, -5.81, -1.855, 2.764, 7.3874, -0.70365, -2.05375,
-4.4283, -2.35745, -4.41, -2.5129, 13.748, 1.7395, -0.749, -4.55095,
1.8968, -0.27075, -2.95, -7.26945, 10.428, -5.40605, 15.20915,
-2.784, -0.1784, -4.16, 4.07175, -5.148, 0.11945, 1.46045, -0.48565,
7.0287, 8.256, -17.613, 11.13375, -2.70515, -0.9968, 2.86, -1.4756,
4.118, 1.7521, 2.59145, 5.16895, -4.4972, -0.76965, 4.41, -1.8904,
6.998, -2.9081, 5.0354, -6.04255, -0.3704, -0.81, -2.53285, 14.8,
-1.0575, -5.91505, 6.634, -4.70575, 2.043, -1.27255, -8.91095,
3.88775, -2.25, -1.77935, 5.432, -3.40435, -3.9124, -2.3, 0.96565,
5.328, 0.36355, 19.79725, -2.1662, -0.2948, -1.1552, -16.34,
5.8247, 11.214, 3.5192, -3.02445, -10.64685, 0.83135, -8.92,
-1.71995, 3.6046, 10.188, -4.97815, -0.91455, -5.63525, -5.0419,
-4.6, -6.17105, 2.306, -3.44855, 1.2718, -1.4427, 6.47015, 1.48,
0.74975, -3.06855, -13.5388, -4.50495, -4.53, -1.4975, -0.43,
1.3575, 0.8793, -3.3098, -9.87755, -11.3284, -1.83, -8.5954,
-1.848, 1.30625, 1.249, -7.5807, 3.7953, -1.27, -3.96645, 13.7,
1.0634, -11.49595, -6.4759, 1.08715, -3.13965, 3.6715, -3.51635,
0.3501, -1.21, -12.3292, -5.244, -0.26525, 10.1788, -7.49, 6.02935,
1.814, 2.3713, -0.39985, -11.26815, -1.36595, -12.96, 0.0857,
0.74145, 18.55, -2.38335, 0.3384, -9.6309, 0.291, -7.78, -3.44695,
11.564, 1.2367, 3.91925, -1.85795, 0.3392, 2.01905, -7.84, 2.8503,
7.83, 3.67985, 3.64675, 1.617, 11.6997, -1.49, -3.83785, 1.014,
-6.08455, -0.76365, -6.99, -4.4902, 6.814, 2.4675, -0.02565,
-2.9331, 3.566, -2.22, 4.65, 5.50915, 10.714, 5.31355, 12.2042,
-6.66715, -1.7102, -0.74, 1.00215, 6.898, 3.9806, 1.1077, 2.27175,
3.76795, -0.52, -0.00055, -1.6705, -1.009, -3.32, 3.38085, 7.998,
-0.08525, 8.21195, 0.3263, 2.98075, -0.15, -2.27235, 0.6842,
0.331, 0.52635, 1.62, -5.1443, 12.1, -3.1422, 0.49035, 1.93415,
-5.7134, 1.4213, -0.95, 0.3376, 15.324, 0.31755, -0.85435, 4.76065,
-12.2947, -2.5269, -4.99, -1.2247, 13.384, -3.5472, 7.58955,
-7.73185, 0.6516, -2.69, 18.2267, 2.918, 3.01765, 0.41325, -2.63,
4.48095, 7.258, 3.0684, -2.627, -3.66735, -0.69105, -2.36, -0.2575,
4.116, 4.64, -0.2985, -3.0891, -0.4855, -0.7349, -1.09, -0.42185,
4.798, -4.2935, 1.07795, -8.2692, 4.1488, 1.3, 9.23025, 7.664,
-3.6629, -0.2892, -1.00205, 9.078, -5.7087, -2.2173, -4.10745,
19.021, 0.37, -10.85725, 7.49445, -4.3211, -0.9439, -2.53, 0.39335,
10.89, 1.67195, 1.0579, -4.9017, -9.7918, -3.2305, -7.6, -3.75035,
21.88, 0.13705, 2.3085, -4.005, -0.9845, 1.91705, -0.15, 3.4676,
-0.38, -6.72005, -4.76505, 5.66655, -4.0637, -1.45, -1.8605,
6.99, -5.0224, 5.5668, -13.7662, 4.26235, 2.652, 5.21815, 9.5853,
-3.2439, 1.78745, -1.33, 0.1856, -0.044, -2.47415, -1.04385,
-0.3808, -4.34405, -2.5727, -9.83, -5.4506, 5.372, 1.02915, -0.7857,
-8.57975, -1.42805, 4.43, -6.5657, 7.91, -3.32815, 6.21025, 3.58325,
-0.42435, -0.7735, -0.6028, 5.08605, 13.6661, -6.7, -1.5533,
10.262, -6.22135, -0.14045, -3.16, 0.67445, 6.504, 0.56145, -0.5133,
-9.1829, 4.3799, -4.0569, -1.06, -3.63245, 15.42, 7.43265, -6.28715,
-7.9766, -2.49665, -8.25, 1.37875, 4.91885, 11.582, 0.71515,
13.42315, -2.3754, -2.0952, -2.09, -3.14205, -0.48, 4.44755,
-6.32835, -11.80655, -4.15875, 3.8, -0.52185, -5.02335, -4.52365,
3.87375, 2.42, -2.80275, 1.894, -0.0854, 3.6338, -2.7309, 1.09985,
-2.8359, -1.16, 0.14165, 13.65, 2.30475, 6.0335, -2.83645, 6.5708,
-3.6, -4.524, 2.02, -3.8586, -11.0334, -7.07725, -2.6752, -6.39
)