R查找高斯密度分布的半高处的全宽 [英] R Find Full width at half maximum for a gausian density distribution

查看:145
本文介绍了R查找高斯密度分布的半高处的全宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集(来自现实),如

I have a data set (come from reality) like

a<-c(12.4314579038074, 30.1197692762127, 31.8986680511062, 21.5000657793742, 
24.2201952026304, 21.4083286311931, 30.543892400514, 11.3243039196637, 
18.6629847817322, 68.5846251690826, 8.15853135278713, 20.0269675183568, 
23.761746451965, 15.7934365856289, 20.2308964167179, 16.1739058219803, 
16.80324393405, 17.8825865979249, 11.4033338599819, 24.6766819397457, 
21.6401012626284, 34.9473576269376, 21.2387163543256, 38.8393540982342, 
11.1324409747932, 27.9691456747847, 35.0247764515163, 25.2955953655814, 
20.1144847120957, 21.601935342838, NA, 37.0382391253826, 23.0768070922688, 
29.7978557208652, 25.5629412341385, 52.3688195218551, 24.3278804498841, 
24.5473987167943, 18.7003825260279, 7.59034179685435, 30.3494564815945, 
11.9464422720518, 31.1286124512956, 35.6013073091488, 59.7732211526442, 
18.1103630173406, 23.6991128199505, 35.0041638638631, 32.3290441334575, 
9.96009633874818, 31.9439199749795, 17.2338813393175, 19.4703069779573, 
40.0710364677356, 21.9784578364056, 14.8391748404154, 36.699595515976, 
8.23000952339805, 29.3936574804397, 16.608043366678, 31.8893140469488, 
25.0034860781714, 5.85410045445957, 33.6738722502197, 19.8719119513059, 
16.5220779562036, 18.5998514048289, 26.2005902882878, NA, 24.6566247442218, 
27.0333844562812, 14.886428829687, 17.5724702275547, 26.2137775245073, 
19.0507021982012, 10.9566296835514, 26.6958883379168, 7.96499401119146, 
26.1859738026908, 17.660793443073, 24.2581780545893, 13.2116252996823, 
20.8404415084083, 13.9759556218075, 8.08290201929875, 19.577431906635, 
30.8617872452287, 17.659162045328, 19.6553312413463, 54.5228181855605, 
8.61384429381566, 8.57902103633537, 14.3833198356842, 44.6520928899702, 
50.1684992597442, 19.1839092769506, 14.1859756348872, 22.319616459382, 
7.04281719040295, 19.9734034824111, 26.5179176521408, 13.1611965717225, 
16.9098287156019, 28.9883554716117, 26.0468146958332, 29.6763235030978, 
48.7345046631538, 38.4339027762459, 31.2090734875574, 15.9385304470886, 
12.8921108018056, 10.9673039456914, 10.3743768429606, 25.9387376803067, 
NA, 11.5544889726556, 18.7480106738499, 13.2374072159457, 16.0463683223854, 
13.6394902895386, 19.6499476784153, 19.6653905961478, 22.6713289483346, 
30.0530150121339, 39.2413167843811, 29.7476825791523, 67.017937817938, 
6.75394239192403, 13.8315465658099, 15.6479984367677, 11.6595078158563, 
16.6153046740276, 29.1944136335659, 20.0699193532974, 23.0964604145297, 
16.4642724437565, 31.4384175748718, 24.9125640407848, 25.0969240666473, 
32.7585005489893, 28.2005135471151, 11.6928832972854, 29.0925157165188, 
27.1449795674534, 19.7174609825609, 11.3155221077222, 13.8725373098617, 
10.4058292934838, 20.5471528311623, 24.593775927458, 24.5992797334339, 
25.7621705532288, 19.429523059737, 23.7267657702523, 26.8378886664471, 
33.0405101400995, 33.8244308994044, 23.923384237542, 10.1422998835261, 
8.36171095318636, 31.7070531272099, 29.7732770732215, 24.8822351146394, 
5.02000303147286, 12.8561338422933, 19.9693656971446, 19.599345558469, 
22.1630854796563, 22.3226724168097, 32.0046288304837, 9.97036087568324, 
17.9532401992864, 27.5200598557606, 18.2493582809349, 19.516614679827, 
8.73100033494884, 9.92568752683278, 36.111580524921, 26.5447538548956, 
31.5801048764258, 30.7784315713327, 43.9917658205537, 5.88518831155849, 
38.6914615372257, 22.4450167569794, 38.471255777786, 17.8759146100263, 
42.1237669506763, 40.8120103320423, 50.9620878359755, 24.8723162387534, 
28.281137488787, 21.1047200631107, NA, 35.6445176565107, NA, 
22.4329601563967, 17.1865147962927, 34.6207419910748, 27.488098898296, 
40.647159426457, 49.0566470559664, 25.2404304347901, 28.9937264113381, 
14.0652751682648, 16.8982448551594, NA, NA, 38.7092724982844, 
51.3923484671426, 56.2948963516975, 17.6784549803966, 21.346370069203, 
40.5568626421931, 11.5473392102776, 29.8901196029765, 55.8045368249135, 
32.5629692658593, 15.7151398771352, 50.69539004787, 28.6630956503548, 
NA, 33.745363485143, 30.1793575796192, 31.5239871763176, 23.413715020835, 
28.4068815777865, 26.628933941261, 28.8040299272661, 38.7590176170059, 
28.5895707604946, 27.3163626291958, 22.4432050319593, 22.8717709770244, 
15.5769117905467, 16.6205562869212, 19.6461009184912, 28.112145862862, 
22.4817869475301, 11.9911595195158, 27.7864754526246, 32.110827889238, 
38.6601905078103, 26.5431928219843, 37.5022713181254, 20.1507313327997, 
26.1701491671608, 13.5713776019221, 24.9836498596017, 21.2698715590683, 
25.0155871471049, 33.7177860466273, NA, 13.9496573767241, 16.1150625739034, 
16.6382037385219, 38.0327684962353, 15.4336346869134, 28.2741877552971, 
18.3988010783219, 46.8872039734549, 39.6400155384279, 42.2346150067755, 
23.8766379243586, 20.6388991126635, 13.4323233360809, 25.7328268912762, 
18.5198704804179, 35.1253893334279, 50.4960266232654, 22.8606920846386, 
16.1816315814691, 24.404001970632, 12.7156971608144, 16.1868830629463, 
30.2499403084286, 49.7785508137954, 33.2123299816736, NA, 12.9230946451066, 
7.08427169664578, 10.0671158815277, 19.7294071616146, 30.8425354787526, 
38.3145455434934, 16.7030543796463, 12.1822921506718, 24.8419226234385, 
NA, 19.6863906566313, 24.8415166763613, 27.2222764218966, 25.4530639943619, 
24.3584061455177, 21.6932253013582, 26.6862568289173, 10.4439641151796, 
8.16828313448626, 24.7764905211242, 24.0153889448978, 42.27494669877, 
23.1024890766068, 12.5421984383058, 28.126105527251, 11.7477790609559, 
37.8210140575854, 16.2510203840877, 29.5179896530944, 19.767113140873, 
21.180255311345, 50.1326402088336, 46.9411426142246, 22.1825770399621, 
38.3217563655723, 32.8198922751461, 18.1215432904772, 36.7957509446084, 
31.0953183824079, 41.2683134903454, 27.3369679280893, 18.6814450240623, 
40.9365261829113, 31.3995794910782, 45.3773497997797, 29.7809299163648, 
25.6494347188067, 12.2371700316698, 24.028235743912, 20.2190137194663, 
63.5048123597575, 19.4212679708406, 28.2540327945574, 15.6824059299007, 
26.4502584835429, 25.6747019832926, 21.3448542479901, 21.5398949527062, 
15.0453039478043, 15.435237823288, 21.9433429596872, 22.4942864667832, 
19.2699097293276, 13.7352833513297, 17.2542472110831, 47.1631828020397, 
43.0112020075035, 16.3372108879913, 24.2918076279655, 26.4439880171655, 
23.1117247311131, 36.6759437723188, 43.6176498793953, 32.0130676806535, 
30.6326404095052, 10.8268556221906, 52.7653604760821, 8.91595447346234, 
13.193539457832, 7.68418008204124, 15.449010979906, 30.9584089126334, 
51.9422244686175, 15.8458479496976, 14.1047956442756, 17.5191070473658, 
31.7011704471313, 14.8239075593942, 26.6479556968534, 12.7304068904724, 
21.6484498326962, 18.5454691264783, 19.7417604612319, 17.4178392306296, 
18.6961734797299, 16.6762708630409, 25.5769497729958, 20.4324858725377, 
48.0108296588978, 22.3873783217253, 61.8180303957998, 60.9275917236957, 
33.6030207132321, NA, 35.5927559357877, 20.7557420025042, 45.0952627270979, 
33.7073022209601, 23.7276388907278, 44.0279966951556, 18.4465734471124, 
35.376096916925, 11.049064991332, 6.38266176887074, 27.770464922835, 
14.3280667570411, 18.2895352437716, 11.8697485564632, 11.9115403522214, 
23.8995147554712, 22.9524551093465, 41.5537350356802, 8.32663490566077, 
41.2800566378259, 37.616909008102, 13.9220837749745, 53.4996016880608, 
38.0527622385737, 36.2584535594006, 31.3674093196625, 24.2902569424465, 
21.440394745746, 32.2127828476281, 22.1521432796998, 16.4186950681111, 
10.4937514476589, 32.4071007810483, 24.498045100507, 25.4241096355652, 
9.73946952507465, 21.4041253422142, 28.8926165924432, 34.512959841434, 
30.0571573052611, 22.4907629383951, 20.2211187443641, 16.8118098933704, 
23.5285775050765, 39.4440966466874, 33.2825067066343, 36.8830992125003, 
21.1282934201697, 18.6272972241037, 15.3140799736706, 40.0011498958142, 
10.0182747888065, 15.3706553616215, 41.9509134815123, 22.303622817723, 
19.2424468127472, 35.0099989943938, 16.6900077828908, 23.4847012508485, 
22.9601479739565, 13.7682136158064, 20.0454049113627, 27.7179470144016, 
43.7485548044574, 27.7379261226753, 32.1756980668739, 32.8029836110017, 
30.2392324390705, 31.3156918552083, 32.1847331854615, 20.5297104164335, 
50.9569341153107, 42.6081618367459, 18.636321910844, 12.4308178035891, 
26.6917378844734, 5.76426461481125, 25.0767930273219, 24.2457959380206, 
11.3931924451717, 19.077483646119, 12.0287714622052, 13.8729173763677, 
15.940072198383, 31.9320584106662, 16.1008550559317, 35.8212131776284, 
15.2435052118809, 3.44730091866671, 13.2863037128651, 33.2528958365812, 
23.0426972188497, 31.9040632994659, 21.2588079706295, 9.56009250089547, 
37.0841912585872, 21.7862379679352, 12.5945799997629, 11.9204901690358, 
34.2003866802345, 22.1076801376058, 14.7504409350283, 12.2988895790339, 
37.4743876245349, 4.40070781544351, 27.47718305659, 45.3352312111182, 
44.7238582623121, 30.1074154853725, 25.3584692242304, 18.2894817200095, 
39.6668104206319, 15.1780135384362, 8.90023187782675, 12.695608490357, 
7.97231909106364, 18.0254627826149, 37.1330399717644, 40.3814619400626, 
15.7530424414729, 26.4871843271195, 11.3849905569825, 14.4310436716623, 
15.7889776729542, 15.3189979064802, 8.14775366334019, 21.3763917473048, 
19.4271587027591, 8.17415804490136, 8.56927307423665, 9.9955524608618, 
15.5450134422331, 10.823091946932, 8.44824243438286, 4.43490646514755, 
5.47934855653405, 7.23626623411468, 25.3530745380911, 24.3179916472365, 
18.7488727821045, 32.190181880216, 20.3023247566628, 16.5179670640049, 
13.5756284381254, 16.6579681190254, 31.1737441837392, 26.4445566581656, 
19.0657083835412, 9.02756346026971, 13.8198542042488, 19.5572751031157, 
15.9815268564019, 21.2096031612745, 23.1965642826673, 22.9413587497691, 
54.0401136217987, 14.3385183237915, 9.56798831205209, 16.8699681496442, 
15.9839479181869, 13.6433809778083, 11.6657052013993, 33.293408496818, 
22.5090700291058, 19.3612583830867, 14.4092661794021, 17.9685233644732, 
5.41812657103551, 5.85301279046166, 16.4916538514991, 32.8886078034163, 
42.5319945344839, 6.96221532796392, 10.8250789766828, 14.0362434679265, 
13.4236572258544, 8.18430437430949, 8.49810493010364, 19.9805220462551, 
7.99530774694417, 7.7257996525705, 29.0351171682388, 4.33760495695362, 
17.6928347163945, 10.1142902669032, 6.06249165375458, 4.74850565714552, 
17.9833699614403, 67.2065822391264, 17.3347810074396, 16.5017818986004, 
23.7514924365845, 37.1851342775933, 21.5618045488646, 30.6788445864795, 
17.1035593022782, 8.42714630237048, 13.4006384220441, 22.1238974112126, 
4.48001569435593, 23.9658029257865, 6.23907173530781, 26.877146564602, 
15.3003261751959, 12.0485155125301, 4.32690092924821, 7.01214075444578, 
16.1791317461962, 13.0728785273578, 7.63109083309118, 16.9972980214674, 
8.30295245274037, 8.7770203067377, 5.67480760942735, 21.3961492360836, 
13.9550988566784, 11.0242554066141, 19.4382013687556, 8.62975825045164, 
11.4164507143039, 8.34586383704729, 3.72091720855698, 8.97296101792361, 
29.8903858240922, 2.32504604168462, 25.8164695705562, 22.061057520145, 
3.4803762605344, 48.3170810944539, 80.6701146444289, 15.0833362411301, 
10.8924796349525, 17.4918647333209, 12.6115824242011, 34.3062414327012, 
8.287617251304, 15.4831104293005, 15.1485432894085, 4.5184565189416, 
3.59999333029852, 3.66865483560892, 29.9677778375668, 34.4509226015574, 
32.5918276015502, 10.6060279795247, 19.7913453571932, 28.266459587366, 
19.6122992848655, 9.57523706552828, 9.04738999444933, 5.25824593606435, 
6.55473931337678, 18.7449471987719, 9.27943740426736, 9.54703445889029, 
3.43647048217306, 17.6920729261708, 25.3789409935332, 43.0995071399241, 
15.7776713016551, 5.96178566715426, 7.04629857379702, 40.3659823950032, 
20.3090509981183, 14.0833358445997, 16.9522805698219, 40.8824485009689, 
21.6424431028975, 11.0653580862889, 9.52636056796406, 13.2093186951614, 
11.180272835061, 28.7154955728657, NA, 8.29026375001596, 30.2969947814111, 
29.9276371600909, 8.84477707628671, 34.8718762912212, 33.7483835972703, 
34.2724400573937, 10.0767436084755, 15.4873945381221, 26.7642017413928, 
51.0184704255941, 13.3969350777478, 26.0049124989409, 24.4542678955175, 
15.3254947646799, 27.6832229022455, 30.8718044931518, 19.7152850968778, 
39.1363812987409, 3.27215259879083, 15.0217151381093, 5.81934884447124, 
30.0083825574588, 12.8728048546551, 39.6060296728825, 25.1813163765464, 
44.1868459510693, 56.2542657142314, 12.8977291749907, 45.114989387575, 
48.6359576292684, 13.6879551288472, 20.8800721437086, 21.1718129052816, 
18.1109547325148, 30.6495392873229, 16.6778394456472, 28.4355940709725, 
40.2732033692905, 16.0324459813519, 21.6715649249579, 21.5745121789595, 
41.0491368236404, 23.1897670150996, 38.6763733544082, 28.2952020362427, 
14.9775146624242, 17.0529816156432, 21.3182907083993, 58.5980139524611, 
34.1182365536438, 66.2307408341237, 10.0250215641074, 19.2484140780393, 
36.1794806395077, 13.3664708666649, 43.0162594869992, 14.6768584506211, 
14.3681241887621, 21.6991390370549, 19.3686839558787, 18.0066235564319, 
26.4208759599778, 8.02575642257494, 6.45796803589213, 11.3672996291157, 
14.4629853700209, 22.159295359166, 9.48235040640243, 28.0483346879341, 
18.7791600825367, 19.7502447289479, 6.97410234941009, 15.552802250357, 
13.3419372146528, 27.5115005559368, 6.97909930700005, NA, 7.05260541598179, 
35.7722821782854, 36.7903676155688, 49.4540597647083, 25.2948226594315, 
10.1520912497611, 13.4494123507724, 4.619799633406, 22.0861395692476, 
14.2039171171824, 26.9952012939039, 9.36273697960081, 36.3471521574781, 
17.1331241745133, 36.2783284115396, 23.2266827910025, 32.5915815527522, 
31.2871980610003, 16.0233005517923, 23.600172770202, 18.2722026855851, 
25.6024146453473, 20.9881450301547, 14.2228275030676, 9.41424245694267, 
10.816472087346, 9.04870233666866, 28.2892191586388, 35.0753624317, 
20.804631336334, 16.4586859700612, 18.4239500923344, 6.3386546363293, 
6.49433203538962, 9.82250938112426, 21.4723821170409, 17.8374467840815, 
35.0187346487592, 16.6827994374155, 10.1793943910258, 20.5493611125065, 
15.7669268485395, 11.1870666093615, 9.10959979062923, 18.6380321376242, 
10.0704206578543, 12.5407783691327, 34.8148633389888, 28.084370623971, 
4.13200285250811, 30.1892030192568, 55.4882769575542, 35.7133359116889, 
25.7829535423758, 24.3427532329746, 26.1373088326654, 12.8559165605457, 
13.4759287411954, 45.973341582547, 16.3120873890776, 11.9948065461913, 
7.92837707316941, 32.2209508527388, 17.166801717345, 22.4859349413392, 
30.5941859604216, 10.9778157606133, 70.2748062001235, 21.5991697951828, 
25.7831959948602, 1.43209618416462, 56.1235033644788, 24.4226310541958, 
20.9224949050978, 36.3840952118939, 35.7276159685088, 37.6827740210086, 
23.5299198435553, 13.6851209030389, 25.5335190230571, 45.4755511169848, 
14.6080811491954, 14.2316318552737, 13.339561577062, 45.9187643234812, 
24.9990910216492, 8.29483649953895, 23.5418927144432, 37.7936234851124, 
12.70652449092, 28.7414210264296, 13.77474354302, 40.7185271359513, 
13.2888748806108, 18.1136413518116, 48.3746826507517, NA, 12.1384015733918, 
19.9658506537594, 13.1441032684027, 26.6795046532402, 11.9603093870165, 
4.66530121380388, 19.473270220492, 27.5276898686734, 18.937349603982, 
18.8155543455793, 13.4728520043676, 12.7940590426415, 16.6697994573555, 
21.3583533715887, 42.5731745705282, 11.3851614825814, 16.7458126574673, 
15.6740255937648, 16.6703517164138, 62.8179873937814, 21.6206878297099, 
46.9610219140348, 53.40123532387, 40.092219470411, 37.8805373833002, 
28.6457545722248, 20.6694999165836, 17.8624286041768, 28.5861053418492, 
17.9939250048543, 37.3414460735396, 16.09898942567, 51.9310125086572, 
19.7924905322066, 14.0565954639482, 46.864231594175, 20.7054727206452, 
51.6787725408675, 37.6405519392879, 23.8641295161859, 14.714628026623, 
10.3999093904835, 28.3638116333964, 29.5945043539217, 15.3139943100935
)

比起我用ggplot绘制曲线密度

Than when I plot a curve density with ggplot

density_plot<-ggplot(data =a, aes(x=truc))+
                    geom_density(binwidth=5, alpha=.5, position="identity")

我得到了这张图

我有2个问题:

  1. 它看起来像是高斯...抽鞭工具,我可以用它玩吗?
  2. 我希望(如果可能)确定半峰全宽(FWHM),以确定有趣的模型空间(来自仿真).

我从mixtools包中找到了normalmixEM,它是由制造而成的(我不确定该如何工作).

I have find normalmixEM from mixtools package the made that (I'm not sure to understand how it work).

fit = normalmixEM(a)
Erreur dans if (any(s.hyp == 0)) s.hyp[which(s.hyp == 0)] = runif(sum(s.hyp ==  : 
  valeur manquante là où TRUE / FALSE est requis

计算FWHM的好方法是什么?

What the good way to calcul de FWHM ?

谢谢

E

推荐答案

对我而言,该图看起来根本不像正态分布.分布看起来右偏.无论如何,这无关紧要:

That plot doesn't look like a normal distribution at all to me. The distribution looks right-skewed. Anyway, that's not relevant:

d <- density(na.omit(a), n=1e4)
plot(d)
xmax <- d$x[d$y==max(d$y)]

x1 <- d$x[d$x < xmax][which.min(abs(d$y[d$x < xmax]-max(d$y)/2))]
x2 <- d$x[d$x > xmax][which.min(abs(d$y[d$x > xmax]-max(d$y)/2))]

points(c(x1, x2), c(d$y[d$x==x1], d$y[d$x==x2]), col="red")

FWHM <- x2-x1
#[1] 25.71115

这篇关于R查找高斯密度分布的半高处的全宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆