Skip to content

Instantly share code, notes, and snippets.

@d--b
Created August 4, 2014 11:32
Show Gist options
  • Save d--b/90085ac88ad2c7c93c5c to your computer and use it in GitHub Desktop.
Save d--b/90085ac88ad2c7c93c5c to your computer and use it in GitHub Desktop.
Created on Spreadboard
{
"tablenames": {
"0": "table_0",
"1": "table_1",
"2": "table_2",
"3": "table_3"
},
"calctree": {
"0": [
["Inv CDF", "=function NormSInv(p) {\n var a1 = -39.6968302866538, a2 = 220.946098424521, a3 = -275.928510446969;\n var a4 = 138.357751867269, a5 = -30.6647980661472, a6 = 2.50662827745924;\n var b1 = -54.4760987982241, b2 = 161.585836858041, b3 = -155.698979859887;\n var b4 = 66.8013118877197, b5 = -13.2806815528857, c1 = -0.00778489400243029;\n var c2 = -0.322396458041136, c3 = -2.40075827716184, c4 = -2.54973253934373;\n var c5 = 4.37466414146497, c6 = 2.93816398269878, d1 = 0.00778469570904146;\n var d2 = 0.32246712907004, d3 = 2.445134137143, d4 = 3.75440866190742;\n var p_low = 0.02425, p_high = 1 - p_low;\n var q, r;\n var retVal;\n if (p < 0 || p > 1) {\n alert('NormSInv: Argument out of range.');\n retVal = 0;\n } else if (p < p_low) {\n q = Math.sqrt(-2 * Math.log(p));\n retVal = (((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1);\n } else if (p <= p_high) {\n q = p - 0.5;\n r = q * q;\n retVal = (((((a1 * r + a2) * r + a3) * r + a4) * r + a5) * r + a6) * q / (((((b1 * r + b2) * r + b3) * r + b4) * r + b5) * r + 1);\n } else {\n q = Math.sqrt(-2 * Math.log(1 - p));\n retVal = -(((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1);\n }\n return retVal;\n}", "=B1", "", "", ""],
["", "", "", "", "", ""],
["Scenarios", "=Array.apply(null, Array(1000)).map(function () {\n return $B$1(Math.random());\n})", "=B3.map(function (x) {\n return x * 0.7 + 0.7 * C1(Math.random());\n})", "", "", ""],
["Round", "=B3.map(function (x) {\n return Math.round(x * 10) / 10;\n})", "=C3.map(function (x) {\n return Math.round(x * 10) / 10;\n})", "", "", ""],
["Counts", "=B4.reduce(function (p, v) {\n if (p[v]) {\n p[v] = p[v] + 1;\n } else {\n p[v] = 1;\n }\n return p;\n}, {})", "=C4.reduce(function (p, v) {\n if (p[v]) {\n p[v] = p[v] + 1;\n } else {\n p[v] = 1;\n }\n return p;\n}, {})", "", "", ""],
["Buckets", "=Object.getOwnPropertyNames(B5).sort(function (a, b) {\n return a - b;\n})", "=Object.getOwnPropertyNames(C5).sort(function (a, b) {\n return a - b;\n})", "", "", ""],
["Values", "=B6.map(function (n) {\n return B5[n];\n})", "=C6.map(function (n) {\n return C5[n];\n})", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""],
["", "", "", "", "", ""]
],
"1": [
["=Chart.bar(table_0.B6, table_0.B7)"]
],
"2": [
["=Chart.bar(table_0.C6, table_0.C7)"]
],
"3": [
["=Chart.scatter(table_0.B3, table_0.C3)"]
]
},
"view": {
"TableDetails": {
"0": {
"left": 280,
"top": 96,
"nrows": 21,
"ncols": 6,
"colwidths": [63, 95, 63, 63, 39, 39],
"rowheights": [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]
},
"1": {
"left": 280,
"top": 456,
"nrows": 1,
"ncols": 1,
"colwidths": [367],
"rowheights": [199]
},
"2": {
"left": 664,
"top": 456,
"nrows": 1,
"ncols": 1,
"colwidths": [367],
"rowheights": [199]
},
"3": {
"left": 664,
"top": 96,
"nrows": 1,
"ncols": 1,
"colwidths": [367],
"rowheights": [335]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment