Algorithms For Dummies


PART 5   Challenging Difficult Problems



Download 7,18 Mb.
Pdf ko'rish
bet532/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   528   529   530   531   532   533   534   535   ...   651
Bog'liq
Algorithms

 

   


  PART 5 

 Challenging Difficult Problems

In a normal distribution, most of the values are around the mean value. Therefore, 

if you pick a random number from the input, you most likely get a number around 

the center of the distribution. However; though less likely, you may also draw a 

number far from the center. If your algorithm works better by using the mean 

than it does with any other number, picking a number at random makes sense and 

may be less trouble than devising a smarter way to draw values from your input.

Another  important  distribution  mentioned  in  this  chapter  is  the  uniform  dis-

tribution. You can represent it using some Python code (the output appears in 

 Figure 17-2), too:

uniform_distribution = uniform(size=10000) * 100

weights = np.ones_like(uniform_distribution

                      ) / len(uniform_distribution)

plt.hist(uniform_distribution, bins=20, weights=weights)

plt.xlabel("Value")

plt.ylabel("Probability")

plt.show()

The  uniform  distribution  is  noticeably  different  from  the  normal  distribution 

because each number has the same probability of being in the input as any other. 

Consequently, the histogram bars are all roughly of the same size, and picking a 

number in a uniform distribution means giving all the numbers the same chance 

to appear. It’s a way to avoid systematically picking the same groups of numbers 

when your algorithm works better with varied inputs. For instance, uniform dis-

tributions work well when your algorithm works fine with certain numbers, so-so 

with most, and badly with a few others, and you prefer to pick numbers randomly 

FIGURE 17-1: 

A histogram  

of a normal 

distribution.




CHAPTER 17


Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   528   529   530   531   532   533   534   535   ...   651




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish