Python တွင် ogive chart ဖန်တီးနည်း
ogive သည် ဒေတာအတွဲတစ်ခုတွင် ဒေတာတန်ဖိုး မည်မျှတန်ဖိုးများ အထက် သို့မဟုတ် အောက်တွင် မည်မျှကျဆင်းသည်ကို ပြသသည့် ဂရပ်ဖစ်တစ်ခုဖြစ်သည်။ ဤသင်ခန်းစာတွင် Python တွင် ထိပ်ဖူးဖန်တီးနည်းကို ရှင်းပြထားသည်။
ဥပမာ- Python တွင် Ogive ဖန်တီးနည်း
Python ရှိ ဒေတာအစုံအတွက် ogive ဖန်တီးရန် အောက်ပါအဆင့်များကို ပြီးအောင်လုပ်ပါ။
အဆင့် 1- ဒေတာအတွဲတစ်ခု ဖန်တီးပါ။
ပထမဦးစွာ ကျွန်ုပ်တို့သည် ရိုးရှင်းသောဒေတာအတွဲတစ်ခုကို ဖန်တီးနိုင်သည်။
import numpy as np #create array of 1,000 random integers between 0 and 10 np.random.seed(1) data = np.random.randint(0, 10, 1000) #view first ten values data[:10] array([5, 8, 9, 5, 0, 0, 1, 7, 6, 9])
အဆင့် 2: Warhead တစ်ခုဖန်တီးပါ။
ထို့နောက် အတန်းများနှင့် အတန်းကြိမ်နှုန်းများကို အလိုအလျောက်ရှာရန် numpy.histogram လုပ်ဆောင်ချက်ကို ကျွန်ုပ်တို့ အသုံးပြုနိုင်သည်။ ထို့နောက် ကျွန်ုပ်တို့သည် ထိပ်ဖူးကိုဖန်တီးရန် matplotlib ကိုသုံးနိုင်သည်။
import numpy as np import matplotlib.pyplot as plt #obtain histogram values with 10 bins values, base = np.histogram(data, bins=10) #find the cumulative sums cumulative = np.cumsum(values) # plot the warhead plt.plot(base[:-1], cumulative, 'ro-')
numpy.histogram လုပ်ဆောင်ချက်တွင် ကျွန်ုပ်တို့သတ်မှတ်ထားသော အကွက်အရေအတွက်ပေါ်မူတည်၍ ကျည်ဆန်ဇယားသည် ကွဲပြားနေပါမည်။ ဥပမာအားဖြင့်၊ ကျွန်ုပ်တို့သည် အဖွဲ့ 30 ကိုအသုံးပြုပါက ဤဇယားသည် မည်သို့မည်ပုံဖြစ်သည်-
#obtain histogram values with 30 bins
values, base = np.histogram(data, bins= 10 )
#find the cumulative sums
cumulative = np.cumsum(values)
# plot the warhead
plt.plot(base[:-1], cumulative, 'ro-')
‘ ro-‘ အကြောင်းပြချက်သည်-
- အနီရောင် (ဒ) ကိုသုံးပါ
- အတန်းခွဲတိုင်းတွင် စက်ဝိုင်းများကို အသုံးပြုပါ (o)
- စက်ဝိုင်းများချိတ်ဆက်ရန် လိုင်းများကိုသုံးပါ (-)
ဇယား၏အလှတရားကိုပြောင်းလဲရန် ဤရွေးချယ်စရာများကို အခမဲ့ပြင်ဆင်ပါ။