14 ms·
Statistics with Julia [pdf]
- aapeli 7y agoAccompanying code here: https://github.com/h-Klok/StatsWithJuliaBook https://github.com/h-Klok/StatsWithJuliaBook
- ChrisRackauckas 7y agoThis is a very good resource. The one thing I would ask is that I would like to see examples of using DifferentialEquations.jl when you get to the section on dynamical systems, especially when doing discrete event simulation and stochastic differential equations. I opened an issue in the repo and we can continue discussing there (I'll help write the code, I want to use this in my own class :P)!
- Cybiote 7y agoI agree it's a wonderful resource. Which is exactly why I disagree with your suggestion. The book is uncommonly clear in how it explains fundamentals and bringing in such a powerful library ends up moving quite a bit away from that. It will no longer be just about the fundamentals of Julia on one hand and on the other, the algorithms will no longer be implementing language invariant. Losing that invariance IMO makes it less of a text on fundamentals.
- ChrisRackauckas 7y agoI would say calling an ODE solver is pretty fundamental to a lot of real scientific workflows, but I am pretty biased on that.
- iamcreasy 7y agoI do not remember using much calculus other than usign it to pass the college courses. Can you point me to some resources that would teach me how to use calculus(or ODE if that's more interesting) to solve interesting problems?
- ynazarathy 7y agoWe actually use the DifferentialEquations.jl package in one of the examples: https://github.com/h-Klok/StatsWithJuliaBook/blob/master/10_chapter/springMass.jl https://github.com/h-Klok/StatsWithJuliaBook/blob/master/10_...
- deleted 7y ago[deleted]
- jbee618 7y agoWould love to see chapter exercises to test comprehension and reinforce learning objectives.
- caiocaiocaio 7y agoJulia looked interesting to me, so I tried 1.0 after it came out. I have a oldish laptop (fine for my needs), and every time I tried to do seemingly anything, it spent ~5 minutes recompiling libraries or something. So I've been waiting newer versions that hopefully stop doing that, or for me to buy a better computer.
- SolarNet 7y agoThis is a core part of the design. It's part of why Julia is so useful for scientific computing, where one often has a large job that will require a lot of processing time, such that it is worth it to do an intensive JIT cycle every-time. And part of that is the analysis to take python-esque code and turning it into C levels of performance.
- aurelian15 7y agoI just looked into Julia (1.1) for scientific use (simulation of very simple dynamical systems) a few days ago. I have to admit that by the end of the day I was surprisingly frustrated. I felt that type annotations were insufficient (one of the reasons to move away from Python); in particular, I didn't find a way to specify statically sized array types as you can do with Eigen, a feature that I find incredibly useful to find mistakes at compile time. Furthermore, just plotting something (using Gadfly) took about 30 seconds the first time after Julia was started and about 20 seconds every consecutive call (on a high-end workstation, mind you). The next day I just ended up using C++/Eigen with a simple matplotlib binding [1]. The code is nearly indistinguishable from Python/Julia (except for having more verbose types where it makes sense, using "auto" otherwise), and the entire compile+run cycle takes less time for some short runs than it takes Julia to print "Hello World". That being said, I'm not advocating for people to use C++. I would love to use Julia, and applaud the developers for their hard work and contribution to scientific computing, but as it stands right now, it doesn't seem to be the right tool for me, since I'm relying on fast editing/execution cycles. [1] https://github.com/lava/matplotlib-cpp https://github.com/lava/matplotlib-cpp
- adamnemecek 7y ago
- plouffy 7y agoCommenting to find later.
- grzm 7y agoYou can effectively bookmark submissions by using the "favorite" link or just upvoting. The submission will show up in your profile under "favorite submissions" or "upvoted submissions", respectively.
- the_duke 7y agoIn addition, I hear that modern browsers support a ground-breaking functionality called "Bookmarks".
- lalaithion 7y agoTo be fair, many modern social media sites break bookmarks.
- iamcreasy 7y agoI would not rely on browse bookmarks too much. Recently I lost a large amount of bookmarks for google chrome sync overwriting my local copy. The bookmarks.bak file was missing too.
- 6gvONxR4sf7o 7y agoPlease don't do this.
- deleted 7y ago[deleted]
- adamnemecek 7y agoI invite everyone to check out julia. The language is pleasant and gets out of the way. The interop is nuts. To call say numpy fft, you just do using PyCall np = pyimport("numpy") np.fft.fft(rand(ComplexF64, 10)) Thats it. You call it with a julia native array, the result is in a julia native array as well. Same with cpp https://github.com/JuliaInterop/Cxx.jl https://github.com/JuliaInterop/Cxx.jl Or matlab https://github.com/JuliaInterop/MATLAB.JL https://github.com/JuliaInterop/MATLAB.JL It's legit magic
- fny 7y agoHow does Julia handle typing for interop?
- adamnemecek 7y agoWhat do you mean?
- StefanKarpinski 7y agoIf I understand your question correctly, the answer is that there are a fixed number of native types supported by Python and NumPy, all of which correspond naturally to Julia types and are converted bidirectionally by PyCall. Julia and NumPy arrays are memory-compatible and Julia knows how to handle arrays with memory allocated by other systems, so conversion back and forth between Julia arrays and NumPy arrays is zero-copy. Other types like Python dicts are proxied in Julia as special types that Julia knows how to work with as dictionaries (user-defined data types are common in Julia), while general Python objects are just proxied transparently and `obj.method` calls are passed through to the embedded Python runtime. You can even define a function object `f` in Python and call it using `f()` syntax in Julia and vice versa. It's all highly transparent and smooth.
- mruts 7y agoJulia is everything python could have been, and much more. I'm stuck with python right now as a lot of people in the data science/ML community are, but it's becoming increasingly viable to use Julia for "real" work. The Python-Julia interop story is pretty strong as well, which allows you to (somewhat) easily convert pandas/pytorch/sklearn code into Julia using Python wrappers. Julia has some unconventional things in it but they are all growing on me: 1. Indices by default start with 1. This honestly makes a ton of sense and off by one errors are less likely to happen. You have nice symmetry between the length of a collection and the last element, and in general just have to do less "+ 1" or "- 1" things in your code. 2. Native syntax for creation of matrices. Nicer and easier to use than ndarray in Python. 3. Easy one-line mathematical function definitions: f(x) = 2*x. Also being able to omit the multiplication sign (f(x) = 2x) is super nice and makes things more readable. 4. Real and powerful macros ala lisp. 5. Optional static typing. Sometimes when doing data science work static typing can get in your way (more so than for other kinds of programs), but it's useful to use most of the time. 6. A simple and easy to understand polymorphism system. Might not be structured enough for big programs, but more than suitable for Julia's niche. Really the only thing I don't like about the language is the begin/end block syntax, but I've mentioned that before on HN and don't need to get into it again.
- kgwgk 7y ago> Julia is everything python could have been The goals of Python were quite different from the goals of Julia.
- mruts 7y agoI’m not sure what Python’s goals are to be honest. It seems to me that the language is outclassed in every way by better, more consistent, more powerful, and more performant languages. Python programmers seem content implementing the same things over and over again. Like, for example, flattening a list/monad. List of things python doesn’t have but should: pattern matching, multi-line lambdas, more data structures (look at Scala for an example of what kind of data structures a standard library should provide), real threading, options, monads, futures, better performance, and more.
- jointpdf 7y agoThis looks like a good reference for the fundamentals of both statistics and Julia, as claimed. I have a small critique, since the authors asked for suggestions. The format for the code samples goes like (code chunk —> output/plots —> bullet points explaining the code line-by-line). This creates a bit of a readability issue. The reader will likely follow a pattern like: (Skim past the code chunk to the explanation —> Read first bullet, referencing line X —> Go back to code to find line X, keeping the explanation in mental memory —> Read second bullet point —> ...). In other words, too much switching/scrolling between sections that can be pages apart. Look at the example on pages 185-187 to see what I mean. I’m not sure what the optimal solution is. Adding comments in the code chunks themselves adds clutter and is probably worse (not to mention creates formatting nightmares). I think my favorite format is two columns, with the code on the left side and the explanations on the right. Here’s what I have in mind (doesn’t work on mobile): https://allennlp.org/tutorials https://allennlp.org/tutorials. Does anyone know of a solution for formatting something like this?
- j88439h84 7y agoI'm not sure how that allennlp site is doing it, but source is here: https://github.com/allenai/allennlp/blob/b0ea7ab6be2787495fa52efd0f603659197c7d76/tutorials/tagger/basic_allennlp.py https://github.com/allenai/allennlp/blob/b0ea7ab6be2787495fa...
- j88439h84 7y agoHere's what they're doing: https://github.com/allenai/allennlp/blob/master/tutorials/tagger/convert.py https://github.com/allenai/allennlp/blob/master/tutorials/ta...
- psychometry 7y agoNot using PDF would be a good start. Bookdown texts tend to be good for mixed code/prose sections.
- jointpdf 7y agoYeah but PDF itself isn’t really the problem. Bookdown is nice, but if you’re using Bookdown then you’re using RMarkdown, so you can easily output the same .Rmd file as HTML/PDF/Reveal.js/EPub/etc. I’m trying to find well-executed examples or templates for what I have in mind (two column layout of code/text, maybe in landscape orientation for better spacing), but I’m drawing up blanks so far. Specifically I’m looking for either LaTeX or Reveal.js packages/templates for this.
- dlphn___xyz 7y agowhats the selling point with Julia? why would i use it over something like R?
- j88439h84 7y agoIt's supposed to be faster
- Buttons840 7y agoIt's a bit more nuanced than that. It's "as fast" without having to write any C. I tried to recreate something like AlphaGo in Python using Keras, I never got the learning to work (probably because I was impatient and training on a laptop CPU), but a lot of the CPU time was simply being spent on manipulating the board state. So I ported my "Board" object to Rust, and it was a lot faster. Things like counting liberties or removing dead stones were a lot faster, which was important. Then I rewrote the whole thing in Julia and it was just as fast as my Python / Rust combo. So I saw for myself that Julia does solve the two language problem. It is as pleasant to write as Python (and I like it better actually), and performed as well as Rust, based on my informal benchmarks.
- j88439h84 7y agoWhat's the nuance? It's much faster?
- cshenton 7y agoJulia code gets compiled native via LLVM so it is about as fast as other natively compiled languages.
- Someone 7y agoNot making any claims about Julia, but “gets compiled native via LLVM” doesn’t imply ”is about as fast as other natively compiled languages” For example, a straightforward Python-to-LLVM compiler would generate code with every variable being a PyObject (https://docs.python.org/3/c-api/structures.html https://docs.python.org/3/c-api/structures.html) instance, and “switch(obj.ob_type)” equivalents that would require a “sufficiently advanced compiler” to get to equivalent speed as, say, C.
- bdod6 7y agoCan someone explain how this is more powerful than someone use an Python/R based workflow? E.g., I currently use a combination .ipynb, python scripts, and RStudio and this feels like it covers everything I need for any data science project.
- snicker7 7y agoFast for-loop, the ability to microoptimize numerical code (skip bounds checking in array access, SIMD optimations), GPU vector computing can use exact same code as CPU due to Julia functions being highly polymorphic. Your research code is your production code. Also the macro system allows one to define powerful DSLs (see Gen.jl for AI).
- jointpdf 7y agoI think Julia has a cleaner focus on scientific and mathematical computing than either R or Python (both for performance and understanding). i.e. the language is designed in such a way that corresponds more directly to mathematical notation and ways of thinking. If you’ve been in a graduate program that’s heavily mathematical, where you spend equal time doing pen and paper proofs and hacking together simulations and such (and frantically trying to learn a language like R/MATLAB/Python while staying afloat in your courses), you’ll appreciate the advantage of this. To my eyes, Python is too verbose and “computer science-y” and R is too quirky to fulfill this niche (I say this as someone that bleeds RStudio blue, and enjoys using Python+SciPy). I don’t think Julia is aimed at garden-variety / enterprise data science workflows. Caveat—I’m not a Julia user currently, so this is sort of a hot take. The “Ju” in Jupyter is for Julia, so it’s designed to be used as an interactive notebook language also. The Juno IDE is modeled after RStudio.
- anthony_doan 7y ago> R is too quirky to fulfill this niche I'd like to offer a counter point or add on to this. It's quirky enough to have many packages backed by some expert statistician. I hope Julia get to be successful in this regard too.
- 7y ago
- superdimwit 7y agoI'd really recommend anyone doing mildly numerical / data-ey work in python to give Julia a patient and fair try. I think the language is really solidly designed, and gives you ridiculously more power AND productivity than python for a whole range of workloads. There are of course issues, but even in the short time I've been following & using the language these are being rapidly addressed. In particular: generally less rich system of libraries (but some Julia libraries are state of the art across all languages, mainly due to easy metaprogramming and multiple dispatch) + generally slow compile times (but this is improving rapidly with caching etc). I would also note that you often don't really need as many "libraries" as you do in python or R, since you can typically just write down the code you want to write, rather than being forced to find a library that wraps a C/C++ implementation like in python/r.
- cauthon 7y agoAre all the plotting/visualization options still half baked?
- 3jckd 7y agoYes, they are. Slow and hardly as expressive or rich as python/r counterparts.
- ViralBShah 7y agoOne can use matplotlib in Julia by PyCall'ing it. So it is at least as good as anything else.
- newen 7y agoOr ggplot2 using RCall, which is what I use and it's quite nice.
- spacedome 7y agoI've found Plots.jl and PyPlots.jl to work well for most basic things, despite not always being entirely pleasant to use, for example the compilation time issue, but this should hopefully improve. The only real problem I had is that these are not quite sufficient for plots to be published in a paper, many visual tweaks you might want are broken or terribly documented, and I have to just use matplotlib or R. It is generally great for jupyter notebooks though. I see the current deficiencies as highlighting just how much work went into matplotlib and others to get where they are today (and even mpl is in some ways still lacking, for example 3D surfaces and meshes). It is unfortunate though, as plotting is a core functionality for their main target of computational science. But to answer your question, mostly yes. Everything seems to be slowly improving though.
- xvilka 7y agoNote that Julia 1.2[1] is on the verge[2] of being released. Also, it is interesting to see the list[3] of GSoC and JSoC (Julia's own Summer of Code). A lot of projects target the ML/AI applications. Personally, I am waiting for proper GNN support[4] in FluxML, but seems not much interest in it. [1] https://github.com/JuliaLang/julia/milestone/30 https://github.com/JuliaLang/julia/milestone/30 [2] https://discourse.julialang.org/t/julia-v1-2-0-rc2-is-now-available/26170 https://discourse.julialang.org/t/julia-v1-2-0-rc2-is-now-av... [3] https://julialang.org/blog/2019/05/jsoc19 https://julialang.org/blog/2019/05/jsoc19 [4] https://github.com/FluxML/Flux.jl/issues/625 https://github.com/FluxML/Flux.jl/issues/625
- cwyers 7y agoFor people who have more Julia experience -- is this (thinking mainly of chapter 4) representative of how most Julia users do plotting? It looks like a lot of calling out to matplotlib via PyPlot. I know Julia has a ggplot-inspired library called Gadfly.jl, is PyPlot more commonly used?
- StefanKarpinski 7y agoPlots.jl seems to be the most popular plotting package these days: https://github.com/JuliaPlots/Plots.jl https://github.com/JuliaPlots/Plots.jl
- thetwentyone 7y agoI bounce back and forth, usually using Gadfly for most plotting but Plots.jl is convenient for some stats plots (see StatsPlots.jl, which extends Plots.jl with nice built in functions for working with stats).
- chrispeel 7y agoThere is not yet a universally-used package for plotting. One recent tool is Makie.jl [1]. Many use Plots.jl [2] as an interface to PyPlot, GR [3], and other backends. I.e. you can change the backend with a single command. [1] https://github.com/JuliaPlots/Makie.jl https://github.com/JuliaPlots/Makie.jl [2] https://github.com/JuliaPlots/Plots.jl https://github.com/JuliaPlots/Plots.jl [3] https://github.com/jheinen/GR.jl https://github.com/jheinen/GR.jl
- chakerb 7y agoI was going to ask is there any Kindle version of this, then I skimmed over the book, and I don't think it will be readable on a Kindle. And even if it does, the reading experience will definitely be inferior.
- ynazarathy 7y agoThe book will be published by Springer (at which point the online draft will be removed). Yoni Nazarathy.
- Merrill 7y agoIn section "1.2 Setup and Interface" there is a very short description of the REPL and how it can be downloaded from julialang.org, as well as a much longer description of JuliaBox and how Jupyter notebooks can be run from juliabox.com for free. Although JuliaBox has been provided for free by Julia Computing, there has been discussion that this may not be possible in the future. However, Julia Computing does provide a distribution of Julia, the Juno IDE, and supported packages known as JuliaPro for free. For new users, would the free JuliaPro distribution be a good alternative to JuliaBox and/or downloading the REPL and kernal from julialang.org?
- improbable22 7y agoNo, I think you should simply download the ordinary version. Jupyter, Juno, etc. are easy enough to install locally. I forget the precise details, but I think JuliaPro comes with certain versions of packages, and it's less confusing just to get the latest of what you need (using the built-in package manager). JuliaBox (and https://nextjournal.com/ https://nextjournal.com/) are cloud services, but if you have a real computer and want to do this for more than a few minutes, just install it. (There's also no need for virtualenv etc.)
- abakus 7y agoI find Julia's .> , .==, .*, ./ (dots for element-by-element ufunc)... really ugly. Numpy's design is cleaner and better.
- ddragon 7y agoWhy? When I see the '.' I immediately know it's a broadcasted function (for example * for matrix multiplication vs *. hadamard product), and I get the vectorized version of any function I write for free with no extra boilerplate (and the compiler will even automatically fuse them together if I chain them to avoid wasting allocations). You can even customize the broadcasting and the fusion.