julia A Fast Dynamic Language for Technical Computing Viral B. Shah Jeff Bezanson, Stefan Karpinski, Alan Edelman, and many others! Prepared for Fifth Elephant July 13, 2013

Tuesday, 10 September 13

Why do we need one more?

Tuesday, 10 September 13

Some noteworthy features ‣ Open source with an MIT licensed core ‣ Easy installation - Just download a precompiled binary and run ‣ Dynamically typed with fast user-defined types ‣ Multiple dispatch with a sophisticated parametric type system ‣ JIT compiler - no need to vectorize for performance ‣ Co-routines ‣ Distributed memory parallelism ‣ Effortlessly call C, Fortran, and Python libraries ‣ Metaprogramming with Lisp-like macros ‣ Unicode support Tuesday, 10 September 13

A simulated stock market julia> plothist(randn(100000), 100)

Tuesday, 10 September 13

julia> plot(cumsum(randn(10000)))

Let’s compute π: Buffon needle problem function buffon(m) hit = 0 for l = 1:m mp = rand() phi = (rand() * pi) - pi / 2 xrechts = mp + cos(phi)/2 xlinks = mp - cos(phi)/2 if xrechts >= 1 || xlinks <= 0 hit += 1 end end miss = m - hit piapprox = m / hit * 2 end

Tuesday, 10 September 13

Let’s compute π in parallel

function buffon_par(m) hit = @parallel (+) for l = 1:m mp = rand() phi = (rand() * pi) - pi / 2 xrechts = mp + cos(phi)/2 xlinks = mp - cos(phi)/2 (xrechts>=1||xlinks<=0) ? 1 : 0 end miss = m - hit piapprox = m / hit * 2 end

Tuesday, 10 September 13

Familiar syntax for Matlab / Octave users function randmatstat(t; n=10) v = zeros(t) w = zeros(t) for i = 1:t a = randn(n,n) b = randn(n,n) c = randn(n,n) d = randn(n,n) P = [a b c d] Q = [a b; c d] v[i] = trace((P'*P)^4) w[i] = trace((Q'*Q)^4) end std(v)/mean(v), std(w)/mean(w) end

Tuesday, 10 September 13

Keyword arguments Familiar array syntax

Common matrix operations Common statistics Last expression is return value

Yes, you can also write low-level code! Pass by reference function qsort!(a,lo,hi) i, j = lo, hi Functions ending in ! modify the while i < hi pivot = a[(lo+hi)>>>1] while i <= j while a[i] < pivot; i = i+1; end while a[j] > pivot; j = j-1; end if i <= j a[i], a[j] = a[j], a[i] Swap elements i, j = i+1, j-1 end end if lo < j; qsort!(a,lo,j); end Recursion lo, j = i, hi end return a end Tuesday, 10 September 13

inputs

Call C, Fortran, Python libraries julia> ccall(:clock, Int32, ()) 2292761 julia> ccall(:getenv, Ptr{Uint8int8}, (Ptr{Uint8},), "SHELL") Ptr{Uint8} @0x00007fff5fbffc45 julia> bytestring(ans) "/bin/bash"

julia> using PyCall # Installed with Pkg.add(“PyCall”) julia> @pyimport math julia> math.sin(math.pi / 4) - sin(pi / 4) 0.0 julia> julia> julia> julia> Tuesday, 10 September 13

@pyimport pylab x = linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x)); pylab.plot(x, y; color="red", linewidth=2.0, linestyle="--") pylab.show()

Micro-benchmarks (log-scale) 10000

1000

100

10

1

Fortran

Julia

Python

Matlab

Octave

R

JavaScript

execution time relative to C++ (lower is better) Benchmarks: fib, parse_int, quicksort, mandel, pi_sum, rand_mat_stat, and rand_mat_mul Tuesday, 10 September 13

Let’s look at some real data julia> Pkg.add("DataFrames") Installing DataFrames: v0.3.6 julia> using DataFrames julia> vl = readtable("2013_BS_VL.csv", allowquotes=false) julia> size(vl) (1797590,12) julia> colnames(vl) julia> describe(vl)

Tuesday, 10 September 13

What does this data look like? julia> colnames(vl) 12-element Union(ASCIIString,UTF8String) Array: "AC" "ACNAME" "PS" "PSNAME" "PSADDR" "PSPART" "VoterID" "Name" "FatherHusband" "House" "Age" "Gender"

Tuesday, 10 September 13

Data is never clean julia> f = [ try int(vl["Age"][i]); catch -1; end for i in 1:size(vl,1) ] julia> vl = vl[f.!=-1, :] julia> vl[:Age] = PooledDataArray(int(vl[:Age])) julia> vl[:ACNAME] = PooledDataArray(int(vl[:ACNAME])) julia> vl[:PSNAME] = PooledDataArray(vl[:PSNAME])

julia> by(vl, :ACNAME, nrow) julia> by(vl, :ACNAME, x->mean(x[:Age])) julia> by(vl, :ACNAME, x->sum(DataArray(x[:Age] .<= 40)))

Tuesday, 10 September 13

Draw your own insights julia> describe(by(vl, :PSNAME, nrow)) PSNAME Length: 1613 Type : Pooled UTF8String NAs : 0 x1 Min 1st Qu. Median Mean 3rd Qu. Max

250.0 772.0 981.0 1113.8326100433974 1276.0 10416.0

julia> plot(1:1613, sort(pspop[:x1]))

Tuesday, 10 September 13

A great community 100+ contributors, 1000+ mailing list subscribers, 175+ packages AWS, ArgParse, BSplines, Benchmark, BinDeps, BioSeq, BloomFilters, Cairo, Calculus, Calendar, Cartesian, Catalan, ChainedVectors, ChemicalKinetics, Clang, Clp, ClusterManagers, Clustering, Codecs, CoinMP, Color, Compose, ContinuedFractions, Cpp, Cubature, Curl, DICOM, DWARF, DataFrames, DataStructures, Datetime, Debug, DecisionTree, Devectorize, DictUtils, DictViews, DimensionalityReduction, DiscreteFactor, Distance, Distributions, DualNumbers, ELF, Elliptic, Example, ExpressionUtils, FITSIO, FactCheck, FastaIO, FastaRead, FileFind, FunctionalCollections, FunctionalUtils, GLFW, GLM, GLPK, GLPKMathProgInterface, GLUT, GSL, GZip, Gadfly, Gaston, GeoIP, GeometricMCMC, GetC, GoogleCharts, Graphs, Grid, Gtk, Gurobi, HDF5, HDFS, HTTP, HTTPClient, Hadamard, HttpCommon, HttpParser, HttpServer, HypothesisTests, ICU, ImageView, Images, ImmutableArrays, IniFile, Iterators, Ito, JSON, JudyDicts, JuliaWebRepl, KLDivergence, LIBSVM, Languages, LazySequences, LibCURL, LibExpat, LinProgGLPK, Loss, MAT, MATLAB, MCMC, MDCT, MLBase, MNIST, MarketTechnicals, MathProg, MathProgBase, Meddle, Memoize, Meshes, Metis, MixedModels, Monads, Mongo, Mongrel2, Morsel, Mustache, NHST, NIfTI, NLopt, Named, NetCDF, NumericExtensions, NumericFunctors, ODBC, ODE, OpenGL, OpenSSL, Optim, Options, PLX, PTools, PatternDispatch, Phylo, Phylogenetics, Polynomial, Profile, ProgressMeter, ProjectTemplate, PyCall, PyPlot, PySide, Quandl, QuickCheck, RDatasets, REPL, RNGTest, RPMmd, RandomMatrices, Readline, Regression, Resampling, Rif, Rmath, RobustStats, Roots, SDE, SDL, SVM, SemidefiniteProgramming, SimJulia, SimpleMCMC, Sims, Sodium, Soundex, Sqlite, Stats, StrPack, Sundials, SymPy, TOML, Terminals, TextAnalysis, TextWrap, TimeModels, TimeSeries, Tk, TopicModels, TradingInstrument, Trie, URLParse, UTF16, Units, ValueDispatch, WAV, WebSockets, Winston, YAML, ZMQ, Zlib, kNN Tuesday, 10 September 13

A Fast Dynamic Language for Technical Computing - GitHub

Jul 13, 2013 - JIT compiler - no need to vectorize for performance. ‣ Co-routines. ‣ Distributed memory ... Effortlessly call C, Fortran, and Python libraries.

319KB Sizes 1 Downloads 302 Views

Recommend Documents

Abstraction in Technical Computing Jeffrey Werner Bezanson - GitHub
programming tools have advanced in terms of the abstractions and generalizations they are capable of. Science as a .... According to our theory, the issue is not really just a lack of types, but an exclusive focus on .... administrative tasks like me

A Declarative Language for Dynamic Multimedia Interaction Systems ⋆
declarative model for dynamic multimedia interaction systems. Firstly, we show that the ... The aim is to devise ways for the machine to be an active partner in a collective behavior con- ... tation of the data structure wrt the model in [5]. Section

A Generic Language for Dynamic Adaptation
extensible dynamically, and is not generic since it is applicable only for Comet. .... In this paper we present two examples for integrating services, one is a mon-.

GPU Computing - GitHub
Mar 9, 2017 - from their ability to do large numbers of ... volves a large number of similar, repetitive cal- ... Copy arbitrary data between CPU and GPU. • Fast.

dynamic array - GitHub
Page 1 ..... Facebook folly::dynamic. > “runtime dynamically typed value for C++, ... linux-only (Ubuntu/Fedora, and even there build is not easy!) dynamic twelve ...

Computing heritability - GitHub
Heritability is usually a desired outcome whenever a genetic component is involved in a model. There are three alternative ways for computing it. 1. Simulation ...

Technical Drawing - GitHub
Page 1. Page 2. 38.67 ). 22.30. 26.37. Page 3. Page 4. 2.05 。.25. 4.92. 0.75. 「. 4.50. 「 2.85. P。RT AND SW_T〔H. DETA_L. PPPPP. Page 5.

Sample Language for Reporting and Confidentially ... - GitHub
misconduct policy.1 Schools must also consult applicable state laws (such as .... order to provide a safe, non-discriminatory environment for all students. ... the College encourages victims to talk to someone, the College provides an online [or.

Technical Drawing - GitHub
Jan 19, 2017 - SD CARD DETAIL. (OMEGA2+ ONLY). D. C. B. A. A. B. C. D. 1. 2. 3. 4. 5. 6. 7. 8. 8. 7. 6. 5. 4. 3. 2. 1. OMEGA2. TITLE. DIMENSION IN MM.

IARC Technical Paper - GitHub
May 28, 2017 - The teams big break came after reaching out to Dr. Maruthi Akella. ... tracks the Roombas as well as keeps its global position using data taken .... studier/emner/matnat/ifi/INF4300/h09/undervisningsmateriale/hough09.pdf.

High Dynamic Range Imaging - GitHub
Oct 2, 2009 - Page 3 .... IC 2233 is an isolated superthin galaxy (D ~ 10.5 +/- 1 Mpc). • Mk 86 is a blue compact dwarf, spiral galaxy (D ~ 7 +/- 1 Mpc).

Pawn The Language - GitHub
1. Foreword. “pawn” is a simple, typeless, 32-bit “scripting” language with a C-like syn- ... language in my publication in Dr. Dobb's Journal and the years since. .... cesses and runs on conforming Pawn programs —either interpreters or com

The Nile Programming Language - GitHub
Skia (Chrome, Android) ... if (currE->fLastY == curr_y) { .... Speedup on 40 core machine. 1. 10. 20. 30. 40. 0. 5. 10. 15. 20. 25. 30. 35. Cores. S p eed u p ...

Open Shading Language 1.9 - GitHub
1 Introduction. 1. 2 The Big Picture. 5. 3 Lexical structure. 11. 3.1 Characters . .... OSL shaders are not monolithic, but rather can be organized into networks of ...

Computing Dynamic Heterogeneous-Agent Economies
Jun 24, 2011 - Feasibility is achieved by using Smolyak's (1963) sparse-grid ... to introduce a method for computing equilibrium in these models by ...... This is made clear in Figure 2 where a scatter plot of today vs ... today's shocks and capital

Computing Dynamic Heterogeneous-Agent Economies ...
Jun 24, 2011 - Keywords: Numerical Solutions, Heterogeneous Agents, Projection Methods. JEL Codes: ..... analytic solution is also given. The OLG model is ...

Computing Dynamic Optimal Mechanisms When ...
Sep 25, 2011 - than 15 dimensions, it is not good enough in many computational ... the problem in which non-local incentive constraints are ignored, and then goes on to check ..... rank K. One can always write π in this way with K = N,3 but it is al

Computing Dynamic Optimal Mechanisms When ...
Sep 25, 2011 - University of Wisconsin, Madison. Yuichiro ..... If the environment is convex, B maps convex sets into convex ...... Princeton University Press.

Scientific Computing for Biologists Hands-On Exercises ... - GitHub
Scientific Computing for Biologists. Hands-On Exercises, Lecture 7 .... Download the file zeros.dat from the course wiki. This is a 25 × 15 binary matrix that ...

The Ruby Programming Language - GitHub
You'll find a guide to the structure and organization of this book in Chapter 1. ..... Determine US generation name based on birth year ...... curly braces: "360 degrees=#{2*Math::PI} radians" # "360 degrees=6.28318530717959 radians" ...... of comput

Scientific Computing for Biologists Hands-On Exercises ... - GitHub
Nov 15, 2011 - computer runs Windows you can have access to a Unix-like environment by installing a program called .... 6 4976 Nov 1 12:21 rolland-etal-2 -cAMP.pdf ..... GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin1 . ).

Computing Science Technical Report No. 99 A ... - Research at Google
phase of their job they had to build a large mechanism that included two or more ... paths to insure that the actual radio links were used at their maximum .... The first public demonstration of the complex computer took place on ..... At the end of