# Find distribution and transform to normal distribution

I have data that describes how often an event takes place during one hour ("number per hour", nph) and how long the events last ("duration in seconds per hour", dph).

This is the original data:

nph <- c(2.50000000003638, 3.78947368414551, 1.51456310682008, 5.84686774940732, 4.58823529414907, 5.59999999993481, 5.06666666666667, 11.6470588233699, 1.99999999998209, NA, 4.46153846149851, 18, 1.05882352939726, 9.21739130425452, 27.8399999994814, 15.3750000002237, NA, 6.00000000004109, 9.71428571436649, 12.4848484848485, 16.5034965037115, 20.6666666666667, 3.49999999997453, 4.65882352938624, 4.74999999996544, 3.99999999994522, 2.8, 14.2285714286188, 11.0000000000915, NA, 2.66666666666667, 3.76470588230138, 4.70588235287673, 13.2727272728677, 2.0000000000137, 18.4444444444444, 17.5555555555556, 14.2222222222222, 2.00000000001663, 4, 8.46153846146269, 19.2000000001788, 13.9024390245481, 13, 3.00000000004366, NA, 7.36000000006855, 1.61137440758472, 1.50000000000873, 3.36585365857481, 22.3750000003256, 10.8387096775008, 2.92307692305075, 3.48837209304214, 5.17647058827074, 37.6666666666667, 1.17647058824335, 7.45454545462435, 36.2352941171508, 6.82352941167125, 2.22222222222222, 6.13333333333333, 11.4285714286665, 42.7058823523563, 28.1052631584975, 18.3333333333333, 1.24999999999091, 5.1034482758211, 1.82857142855926, 1.30693069306629, 3.22222222222222, 17.2800000001609, 10.5714285715165, 7.81818181826456, 3.14285714288328, 4.05194805197256, 3.6, 23.0909090904203, 0.249999999998181, 10, 27.3043478258106, 2.49999999998181, 2.00000000001663, 9.14285714293317, 4.74999999996544, 29.3999999996577, 16.9999999998021, 15.7777777777778, 1.74999999998727, 3.46666666666667, 2.45161290324422, 2.05231388331614, 2.60000000001513, 15.4054054053569, 4, 12.2222222222222, 2.46153846151642, 8.15384615399219, 2.23529411761644, 15.1111111111111, 0.23529411764867, 10.5454545455661, 17.5714285715747, 2.3030303030303, 1.37931034481651, 8.32000000007749, 5.1578947368105, 24.1999999997183, 15.4782608694085, 21.8749999998408, 2.74999999997999, 9.91304347823578, 3.86206896548623, 1.16959064328441, 2.84210526319272, 12.857142856929, 4, 3.69230769227463, 2, NA, 1.88888888888889, 15.4285714283148, 0.222222222222222, 6.16666666666667, 13.1034482757569, 3.19999999996275, 4.87499999996453, 2.88000000002682, 5.12499999996271, 26.6666666666667, 9.75000000014188, 17.2048192770602, 1.99999999998545, 1.65517241377981, 3.16666666666667, 2.23529411766237, 6.82352941181143, 2.74999999991996, 2.99999999997817, 11.4929577463281, 1.59999999998137, 8.65116279074452, 5.69230769240964, 13.7777777777778, 0.222222222222222, 10.6000000002468, 13.91304347812, 2.75862068963302, NA, 4.26666666666667, 5.64705882356808, 2.74999999997999, 15.047619047619, 16.6666666666667, 1.49999999998909, 4.62499999996635, 5.71428571428571, 1.83206106868927, 2.44444444444444, 2.4, 3.9999999999709, 2.33333333333333, 3.20000000007451, 5.931034482711, 7.14285714273835, 14.7272727274286, 0.352941176465754, 8.40000000019558, 10.1250000001473, 2.66666666666667, NA, 2.66666666666667, 4.7058823529734, 4.83333333333333, 9.31034482751146, 24.5882352937809, 2.13333333333333, 10.1739130434525, 5.56521739124801, 2.12658227848728, 1.88888888888889, 5.80000000013504, 7.14285714291654, 1.71428571429997, 1.99999999994179, NA, 5.00000000007276, NA, 0.129032258062578, 8.22222222222222, 7.16666666666667, 4.13793103444954, 2.82352941178404, 3.07692307697818, 4.00000000004902, 4.74999999986176, 9.75000000014188, 20.1333333333333, 2.66666666666667, 6.78947368416893, 1.46666666666667, 1.73195876289076, 4.76923076931619, 2.88888888888889, 7.4285714286332, 5.2, 3.384615384676, 4.7727272727399, 6.59999999992317, 11.4545454546667, 1.41176470586302, 11.1999999998696, 6.08000000005662, 4, 4.71428571432492, 5.00000000004158, 6.8, 6.83870967747072, 14.2500000002074, 5.49999999983993, 2.4, 4.71910112354612, 4, 1.72185430463842, 2.44444444444444, 4.30769230776946, 6.30769230780528, 3.53846153852491, 4.35294117641097, NA, 5.99999999990022, NA, NA, 7.42857142857143, 10.1333333333333, 6.79999999992084, 5.54838709681587, 1.83333333333333, 7.06666666666667, 2.9090909091217, 10.8000000001006, NA, 2.13333333333333, NA, 5.09090909090909, 4.21052631570563, 4.00000000003326, 4.28571428571429, 4.28571428574992, 2.49999999998181, 2.76923076928037, 4.99999999985448, 3.87500000005639, NA, NA, 12.2105263159391, 5.44444444444444, 2.6249999999809, 3.74193548389907, 3.28571428574161, 4.88888888888889, 9.33333333333333, 4.21621621620295, NA, 0.8, 4.5306122448549, 4.14285714289159, 3.1137724550985, 0.266666666666667, 5.27272727261567, 1.84615384613731, 8.36363636372488, 2.42857142853104, NA, 2.42857142853104, 8.28571428578318, 1.64705882350685, 8.2, 6.88888888888889, 1.74999999998727, 7.6, 3.33333333333333, 6.24999999995453, 9.56521739120752, 4.93333333333333, 16.4, 2.53333333333333, 7.2, 1.33333333333333, 3.3962264151018, 2, 9.38461538453135, 1.57142857144164, 3.45454545458201, 5.37499999996089, 7.74193548375467, 3.38461538458508, 7, NA, 4.54545454545455, 14.5, 1.93939393939394, 4.33333333333333, 4, 6.58823529402741, 2.90909090902933, 3.32530120480995, 25.6666666666667, 2, 6.54545454545455, 4.4, 3.54378818739119, 1.62499999998818, 4.22222222222222, 2.53333333333333, 14.6666666666667, 2.96296296296296, NA, 3.00000000004366, 16.1999999998114, 1.55555555555556, 3.11111111111111, NA, 4.8, 3.99999999997339, 4, 6.37499999995362, 2.7999999999674, NA, 32.8, 2.49999999998181, 11.0561797754255, NA, 2.75229357793903, 1.7142857142572, 7.66666666666667, 7.28571428577487, 2.36363636358633, 2.14285714287496, 6.27272727274387, 3.62499999997362, 19.6666666666667, 1.71428571427431, 6.60869565210701, 5.57894736838687, 5.84615384610149, 3.03030303030303, 1.33333333333333, 4.87499999996453, 4.71428571432492, 4.74418604653732, 13.0588235292329, 3.12500000004547, NA, 3.37500000004911, 2.41525423729648, 2.37499999998272, 4.54545454550265, 6.28571428576655, 2.55555555555556, 3.17647058819179, 5.59999999993481, 5.85714285719156, 7.42857142844789, NA, 4.83333333333333, 5.33333333333333, 4.48484848484848, 2.93333333333333, 3.83333333333333, 5.52941176474375, 9.33333333333333, 5.16666666666667, 18, 2.82352941178404, 5.54838709681587, 3.55555555555556, 1.25237191650965, 2, 2.16666666666667, 7.16666666666667, 3.00000000002495, 2.83333333333333, 2.48275862068966, 4.42857142860825, 11.1428571426718, NA, 5.52380952380952, 34.3448275859312, 4.75000000006912, 3.26315789471685, 10.2857142857998, 10.5555555555556, 5.00000000004158, 19.0843373493441, 20.6153846152, 2.24999999998363, 8.59259259259259, 4.25806451616101, 2.85714285716014, 5.1578947368105, 8.66666666666667, 3.14285714280487, 6.30769230763582, 6.79999999992084, 8.07692307663376, 5.73333333333333, 8.46153846146269, 2.34482758618807, 4.31999999991953, 4.57142857135254, 2.87500000004184, 2.28571428567627, 0.857142857149985, 10.2352941175069, 3.26086956520914, NA, 13.3333333333333, 2.75000000004002, 6.45161290312889, 3.61290322575218, 1.48854961831995, 3.37499999997544, 4.0540540540413, 5.73333333333333, 3.85714285707871, 3, 6.31578947364551, 1.55555555555556, 7.84615384608358, 0.4, 7.66666666666667, NA, 7.85185185185185, 2.59090909091595, 7.28571428577487, 5.74999999995816, 3.28571428574161, 16.043478260829, 15.8000000003679, 2.50000000003638, NA, 2.06451612904776, 1.82163187855948, 0.874999999993634, 13.2000000001229, 6.92307692301493, 3.7142857143166, 3.00000000001343, 5.83333333333333, 3.86666666666667, 9.39999999989057, 2.49999999998181, 6.24000000005811, 4.58823529414907, 3.72413793109428, 3.21428571427235, 6.85714285719988, 8.42857142864151, 5.23076923086291, 10.5454545455661, 14.1428571429747, 4.00000000005821, 4.08791208795393, 8.47058823517811, 3.94422310755509, 3.62500000005275, 6.0000000001397, 1.33333333333333, 3.73333333333333, 6.31578947352942, NA, 4.53333333333333, 8.46153846169001, 0.470588235287673, 2.28571428571429, 22.7142857144746, 8.00000000012846, 2.8108108108285, 4.57142857146658, 5.87500000008549, 6.42857142862488, 19.2258064513241, 13.4666666666667, 3.46666666666667, 4.90322580648844, 3.51515151515152, 1.56862745098755, 1.53846153844776, 3.63636363636364, 4.71428571432492, 3.06666666666667, 4.61538461546728, NA, 2.83333333333333, 5.53846153841194, 1.80645161287609, 9.14285714285714, 2.42857142853104, 3.2, 5.00000000007276, 4.42857142860825, 6.12500000008913, 3.24999999990541, 4.16326530608288, 14.6666666666667, 5.37499999996089, 7.43478260867684, 9.93548387104236, 3.73205741626378, 2.24999999998363, 13.7777777777778, 4.74074074074074, 7.4285714286332, 3.61904761904762, 7.13513513511269, 5.28571428575824, 5, 2.5882352940822, 11.5000000001673, 27.1249999998026, 2.875, 2.81081081077544, 9.42857142864983, 7.05882352931509, 3.83333333333333, 16.8695652172205, 16.7692307690806, 10.1333333333333, 5.45454545455989, 7.8750000001146, 1.6883116883219, 2.66666666666667, 11.7857142856653, 3.33333333333333, 6.33333333333333, 7.39999999991385, 12.5882352942039, 4.00000000003326, 6.72727272734392, 3.03030303030303, 6, 30.6666666666667, 3.74999999997272, 3.00000000003011, 8.00000000006652, 8.00000000006009, 2.57142857144995, 10.695652173886, 14.2666666666667, 7.75000000011278, 2.51162790697674, 6.33333333333333, 3.28125000004775, 1.88888888888889, 10.4000000002421, 4.87499999996453, 13.7142857143998, 8.5, NA, 4.87499999996453, 8.181818181645, 1.24999999999091, 4.38095238095238, 27.1764705878631, 2.37499999998272, 2.94117647060838, 11.7142857143831, 5.99999999996324, 2.37499999998272, 14.7637795275455, 14.313253012008)
dph <- c(3.12500000004547, 6.69473684199041, 4.3106796117187, 11.6937354988146, 103.882352941888, 10.9999999998719, 7.33333333333333, 20.3529411761918, 5.23076923072239, NA, 4.61538461534328, 47.5555555555556, 2.94117647054795, 18.9565217389385, 44.3199999991745, 28.5000000004147, NA, 10.4705882353658, 19.000000000158, 25.8181818181818, 43.2167832173461, 51.5555555555556, 8.37499999993906, 6.91764705878563, 9.37499999993179, 5.64705882345207, 4.53333333333333, 27.4285714286627, 14.4285714286914, NA, 1.6, 5.76470588227399, 4.70588235287673, 55.2727272733122, 2.11764705883803, 30.8888888888889, 41.2222222222222, 23.4444444444444, 2.42857142859162, 6.2, 17.0769230767702, 21.2800000001982, 40.8292682931466, 14.5, 6.25000000009095, NA, 15.0400000001401, 5.68720379147547, 2.40000000001397, NA, 26.3750000003838, 18.0645161291679, 3.99999999996418, 6.13953488375417, 8.47058823535212, 128.666666666667, 2.23529411766237, 34.1818181821799, 115.999999998411, 5.99999999991782, 5.77777777777778, 10.6666666666667, 15.4285714286997, 54.8235294110138, 81.315789475428, 42.3333333333333, 1.74999999998727, 7.99999999993577, 4.34285714282825, 1.90099009900552, 5.22222222222222, 39.840000000371, 25.1428571430662, 7.81818181826456, 8.57142857149985, 15.2727272728196, 6.4, 93.0909090889387, 0.374999999997272, 23.1666666666667, 29.3913043475286, 0.874999999993634, 1.71428571429997, 13.5714285715414, 5.49999999995998, 134.799999998431, 77.7999999990943, 18, 2.24999999998363, 5.73333333333333, 3.09677419357165, 2.29376257547098, 5.70000000003318, 23.1891891891162, 14, 13.5555555555556, 1.69230769229254, 9.23076923093455, 4.35294117641097, 48.6666666666667, 0.352941176473005, 16.0000000001693, 56.7142857147573, 1.81818181818182, 1.37931034481651, 19.6800000001833, 6.63157894732779, 134.999999998428, 41.0434782604541, 26.8749999998045, 3.62499999997362, 16.5652173912624, 10.3448275861238, 1.28654970761285, 2.94736842108875, 13.4285714283481, 7.6, 3.2307692307403, 2, NA, 3.44444444444444, 93.1428571413081, 0.111111111111111, 13.6666666666667, 28.1379310342568, 2.39999999997206, 7.8749999999427, 4.00000000003725, 6.99999999994907, 60, 26.8750000003911, 30.5060240963, 3.12499999997726, 3.17241379307798, 4.83333333333333, 9.29411764712247, 12.7058823530282, 4.24999999987631, 6.99999999994907, 9.97183098578469, 2.39999999997206, 8.93023255818789, 15.3846153848909, 94, 0.111111111111111, 21.4000000004983, 29.9130434779581, 1.24137931033486, NA, 15.8666666666667, 7.17647058828444, 1.49999999998909, 37.9047619047619, 27.6666666666667, 1.74999999998727, 9.37499999993179, 17.3333333333333, 11.603053435032, 5.33333333333333, 2.8, 7.99999999994179, 3.5, 1.60000000003725, 7.31034482752751, 6.42857142846452, 56.7272727278731, 0, 21.6000000005029, 28.8750000004202, 1.6, NA, 4.5, 5.64705882356808, 7.16666666666667, 36.2068965514334, 40.235294117096, 4.8, 22.3043478260305, 8.86956521730152, 3.94936708861923, 3.33333333333333, 12.6000000002934, 20.0000000001663, 1.28571428572498, 0.749999999978172, NA, 6.25000000009095, NA, 0.258064516125156, 18.6666666666667, 17, 5.51724137926605, 2.58823529413537, 11.0769230771215, 5.26315789480134, 11.4999999996653, 34.1250000004966, 42.4, 6.53333333333333, 33.1578947366389, 4.4, 4.9484536082593, 11.2307692309704, 5.11111111111111, 23.8571428573412, 0.4, 2.30769230773364, 6.81818181819986, 8.19999999990454, 26.7272727275556, 0.352941176465754, 24.1999999997183, 7.04000000006557, 2.5, 7.14285714291654, 11.4285714286665, 12.1333333333333, 2.83870967744068, 42.7500000006221, 4.99999999985448, 3.33333333333333, 10.112359550456, 16.8, 4.23841059603303, 2.22222222222222, 14.4615384617975, 15.6923076925887, 3.23076923082709, 1.05882352939726, NA, 7.42857142844789, NA, NA, 16.952380952381, 12.4, 6.29999999992666, 85.4193548393512, 4.33333333333333, 11.8666666666667, 6.0000000000635, 19.6800000001833, NA, 3.46666666666667, NA, 13.0909090909091, 12.6315789471169, 5.14285714289991, 9.14285714285714, 12.1428571429581, 2.87499999997908, 1.692307692338, 10.2499999997017, 5.00000000007276, NA, NA, 19.578947368661, 10.4444444444444, 1.74999999998727, 4.77419354842295, 8.57142857149985, 9.66666666666667, 13.5238095238095, 7.29729729727434, NA, 1.6, 9.18367346930048, 6.85714285719988, 4.5508982036055, 0.666666666666667, 10.90909090886, 2.61538461536119, 6.1818181818836, 1.57142857140244, NA, 1.99999999996674, 24.4285714287746, 0.941176470575345, 16.6, 17.6666666666667, 0.999999999992724, 10.2666666666667, 7.5, 11.2499999999181, 11.9999999998785, 12.8, 29.7333333333333, 5.33333333333333, 13.6, 1.84615384615385, 12.7924528302168, 2.4, 23.6923076920955, 2.42857142859162, 4.90909090914286, 3.62499999997362, 11.4193548385381, 4.92307692303284, 17, NA, 16.9090909090909, 20.8333333333333, 0.96969696969697, 8, 11.8333333333333, 10.2352941175069, 5.81818181805867, 6.07228915660947, 39.3333333333333, 4.13333333333333, 9.6969696969697, 11.2, 7.94297352346302, 2.12499999998454, 4.66666666666667, 2.66666666666667, 11.3333333333333, 3.7037037037037, NA, 2.87500000004184, 24.3999999997159, 1.88888888888889, 10.4444444444444, NA, 3.73333333333333, 7.08571428566715, 15.8333333333333, 11.2499999999181, 2.59999999996973, NA, 43.6, 3.24999999997635, 22.9213483149066, NA, 5.22935779808415, 1.85714285711197, 14.3333333333333, 15.4285714286997, 4.363636363544, 1.8571428571583, 7.36363636365585, 6.37499999995362, 51.3333333333333, 3.42857142854862, 1.043478260859, 4.94736842102232, 2.76923076920597, 5.09090909090909, 2.5, 7.49999999994543, 9.71428571436649, 7.25581395352766, 29.8823529407672, 6.62500000009641, NA, 6.12500000008913, 5.59322033900236, 5.12499999996271, 5.45454545460318, 7.00000000005821, 2.44444444444444, 3.05882352936987, 16.9999999998021, 7.71428571434986, 16.8571428568625, NA, 8.83333333333333, 6.77777777777778, 2.78787878787879, 5.06666666666667, 8.83333333333333, 9.17647058829813, 14.1666666666667, 5.5, 36.6666666666667, 4.23529411767606, 7.48387096779814, 5.33333333333333, 2.73244781783923, 2.13333333333333, 2.5, 11.5, 6.42857142862488, 3, 1.79310344827586, 8.00000000006652, 24.8571428567295, NA, 6.09523809523809, 68.5517241373807, 21.2500000003092, 6.21052631575142, 19.2857142858747, 15.1111111111111, 5.5714285714749, 42.6506024095189, 42.615384615003, 4.87499999996453, 13.3333333333333, 11.8709677420246, 8.83116883122224, 6.31578947364551, 9.83333333333333, 1.99999999996674, 7.69230769223881, 4.39999999994878, 17.3076923070723, 8.13333333333333, 16.461538461391, 1.65517241377981, 7.03999999986887, 10.2857142855432, 2.12500000003092, 1.14285714283814, 1.14285714286665, 13.1764705880548, 3.7826086956426, NA, 28.1333333333333, 3.75000000005457, 8.38709677406756, 6.83870967731663, 3.20610687022758, 6.49999999995271, 6.32432432430443, 13.8666666666667, 8.42857142843125, 2.83333333333333, 13.4210526314967, 3.33333333333333, 14.1538461537194, 0.933333333333333, 15.8333333333333, NA, 8.2962962962963, 5.31818181819589, 13.5714285715414, 10.1249999999263, 6.28571428576655, 39.260869565118, 26.6000000006193, 4.00000000005821, NA, 3.74193548389907, 5.35104364326849, 0.749999999994543, 12.0000000001118, 4.30769230765373, 6.57142857148322, 6.00000000002686, 13.3333333333333, 5.33333333333333, 16.1999999998114, 1.87499999998636, 13.1200000001222, 11.0588235294875, 2.0689655172746, 5.57142857140541, 17.1428571429997, 12.8571428572498, 10.4615384617258, 27.2727272730159, 25.5714285716412, 9.25000000013461, 12.3956043957313, 20.8235294114795, 4.54183266930586, 6.25000000009095, 14.000000000326, 1.33333333333333, 8.13333333333333, 7.15789473666668, NA, 62.6666666666667, 18.0000000003224, 0.117647058821918, 6.66666666666667, 43.8571428575075, 8.55172413806835, 5.40540540543942, 7.71428571434986, 11.0000000001601, 18.2857142858663, 52.6451612895318, 26.4, 5.6, 13.1612903226795, 5.93939393939394, 2.48366013073029, 1.53846153844776, 2.36363636363636, 4.14285714289159, 1.33333333333333, 9.23076923093455, NA, 2.83333333333333, 10.9230769229791, 2.19354838706382, 18.6666666666667, 3.57142857136918, 1.6, 8.50000000012369, 9.85714285722482, 11.2500000001637, 1.74999999994907, 6.367346938715, 33, 10.8749999999209, 23.9999999999393, 23.4838709679183, 3.73205741626378, 2.74999999997999, 20.6666666666667, 4.14814814814815, 13.2857142858248, 4.57142857142857, 15.2432432431953, 5.85714285719156, 10, 2.5882352940822, 20.5000000002983, 58.3749999995753, 1.875, 5.08108108101713, 13.5714285715414, 10.8235294116165, 2.66666666666667, 27.4782608692871, 30.9230769228, 17.6, 7.77272727274784, 15.7500000002292, 2.46753246754739, 2.77777777777778, 12.6428571428046, 3.6, 11.2222222222222, 6.79999999992084, 20.705882353083, 2.85714285716662, 14.1818181819683, 3.51515151515152, 11.7777777777778, 57.8888888888889, 3.9999999999709, 5.58620689660779, 15.4285714286997, 11.3548387097627, 1.00000000000832, 23.9999999999393, 25.3333333333333, 20.1250000002929, 4.88372093023256, 13.1111111111111, 2.57812500003752, 2.66666666666667, 12.0000000002794, 7.74999999994361, 23.2857142859079, 10.3333333333333, NA, 4.74999999996544, 12.545454545189, 1.74999999998727, 8, 55.999999999233, 2.12499999998454, 5.05882352944641, 24.5714285716329, 8.21052631573917, 1.99999999998545, 29.17322834643, 30.5060240963)
par(mfrow = c(2, 2))
hist(nph)
hist(dph)
qqnorm(nph)
qqline(nph)
qqnorm(dph)
qqline(dph)


These are the distributions:

As the data is obviously not normally distributed, many statistical test cannot be applied to this data. But maybe I can transform the data to a normal distribution?

### How can I find out which distribution this is?And how can I transfrom the data to a normal distribution?

The goal is to do an analysis of variance (MANOVA) or some such (the data presented here are the two dependent variables).

The data looks like having an exponential distribution. For transformation, simple log seems to work fine.

hist(log(dph), freq=FALSE, ylim=c(0, .4))
lines(seq(-6, 6, by=0.01), dnorm(seq(-6, 6, by=0.01), 2, 1), col="red")
qqnorm(log(dph), ylim=c(0, 5))
qqline(log(dph), col="red")


• Thank you, @Tim. Could you post your code? The Q-Q plot looks different when I do it (less steep). Also, did you exclude the one value that is -Inf after transformation? – user14650 Feb 10 '15 at 11:47
• @what Sorry for that, in the initial version I used some strange xlim and ylim parameters. And no - nothing was excluded. – Tim Feb 10 '15 at 12:02
• Looking for instructions on how to interpret results from hypothesis testing logarithmically transformed data, I stumbled upon a comment by whuber (first under this question: stats.stackexchange.com/q/20397/14650) saying that a Poisson distribution is "naturally indicated for count data", and from there found this article explaining why: r-bloggers.com/do-not-log-transform-count-data-bitches What do you think? – user14650 Feb 10 '15 at 12:34
• Sometimes you want or need to transform your variables - it is certainly not the only, or not the always-bets approach. Generally yes, there are distributions that are designed for count data (e.g. Poisson) or for skewed distributions (e.g. Geometrical, Exponential), but it is not always possible to use them. For example, you may want to use a variable as independent variable in linear regression, so you don't want it to be skewed and you transform it. Generally it depends of situation. – Tim Feb 10 '15 at 13:22
• @what Yes, I agree that you must think in the process originating your data at hand (~variable type). Remember that distribution is an ASSUMPTION that you are willing to make, which dictates the validity of your model and results. Think of a conditional: results are such and such IF (or given) this assumption (and others) is true. Tests on the actual sample usually help to test on that assumption, but they do not make it TRUE or FALSE. And that is why assuming something believable for your variable is so important :) – FairMiles Feb 10 '15 at 17:27

Any continuous distribution can be turned into a normal distribution through a process called Gaussianization (Chen & Gopinath, 2001). For univariate distributions, Gaussianization is simple. If a random variable $Y$ has cumulative distribution function (CDF) $F_Y$ and $\Phi$ is the CDF of a standard normal, then

$$X = \Phi^{-1}(F_Y(Y))$$

will have a standard normal distribution. This is easy to see, since the CDF of $X$ is

$$F_X(x) = P(X \leq x) = P(\Phi^{-1}(F_Y(Y)) \leq x) = P(Y \leq F_Y^{-1}(\Phi(x))) = F_Y(F_Y^{-1}(\Phi(x))) = \Phi(x).$$

If $Y$ is exponentially distributed with rate $\lambda$, then the data could be transformed via

$$X = \Phi^{-1}\left(1 - e^{-\lambda Y} \right),$$

which looks similar to a logarithm:

I don't use R, but I'm sure you can find implementations of the inverse CDF (also known as quantile function) of the normal, $\Phi^{-1}$.

• You lost me at "This is easy to see..." :-) I understand y = 3x, but I don't understand F(x) = 3x. I have had this in school for years, and hear it in university every day, but "function of x" is completely meaningless to me. I don't see what it correlates to in the world that I live in and experience through my senses. I therefore do not understand what you are saying I might do in "the data could be transformed via ...". But +1 for your kindness in trying to help me. It's not your fault I cannot think abstractly. – user14650 Feb 11 '15 at 7:56
1. How can I find out which distribution this is? Here you can use some statistical tests from R package fitdistrplus. From the package You will find fitting crateria i.e AIC, BIC etc. The Fitting of the distribution ' gamma or mor disrtribution like "normal". Here are the methods.

• MAXIMUM LIKELIHOOD ESTIMATION
• MOMENT MATCHING ESTIMATION
• QUANTILE MATCHING ESTIMATION
• MAXIMUM GOODNESS-OF-FIT ESTIMATION (Goodness-of-fit statistics and Goodness-of-fit criteria)

Then finally you will find among several theoritical models the best one that resembles your observed data.

1. And how can I transfrom the data to a normal distribution? Here you can use Box Cox Transfom

Box_Cox_tran=function(x, lambda, jacobian.adjusted = FALSE)
{
bc1 <- function(x, lambda)
{
if (any(x[!is.na(x)] <= 0))
stop("First argument must be strictly positive.")
z <- if (abs(lambda) <= 1e-06)
log(x)
else ((x^lambda) - 1)/lambda
z * (exp(mean(log(x), na.rm = TRUE)))^(1 - lambda)
}
else z
}
out <- x
out <- if (is.matrix(out) | is.data.frame(out)) {
if (is.null(colnames(out)))
colnames(out) <- paste("Z", 1:dim(out)[2], sep = "")
for (j in 1:ncol(out)) {
out[, j] <- bc1(out[, j], lambda[j])
}
colnames(out) <- paste(colnames(out), round(lambda, 2),
sep = "^")
out
}
else bc1(out, lambda)
out
}


Here is my working exmaple:

# ---------------------------------------------------------------------------------------------------------------------------
# Objective three starts Here
# (3)= Bivariate modelling of annual maxima using traditional approach
# a)    First transform onbserved seasonal maxima into normal distribution using Box-Cox Transformations(x to z)
# b)    Finaly, Estimate Pearson coefficient using traditional bivariate normal distribution
# ---------------------------------------------------------------------------------------------------------------------------
rm(list=ls())
Sys.setenv(LANGUAGE="en")  # to set languege from Polish to English
setwd("C:/Users/sdebele/Desktop/From_oldcomp/Old_Computer/Seasonal_APP/Data/Data_Winter&Summer")
library(MASS)
library(geoR)
require(scales)
require(plyr)
require(car)
library(ggplot2)
require(alr3)
library(ggplot2)
library(reshape2)
library(nortest)
require(AID)
require(distr)
require(fBasics)
# -----------------------------------------------------------------------------------------------------------------------------
# Here the Box-Cox Transformations equations
# x(lambda)=x^lamda-1/lambda, if lambda is not zero
# else log(x) if lambda=0
#--------------------------------------------------------------------------------------------------------------------------------
# Here is the data for six guaging stations of dependant ( 51.12% to 89.85%)
filenames=c("ZAPALOW.txt","GORLICZYNA.txt","SARZYNA.txt","OSUCHY.txt","HARASIUKI.txt","RUDJASTKOWSKA.txt")
# ---------------------------------------------------------------------------------------------------------------------------
# (1)= For ZAPALOW hydrological guaging stations starts here
# --------------------------------------------------------------------------------------------------------------------------------
newZAPALOW <- na.omit(ZAPALOW) # to eliminte the missing value from the data sets
Years=newZAPALOW$Year Winter=newZAPALOW$Winter
Summer=newZAPALOW$Sumer source("Box_Cox_Transfom.R") # R_script containing the tranformation equations # estimation of lambda using AID R package # boxcoxnc(Sumer, method="ac", lam=seq(-2,2,0.01), plotit=TRUE, rep=30, p.method="BY") # boxcoxnc(Winter, method="ac", lam=seq(-2,2,0.01), plotit=TRUE, rep=30, p.method="BY") Trans_Win=boxcoxnc(Winter) Trans_Sum=boxcoxnc(Summer) Winter_trans=Box_Cox_tran(Winter,Trans_Win$result[1,1],jacobian.adjusted=T)
Summer_trans=Box_Cox_tran(Summer,Trans_Sum$result[1,1],jacobian.adjusted=T) newZAPALOW[,4]=Winter_trans newZAPALOW[,5]=Summer_trans colnames(newZAPALOW)= c("Year","Winter " ,"Summer","Winter_Trans","Summer_Trans") par(mfrow=c(2,2)) par("lwd"=2) ## Plot histogram with overlayed normal distribution. hist(newZAPALOW[,4],main="",xlab="Discharge",freq=FALSE,col="lightblue") curve(dnorm(x,mean=mean(newZAPALOW[,4]),sd=sd(newZAPALOW[,4])), add=TRUE, col="darkred",lwd=2) qq.plot(newZAPALOW[,4], dist= "norm", col=palette()[1], ylab="Sample Quantiles", main="Normal Probability Plot", pch=19) #b <- mydata[,c(2,3)] # select interesting columns result <- shapiro.test(newZAPALOW[,4]) # checking for normality test result$p.value
ad.test(newZAPALOW[,4]) # checking for normality test
## Plot histogram with overlayed normal distribution.
hist(newZAPALOW[,5],main="",xlab="Discharge",freq=FALSE,col="lightblue")
qq.plot(newZAPALOW[,5], dist= "norm", col=palette()[1], ylab="Sample Quantiles",
main="Normal Probability Plot", pch=19)
result <- shapiro.test(newZAPALOW[,5]) # checking for normality test
result\$p.value
ad.test(newZAPALOW[,5]) # checking for normality test
write.table(newZAPALOW, "newZAPALOW_trans.txt", sep="\t")
For sure this will be helpfull for you.

• Please try to edit your post so it is more readable. Your Box-Cox code seems to contain bugs (if-else loops are not properly closed etc.), so please fix it. – Tim Feb 10 '15 at 11:17
• @Tim when inside a list, we need to add four more spaces in the beginning of each line to have it formatted as code. – Shadow Wizard is Vaccinating Feb 10 '15 at 12:24