Perhaps you can make a decision after reading the following short paragraph.

In an exclusive interview with NewsBTC, Yoni Assia, the CEO of the trading platform eToro discussed the Bitcoin evolution. According to him in August, the New York Stock Exchange, Microsoft, and Starbucks formed an initiative called BAAK to improve the usability and adoption of cryptocurrencies. The Japanese and South Korea governments disclosed they intend to strictly regulate cryptocurrency exchanges as regulated financial institutions and the government of China has spent over 3 B$ to finance blockchain initiatives.

A cryptocurrency is a collection of concepts and technologies that form the basis of a digital money ecosystem. The first blockchain was conceptualized by Satoshi Nakamoto in 2008 for Bitcoin. The original paper is available online. The current market cap of all cryptocurrencies is about less than 200 B$ with Bitcoin covering over half of it followed by Ethereum and other coins. In total there are over a thousand different coins by 2018.

The block time is the average time it takes for the network to generate one extra block in the blockchain. The block time for Ethereum is set to between 14 and 15 seconds, while for Bitcoin it is 10 minutes. It means perhaps a transaction can be performed faster with Ethereum than Bitcoin. By storing data across its peer-to-peer network, the blockchain eliminates a number of risks that come with data being held centrally. Bitcoins are created as a reward for a process known as mining. According to Wikipedia, Bitcoin had 5 million unique users in 2017.

After early “proof-of-concept” transactions, the first major users of Bitcoin were black markets, such as Silk Road. During its 30 months of existence, starting in February 2011, Silk Road exclusively accepted Bitcoins as payment, transacting 9.9 million in Bitcoins, worth about $214 million (2011-2012). It is a general trend that criminals adopt new technologies early enough.

In 2012 Bitcoin prices started at about one Euro growing to about ten for the year. In 2013 prices started at 10 Euro rising to 560 Euro by 1 January 2014. In 2015 prices started at 260 Euro and rose to about 400 Euro for the year. In 2016 prices rose to over 900 Euro on 1 January 2017 and rose to 16,500 Euro on Dec 17, 2017. Since then, the price collapsed in several steps. Early 2018, Google and Facebook announced that they ban advertisement of cryptocurrency. Throughout the rest of the first half of 2018, Bitcoin’s price fluctuated between 10,000 and 5,848 Euro. On Aug 18 2018 Bitcoin’s price was about 5750 Euro. Daily volume of the Bitcoin exchange is usually several billion Euro while the market cap is currently about 96 B Euro.

The price of Bitcoin and other cryptocurrencies are volatile compared to gold or standard currencies. About 20% of all Bitcoins are believed to be lost. The lost coins would have a market value of about $20 billion at July 2018 prices. Approximately 1 million Bitcoins have been stolen, which would have a value of about $7 billion at July 2018 prices. Bulk of the Bitcoin is traded in US $ or Japanese Yen.

Before getting started, you have to make sure that you are doing everything safely and properly. There have been a number of major hacking incidents in the past. This means your first step is to find the proper cryptocurrency wallet for storing your currency with proper security. Remember that there is no central bank to store your asset. You yourself have to take care of it in your wallet. Bitcoin is transferred in a peer-to-peer system: there is no central bank or server.

Bitcoin uses public-key cryptography, in which two cryptographic keys, one public and one private, are generated. At its most basic, a wallet is a collection of these keys. A wallet to cryptocurrency is like a browser to html. You need a wallet to perform standard operations: buy/sell, send/receive, and store. Some wallets also allow you to exchange one form of the cryptocurrency to another (see this and this).

Bitcoin Core is, perhaps, the best known implementation or client. It is an open source program available on GitHub. If you prefer to have a full node, Bitcoin Core requires a one-time download of about 210 GB of data plus a further 5-10 GB per month. By default, you will need to store all of that data, but if you enable pruning, you can store as little as 6 GB total without sacrificing any security.

There are tons of wallets for desktops, mobile apps, and web applications. Mobile wallets are user friendly but otherwise not the safest place to store your digital asset.

To buy Bitcoin or other coins, you need to verify your identity in one of the many places. The verification procedure usually takes a few days. You can buy Bitcoin with your bank account, credit card, PayPal, …. Nowadays even vouchers of Bitcoin are available in supermarket. Some of the exchange places like Coinbase, Bitstamp, eToro, Kraken, … allows you to have an online wallet on their webpage. However if you prefer to stay anonymous, you need a desktop wallet independent from your online or mobile app wallets.

There are certain places like Coin360 where you can have an eye on the developments in the market. Another example is the cryptocompare webpage. There are tons of other page providing near real-time data of the market. There are also dedicated mobile apps just to update users with the latest changes in the crypto market including the rising/falling prices, volume 24h (total transaction volume per day), market cap (total value of a certain type of coin), …

Bitcoin and other digital coins are interesting tools but perhaps not for everybody in the current state. It is worth, however, to study their structures as more and more companies adopt their usage. If you would like to know more about regulatory issues, for instance if a Bitcoin is a property, a currency, or a commodity, there are webpgaes like Cointelegraph which you can visit.

If someone has no interest in learning about the Bitcoin and co, it is better to stay away. Learning about cryptocurrency is similar to sex education for teenagers: one has to know it in advance.

]]>A classical approach is to use the reduced chi-square which takes into account the degrees of freedom in each fit. In Bayesian statistics, we can use the Bayes factor to perform decision making. The aim of the Bayes factor is to quantify the support for a model over another. When we want to choose between two models based on observed data, we calculate the evidence of each model, also called the marginalized likelihood. The Bayes factor is the ratio of the two evidences.

K = P(D|M1) / P(D|M2)

A value of K larger than one means support for model M1. There are, however, detailed tables about how to interpret the Bayes factor. Kass and Raftery (1995) presented the following table:

K Strength of evidence

1 to 3 not worth more than a bare mention

3 to 20 positive

20 to 150 strong

>150 very strong

in python, it can be done in different ways. One option is to use the PT Sampler in EMCEE. Another one is to use the PyMultinest, an advanced MCMC package which performs importance nested sampling.

In our example, the PT Sampler finds that there are strong support for the parabolic model compared to the cubic model, and at the same time very strong support for the parabolic model against the linear model. Please note that the Bayes factor does not tell which model is correct, it just quantitatively estimates which model is preferred given the observed data.

]]>the core program is fairly easy as it is a built-in function in python:

from scipy.interpolate import RBF

rbf = RBF(x, y, function=’quintic’, smooth=0.1)

s = rbf(x)

Unlike the previous example, we do not use the curve_fit module of Scipy, Instead, there is another dedicated module to estimate the orthogonal distance regression (odr). The program with some comments is shown below:

import numpy as np

from pylab import *

from scipy.optimize import curve_fit

from scipy import odr

def func(p, x):

a, b, c = p

return a * x *x + b*x + c

# Model object

quad_model = odr.Model(func)

# test data and error

x0 = np.linspace(-10, 10, 100)

y0 = – 0.07 * x0 * x0 + 0.5 * x0 + 2.

noise_x = np.random.normal(0.0, 1.0, len(x0))

noise_y = np.random.normal(0.0, 1.0, len(x0))

y = y0 + noise_y

x = x0 + noise_x

# Create a RealData object

data = odr.RealData(x, y, sx=noise_x, sy=noise_y)

# Set up ODR with the model and data.

odr = odr.ODR(data, quad_model, beta0=[0., 1., 1.])

# Run the regression.

out = odr.run()

#print fit parameters and 1-sigma estimates

popt = out.beta

perr = out.sd_beta

print(‘fit parameter 1-sigma error’)

print(‘———————————–‘)

for i in range(len(popt)):

print(str(popt[i])+’ +- ‘+str(perr[i]))

# prepare confidence level curves

nstd = 5. # to draw 5-sigma intervals

popt_up = popt + nstd * perr

popt_dw = popt – nstd * perr

x_fit = np.linspace(min(x), max(x), 100)

fit = func(popt, x_fit)

fit_up = func(popt_up, x_fit)

fit_dw= func(popt_dw, x_fit)

#plot

fig, ax = plt.subplots(1)

rcParams[‘font.size’]= 20

errorbar(x, y, yerr=noise_y, xerr=noise_x, hold=True, ecolor=’k’, fmt=’none’, label=’data’)

xlabel(‘x’, fontsize=18)

ylabel(‘y’, fontsize=18)

title(‘fit with error on both axis’, fontsize=18)

plot(x_fit, fit, ‘r’, lw=2, label=’best fit curve’)

plot(x0, y0, ‘k–‘, lw=2, label=’True curve’)

ax.fill_between(x_fit, fit_up, fit_dw, alpha=.25, label=’5-sigma interval’)

legend(loc=’lower right’,fontsize=18)

show()

Please note that as you know, python is case sensitive so do not try to use change the upper/lower case in the above commands. A general comment is that you can easily change the second order function of this example to any desired function. The method we used to estimate the uncertainties of fit parameters are the standard method using diagonal elements of the co-variance matrix.

]]>As you see in the above example, we fit a simple function with measured y-error, estimate the fit parameters and their uncertainties, and plot a confidence level of a given range. The program is shown below:

import numpy as np

from pylab import *

from scipy.optimize import curve_fit

def func(x, a, b, c):

return a * x *x + b*x + c

# test data and error

x = np.linspace(-10, 10, 100)

y0 = – 0.07 * x * x + 0.5 * x + 2.

noise = np.random.normal(0.0, 1.0, len(x))

y = y0 + noise

# curve fit [with only y-error]

popt, pcov = curve_fit(func, x, y, sigma=1./(noise*noise))

perr = np.sqrt(np.diag(pcov))

#print fit parameters and 1-sigma estimates

print(‘fit parameter 1-sigma error’)

print(‘———————————–‘)

for i in range(len(popt)):

print(str(popt[i])+’ +- ‘+str(perr[i]))

# prepare confidence level curves

nstd = 5. # to draw 5-sigma intervals

popt_up = popt + nstd * perr

popt_dw = popt – nstd * perr

fit = func(x, *popt)

fit_up = func(x, *popt_up)

fit_dw = func(x, *popt_dw)

#plot

fig, ax = plt.subplots(1)

rcParams[‘xtick.labelsize’] = 18

rcParams[‘ytick.labelsize’] = 18

rcParams[‘font.size’]= 20

errorbar(x, y0, yerr=noise, xerr=0, hold=True, ecolor=’k’, fmt=’none’, label=’data’)

xlabel(‘x’, fontsize=18)

ylabel(‘y’, fontsize=18)

title(‘fit with only Y-error’, fontsize=18)

plot(x, fit, ‘r’, lw=2, label=’best fit curve’)

plot(x, y0, ‘k–‘, lw=2, label=’True curve’)

ax.fill_between(x, fit_up, fit_dw, alpha=.25, label=’5-sigma interval’)

legend(loc=’lower right’,fontsize=18)

show()

Please note that using the measurement error is optional. If you do not have y-error, simply skip its command in the fit procedure:

# curve fit [with only y-error]

popt, pcov = curve_fit(func, x, y)

You still get an estimate for the uncertainty of the fit parameters, although it is less reliable. In the next post, I show an example of a least-square fit with error on both axis.

]]>