You are on page 1of 3

Stelsels en Seine / Systems and Signals 344 Tutorial/Tutoriaal 6

1. Histograms are a useful nonparametric probability Histogramme is ’n nuttige nie-parametriese metode


density estimator. Given a set of N data points om ’n waarskynlikheidsdigtheidsfunksie af te skat.
x = {x1 , x2 , . . . , xN }, the range of x (i.e. the interval Gegee ’n stel N data punte x = {x1 , x2 , . . . , xN }, word
between the minimum and maximum values in x) is die bereik van x (d.w.s. die interval tussen die min-
evenly divided into B non-overlapping and adjacent imum en maksimum waarde in x) gelyk ingedeel in
bins. Next, the number of elements of x falling into B nie-oorvleulende en aangrensende intervalle. Dan
each bin is determined. Finally, the number of ele- word die aantal elemente van x wat in elke interval
ments in each bin is appropriately normalised so that val bepaal. Laastens word die aantal elemente in elke
it approximates the probability density fX (x) over the interval genormaliseer sodat dit die waarkynlikheids-
interval spanned by the bin. This is illustrated in the digtheid fX (x) benader oor die betrokke interval. Die
figure below. volgende figuur illustreer hierdie proses.

MIN MAX

(a) Write a Python function histpdf that takes the Skryf ’n Python funksie histpdf wat die param-
parameters x (vector of data points) and B (num- eters x (vektor data punte) en B (aantal inter-
ber of bins) and plots a histogram estimate of the valle) aanvaar en ’n histogram afskatting van die
probability density of the data. For example: waaskynlikheidsdigtheid van die data plot. By
voorbeeld:
rng = np . random . default_rng ()
x = rng . random (10000)
histpdf (x ,20)
would estimate the probability density function of sou die waaskynlikheidsdigtheidsfunksie van x
x using 20 bins (Tip: See the documentation for afskat deur middel van 20 intervalle (Wenk:
pyplot.hist. Set density=True to have the area Sien die dokumentasie vir pyplot.hist. Stel
of the histogram equal to one. Also set the color density=True om die area van histogram gelyk te
and edgecolor arguments to different color values maak aan een. Stel ook die color en edgecolor
to better visualise the intervals). argumente na verskillende kleur waardes om die in-
tervalle beter te visualiseer).
(b) Use your function to visualise the probability den- Gebruik jou funksie om die waaskynlikheidsdigth-
sity of the following dataset using 30 bins: eidsfunksie van die volgende datastel te visualiseer
met 30 intervalle:
x = np . hstack ([ rng . random (50000) , rng . random (50000) +2])
Explain why do you seen only 20 bars when you Verduidelik hoekom jy net 20 kolomme sien terwyl
specify 30 bins. jy 30 intervalle gespesifiseer het.

(c) Now download the data file ”dat.txt” from Laai nou die datastel ”dat.txt” af van learn.sun.
learn.sun. Load it into Python using the func- Laai dit dan in Python in met die funksie
tion np.loadtxt (use dtype=float). Use your his- np.loadtxt (gebruik dtype=float). Gebruik jou
togram function to investigate the probability den- histogram funksie om die waaskynlikheidsdigthei-
sity of this data. Use 10, 20, 40 and 80 bins to dsfunksie van die datastel te visualiseer. Gebruik
estimate the probability density function. Explain 10, 20, 40 en 80 intervalle om die waaskynlikhei-
what you see. dsdigtheidsfunksie af te skat. Verduidelik wat jy
sien.

22 August 2022
Stelsels en Seine / Systems and Signals 344 Tutorial/Tutoriaal 6

2. Two random variables X and Y have the following Twee toevalverandelikes X en Y het die vol-
joint probability density function fX,Y (x, y). gende gesamentlike waarskynlikheidsdigtheidsfunksie
fX,Y (x, y).

|x| ≤ 1 and/en − 2 ≤ y ≤ 2x
(
a
fX,Y (x, y) =
0 otherwise/elders

(a) Calculate the value of a. Hint: You may use geo- Bereken die waarde van a. Wenk: U mag
metrical arguments. meetkundige argumente gebruik.

(b) Using integration, determine the simplified expres- Deur integrasie te gebruik, bepaal die vereen-
sion for the marginal probability density functions voudigde uitdrukking vir die randwaarskynlikheids-
fX (x) and fY (y). Sketch both densities for the in- digtheidsfunksies fX (x) en fY (y). Skets beide digt-
terval −3 ≤ x ≤ 3 and −3 ≤ y ≤ 3. heidsfunksies vir die interval −3 ≤ x ≤ 3 en
−3 ≤ y ≤ 3.

(c) Are the random variables X and Y statistically in- Is die toevalsverandelikes X en Y statisties on-
dependent? Motivate your answer. afhanklik? Motiveer u antwoord.

3. Let X and Y be jointly continuous random variables Laat X en Y gesamentlike kontinue toevalsverander-
with joint PDF likes wees met gesamentlike WDF
(
cx + 1 x, y ≥ 0, x + y < 1
fX,Y (x, y) =
0 otherwise

(a) Show the range (X, Y ), SXY , in the x − y plane. Wys die omvang (X, Y ), SXY , in die x − y vlak.

(b) Find the constant c. Vind die konstante c.

(c) Find the marginal PDFs fX (x) and fY (y). Vind die marginale WDFs fX (x) en fY (y).

(d) Find P (Y < 2X 2 ). Vind P (Y < 2X 2 ).

4. Two random variables X and Y have the following Twee toevalverandelikes X en Y het die vol-
joint probability density function fX,Y (x, y). gende gesamentlike waarskynlikheidsdigtheidsfunksie
fX,Y (x, y).

0 ≤ x < a and/en 0 ≤ y < b


(
1/ab
fX,Y (x, y) =
0 otherwise/elders

Calculate FX,Y (x, y). Show and motivate your work- Bereken FX,Y (x, y). Wys en motiveer u bewerkings
ing clearly. Hint: Your answer will have to be valid duidelik. Wenk: U antword moet geldig wees vir alle
for all possible values of x and y. moontlik waardes van x en y.

22 August 2022
Stelsels en Seine / Systems and Signals 344 Tutorial/Tutoriaal 6

5. Each test of an integrated circuit produces an accept- Elke toets van ’n geı̈ntegreerde stroombaan produseer
able circuit with probability p, independent of the out- ’n aanvaarbare stroombaan met ’n waarskynlikheid
come of the test of any other circuit. In testing n cir- van p, onafhanklik van die uitkoms van enige ander
cuits, let K denote the number of circuits rejected and stroombaan se toets. As daar n stroombane getoets
let X denote the number of acceptable circuits that word, laat K die hoeveelheid stroombane wees wat
appear before the first reject is found. Find the joint verwerp word en laat X die hoeveelheid aanvaarbare
PMF PK,X (k, x). stroombane wees wat verskyn voordat die eerste ver-
werpde stroombaan gevind word. Vind die WMF
PK,X (k, x).

6. Consider two random variables X and Y for which: Beskou twee toevalsveranderlikes X en Y waarvoor:

E[X] = 5 E[Y ] = 3 2
σX =4 σY2 = 7 ρX,Y = − 21

Calculate: Bereken:

(a) The covariance C[X, Y ] Die kovariansie C[X, Y ]

(b) The correlation rX,Y Die korrelasie rX,Y

22 August 2022

You might also like