2 Getting started with Julia

 

This chapter covers

  • Understanding values and variables
  • Defining loops, conditional expressions, and functions
  • Variable scoping rules in Julia

If you are new to the Julia language, in this chapter, you will learn its basic syntax and most important concepts. We’ll focus on the aspects that are different from those in Python and R. Even if you already know Julia, I recommend that you quickly go through this chapter to make sure you have a complete understanding of the basic concepts.

If you are not sure how to install, set up, and use your working environment, how to get help, or how to install and manage packages, refer to appendix A.

Note that the chapters in part 1 are not meant to be a full course on Julia. They contain only essential information required for you to start doing data science in Julia. I recommend you refer to the books listed on the Julia project “Books” page (https://julialang.org/learning/books/) or to the Julia Manual (https://docs.julialang.org/en/v1/) for a complete introduction to Julia programming.

In this chapter, our goal is to write a function that calculates a winsorized mean of a vector. Informally speaking, a winsorized mean replaces the smallest and largest values with the less extreme observations closest to them. This is done to limit the effect of outliers on the result (http://mng.bz/m2yM). Let me start with explaining how you can compute this mean.

2.1 Representing values

2.2 Defining variables

2.3 Using the most important control-flow constructs

2.3.1 Computations depending on a Boolean condition

2.3.2 Loops

2.3.3 Compound expressions

2.3.4 A first approach to calculating the winsorized mean

2.4 Defining functions

2.4.1 Defining functions using the function keyword

2.4.2 Positional and keyword arguments of functions

2.4.3 Rules for passing arguments to functions

2.4.4 Short syntax for defining simple functions

2.4.5 Anonymous functions

sitemap