This commit is contained in:
2026-05-04 16:07:01 +02:00
parent 9aa0e5e9e9
commit e4ae092371
+37
View File
@@ -213,4 +213,41 @@ model_apartments <- lm(log_price_m2_n ~ centreDistance +
summary(model_apartments)
par(mfrow = c(2,2))
plot(model_apartments)
```
#porównanie dystrybuanty empirycznej z teoretyczną
```{r dyst empi vs dyst teor}
install.packages("ggplot2")
library(ggplot2)
x<-log(rent$price_m2)
z <- seq(min(x), max(x), length.out = 20000)
dystrybuanta_empiryczna<-ecdf(x)
dystrybuanta_teoretyczna<-pnorm(z, mean=mean(x), sd=sd(x))
ggplot() +
# Dystrybuanta empiryczna
geom_step(
aes(x = z, y = dystrybuanta_empiryczna(z), color = "Empiryczna"),
linewidth = 1,
linetype = "solid"
) +
# Dystrybuanta teoretyczna
geom_line(
aes(x = z, y = dystrybuanta_teoretyczna, color = "Teoretyczna"),
linewidth = 1,
linetype = "dashed"
) +
# Dodanie legendy i dostosowanie kolorów
scale_color_manual(
values = c("Empiryczna" = "blue", "Teoretyczna" = "red"),
labels = c("Empiryczna", "Teoretyczna")
) +
# Etykiety i tytuł
labs(
title = "Porównanie dystrybuanty empirycznej i teoretycznej",
x = "Wartość",
y = "Prawdopodobieństwo skumulowane",
color = "Typ dystrybuanty" # Tytuł legendy
) +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5))
```