diff --git a/chapters/convention.md b/chapters/convention.md index b53b4a0..245c9fc 100644 --- a/chapters/convention.md +++ b/chapters/convention.md @@ -54,6 +54,9 @@ As we can see from the function type, the output can be specified by an optional Most binary math functions in Owl are associated with a shorthand operator, such as `+`, `-`, `*`, and `/`. The impure versions also have their own operators. For example, corresponding to `Arr.(x + y)` which returns the result in a new ndarray, you can write `Arr.(x += y)` which adds up `x` and `y` and saves the result into `x`. + +The table below shows alias of pure and impure binary math functions. + Function Name |Pure |Impure -------------- |-------------- |-------------- add |`+` |`+=` @@ -65,7 +68,6 @@ sub_scalar |`-$` |`-$=` mul_scalar |`*$` |`*$=` div_scalar |`/$` |`/$=` -: Alias of pure and impure binary math functions {#tbl:convention:pure} ## Ndarray vs. Scalar @@ -155,6 +157,8 @@ As long as a module implements all the functions defined in the module signature The operators have been included in each `Ndarray` and `Matrix` module. The following table summarises the operators currently implemented. In the table, both `x` and `y` represent either a matrix or an ndarray while `a` represents a scalar value. +The table below shows infix operators in ndarray and matrix modules. + Operator |Example |Operation |Dense/Sparse |Ndarray/Matrix ------------ |------------ |------------------------ |------------ |----------------- `+` |`x + y` |element-wise add |both |both @@ -212,7 +216,6 @@ Operator |Example |Operation |Dense/Sparse |Ndarray/ `@=` |`x @= y` |concatenate vertically |Dense |both `@||` |`x @|| y` |concatenate horizontally |Dense |both -: Infix operators in ndarray and matrix modules {#tbl:convention:infix} There is a list of things worth your attention as below. @@ -301,11 +304,9 @@ Operator | Example | Operation `min2` | `min2 x y` | element-wise min `max2` | `max2 x y` | element-wise max -: Operator extensions {#tbl:convention:ext} +You may have noticed, the operators ended with `$` (e.g., `+$`, `-$` ...) disappeared from the table, which is simply because we can add/sub/mul/div a scalar with a matrix directly and we do not need these operators any more. Similar for comparison operators, because we can use the same `>` operator to compare a matrix to another matrix, or compare a matrix to a scalar, we do not need `>$` any longer. Allowing inter-operation makes the operator table much shorter. -You may have noticed, the operators ended with `$` (e.g., `+$`, `-$` ...) disappeared from the table, which is simply because we can add/sub/mul/div a scalar with a matrix directly and we do not need these operators any more. Similar for comparison operators, because we can use the same `>` operator to compare a matrix to another matrix, or compare a matrix to a scalar, we do not need `>$` any longer. Allowing interoperation makes the operator table much shorter. - -Currently, the operators in `Ext` only support interoperation on dense structures. Besides binary operators, `Ext` also implements most of the common math functions which can be applied to float numbers, complex numbers, matrices, and ndarray. These functions are: +Currently, the operators in `Ext` only support inter-operation on dense structures. Besides binary operators, `Ext` also implements most of the common math functions which can be applied to float numbers, complex numbers, matrices, and ndarray. These functions are: `im`; `re`; `conj`, `abs`, `abs2`, `neg`, `reci`, `signum`, `sqr`, `sqrt`, `cbrt`, `exp`, `exp2`, `expm1`, `log`, `log10`, `log2`, `log1p`, `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, `floor`, `ceil`, `round`, `trunc`, `erf`, `erfc`, `logistic`, `relu`, `softplus`, `softsign`, `softmax`, `sigmoid`, `log_sum_exp`, `l1norm`, `l2norm`, `l2norm_sqr`, `inv`, `trace`, `sum`, `prod`, `min`, `max`, `minmax`, `min_i`, `max_i`, `minmax_i`. @@ -347,8 +348,6 @@ These modules are simply the wrappers of the original modules in `Owl.Dense` mod ``` -There are also corresponding `packing` and `unpacking` functions you can use, please read `owl_ext_types.ml `_ for more details. - Let's see some examples to understand how convenient it is to use `Ext` module. ```ocaml @@ -577,7 +576,7 @@ R4 (0.981664, 0i) (0.446936, 0i) (0.276383, 0i) (0.414747, 0i) (0.174775, 0i) To know more about the functions provided in each module, please read the corresponding interface file of `Generic` module. The `Generic` module contains the documentation. -* [Dense.Ndarray.Generic](https://github.com/ryanrhymes/owl/blob/master/src/owl/dense/owl_dense_ndarray_generic.mli) -* [Dense.Matrix.Generic](https://github.com/ryanrhymes/owl/blob/master/src/owl/dense/owl_dense_matrix_generic.mli) -* [Sparse.Ndarray.Generic](https://github.com/ryanrhymes/owl/blob/master/src/owl/sparse/owl_sparse_ndarray_generic.mli) -* [Sparse.Matrix.Generic](https://github.com/ryanrhymes/owl/blob/master/src/owl/sparse/owl_sparse_matrix_generic.mli) +* [Dense.Ndarray.Generic](https://github.com/owlbarn/owl/blob/master/src/owl/dense/owl_dense_ndarray_generic.mli) +* [Dense.Matrix.Generic](https://github.com/owlbarn/owl/blob/master/src/owl/dense/owl_dense_matrix_generic.mli) +* [Sparse.Ndarray.Generic](https://github.com/owlbarn/owl/blob/master/src/owl/sparse/owl_sparse_ndarray_generic.mli) +* [Sparse.Matrix.Generic](https://github.com/owlbarn/owl/blob/master/src/owl/sparse/owl_sparse_matrix_generic.mli) diff --git a/chapters/introduction.md b/chapters/introduction.md index 0b1cd75..db58447 100644 --- a/chapters/introduction.md +++ b/chapters/introduction.md @@ -377,7 +377,7 @@ To load the image into browser, we need to call the `Jupyter_notebook.display_fi Jupyter_notebook.display_file ~base64:true "image/png" "plot_00.png" ``` -![Plot example using Owl Notebook](../images/introduction/plot_00.png "plot_00"){ width=90% #fig:introduction:example00} +![Plot example using Owl Notebook](../images/introduction/plot_00.png "plot_00") Even though the extra call to `display_file` is not ideal, it is obvious that the tooling in OCaml ecosystem has been moving forward quickly. I believe we will soon have even better and more convenient tools for interactive data analytical applications. @@ -405,6 +405,6 @@ For the time being, if you want to save that extra line to display a image in Ju ``` -![Plot example using Owl-Jupyter](../images/introduction/plot_01.png "plot_01"){ width=90% #fig:introduction:plot01 } +![Plot example using Owl-Jupyter](../images/introduction/plot_01.png "plot_01") From the example above, you can see Owl users' experience can be significantly improved by using the notebook. \ No newline at end of file diff --git a/chapters/maths.md b/chapters/maths.md index 0880db5..e1a6dbb 100644 --- a/chapters/maths.md +++ b/chapters/maths.md @@ -23,7 +23,7 @@ You can use these unary functions easily from the `Maths` module. For example: - : float = 1.41421356237309515 ``` -The [@tbl:maths:basic_unary] lists these unary functions supported in this module. +The table below lists these unary functions supported in this module. Function | Explanation ------------ | ------------------------------------------------------- @@ -34,15 +34,13 @@ Function | Explanation `ceil` | the smallest integer that is larger than `x` `round` | rounds `x` towards the bigger integer when on the fence `trunc` | integer part of `x` -`sqr` | $x^2$ -`sqrt` | $\sqrt{x}$ - -: Basic unary math functions {#tbl:maths:basic_unary} +`sqr` | $$x^2$$ +`sqrt` | $$\sqrt{x}$$ ### Basic Binary Functions Unlike the unary ones, the *binary functions* take two floats as inputs and return one float as output. -Most common arithmetic functions belong to this category, as shown in [@tbl:maths:binary]. +Most common arithmetic functions belong to this category: Function | Explanation ------------ | ------------------------------------------------------- @@ -56,57 +54,38 @@ Function | Explanation `atan2` | returns $$\arctan(y/x)$$, accounting for the sign of the | arguments; this is the angle to the vector $$(x, y)$$ counting from the x-axis. -: Binary math functions {#tbl:maths:binary} ### Exponential and Logarithmic Functions -The constant $e = \sum_{n=0}^{\infty}\frac{1}{n!}$ is what we call the *natural constant*. +The constant $$e = \sum_{n=0}^{\infty}\frac{1}{n!}$$ is what we call the *natural constant*. It is named this way because the exponential function and its inverse function logarithm are so frequently used in nature and our daily life: logarithmic spiral, population growth, carbon date ancient artifacts, computing bank investments, etc. -As an example, in a scientific experiment about bacteria, we can assume the number of bacterial at time $t$ follows an exponential function $n(t) = Ce^rt$ where $C$ is the initial population and $r$ is the daily increase rate. +As an example, in a scientific experiment about bacteria, we can assume the number of bacterial at time $$t$$ follows an exponential function $$n(t) = Ce^rt$$ where $$C$$ is the initial population and $$r$$ is the daily increase rate. With this model, we can predict how the population of bacterial grows within certain time. We also have this beautiful Euler's formula that connects the two most frequently used constants and the base of complex numbers and natural numbers: $$e^{i\pi}+ 1=0.$$ -The full list of exponential and logarithmic functions, together with some handy variants, are presented in [@tbl:maths:explog]. - ------------- ------------------------------------------------------- -Function Explanation ------------- ------------------------------------------------------- -`exp` exponential $e^x$ - -`exp2` $2^x$ - -`exp10` $10^x$ - -`expm1` returns $\exp(x) - 1$ but more accurate for $x \sim 0$ - -`log` $\log_e~x$ - -`log2` $\log_2~x$ - -`log10` $\log_10~x$ - -`logn` $\log_n~x$ - -`log1p` inverse of `expm1` - -`logabs` $\log(|x|)$ - -`xlogy` $x \log(y)$ - -`xlog1py` $x \log(y+1)$ - -`logit` $\log(p/(1-p))$ - -`expit` $1/(1+\exp(-x))$ - -`log1mexp` $\log(1-\exp(x))$ +The full list of exponential and logarithmic functions, together with some handy variants, are presented in the table below. -`log1pexp` $\log(1+\exp(x))$ ------------- ------------------------------------------------------- -: Exponential and logarithmic math functions {#tbl:maths:explog} +unction | Explanation +------------ | ------------------------------------------------------- +`exp` | exponential $$e^x$¥ +`exp2` | $$2^x$$ +`exp10` | $$10^x$$ +`expm1` | returns $$\exp(x) - 1$$ but more accurate for $$x \sim 0$$ +`log` | $$\log_e~x$$ +`log2` | $$\log_2~x$$ +`log10` | $$\log_10~x$$ +`logn` | $$\log_n~x$$ +`log1p` | inverse of `expm1` +`logabs` | $$\log(|x|)$$ +`xlogy` | $$x \log(y)$$ +`xlog1py` | $$x \log(y+1)$$ +`logit` | $$\log(p/(1-p))$$ +`expit` | $$1/(1+\exp(-x))$$ +`log1mexp` | $$\log(1-\exp(x))$$ +`log1pexp` | $$\log(1+\exp(x))$$ ### Trigonometric Functions @@ -119,54 +98,46 @@ The triangular functions are all unary functions, for example: - : float = 1. ``` -They are all included in the math module in Owl, as shown in [@tbl:maths:triangular]. - ------------- ---------------- ----------------- --------------------------------------------- -Function Explanation Derivatives Taylor Expansion ------------- ---------------- ----------------- --------------------------------------------- -`sin` $\sin(x)$ $\cos(x)$ $\sum_{n=1}(-1)^{n+1}\frac{x^{2n+1}}{(2n+1)!}$ - -`cos` $\cos(x)$ $-\sin(x)$ $\sum_{n=1}(-1)^n\frac{x^{2n}}{(2n)!}$ - -`tan` $\tan(x)$ $1 + \tan^2(x)$ $\sum_{n=1}\frac{4^n(4^n-1)B_n~x^{2n-1}}{(2n)!}$ +They are all included in the math module in Owl. -`cot` $1/\tan(x)$ $-(1 + \textrm{cot}^2(x))$ $\sum_{n=0}\frac{E_n~x^{2n}}{(2n)!}$ +Function | Explanation | Derivatives | Taylor Expansion +------------ | ---------------- | ----------------- | --------------------------------------------- +`sin` | $$\sin(x)$$ | $$\cos(x)$$ | $$\sum_{n=1}(-1)^{n+1}\frac{x^{2n+1}}{(2n+1)!}$$ +`cos` | $$\cos(x)$$ | $$-\sin(x)$$ | $$\sum_{n=1}(-1)^n\frac{x^{2n}}{(2n)!}$$ +`tan` | $$\tan(x)$$ | $$1 + \tan^2(x)$$ | $$\sum_{n=1}\frac{4^n(4^n-1)B_n~x^{2n-1}}{(2n)!}$$ +`cot` | $$1/\tan(x)$$ | $$-(1 + \textrm{cot}^2(x))$$ | $$\sum_{n=0}\frac{E_n~x^{2n}}{(2n)!}$$ +`sec` | $$1/\cos(x)$$ | $$\textrm{sec}(x)\tan(x)$$ | $$\sum_{n=0}\frac{2(2^{2n-1})B_n~x^{2n-1}}{(2n)!}$$ +`csc` | $$1/\sin(x)$$ | $$-\textrm{csc}(x)\textrm{cot}(x)$$ | $$\frac{1}{x}-\sum_{n=1}\frac{4^n~B_n~x^{2n-1}}{(2n)!}$$ -`sec` $1/\cos(x)$ $\textrm{sec}(x)\tan(x)$ $\sum_{n=0}\frac{2(2^{2n-1})B_n~x^{2n-1}}{(2n)!}$ - -`csc` $1/\sin(x)$ $-\textrm{csc}(x)\textrm{cot}(x)$ $\frac{1}{x}-\sum_{n=1}\frac{4^n~B_n~x^{2n-1}}{(2n)!}$ ------------- ---------------- ----------------- --------------------------------------------- -: Trigonometric math functions {#tbl:maths:triangular} - -Here the $B_n$ is the $n$th [Bernoulli number](https://en.wikipedia.org/wiki/Bernoulli_number), and $E_n$ is the $n$th [Euler number](https://en.wikipedia.org/wiki/Euler_number). -The [@fig:algodiff:trio] shows the relationship between these trigonometric functions. This figure is inspired by a [wiki post](https://zh.wikipedia.org/wiki/%E5%8F%8C%E6%9B%B2%E5%87%BD%E6%95%B0). -These functions also have corresponding inverse functions: `asin`, `acos`, `atan`, `acot`, `asec`, `acsc`. For example, if $\sin(a) = b$, then $\textrm{asin}(b) = a$. +Here the $B_n$ is the $n$th [Bernoulli number](https://en.wikipedia.org/wiki/Bernoulli_number), and $$E_n$$ is the $$n$$-th [Euler number](https://en.wikipedia.org/wiki/Euler_number). +The figure below shows the relationship between these trigonometric functions. This figure is inspired by a [wiki post](https://zh.wikipedia.org/wiki/%E5%8F%8C%E6%9B%B2%E5%87%BD%E6%95%B0). +These functions also have corresponding inverse functions: `asin`, `acos`, `atan`, `acot`, `asec`, `acsc`. For example, if $$\sin(a) = b$$, then $$\textrm{asin}(b) = a$$. ![Relationship between different trigonometric functions](../images/maths/trio.png "trio") Another related idea is the *Hyperbolic functions* such as `sinh` and `cosh`. These functions are defined using exponential functions. -We have seen in [@#fig:algodiff:trio] that the trigonometric functions are related to a circle. Similarly, the hyperbolic functions are related to a hyperbola. +We have seen that the trigonometric functions are related to a circle. Similarly, the hyperbolic functions are related to a hyperbola. For example, the points `(cosh(x), sinh(x))` form the right half of the equilateral hyperbola, just like `(cos(x), sin(x))` on a circle. The hyperbolic functions is applied widely in numerical computing, such as in the differential equation solutions, hyperbolic geometry, etc. These functions in Owl are shown below: -- `sinh`: $\frac{e^x - e^{-x}}{2}$, derivative is $\cosh(x)$, and taylor expansion is $\sum_{n=0}\frac{x^{2n+1}}{(2n+1)!}$. -- `cosh`: $\frac{e^x + e^{-x}}{2}$, derivative is $\sinh(x)$, and taylor expansion is $\sum_{n=0}\frac{x^{2n+1}}{(2n+1)!}$. -- `tanh`: $\frac{\sinh{x}}{\cosh{x}}$, derivative is $1-\tanh^2(x)$, and taylor expansion is $\sum_{n=1}\frac{4^n(4^n-1)B_{2n}~x^{2n-1}}{(2n)!}$. -- `coth`: $\frac{\cosh{x}}{\sinh{x}}$, derivative is $1-\coth^2(x)$, and taylor expansion is $\frac{1}{x}-\sum_{n=1}\frac{4^n~B_{2n}~x^{2n-1}}{(2n)!}$. -- `sech`: $1/\cosh(x)$, derivative is $-\tanh(x)/\cosh(x)$, and taylor expansion is $\sum_{n=0}\frac{E_{2n}~x^{2n}}{(2n)!}$. -- `csch`:$1/\sinh(x)$, derivative is $-\coth(x)/\sinh(x)$, and taylor expansion is $\frac{1}{x}+\sum_{n=1}\frac{2(1-2^{2n-1})B_{2n}~x^{2n-1}}{(2n)!}$. +- `sinh`: $$\frac{e^x - e^{-x}}{2}$$, derivative is $$\cosh(x)$$, and taylor expansion is $$\sum_{n=0}\frac{x^{2n+1}}{(2n+1)!}$$. +- `cosh`: $$\frac{e^x + e^{-x}}{2}$$, derivative is $$\sinh(x)$$, and taylor expansion is $$\sum_{n=0}\frac{x^{2n+1}}{(2n+1)!}$$. +- `tanh`: $$\frac{\sinh{x}}{\cosh{x}}$$, derivative is $$1-\tanh^2(x)$$, and taylor expansion is $$\sum_{n=1}\frac{4^n(4^n-1)B_{2n}~x^{2n-1}}{(2n)!}$$. +- `coth`: $$\frac{\cosh{x}}{\sinh{x}}$$, derivative is $$1-\coth^2(x)$$, and taylor expansion is $$\frac{1}{x}-\sum_{n=1}\frac{4^n~B_{2n}~x^{2n-1}}{(2n)!}$$. +- `sech`: $$1/\cosh(x)$$, derivative is $$-\tanh(x)/\cosh(x)$$, and taylor expansion is $$\sum_{n=0}\frac{E_{2n}~x^{2n}}{(2n)!}$$. +- `csch`: $$1/\sinh(x)$$, derivative is $$-\coth(x)/\sinh(x)$$, and taylor expansion is $$\frac{1}{x}+\sum_{n=1}\frac{2(1-2^{2n-1})B_{2n}~x^{2n-1}}{(2n)!}$$. Similarly, each of these functions has a corresponding inverse functions: `asinh`, `acosh`, `atanh`, `acoth`, `asech`, `acsch`. -The relationship between these hyperbolic trigonometric functions are clearly depicted in [@fig:algodiff:hyper_trio]. +The relationship between these hyperbolic trigonometric functions are clearly depicted in the figure below. ![Relationship between different hyperbolic trigonometric functions](../images/maths/hyper_trio.png "hyper_trio") Besides these functions, there are also some related functions. -`sinc` returns $\sin(x)/x$ and 1 for $x=0$. -`logsinh` returns $\log(\sinh(x))$ but handles large $|x|$. -`logcosh` returns $\log(\cosh(x))$ but handles large $|x|$. +`sinc` returns $$\sin(x)/x$$ and 1 for $$x=0$$. +`logsinh` returns $$\log(\sinh(x))$$ but handles large $$|x|$$. +`logcosh` returns $$\log(\cosh(x))$$ but handles large $$|x|$$. `sindg`/`cosdg`/`tandg`/`cotdg` are the sine/cosine/tangent/cotangent of the angle given in degrees. ### Other Math Functions @@ -176,10 +147,10 @@ Functions such as `sigmoid` and `relu` are frequently used in the Deep Learning The activation functions are crucial to the neural network regarding various aspects, including output result, accuracy, convergence speed, etc. We will talk about them in detail in the Neural Network chapter later in this book. -- `sigmoid x`: $1 / (1 + \exp(-x))$ +- `sigmoid x`: $$1 / (1 + \exp(-x))$$ - `signum x`: returns the sign of `x`: -1, 0, or 1 - `softsign x`: smooths `sign` function -- `relu x`: $\max(0, x)$ +- `relu x`: $$\max(0, x)$$ ## Special Functions @@ -203,7 +174,7 @@ val airy : float -> float * float * float * float The four returned numbers are `Ai`, its derivative `Ai'`, `Bi`, and its derivative `Bi'`. Let's look at an example. -It plots the two solutions `Ai` and `Bi` in [@fig:algodiff:airy]. +It plots the two solutions `Ai` and `Bi`. ```ocaml let x = Mat.linspace (-15.) 5. 200 @@ -238,48 +209,30 @@ The complex number $\alpha$ is called the "order" of the bessel function. Bessel functions are important for many problems in studying the wave propagation and static potentials, such as electromagnetic waves in a cylindrical waveguide. In solving cylindrical coordinate systems, Bessel functions of integer order or half integer order are often used. -The Bessel functions can be divided into two kinds. Both kinds are solutions to the Bessel's differential equations, but the first kind is non-singular at the origin, while the second kind is singular at the origin ($x=0$). -A special case is when $x$ is purely imaginary. In this case, the solutions are called the modified Bessel functions, which can also be categorised into first kind and second kind. +The Bessel functions can be divided into two kinds. Both kinds are solutions to the Bessel's differential equations, but the first kind is non-singular at the origin, while the second kind is singular at the origin ($$x=0$$). +A special case is when $$x$$ is purely imaginary. In this case, the solutions are called the modified Bessel functions, which can also be categorised into first kind and second kind. Based on these category, Owl provides these functions. --------- --------------------------------------------- -Function Explanation --------- --------------------------------------------- -`j0 x` Bessel function of the first kind of order 0 - -`j1 x` Bessel function of the first kind of order 1 - -`jv x y` Bessel function of the first kind of real order - -`y0 x` Bessel function of the second kind of order 0 - -`y1 x` Bessel function of the second kind of order 1 - -`yv x y` Bessel function of the second kind of real order - -`yn a x` Bessel function of the second kind of integer order - -`i0 x` Modified Bessel function of order 0 - -`i1 x` Modified Bessel function of order 1 - -`iv x y` Modified Bessel function of real order - -`i0e x` Exponentially scaled modified Bessel function of order 0 - -`i1e x` Exponentially scaled modified Bessel function of order 1 - -`k0 x` Modified Bessel function of the second kind of order 0 - -`k1` Modified Bessel function of the second kind of order 1 - -`k0e` Exponentially scaled modified Bessel function of the second kind of order 0 - -`k1e` Exponentially scaled modified Bessel function of the second kind of order 1 --------- --------------------------------------------- -: Bessel functions {#tbl:maths:bessel} - -In the example below, we plot the first kind Bessel function of order 0, 1, and 2, as shown in [@fig:algodiff:bessel]. +Function | Explanation +-------- | --------------------------------------------- +`j0 x` | Bessel function of the first kind of order 0 +`j1 x` | Bessel function of the first kind of order 1 +`jv x y` | Bessel function of the first kind of real order +`y0 x` | Bessel function of the second kind of order 0 +`y1 x` | Bessel function of the second kind of order 1 +`yv x y` | Bessel function of the second kind of real order +`yn a x` | Bessel function of the second kind of integer order +`i0 x` | Modified Bessel function of order 0 +`i1 x` | Modified Bessel function of order 1 +`iv x y` | Modified Bessel function of real order +`i0e x` | Exponentially scaled modified Bessel function of order 0 +`i1e x` | Exponentially scaled modified Bessel function of order 1 +`k0 x` | Modified Bessel function of the second kind of order 0 +`k1` | Modified Bessel function of the second kind of order 1 +`k0e` | Exponentially scaled modified Bessel function of the second kind of order 0 +`k1e` | Exponentially scaled modified Bessel function of the second kind of order 1 + +In the example below, we plot the first kind Bessel function of order 0, 1, and 2. ```ocaml let x = Mat.linspace (0.) 20. 200 @@ -310,32 +263,23 @@ There are twelve Jacobi elliptic functions and `ellipj` we include here in Owl r On the other hand, the *Elliptic integrals* are initially used to find the perimeters of ellipses. A Elliptic integral function can be expressed in the form of: $$f(x)=\int_c^xR(t, \sqrt(P(t)))dt,$$ -where $R$ is a rational function of its two arguments, $P$ is a polynomial of degree 3 or 4 with no repeated roots, and $c$ is a constant. +where $R$ is a rational function of its two arguments, $$P$$ is a polynomial of degree 3 or 4 with no repeated roots, and $$c$$ is a constant. An elliptic integral can be categorised as "complete" or "incomplete". The former one is function of a single argument, while the latter contains two arguments. Each elliptic integral can be transformed so that it contains integrals of rational functions and the three Legendre canonical forms, according to which the elliptic can be categorised into the first, second, and third kind. -The elliptic functions in Owl are listed in [@tbl:maths:elliptic]. - ----------------------- ----------------------------------------------------------------------------------- -Function Explanation ----------------------- ----------------------------------------------------------------------------------- -`ellipj u m` Jacobian elliptic functions of parameter `m` between 0 and 1, and real argument `u` - -`ellipk m` Complete elliptic integral of the first kind - -`ellipkm1 p` Complete elliptic integral of the first kind around m = 1 - -`ellipkinc phi m` Incomplete elliptic integral of the first kind - -`ellipe m` Complete elliptic integral of the second kind - -`ellipeinc phi m` Incomplete elliptic integral of the second kind ----------------------- ----------------------------------------------------------------------------------- -: Elliptic functions {#tbl:maths:elliptic} +The elliptic functions in Owl are listed below. +Function | Explanation +----------------- | ----------------------------------------------------------------------------------- +`ellipj u m` | Jacobian elliptic functions of parameter `m` between 0 and 1, and real argument `u` +`ellipk m` | Complete elliptic integral of the first kind +`ellipkm1 p` | Complete elliptic integral of the first kind around m = 1 +`ellipkinc phi m` | Incomplete elliptic integral of the first kind +`ellipe m` | Complete elliptic integral of the second kind +`ellipeinc phi m` | Incomplete elliptic integral of the second kind We can use `ellipe` to compute the circumference of an ellipse. To compute that normally requires calculus, but the elliptic functions provides a simple solution. -Suppose an ellipse has semi-major axis $a=4$ and semi-minor axis $b=3$. We an compute its circumference simply using $4a\textrm{ellipe}(1 - \frac{b^2}{a^2})$. +Suppose an ellipse has semi-major axis $$a=4$$ and semi-minor axis $$b=3$$. We an compute its circumference simply using $$4a\textrm{ellipe}(1 - \frac{b^2}{a^2})$$. ```ocaml # let a = 4. @@ -361,28 +305,19 @@ Here the gamma function is an integral from zero to infinity. If we change it to Similarly, if it is an integral from a certain lower limit to infinity, the integral is called the "upper incomplete gamma function". The Gamma function is widely used in a range of areas such as fluid dynamics, geometry, astrophysics, etc. It is especially suitable for describing a common pattern of processes that decay exponentially in time or space. -The Gamma function and related function provided in Owl are listed in [@tbl:maths:gamma]. - -------------------------- ------------------------------------------------------ -Function Explanation -------------------------- ------------------------------------------------------ -`gamma z` Returns the value of the Gamma function - -`rgamma z` Reciprocal of the Gamma function - -`loggamma z` Principal branch of the logarithm of the Gamma function - -`gammainc a x` Regularized lower incomplete gamma function +The Gamma function and related function provided in Owl are listed below. -`gammaincinv a y` Inverse function of `gammainc` +Function | Explanation +------------------------- | ------------------------------------------------------ +`gamma z` | Returns the value of the Gamma function +`rgamma z` | Reciprocal of the Gamma function +`loggamma z` | Principal branch of the logarithm of the Gamma function +`gammainc a x` | Regularized lower incomplete gamma function +`gammaincinv a y` | Inverse function of `gammainc` +`gammaincc a x` | Complemented incomplete gamma integral +`gammainccinv a y` | Inverse function of `gammaincc` +`psi z` | The digamma function -`gammaincc a x` Complemented incomplete gamma integral - -`gammainccinv a y` Inverse function of `gammaincc` - -`psi z` The digamma function -------------------------- ------------------------------------------------------ -: Gamma functions {#tbl:maths:gamma} Here is an example of using `gamma`. @@ -489,26 +424,19 @@ We can evaluate the zeta function at certain points, for example: The error functions here are not about error processing in programming, but yet another family of special functions. In mathematics, an error function is defined as: -$$\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2})dt.$$ +$$\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2}dt.$$ The error function occurs often in probability and statistics. Actually, in statistics, for a non-negative value `x`, `erf x` is the probability that a random variable `y` falls in the range `[-x, x]`. Here `y` follows a normal distribution with mean 0 and variance 0.5. Since it represents certain probability, the *complementary* error function `1 - erf(x)` is also frequently used. -The error function and related variants in Owl are listed in [@tbl:maths:error]. - -------------------------- ------------------------------------------------------ -Function Explanation -------------------------- ------------------------------------------------------ -`erf x` Error function - -`erfc x` Complementary error function: $1 - \textrm{erf}(x)$ +The error function and related variants in Owl are listed below. -`erfcx x` Scaled complementary error function: $\exp(x^2) \mathrm{erfc}(x)$ - -`erfinv x` Inverse function of `erf` - -`erfcinv x` Inverse function of `erfc` -------------------------- ------------------------------------------------------ -: Error functions {#tbl:maths:error} +Function | Explanation +------------- | ------------------------------------------------------ +`erf x` | Error function +`erfc x` | Complementary error function: $$1 - \textrm{erf}(x)$$ +`erfcx x` | Scaled complementary error function: $$\exp(x^2) \mathrm{erfc}(x)$$ +`erfinv x` | Inverse function of `erf` +`erfcinv x` | Inverse function of `erfc` The error function is a sigmoid function. We can observe its shape by the code below. @@ -551,26 +479,24 @@ let _ = ![Plot of the Dawson and Fresnel integral function.](../images/maths/example_integrals.png "integrals") -Besides these two, several other type of special integral functions are also provided. The full list is shown in [@tbl:maths:integral]. +Besides these two, several other type of special integral functions are also provided. The full list is shown below. Function |Explanation ----------------- |----------------------------------------------------------- -`expn n x` |Generalized exponential integral $E_n(x) = x^{n-1}\int_x^{\infty}\frac{e^{-t}}{t^n}dt$ -`shi x` |Hyperbolic sine integral: $\int_0^x~\frac{\sinh~t}{t}dt$ -`chi x` |Hyperbolic cosine integral: $\gamma + \log(x) + \int_0^x~\frac{\cosh~t -1}{t}dt$ +`expn n x` |Generalized exponential integral $$E_n(x) = x^{n-1}\int_x^{\infty}\frac{e^{-t}}{t^n}dt$$ +`shi x` |Hyperbolic sine integral: $$\int_0^x~\frac{\sinh~t}{t}dt$$ +`chi x` |Hyperbolic cosine integral: $$\gamma + \log(x) + \int_0^x~\frac{\cosh~t -1}{t}dt$$ `shichi x` |(`shi x`, `chi x`) -`si x` |Sine integral: $\int_0^x~\frac{\sin~t}{t}dt$ -`ci x` |Cosine integral: $\gamma + \log(x) + \int_0^x~\frac{\cos~t -1}{t}dt$ +`si x` |Sine integral: $$\int_0^x~\frac{\sin~t}{t}dt$$ +`ci x` |Cosine integral: $$\gamma + \log(x) + \int_0^x~\frac{\cos~t -1}{t}dt$$ `sici x` |(`si x`, `ci x`) -: Special integral functions {#tbl:maths:integral} - ## Factorials After the functions, let's turn to a concept that we are familiar with: the *factorials*. The definition of factorials is simple: -$F(n) = n! = n \times (n - 1) \times (n-2) \ldots \times 1$ +$$F(n) = n! = n \times (n - 1) \times (n-2) \ldots \times 1$$ The factorial function, together with several of its variants, are contained in the `Math` module. @@ -578,11 +504,9 @@ Function |Explanation ----------------- |----------------------------------------------------------- `fact n` |Factorial function $!n$ `log_fact n` |Logarithm of factorial function -`doublefact n` |Double factorial function calculates $n!! = n(n-2)(n-4)\dots 2$ (or 1) +`doublefact n` |Double factorial function calculates $$n!! = n(n-2)(n-4)\dots 2$$ (or 1) `log_doublefact n` |Logarithm of double factorial function -: Factorial functions {#tbl:maths:factorial} - The factorial functions accepts integer as input, for example: ```ocaml @@ -592,25 +516,17 @@ The factorial functions accepts integer as input, for example: The factorials are applied in many areas of mathematics, most notably the combinatorics. The permutation and combination are both defined in factorials. -The permutation function returns the number $n!/(n-k)!$ of ordered subsets of length $k$, taken from a set of $n$ elements. -The combination function returns the number ${n\choose k} = n!/(k!(n-k)!)$ of subsets of $k$ elements of a set of $n$ elements. -[@tbl:maths:perm] provides the combinatorics functions you can use in the `Math` module. - +The permutation function returns the number $$n!/(n-k)!$$ of ordered subsets of length $$k$$, taken from a set of $$n$$ elements. +The combination function returns the number $${n\choose k} = n!/(k!(n-k)!)$$ of subsets of $$k$$ elements of a set of $n$ elements. +The table below provides the combinatorics functions you can use in the `Math` module. ----------------------- ----------------------------------------------------------- Function Explanation ---------------------- ----------------------------------------------------------- `permutation n k` Permutation number - `permutation_float n k` Similar to `permutation` but deals with larger range and returns float - `combination n k` Combination number - `combination_float n k` Similar to `combination` but deals with larger range and returns float - -`log_combination n k` Returns the logarithm of ${n\choose k}$ ----------------------- ----------------------------------------------------------- -: Permutation and combination functions {#tbl:maths:perm} +`log_combination n k` Returns the logarithm of $${n\choose k}$$ Let's take a look at a simple example. @@ -623,8 +539,8 @@ val y : float = 45. ## Interpolation and Extrapolation -Sometimes we don't know the full description of a function $f$, but only some points on it, and therefore we cannot calculate its value at an aribitrary point. -The target is to esimate the $f(x)$ for an arbitrary $x$ by drawing a smooth curve through the given data. If $x$ is within the range of the given data, this taks is called *interpolation*, otherwise it's called *extrapolation*, which is much more difficult to do. +Sometimes we don't know the full description of a function $$f$$, but only some points on it, and therefore we cannot calculate its value at an aribitrary point. +The target is to esimate the $$f(x)$$ for an arbitrary $$x$$ by drawing a smooth curve through the given data. If $$x$$ is within the range of the given data, this taks is called *interpolation*, otherwise it's called *extrapolation*, which is much more difficult to do. The `Owl_maths_interpolate` module provides an `polint` function for interpolation and extrapolation: @@ -633,11 +549,11 @@ val polint : float array -> float array -> float -> float * float ``` The function `polint xs ys x` performs polynomial interpolation of the given arrays `xs` and `ys`. -Given arrays $xs[0 \ldots (n-1)]$ and $ys[0\ldots~(n-1)]$, and a value `x`, this function returns a value `y`, and an error estimate `dy`. +Given arrays $$xs[0 \ldots (n-1)]$$ and $$ys[0\ldots~(n-1)]$$, and a value `x`, this function returns a value `y`, and an error estimate `dy`. As its name suggests, the `polint` approximates complicated curves with polynomial of the lowest possible degree that passes the given points. We show how this interplation method works with an example. -In the previous section we have said that the Gamma function is actually an interpolation solution to the integer function $y(x) = (n-1)!$. +In the previous section we have said that the Gamma function is actually an interpolation solution to the integer function $$y(x) = (n-1)!$$. So we can specify five nodes on a plane that are generated from this factorial functions, and see how the interpolation function works compared with the Gamma function itself. ```ocaml @@ -662,7 +578,7 @@ let ym = Mat.of_array y 1 5 ``` Now we can plot the interpolation function and compare it to the Gamma function. -As can be seen in [@fig:maths:interp], both lines cross the given nodes. The interpolated line fits well with the "true interpolation", i.e. the Gamma function, within a certain range. +Both lines cross the given nodes. The interpolated line fits well with the "true interpolation", i.e. the Gamma function, within a certain range. However, the extrapolation fitting where the x-value falls out of given data, is less than ideal. ```ocaml @@ -680,13 +596,13 @@ let _ = ## Integration We have introduced some special integral functions, but we still need general integration methods that work for any input functions. -Given a function $f$ that accepts a real variable and an interval $[a, b]$ of the real line, the integral of this function +Given a function $f$ that accepts a real variable and an interval $$[a, b]$$ of the real line, the integral of this function $$\int_a^bf(x)dx$$ -can be thought of as the sum of signed area of the region in the cartesian plane that is bounded by the curve of f, the x-axis within the x-axis range $[a, b]$. The area above the x-axis adds to the sum and that below the x-axis subtracts from the area sum. +can be thought of as the sum of signed area of the region in the cartesian plane that is bounded by the curve of f, the x-axis within the x-axis range $$[a, b]$$. The area above the x-axis adds to the sum and that below the x-axis subtracts from the area sum. -In the `Owl_maths_quandrature` module, Owl provides several neumerical routines to help you to do integrations. For example, we can compute $\int_1^4x^2$ with the code below: +In the `Owl_maths_quandrature` module, Owl provides several neumerical routines to help you to do integrations. For example, we can compute $$\int_1^4x^2$$ with the code below: ```ocaml # Owl_maths_quadrature.trapz (fun x -> x ** 2.) 1. 4. @@ -702,7 +618,7 @@ Using numerical methods (or *quadrature*) to do integration dates back to the in The basic idea is to use summation of small areas to approximate that of an integration. There exist a lot of algorithms to do numerical integration, and using the trapezoial rule is one of them. -This classical method divides `a` to `b` into $N$ equally spaced abscissas: $x_0, x_1, \ldots, x_N$. Each area between $x_i$ and $x_j$ is seen as an "Trapezoid" and the area formula is computed as: +This classical method divides `a` to `b` into $N$ equally spaced abscissas: $$x_0, x_1, \ldots, x_N$$. Each area between $$x_i$$ and $$x_j$$ is seen as an "Trapezoid" and the area formula is computed as: $$\int_{x_0}^{x_1}f(x)dx = h(\frac{f(x_0)}{2} + \frac{f(x_1)}{2}) + O(h^3f'').$$ @@ -715,7 +631,7 @@ val trapz : ?n:int -> ?eps:float -> (float -> float) -> float -> float -> float `trapz ~n ~eps f a b` computes the integral of `f` on the interval `[a,b]` using the trapezoidal rule. It works by iterating for several stages, each stage improving the accuracy by adding more interior points. -The argument $n$ specifies the maximum step which defaults to 20, and `eps` is the desired fractional accuracy threshold, which defaults to `1e-6`. +The argument $$n$$ specifies the maximum step which defaults to 20, and `eps` is the desired fractional accuracy threshold, which defaults to `1e-6`. The other methods are similar to `trapz` in interface, only different in implementation. For example, the `simpson` uses the Simpson formula: @@ -725,7 +641,7 @@ $$\int_{x_0}^{x_2}f(x)dx = h(\frac{f(x_0)}{3} + \frac{4f(x_1)}{3} + \frac{f(x_2) Then there is the *Romberg integration* (`romberg`) that can choose methods of different orders to give good accuracy, and the algorithms are normally much faster than the `trapz` and `simpson` methods. Moreover, if the abscissas can be varied, we have the adaptive Gaussian quadrature of fixed tolerance (`gaussian`) and Gaussian quadrature of fixed order (`gaussian_fixed`). -As an example, we can compute the special sine integral function $Si(x)=\int_0^x\frac{sin(t)}{t}dt$ from previous section using the numerical integration method. Let's set $x=4$. +As an example, we can compute the special sine integral function $$Si(x)=\int_0^x\frac{sin(t)}{t}dt$$ from previous section using the numerical integration method. Let's set $$x=4$$. We can see the numerical method `gaussian` works well to approximate this special integral function. ```ocaml @@ -750,8 +666,8 @@ This function is deterministic for all numbers representable by an int. It is im - : bool = true ``` -Another number theory related idea is the *Fermat's factorization*, which represents an odd integer as the difference of two squares: $N = a^2 - b^2$, and therefore `N` can be factorised as $(a+b)(a-b)$. -The function `fermat_fact` performs Fermat factorisation over odd number `N`, i.e. into two roughly equal factors $x$ and $y$ so that $N=x\times~y$. +Another number theory related idea is the *Fermat's factorization*, which represents an odd integer as the difference of two squares: $$N = a^2 - b^2$$, and therefore `N` can be factorised as $$(a+b)(a-b)$$. +The function `fermat_fact` performs Fermat factorisation over odd number `N`, i.e. into two roughly equal factors $x$ and $y$ so that $$N=x\times~y$$. ```ocaml # Maths.fermat_fact 6557 @@ -776,9 +692,8 @@ For example: - : float = 0.999999999999999889 ``` -## Summary We start the topic of numeric computation from the mathematics functions we are familiar with. This chapter introduces the math functions supported by Owl, including the basic and commonly used functions, some less freqently used but nontheless important special function, factorial, interpolation, extrapolation, integration, etc. Feel free to jump into any part you are interested in and use these functions to solve a mathematical problem at hand. -You may find Owl as good a calculator as any other numerical library. +You may find Owl as good a calculator as any other numerical library. \ No newline at end of file diff --git a/chapters/visualization.md b/chapters/visualization.md index 170597b..9f0bbcf 100644 --- a/chapters/visualization.md +++ b/chapters/visualization.md @@ -45,7 +45,7 @@ You will find that these commands are similar to those in other plotting tools s Once you call `Plot.output`, the plot will be "sealed" and written into the final file. The generated figure is shown below. -![Basic function plot](../images/visualisation/plot_001.png "plot_01"){ width=70% #fig:visualisation:plot_001} +![Basic function plot](../images/visualisation/plot_001.png "plot_01") If this looks too basic for you, then we have some fancy 3-D mesh graphs in the next part. @@ -84,7 +84,7 @@ In the following, we will provide some examples to show how to use the `spec` pa - : unit = () ``` -![Plot specification](../images/visualisation/plot_020.png "plot_20"){ width=90% #fig:visualisation:plot_020} +![Plot specification](../images/visualisation/plot_020.png "plot_20") The second example shows how to tune the `surf` plotting function in drawing a 3D surface. @@ -115,7 +115,7 @@ The second example shows how to tune the `surf` plotting function in drawing a 3 - : unit = () ``` -![Surf plot](../images/visualisation/plot_021.png "plot_21"){ width=90%,#fig:visualisation:plot_021 } +![Surf plot](../images/visualisation/plot_021.png "plot_21") ## Subplots @@ -162,7 +162,7 @@ Indeed, you can change the number of rows and columns of the subgraph layout by - : unit = () ``` -![Subplots](../images/visualisation/plot_002.png "plot_002"){ width=90% #fig:visualisation:plot_002} +![Subplots](../images/visualisation/plot_002.png "plot_002") ## Multiple Lines @@ -179,7 +179,7 @@ Here is one example with both sine and cosine lines in one plot. - : unit = () ``` -![Plot multiple lines](../images/visualisation/plot_024.png "plot_24"){ width=70% #fig:visualisation:plot_024 } +![Plot multiple lines](../images/visualisation/plot_024.png "plot_24") Here is another example which has both histogram and line plot in one figure. @@ -199,7 +199,7 @@ Here is another example which has both histogram and line plot in one figure. - : unit = () ``` -![Mix line plot and histogram](../images/visualisation/plot_025.png "plot_25"){ width=90% #fig:visualisation:plot_025 } +![Mix line plot and histogram](../images/visualisation/plot_025.png "plot_25") So as long as you "hold" the plot without calling `Plot.output`, you can plot many data sets in one figure. @@ -244,7 +244,7 @@ Despite of its messy looking, the following example shows how to use legend in O - : unit = () ``` -![Plot with legends](../images/visualisation/plot_026.png "plot_26"){ width=90% #fig:visualisation:plot_026 } +![Plot with legends](../images/visualisation/plot_026.png "plot_26") ## Drawing Patterns @@ -269,7 +269,7 @@ The plotting module supports multiple pattern of lines, as shown below: - : unit = () ``` -![Draw lines](../images/visualisation/plot_004.png "plot_24"){ width=90% #fig:visualisation:plot_004 } +![Draw lines](../images/visualisation/plot_004.png "plot_24") Similarly, we can also fill rectangles with different patterns, as shown in the example below. @@ -287,7 +287,7 @@ Similarly, we can also fill rectangles with different patterns, as shown in the - : unit = () ``` -![Fill patterns](../images/visualisation/plot_005.png "plot_05"){ width=90% #fig:visualisation:plot_005 } +![Fill patterns](../images/visualisation/plot_005.png "plot_05") ## Line Plot @@ -306,7 +306,7 @@ Line plot is the most basic function. You can specify the colour, marker, and li - : unit = () ``` -![Line plot with customised marker](../images/visualisation/plot_022.png "plot_22"){ width=90% #fig:visualisation:plot_022 } +![Line plot with customised marker](../images/visualisation/plot_022.png "plot_22") ## Scatter Plot @@ -341,7 +341,7 @@ The example below actually shows the various patterns of markers. They are refer - : unit = () ``` -![Scatter plot](../images/visualisation/plot_006.png "plot_006"){ width=90% #fig:visualisation:plot_006 } +![Scatter plot](../images/visualisation/plot_006.png "plot_006") ## Stairs Plot @@ -363,7 +363,7 @@ The step plot is also called "stairstep plot", since it draws the elements in a - : unit = () ``` -![Stairs plot](../images/visualisation/plot_007.png "plot_007"){ width=90% #fig:visualisation:plot_007 } +![Stairs plot](../images/visualisation/plot_007.png "plot_007") ## Box Plot @@ -382,7 +382,7 @@ A box plot graphically shows groups of numerical data through their quartiles. I - : unit = () ``` -![Box plot](../images/visualisation/plot_008.png "plot_008"){ width=90% #fig:visualisation:plot_008 } +![Box plot](../images/visualisation/plot_008.png "plot_008") ## Stem Plot @@ -403,7 +403,7 @@ Stem plot is simple, as the following code shows. - : unit = () ``` -![Steam plot](../images/visualisation/plot_009.png "plot_009"){ width=90% #fig:visualisation:plot_009 } +![Steam plot](../images/visualisation/plot_009.png "plot_009") Stem plot is often used to show the autocorrelation of a variable, therefore Plot module already includes `autocorr` for your convenience. @@ -422,7 +422,7 @@ Stem plot is often used to show the autocorrelation of a variable, therefore Plo - : unit = () ``` -![Stem plot with autocorrelation](../images/visualisation/plot_010.png "plot_010"){ width=90% #fig:visualisation:plot_010 } +![Stem plot with autocorrelation](../images/visualisation/plot_010.png "plot_010") ## Area Plot @@ -443,7 +443,7 @@ Area plot is similar to the line plot, but it fills the space between the line a - : unit = () ``` -![Area plot](../images/visualisation/plot_011.png "plot_011"){ width=90% #fig:visualisation:plot_011 } +![Area plot](../images/visualisation/plot_011.png "plot_011") ## Histogram & CDF Plot @@ -464,7 +464,7 @@ Given a series of measurements, you can easily plot the histogram and empirical - : unit = () ``` -![Histogram plot and CDF](../images/visualisation/plot_012.png "plot_012"){ width=90% #fig:visualisation:plot_012 } +![Histogram plot and CDF](../images/visualisation/plot_012.png "plot_012") ## Log Plot @@ -499,7 +499,7 @@ In the Owl plots, you can choose to use the log-scale on either or both x and y - : unit = () ``` -![Change plot scale on x- and y-axis to log](../images/visualisation/plot_013.png "plot_013"){ width=90% #fig:visualisation:plot_013 } +![Change plot scale on x- and y-axis to log](../images/visualisation/plot_013.png "plot_013") ## 3D Plot @@ -525,7 +525,7 @@ First, let's look at `mesh` and `surf` functions. - : unit = () ``` -![3D plot](../images/visualisation/plot_014.png "plot_014"){ width=90% #fig:visualisation:plot_014 } +![3D plot](../images/visualisation/plot_014.png "plot_014") It is easy to control the viewpoint with `altitude` and `azimuth` parameters. Here is an example. @@ -545,7 +545,7 @@ It is easy to control the viewpoint with `altitude` and `azimuth` parameters. He The generated figure is shown as below. -![Customised 3D Plot, example 1](../images/visualisation/plot_015.png "plot_015"){ width=90% #fig:visualisation:plot_015 } +![Customised 3D Plot, example 1](../images/visualisation/plot_015.png "plot_015") Here is another similar example with different functions. @@ -575,7 +575,7 @@ Here is another similar example with different functions. - : unit = () ``` -![Customised 3D Plot, example 2](../images/visualisation/plot_016.png "plot_016"){ width=90% #fig:visualisation:plot_016 } +![Customised 3D Plot, example 2](../images/visualisation/plot_016.png "plot_016") Finally, let's look at how heatmap and contour plot look like, using the same function as before. @@ -602,7 +602,7 @@ Finally, let's look at how heatmap and contour plot look like, using the same fu - : unit = () ``` -![Headmap and contour plot](../images/visualisation/plot_017.png "plot_017"){ width=90% #fig:visualisation:plot_017 } +![Headmap and contour plot](../images/visualisation/plot_017.png "plot_017") ## Advanced Statistical Plot @@ -645,7 +645,7 @@ A `qqplot` displays a quantile-quantile plot of the quantiles of the sample data - : unit = () ``` -![Advanced statistical plots with qqplot](../images/visualisation/plot_018.png "plot_018"){ width=90% #fig:visualisation:plot_018 } +![Advanced statistical plots with qqplot](../images/visualisation/plot_018.png "plot_018") The `probplot` is similar to `qqplot`. It contains two special cases: `normplot` for when the given theoretical distribution is Normal distribution, and `wblplot` for Weibull Distribution. Here is an example of them. @@ -668,7 +668,7 @@ The `probplot` is similar to `qqplot`. It contains two special cases: `normplot` - : unit = () ``` -![Advanced statistical plots with probplot](../images/visualisation/plot_019.png "plot_019"){ width=90% #fig:visualisation:plot_019 } +![Advanced statistical plots with probplot](../images/visualisation/plot_019.png "plot_019") ## Summary