expr()
-- creates an expression
expr(y <- 1)
"Parsing" = convert string to AST
parse_expr("y <- 1")
parse_exprs("y <- 1; x <- 3")
"Deparsing" = convert AST to string
class Solution: | |
def numIslands(self, grid: List[List[str]]) -> int: | |
num_island = 0 | |
queue = deque() | |
for x in range(len(grid)): | |
for y in range(len(grid[0])): | |
if grid[x][y] == "1": | |
queue.append((x, y)) | |
while queue: |
# start container with correct port and bind mount | |
docker run -d -it -p 8788:8787 -v ~/two_sided_matching_empirical:/home/rstudio/two_sided_matching_empirical rocker/rstudio | |
# 8788 is the host port, to be access from browser | |
docker container ps # list containers | |
# Log into docker terminal as root (to install Miniconda) | |
docker exec -ti -u root container_name bash | |
apt update && apt install bzip2 # always update first so that the image has package cache | |
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh |
#include <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
NumericVector f_MHC(NumericVector y, double delta2, double S) { | |
double s2 = 1; // known data variance | |
double mu = 5; // prior mean | |
double t2 = 10; // prior variance | |
// Initialize storage |
expr()
-- creates an expression
expr(y <- 1)
"Parsing" = convert string to AST
parse_expr("y <- 1")
parse_exprs("y <- 1; x <- 3")
"Deparsing" = convert AST to string
# Conditional logit model where the covariates only vary across choice, NOT across respondent | |
ww2 <- matrix(c(18, 40.9, 33.5, 0.256, 0.065, 0.123), nrow = 3) # Covariates, taken from real data | |
true_alpha <- c(0.07, 1) # Assuming we know the true preference parameter | |
num_obs <- 5000 # Number of observations | |
num_choices <- 3 # Number of choices | |
S <- 1000 # Number of simulations | |
res <- matrix(NA, nrow = S, ncol = length(true_alpha)) # Storage for simulation result | |
for (s in 1:S) { | |
# Calculate the utility of respondent i for choice j | |
Uij <- matrix(NA, nrow = num_obs, ncol = num_choices) |
# Simulations to understand the standard error of conditional logit | |
# In this particular case, my covariates are alternative specific, | |
# and do NOT vary across respondents | |
# (in Cameron and Triverdi, even alternative-specific covariates vary | |
# across respondents) | |
negloglik <- function(beta) { | |
xb <- xx %*% beta | |
- sum(y * (xb - log(1 + exp(xb))) + (1 - y) * (-log(1 + exp(xb)))) | |
} |
If you have full lane control: (can't do this anymore with patch 7.09)
Always start attacking and denying as much as possible so that the two creep waves reset every time.
Deny your ranged creep sooner let the enemy creeps stay alive longer. This gives you more time to harass the offlaner without losing CS. (BSJ's concept of obligations)
The impact of tower on farming pattern
# Unix tool | |
brew install wget # needed downstream | |
# R and RStudio | |
brew tap homebrew/science | |
brew install --with-x11 r | |
brew cask install --appdir=/Applications rstudio | |
# Miniconda | |
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh |
#!/usr/bin/env python | |
# coding=utf-8 | |
from __future__ import print_function | |
import functools | |
import json | |
import os | |
import re | |
import sys |