TU Wien:Statistik und Wahrscheinlichkeitstheorie UE (Levajkovic)/Übungen 2022W/HW04.1
Zur Navigation springen
Zur Suche springen
- R-functions
- (a)
trees
is theR
Dataset Package containing Diameter, Height and Volume for 31 Black Cherry trees. UsingR
define a vector that contains the values of the columnHeight
and define a vector that contains the values of the columnVolume
from the datasettrees
. Use the commandtable(h)
to obtain the frequency table of the vector . What are the outputs of the commandssummary(h)
andfactor(h)
? Compute the sample meansmean()
and the sample variancesvar()
for both vectors. Use the commandplot()
to plot the points .
- (b)
- Consider the curve given by the parametrization
- Use
plot()
to plot the curve anddev.print()
to save the result as a pdf file.
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]
(a)[Bearbeiten | Quelltext bearbeiten]
trees
h=trees$Height
v=trees$Volume
factor(h)
# Output:
# [1] 70 65 63 72 81 83 66 75 80 75 79 76 76 69 75 74 85 86 71 64 78 80 74 72
# [25] 77 81 82 80 80 80 87
# Levels: 63 64 65 66 69 70 71 72 74 75 76 77 78 79 80 81 82 83 85 86 87
table(h)
# Output:
# 63 64 65 66 69 70 71 72 74 75 76 77 78 79 80 81 82 83 85 86 87
# 1 1 1 1 1 1 1 2 2 3 2 1 1 1 5 2 1 1 1 1 1
mean(h);mean(v)
# Output:
# [1] 76
# [1] 30.17097
var(h);var(v)
# Output:
# [1] 40.6
# [1] 270.2028
plot(h, v, type="p", xlab="Height (in ft)", ylab="Volume (in cubuc ft)", main="Volmes and Heights of 31 black cherry trees", col="blue")
(b)[Bearbeiten | Quelltext bearbeiten]
plot.new()
par(mfrow=c(1,1))
t=seq(0,5*pi,0.01)
plot(exp(-t/8)*cos(2*t),exp(t/5)*sin(3*t), type='l', xlab="x", ylab="y", main = "Parametric curve", col="violet")
Lösungsvorschlag von Simplex[Bearbeiten | Quelltext bearbeiten]
(a)[Bearbeiten | Quelltext bearbeiten]
data(trees)
h <- trees [,2]
v <- trees [,3]
table_h <- table(h)
summary_h <- summary(h)
factor_h <- factor(h)
mean_h <- mean(h)
mean_v <- mean(v)
var_h <- var(h)
var_v <- var(v)
plot(h,v, type="l")
summary(h)
: This command prints the following data retreived from the numbers: Mean, 1st Quadrand, Median, Mean, 3rd Quadrant and Max.factor(h)
: Prints the set (each number only one time) of all numbers sorted ascending.mean()
: This function calculates the mean of the given list.var()
: This function calculates the variance of the given list.
(b)[Bearbeiten | Quelltext bearbeiten]
t <- seq(0,(5*pi),pi/50)
t_x <- exp(-t/8) * cos(2*t)
t_y <- exp(t/5) * sin(3*t)
plot(t_x, t_y, type="l")
dev.print(pdf, "print_1b")
--Simplex 22:43, 28. Jan. 2023 (CET)