čtvrtek 19. listopadu 2015

Metric

A metric has has to fulfill following properties:
  1. Be symmetric
  2. Zero for d(A, A)
  3. Be non-negative
  4. Follow the triangle inequality
Symmetry is an useful property - the distance between city A and city B should be the same as the distance between city B and city A. However, if we were measuring gas consumption of a car and city B was on a hill and city A was in the valley bellow the hill, we would expect to see different results for a route from A to B (to the hill), than from a route from B to A (down the hill).

Similarly, zero property may not be always fulfilled - for example, a taxi fare is not a metric, because you pay a minimal fare just for sitting into the taxi.

Non-negativity is not be fulfilled whenever we are interested into the direction. For example, in transactions with money, we are commonly quite interested into the direction of the money transfer.

Triangle inequality is does not hold, for instance, what if we represent the weights between nodes as the time required to travel between the points  represented by the nodes.  Further, to make this scenario more physical, let us consider 3 points. A, B, and C.  Imagine that A and C
are separated by a lake, whereas a and b are on a bank such that I can walk from A to B on land, and on B to C on land.  Let's say I can walk the ABC path in about 15 minutes, but it will take me 30 minutes to swim across the lake from A to C.  This problem is a physical possibility, but it does not exhibit triangle inequality because I increase the cost of my path by removing an intermediary point.

pondělí 2. listopadu 2015

Přijme Česká Republika Euro?

Ohlédnutí zpět:

V době hojnosti je pro státy výhodné vytvořit soulodí, protože všechny lodě míří přibližně stejným směrem - za blahobytem a prosperitou. A pro posádky lodí je výhodné, že můzou mezi sebou volně obchodovat. Problém ale nastává, když přijde bouřka. Pro velké lodě, jako Německo, je i za bouřky výhodné dál pokračovat nejkratší cestou za blahobytem a prosperitou, protože je nějaká malá bouře neohrozí. Ale pro malé lodě může být výhodnější se stočit proti vlnám, aby je vlny nezavalily. A teprve jak bouře pomine, vyrazit směr blahobyt a prosperita.

Když má stá vlastní měnu, má kontrolu nad kormidlem. Když ale stát přijme Euro, o tuto kontrolu přichází.

Jak jsem již řekl, v době blahobytu je Euro výhodné. Ale v době krize je Euro, zvláště pro malou ekonomiku, smrtící.

V současné době je pro Českou Republiku nejvýhodnější, když většina zemí přijme Euro, ale samo Euro nepřijme. Život občanů se tím zjednoduší - když vyjedou do zahraničí a zůstanou jim Eura, můžou je v klidu uložit do šuplíku, protože příští rok zase vyjedou do země, kde se platí Eurem. Přitom ale státu zůstane možnost kormidlovat v čase nečasu.

sobota 31. října 2015

I hate OS X El Capitan

There are following quirks on the new OS X that drives me crazy:
  1. I like if the typed text immediately shows on the display. However, on El Capitan the text can get sometimes delayed by whole seconds. This is a system wide problem - the "feature" equally affects Mail just as TextEdit. And when text lags behind typing even in such undemanding applications like TextEdit, I am getting furious.
  2. Why do they have to move previous/next week controls in Calendar in each version? Every time I get finally accustomed to the new position they move it from one side of the window to the other side. Guys, make your mind!
  3. GUI in some applications, like Navicat, got unbearably sluggish. This will likely get fixed with updates of the affected applications. But in the mean time, I am not happy.
  4. With each update of OS X the GUI (or display setting) gets more colorful. The change is  subtle - I am noticing the change only for the first few hours. But still, I am terrified of where this trend will end.

neděle 18. října 2015

The optimal length of text

When I was working with text I noticed that the optimal length of text is somewhere around 100 characters.

The estimate is based on following measures:
  • Twitter: 140 charactes
  • Performance of bank tellers based on their notes about the clients: 100-150 characters
  • Dating websites: 97 characters

neděle 7. června 2015

What is wrong with SQL

There are several things I wish were different in SQL:
  1. When you want to select whole table, just without one column, how do approach it in (pure) SQL? You have to write the names of all the columns that you want to keep. If you have a table with 1000 columns, you have to name 999 columns. In other languages, like R (with negative index) or SAS (with drop command), you would just name that single column that you don't want to preserve. SQL should have the same functionality.
  2. Intelligent code completion in SQL simply doesn't work very well. First you have to select the names of the columns you want to keep (out of thousands of columns in the schema) and then you have to name the source tables (out of tens of tables in the schema). If the order was just reversed, intelligent code completion would work like a charm - select table names out of tens of tables and then select column names from the list of columns present in the selected columns. In LINQ the correct order was used.

pondělí 25. května 2015

MAPE - Mean Absolute Percent Error

The problem with percentage errors that is often overlooked is that they assume a meaningful zero. For example, a percentage error makes no sense when measuring the accuracy of temperature forecasts on the Fahrenheit or Celsius scales.

It means that percentage errors are useful only when changing the scale does not make any difference to the percentage error. It is said that percentage error is not useful incase of Celsius and Fahrenheit calculation because consider forecasted value is 10 degree and actual value is 11 degree then percentage error is 9.09% but the same thing gives a different solution when we convert to Fahrenheit, 10 degree Celsius is 50 Fahrenheit and 11 degree is 51.8 Fahrenheit so here the percentage error becomes 3.47%.

But when we consider a different measure like meters and inches, here we have a meaningful zero. Forecasted is 10 m and actual is 11m then percentage error is 9.09% . 10m is 393.7 inch and 11m is 433.07 inch and here the percentage error is also 9.09%.

They (MAPE) also have the disadvantage that they put a heavier penalty on negative errors than on positive errors.

This means that if there are negative errors the MAPE value becomes higher than for positive cases. Example if forecasted value is 27 and actual is 23 then MAPE is 17% and if forecasted is 23 and actual is 27 then MAPE is 14.8%. Though the absolute difference in both cases is 4 but the negative error gives a higher percentage error when compared to positive error.