R တွင် ဒေတာအတွဲတစ်ခုနှင့် gamma ဖြန့်ဝေမှုအား မည်သို့ အံဝင်ခွင်ကျလုပ်မည်နည်း။
ဤသင်ခန်းစာသည် R ရှိ ဒေတာအတွဲတစ်ခုနှင့် ဂမ်မာဖြန့်ဝေမှုအား မည်သို့အံဝင်ခွင်ကျဖြစ်စေရန် ရှင်းပြထားသည်။
R တွင် gamma ဖြန့်ဖြူးမှုအား တပ်ဆင်ခြင်း
အောက်ပါချဉ်းကပ်နည်းကို အသုံးပြု၍ သင့်တွင် dataset z ထုတ်ပေးသည်ဆိုပါစို့။
#generate 50 random values that follow a gamma distribution with shape parameter = 3 #and shape parameter = 10 combined with some gaussian noise z <- rgamma(50, 3, 10) + rnorm(50, 0, .02) #view first 6 values head(z) [1] 0.07730 0.02495 0.12788 0.15011 0.08839 0.09941
gamma ဖြန့်ဝေမှုတစ်ခုသည် ဤဒေတာ set z နှင့် မည်မျှကိုက်ညီကြောင်းကြည့်ရန် R တွင် fitdistrplus ပက်ကေ့ဂျ်ကို အသုံးပြုနိုင်ပါသည်။
#install 'fitdistrplus' package if not already installed install. packages ('fitdistrplus') #load package library(fitdistrplus)
ဤပက်ကေ့ဂျ်ကို အသုံးပြု၍ ဖြန့်ဖြူးမှုတစ်ခုအား လိုက်လျောညီထွေဖြစ်အောင် အသုံးပြုရန် ယေဘူယျ syntax မှာ-
fitdist(ဒေတာအစုံ၊ disstr = “ သင့်ရဲ့ ဖြန့်ဖြူးမှုရွေးချယ်မှု” ၊ နည်းလမ်း = “ သင့်ရဲ့ အချက်အလက်နဲ့ ကိုက်ညီတဲ့ နည်းလမ်း” )
ဤကိစ္စတွင်၊ ကျွန်ုပ်တို့သည် ဒေတာနှင့်ကိုက်ညီရန် gamma ဖြန့်ဖြူးမှုနှင့် အများဆုံးဖြစ်နိုင်ခြေ ခန့်မှန်းရေးချဉ်းကပ်မှုတို့ကို အသုံးပြု၍ ယခင်က ထုတ်လုပ်ခဲ့သော z ဒေတာအတွဲနှင့် ကိုက်ညီပါမည်-
#fit our dataset to a gamma distribution using mle fit <- fitdist(z, distr = "gamma", method = "male") #view the summary of the fit summary(fit)
၎င်းသည် အောက်ပါရလဒ်ကို ဖြစ်ပေါ်စေသည်-
ထို့နောက် အောက်ပါ syntax ကို အသုံးပြု၍ gamma ဖြန့်ဝေမှုသည် dataset နှင့်ကိုက်ညီကြောင်းပြသသည့် ဂရပ်ဖစ်များကို ထုတ်လုပ်နိုင်သည်-
#produce plots
plot(fit)
၎င်းသည် အောက်ပါမြေကွက်များကို ထုတ်လုပ်သည်။
ဤသည်မှာ R ရှိ ဒေတာအတွဲတစ်ခုနှင့် gamma ဖြန့်ဝေမှုတစ်ခုနှင့် အံဝင်ခွင်ကျအသုံးပြုခဲ့သော ကုဒ်အပြည့်အစုံဖြစ်သည်။
#install 'fitdistrplus' package if not already installed install. packages ('fitdistrplus') #load package library(fitdistrplus) #generate 50 random values that follow a gamma distribution with shape parameter = 3 #and shape parameter = 10 combined with some gaussian noise z <- rgamma(50, 3, 10) + rnorm(50, 0, .02) #fit our dataset to a gamma distribution using mle fit <- fitdist(z, distr = "gamma", method = "male") #view the summary of the fit summary(fit) #produce plots to visualize the fit plot(fit)