Skip to content

Instantly share code, notes, and snippets.

@neworderofjamie
Created November 2, 2016 15:33
Show Gist options
  • Save neworderofjamie/903ce0d4735f20c8fedd3ca2ace04098 to your computer and use it in GitHub Desktop.
Save neworderofjamie/903ce0d4735f20c8fedd3ca2ace04098 to your computer and use it in GitHub Desktop.
Estimation of how a row of synapses will be split into delay sub-rows
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import math\n",
"import numpy as np\n",
"import scipy.stats as stats\n",
"\n",
"mean = 1.5\n",
"sd = 0.75\n",
"\n",
"mean_row_length = 100\n",
"\n",
"dist = stats.truncnorm\n",
"params = {\"loc\": mean, \"scale\": sd, \"a\": (0.1 - mean) / sd, \"b\": (np.inf - mean) / sd}"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Average upper bound:3.354976, average lower bound:0.166187, average delay range:3.188790\n"
]
}
],
"source": [
"mean_upper = dist.ppf(0.5 ** (1.0 / float(mean_row_length)), **params)\n",
"mean_lower = dist.ppf(1.0 - 0.5 ** (1.0 / float(mean_row_length)), **params)\n",
"delay_range = mean_upper - mean_lower\n",
"print \"Average upper bound:%f, average lower bound:%f, average delay range:%f\" % (mean_upper, mean_lower, delay_range)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Num sub-rows:4\n",
"Sub-row bin edges:[ 0.16618661 0.96618661 1.76618661 2.56618661 3.36618661]\n",
"Sub-row bin edge cdf:[ 0.0069075 0.21396265 0.62712406 0.91994663 0.99337614]\n",
"Sub-row probability mass:[ 0.20989532 0.41882873 0.29683921 0.07443674]\n",
"25\n"
]
}
],
"source": [
"num_sub_rows = int(math.ceil(delay_range / 0.8))\n",
"print \"Num sub-rows:%u\" % num_sub_rows\n",
"\n",
"sub_row_delay_bin_edges = np.arange(mean_lower, mean_upper + 0.8, 0.8)\n",
"print \"Sub-row bin edges:%s\" % str(sub_row_delay_bin_edges)\n",
"\n",
"sub_row_delay_cdf = dist.cdf(sub_row_delay_bin_edges, **params)\n",
"print \"Sub-row bin edge cdf:%s\" % str(sub_row_delay_cdf)\n",
"\n",
"sub_row_prob_mass = sub_row_delay_cdf[1:] - sub_row_delay_cdf[:-1]\n",
"sub_row_prob_mass /= (sub_row_delay_cdf[-1] - sub_row_delay_cdf[0])\n",
"print \"Sub-row probability mass:%s\" % (str(sub_row_prob_mass))\n",
"\n",
"print mean_row_length // num_sub_rows \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment