DS4 Song Simulation

Kaeden Asprocolas

Calculating Experimental Probabilities

We need to load tidyverse

{r} install.packages("tidyverse")

{r} library(tidyverse)

read playlist / find rows and columns

{r} df <- read_csv("Playlist - Clean.csv")

show artist and songs names in the columns

{r} head(df)

{r} df$Genre <- as.factor(df$Genre)

count Genre

{r} df %>% count(df$Genre)

{r} Genre_counts <- df %>% count(Genre)

calculate probabilities for Genres

{r} Genre_counts <- Genre_counts %>% mutate(prob=n/sum(n)) Genre_counts

show simplified Genre prob

{r} Genre_counts$prob <- round(Genre_counts$prob, 2) Genre_counts

Our next task is to simulate how shuffle works by pulling a random sample of songs and saving it as a new table. Now I will adjust this table to show me just the genres and their probabilities.

#4.5

{r} playlist<-sample_n(df, 10) playlist_genres<-playlist %>% count(Genre) playlist_genres<-playlist_genres %>% mutate(probabilties = n/sum(n)) playlist_genres

4.5

larger sample size

```{r} sample_n(df, 20) %>% count(Genre) %>% mutate(probability = round(n/sum(n), 2))


```{r}
sample_n(df, 30) %>% count(Genre) %>% mutate(probability = round(n/sum(n), 2))

```{r} sample_n(df, 40) %>% count(Genre) %>% mutate(probability = round(n/sum(n), 2))

```

#questions

my expiremental porbabilities are similar but not exactly the same

most numbers are within .1 from eachother

expiremental probability is most acurate with a large sample size

#reflect

coding helped me visualize the similarities and differences in the probabilities.

the most challenging code was finding the probabilties

finding the probabilities becuase it was the hardest

id like to learn more about

id ask for help more to get a better understanding

im wondering how