Book Image

Mathematica Data Analysis

By : Sergiy Suchok
Book Image

Mathematica Data Analysis

By: Sergiy Suchok

Overview of this book

There are many algorithms for data analysis and it’s not always possible to quickly choose the best one for each case. Implementation of the algorithms takes a lot of time. With the help of Mathematica, you can quickly get a result from the use of a particular method, because this system contains almost all the known algorithms for data analysis. If you are not a programmer but you need to analyze data, this book will show you the capabilities of Mathematica when just few strings of intelligible code help to solve huge tasks from statistical issues to pattern recognition. If you're a programmer, with the help of this book, you will learn how to use the library of algorithms implemented in Mathematica in your programs, as well as how to write algorithm testing procedure. With each chapter, you'll be more immersed in the special world of Mathematica. Along with intuitive queries for data processing, we will highlight the nuances and features of this system, allowing you to build effective analysis systems. With the help of this book, you will learn how to optimize the computations by combining your libraries with the Mathematica kernel.
Table of Contents (10 chapters)
9
Index

Main features for writing expressions

At the beginning, it should be mentioned that Wolfram Mathematica has a very extensive reference system. You can access it by selecting in this menu: Support | Wolfram Documentation:

Main features for writing expressions

Let's get acquainted with some distinctions of Mathematica that will help us to understand the source code in the following chapters.

Let's create our first notebook. When Mathematica starts, you should choose New Document and then Notebook.

In order to compute any expression, press Shift + Enter after entering it. The input expression will be denoted by In and the output by Out:

In[1]:= 1 + 4
Out[1]= 5

Note

In this and other samples, all the formulas will start with In[Number]; you shouldn't type this because it is the number of the input that Mathematica calculates automatically.

All built-in functions always start with a capital letter, as shown here:

Main features for writing expressions

No variables should start with a number, since it will automatically be treated as a multiplication operation. They cannot end with a $ symbol.

If the variable ends with _, then it is a template expression and it can be substituted with anything, for example:

Main features for writing expressions

In Mathematica, there are four types of brackets:

  • Square []: These are used to describe the function parameters
  • Round (): These are used to group expressions and logical elements
  • Curly {}: These are used to describe the elements of arrays, vectors, and data lists
  • Double Square [[ ]]: These are used to allocate a specific item in a data list

In Mathematica, there are two types of assignments: absolute (=) and delayed (:=).

The difference is that in a delayed assignment, the right-hand side of the expression is always recomputed if the function is called. In an absolute assignment, the value that was in place during the assignment is stored.

Main features for writing expressions

In this example, we see that at the time of the second call of variables, x2 adopted the current time value. At the same time, x1 remained unchanged.

In order to use the result of the preceding expression, one can use the % symbol:

Main features for writing expressions

The basis of the Mathematica language is the functional form of all the expressions. In order to see a complete expression, the FullForm function should be used:

Main features for writing expressions

The variables that are not used should be cleared by the Clear function. Otherwise, computation errors will occur:

Main features for writing expressions