This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import functools as ft | |
| def display_hist(x, num_bins = 8, zeros_as_blank = False): | |
| '''Returns a histogram as a unicode text string, e.g. '▁▂▄█▆▃▁▁' | |
| Inspired by the `precis` function from the Statistical Rethinking R package | |
| by Richard McElreath. This function will calculate a histogram and then | |
| returns a string displaying the histogram in unicode characters. It uses the | |
| LOWER BLOCK group like "2584 ▄ LOWER HALF BLOCK". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| prize_money <- function(places, entry_fee, members){ | |
| gold <- (1 + sqrt(5)) / 2 | |
| place_count <- function(prize_dist, places, place_counter){ | |
| if(place_counter == 1){ | |
| result <- place_count(c(1 - 1 / gold, 1/gold), places, place_counter + 1) | |
| } else if(place_counter == places){ | |
| return(prize_dist) | |
| } else { | |
| result <- place_count(c(c(1 - 1 / gold, 1 / gold) * prize_dist[1], prize_dist[-1]), places, place_counter + 1) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(devtools) | |
| install_github("tiagomendesdantas/Rspotify") | |
| library(Rspotify) | |
| # https://github.com/tiagomendesdantas/Rspotify | |
| keys <- spotifyOAuth(app_id = "Discover Mills", client_id = "1bf895600e3648b6bc3509f5df59c505", client_secret = "a2981db70b424244b14c2ff18e7b32e4") | |
| user <- getUser("mattmills49", token = keys) | |
| test <- httr::GET(paste0("https://api.spotify.com/v1/users/","mattmills49"), httr::config(token = keys)) | |
| json1 <- httr::content(test) | |
| test <- getPlaylist(name = "mattmills49", offset = 0, token = keys) |