Python တွင် ပုံမှန်ဖြန့်ဝေနည်းကို ပုံဆွဲနည်း- ဥပမာများဖြင့်
Python တွင် သာမာန်ဖြန့်ဝေမှု တစ်ခုကို ကြံစည်ရန်၊ သင်သည် အောက်ပါ syntax ကို အသုံးပြုနိုင်သည်။
#x-axis ranges from -3 and 3 with .001 steps x = np. arange (-3, 3, 0.001) #plot normal distribution with mean 0 and standard deviation 1 plt. plot (x, norm. pdf (x, 0, 1))
x array သည် x ဝင်ရိုး၏ အကွာအဝေးကို သတ်မှတ်ပေးပြီး plt.plot() သည် သတ်မှတ်ထားသော ပျမ်းမျှနှင့် စံသွေဖည်မှုဖြင့် ပုံမှန်ဖြန့်ဖြူးမှု၏မျဉ်းကွေးကို ထုတ်လုပ်သည်။
အောက်ဖော်ပြပါ ဥပမာများသည် ဤလုပ်ဆောင်ချက်များကို လက်တွေ့အသုံးချနည်းကို ပြသထားသည်။
ဥပမာ 1- ပုံမှန်ဖြန့်ဝေမှုတစ်ခုကို စီစဉ်ခြင်း။
အောက်ဖော်ပြပါ ကုဒ်သည် ပုံမှန်ဖြန့်ဝေမှုမျဉ်းကွေးတစ်ခုအား 0 နှင့် 1 ၏ စံသွေဖည်မှုဖြင့် ပုံဖော်နည်းကို ပြသသည်-
import numpy as np import matplotlib. pyplot as plt from scipy. stats import norm #x-axis ranges from -3 and 3 with .001 steps x = np. arange (-3, 3, 0.001) #plot normal distribution with mean 0 and standard deviation 1 plt. plot (x, norm. pdf (x, 0, 1))
ဇယားရှိ စာကြောင်း၏အရောင်နှင့် အကျယ်ကိုလည်း သင်ပြောင်းနိုင်သည်-
plt. plot (x, norm. pdf (x, 0, 1), color=' red ', linewidth= 3 )
ဥပမာ 2- ပုံမှန်ဖြန့်ဝေမှုများစွာကို စီစဉ်ခြင်း။
အောက်ဖော်ပြပါ ကုဒ်သည် ကွဲပြားခြားနားသော နည်းလမ်းများနှင့် စံသွေဖည်မှုများဖြင့် ပုံမှန်ဖြန့်ဝေမှုမျဉ်းကွေးများစွာကို မည်သို့စီစဉ်ရမည်ကို ပြသသည်-
import numpy as np import matplotlib. pyplot as plt from scipy. stats import norm #x-axis ranges from -5 and 5 with .001 steps x = np. arange (-5, 5, 0.001) #define multiple normal distributions plt. plot (x, norm. pdf (x, 0, 1), label=' μ: 0, σ: 1 ') plt. plot (x, norm. pdf (x, 0, 1.5), label=' μ:0, σ: 1.5 ') plt. plot (x, norm. pdf (x, 0, 2), label=' μ:0, σ: 2 ') #add legend to plot plt. legend ()
လိုင်းအရောင်များကို လွတ်လပ်စွာပြောင်းနိုင်ပြီး ဇယားကို အပြီးသတ်ရန် ခေါင်းစဉ်နှင့် ဝင်ရိုးအညွှန်းများ ထည့်ပါ-
import numpy as np import matplotlib. pyplot as plt from scipy. stats import norm #x-axis ranges from -5 and 5 with .001 steps x = np. arange (-5, 5, 0.001) #define multiple normal distributions plt. plot (x, norm. pdf (x, 0, 1), label=' μ: 0, σ: 1 ', color=' gold ') plt. plot (x, norm. pdf (x, 0, 1.5), label=' μ:0, σ: 1.5 ', color=' red ') plt. plot (x, norm. pdf (x, 0, 2), label=' μ:0, σ: 2 ', color=' pink ') #add legend to plot plt. legend (title=' Parameters ') #add axes labels and a title plt. ylabel (' Density ') plt. xlabel (' x ') plt. title (' Normal Distributions ', fontsize= 14 )
plt.plot() လုပ်ဆောင်ချက်၏ အသေးစိတ်ရှင်းလင်းချက်အတွက် matplotlib စာရွက်စာတမ်းကို ကိုးကားပါ။