## Making Graphs using Elixir inside Jupyter Notebook

Jupyter Notebook is known for being an interactive workbench for Python code. However, you can actually use it with the Elixir programming language.

This assumes you already have Python (3.7.3), Jupyter Notebook (5.7.8), and Elixir (1.8.1) installed. Then you just need to install Elixir's Jupyter kernel:

$git clone https://github.com/pprzetacznik/IElixir.git$ cd IElixir
$mix deps.get$ MIX_ENV=prod mix compile
$./install_script.sh After that you can launch Notebook as usual:$ jupyter notebook

Now you will have the option of creating a new Elixir notebook.

#### Installing Hex Packages

Of course what we can accomplish would be pretty restrictive without using any libraries. To use Hex packages inside Notebook, we can use the Boyle library like this:

# make a new environment
Boyle.mk("project1")
Boyle.activate("project1")
# install package to this environment
Boyle.install({:timex, "~> 3.1"})

With the package installed, we can use it as usual:

You can use a previously created environment on another notebook like this:

Boyle.list() # find the environment name

#### Graphing with Elixir

Now comes the fun part. First install the required libraries. Explot is a wrapper for Matplotlib.

Boyle.mk("graph")
Boyle.activate("graph")
Boyle.install({:explot, "~> 0.1.0"})
Boyle.install({:dataframe, "~> 0.3.1"})

After that you can use plot_command to graph:

plot = Explot.new()
command = "scatter([0, 1, 2, 3], [0, 1, 4, 9])"
Explot.plot_command(plot, command)
Explot.show(plot)

The graph is not displayed inline but on another window which is annoying, but other than that it works great.

To draw a set of points, you can use the unzip method.

{xs, ys} = 0..3
|> Enum.map(& {&1, &1 * &1})
|> Enum.unzip()
xs_str = inspect(xs, limit: :infinity)
ys_str = inspect(ys, limit: :infinity)

plot = Explot.new()
command = "scatter(#{xs_str}, #{ys_str})"
Explot.plot_command(plot, command)
Explot.show(plot)

Which will draw the same graph as the first one.

Here's one example of a more interesting graph:

You can change the styling of the plot like this:

# set size (s) and opacity (alpha)
command = "scatter(#{xs_str}, #{ys_str}, s=25.0, alpha=0.3)"
Explot.plot_command(plot, command)
# give title
Explot.title(plot, "y=sin(x)")

Have fun!

## How to Generate Standard Deviation Graph in Python

pyplot.hist(np.random.randn(1000000),
bins=np.linspace(-4, 4, 200));

The function call randn gives you 1 million samples from the standard normal distribution (mean = 0, standard deviation = 1). linspace divides the interval -4 to 4 to 201 points (which means 200 equally spaced interval). Lastly, hist plots the histogram. Any values below -4 or above 4 is ignored.

## Essential WordPress Plugins for Math, Science, and Programming Blogs

If you are writing content related to math, science, or programming, chances are you will need to write mathematical equations or source code!

Luckily, if you use WordPress there are many plugins that will make your life easier and your site fabulous. This post will write about some plugins used to display geeky contents on this site.

#### Mathematical Equations

For mathematical equations, you can use the plugin LaTeX for WordPress. It uses LaTeX syntax which is the de facto standard for writing academic papers.

Currently the default settings doesn't work because the previous CDN of MathJax has shut down. Go to settings and change the MathJax server to https://cdn.rawgit.com/mathjax/MathJax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML

To write an inline formula, the syntax is:

$$YOUR-LATEX-CODE$$

For example:

$$\alpha+\beta\geq\gamma$$

Which will produce:

For equations that will be displayed on a single line (math mode in LaTeX lingo), use:

$YOUR-LATEX-CODE$

Which produces for example:

#### Source Code

Source code is displayed using the plugin Syntax Highlighter Evolved. To write a block of code, just surround with with [LANGUAGE][/LANGUAGE] where LANGUAGE is for example python or php.

The result is like this:

from math import sin

x = sin(0.0)
print(x)

#### Closing

As you can see, with some plugins your WordPress site will be ready to tackle any technical content. If you have other plugins to recommend please feel free to write in the comments.