TU Wien:Statistik und Wahrscheinlichkeitstheorie UE (Levajkovic)/Übungen 2022W/HW04.5

Aus VoWi
Zur Navigation springen Zur Suche springen
Generating random numbers from a Weibull distribution

The cumulative distribution function of a random variable is given by

Example 4.4 shows that if , then generates a random number from any continuous distribution with the specified cdf . This gives us the following algorithm to generate random numbers from a random variable with the given cdf .

Algorithm: Inversion method

1° compute the inverse of
2° generate </math>n</math> independent random numbers from
3° compute

Then, are independent random observations of the random variable .

In R, generate 30 observations from a random variable with the by applying the inversion method.

Dieses Beispiel hat einen unbekannten Lösungsstatus. Bitte editiere diese Seite und schreibe den dir bekannten Status ins Beispiel. Die möglichen Werte sind hier: Vorlage:Beispiel dokumentiert. Führe folgende Änderung durch:
{{Beispiel|1=
Angabetext
}}

oder

{{Beispiel|
Angabetext
}}

zu (im Falle einer korrekten, unverifizierten Lösung "solved". Auch möglich "unsolved", "wrong", "verified_by_tutor". Alle möglichen Werte sind hier: Vorlage:Beispiel dokumentiert.)

{{Beispiel|status=solved|1=
Angabetext
}}


Lösung von Tutorin[Bearbeiten | Quelltext bearbeiten]

The cdf is continuous and increasing function, and therefore for the -distribution (with the parameters and ). Then we generate 30 random numbers from distribution, and finally, apply the function inverseF on the generated 30 random uniform numbers.

set.seet(2022)

# Define inverse function
inverseF <- function(y) {(-log (1-y))^(0.5)}

# Simulate 30 uniform observations
u <- runif(30)

# Compute the inverse (generating 30 random numbers from the Weibull (2,1) distribution)
inverseF(U)

Dieses Beispiel hat noch keinen Lösungsvorschlag. Um einen zu erstellen, kopiere folgende Zeilen, bearbeite die Seite und aktualisiere den status=unsolved Mögliche status=... Werte stehen hier: Vorlage:Beispiel

== Lösungsvorschlag von ~~~ ==
--~~~~

Siehe auch Hilfe:Formeln und Hilfe:Beispielseiten.