{"cells":[
 {
  "cell_type": "markdown",
  "metadata": {},
  "source": "# Open Boundary Condition\n![The edge of a flat world](http://static.tvtropes.org/pmwiki/pub/images/rsz_world-flat_5884.jpg)\n\nThe data are generated from a model with open boundary condition.\nLet see the histogram of checkins along axe x and close to the border x=0. "
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\nplt.rcParams['figure.figsize'] = (16,5)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "train = pd.read_csv('../input/train.csv', index_col='row_id')"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "train[train.x<0.1].x.hist(bins=100)\n\nplt.xlabel('x')\nplt.ylabel('Number of checkins');"
 },
 {
  "cell_type": "markdown",
  "metadata": {},
  "source": "The pictures for all 4 borders is similar ([A 3D plot by Namra](https://www.kaggle.com/namra42/facebook-v-predicting-check-ins/gridwise-open-boundary)). I think the reason is: \n\nThe reported position of a device (x,y), \nmight be different from its true position (x_t, y_t) because of the errors. \nNow assume that the probability of having a value lesser or greater that its true value \nis equal, P(x > x_t | x_t) = P(x < x_t | x_t). \nFor any point that is far from border, we should get an almost flat density P(x) = const. \nBut on the border the story is different. \n\nIf the true position is on the border, \nand the measured position is inside the border, \nthen we see that device, but if the observed is outside of the border, \nthen we have a loss, its coordinates are not reported. \nBeyond the borders there is only void so there is nothing to compensate the loss. \nWe have lower density of checkins at the borders. \nThe density increases as we go farther. "
 }
],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}}, "nbformat": 4, "nbformat_minor": 0}