Bogumił Kamiński
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
using Requests | |
using StatsBase | |
const URL = "https://drive.google.com/uc?export=download&id=0B6ZlG_Eygdj-c1kzcmUxN05VUXM" | |
const ZNAME = "developer_survey_2017.zip" | |
const DNAME = "survey_results_public.csv" | |
function load() | |
isfile(DNAME) && return | |
if !isfile(ZNAME) |
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
using StatsBase # sample function | |
using Combinatorics # combinations function | |
using Plots # plotting infrastructure | |
# Code calculating distribution of HCP in hands of a pair of players in bridge | |
# Ace is worth 4 points, King 3, Queen 2, Jack 1, all other cards (36 in total) count as 0 | |
# Get the distribution using simulation | |
function sim_hand() | |
n = 1_000_000 |
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
function v_asian_sample(T, r, K, σ, X₀, m::Integer) | |
X = X₀ | |
x̂ = zero(X) | |
Δ = T/m | |
for i in 1:m | |
X *= exp((r-σ^2/2)*Δ + σ*√Δ*randn()) | |
x̂ += X | |
end | |
exp(-r*T)*max(x̂/m - K, 0) | |
end |
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 math | |
import random | |
import statistics | |
import numpy | |
from timeit import default_timer as timer | |
from numba import jit | |
def v_asian_sample(T, r, K, s, X0, m): | |
xhat = 0.0 | |
X = X0 |
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
function decode_utf8(x::Char) | |
c = reinterpret(UInt32, x) | |
if c < 0x00000080 | |
return c | |
end | |
if 0x0000C200 <= c & 0x0000FF00 <= 0x0000DF00 | |
if c & 0xffff0000 == 0 && 0x00000080 <= c & 0x000000FF <= 0x000000BF | |
return (c & 0x0000003F) | ((c & 0x00001F00) >> 2) | |
end | |
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# K. Growiec, J. Growiec, B. Kamiński | |
# Social Network Structure and The Trade-Off Between Social Utility and Economic Performance | |
# Simulation experiment design generation file | |
library(randtoolbox) | |
size <- 65536 | |
s_design <- sobol(size, 9, TRUE, 3, 4711, FALSE) | |
colnames(s_design) <- c("r", "p", "lambda", "sigma", "rho", |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
using Random | |
function setup(density) | |
[x == 1 ? 2 : rand() < density ? 1 : 0 for x in 1:251, y in 1:251] | |
end | |
function go(grid) | |
any(isequal(2), grid) || return true | |
for pos in shuffle!(findall(isequal(2), grid)) | |
x, y = pos[1], pos[2] |
OlderNewer