{
 "blyg": "0.4",
 "id": "781nnrtee2s06ha1b6w0fw4354",
 "kind": "thread",
 "origin": "https://notionparallax.co.uk/",
 "page": "https://notionparallax.co.uk/2010/drawing-a-bell-curve",
 "author": {
  "name": "Ben Doherty",
  "url": "https://notionparallax.co.uk/"
 },
 "created": "2010-01-24T10:43:50Z",
 "updated": "2010-01-24T10:43:50Z",
 "version": 1,
 "content_md": "# Drawing a bell curve\n\n\n<p>I've got to Illustrate why questions on a questionnaire need to be of a range of difficulties. If they are all too hard then the distribution of answers will all be pushed up to one end, and too easy, the opposite. So I needed to <a href=\"http://en.wiktionary.org/wiki/yak_shaving\">shave a yak</a> until I had a good way to show this.</p>\n<p>I parallel-posted this on the GC forum too, so if I'm going to be forced to open IE to post to the GC forum, I thought I'd do a decent job of it.</p>\n<p>Below is the GCscript that draws a bell curve. It is almost entirely based on Daniel Shiffman's processing code on his website at  <a href=\"http://www.shiffman.net/teaching/nature/week-1/\">http://www.shiffman.net/teaching/nature/week-1/</a></p>\n<p>It is driven by a point that controls the standard deviation (**?**<sup>**2** </sup>width of the bell) and the offset from zero (**?**) .</p>\n<p>There are a few other variables, but these just change the size of the curve.</p>\n<p>See how you get on with it and if it is at all useful.</p>\n<p><img title=\"Bell Curve\" src=\"https://notionparallax.co.uk/assets/original.aspx\" border=\"0\" alt=\"this is a few versions of the bell curve under different transformations\" width=\"490\" /></p>\n<p>the code is after the fold </p>\n<pre name=\"code\" class=\"c-sharp\">\ntransaction modelBased 'draw a bell curve'\n{\n    feature User.Objects.baseCS Bentley.GC.CoordinateSystem\n    {\n        SymbolSize                = 10;\n    }\n    feature User.Objects.width Bentley.GC.GraphVariable\n    {\n        Value                     = 100;\n    }\n    feature User.Objects.point02 Bentley.GC.Point\n    {\n        CoordinateSystem          = baseCS;\n        XTranslation              = <free> (51.55);\n        YTranslation              = <free> (-3.22);\n        ZTranslation              = 0.0;\n    }\n    feature User.Objects.point01 Bentley.GC.Point\n    {\n        Function                  = \n    function (CoordinateSystem CS, double varX, double width, double xcoord, double amplification, double widthAmp)\n    {\n       /* 2010 01 24 Ben Doherty \n        * This function draws a bell curve\n        * it is based on Daniel Shiffman's processing code\n        * http://www.shiffman.net/teaching/nature/week-1/\n        * the comments are his*/\n\n        //\"e\", see http://mathforum.org/dr.math/faq/faq.e.html for more info\n        double e = 2.71828183;\n        //a list to store all the \"y\" values\n        double normal = {};\n        //default mean of 0\n        double m = 0;\n        //standard deviation based on varX, driven here by the position of a point\n        double sd = (0.5 + varX)/width;\n\n        //double xcoord = -3;\n        //uncomment to start the graph at -3, i.e. centred\n        for (int i = 0; i < ToInt(width); ++i)\n        {\n            //square root of 2 * PI\n            double sq2pi = Sqrt(2*PI);\n            //-(x - mu)^2\n            double xmsq = -1*(xcoord-m)*(xcoord-m);\n            //variance (standard deviation squared)\n            double sdsq = sd*sd;\n            //P(x) function\n            normal[i] = (1 / (sd * sq2pi)) * (Pow(e, (xmsq/sdsq)));\n           //increment x coordinate\n            xcoord += 6 / width;\n        }\n        //breakpoint;\n        Point graphPoints = new Point();\n        graphPoints.ByCartesianCoordinates(CS,Series(0,width,1)*widthAmp,normal*amplification,0);\n        return graphPoints;\n    };\n        FunctionArguments         = {baseCS,point02.X,width, point02.Y, 100, 3};\n    }\n\n}\n</free></free></pre>\n",
 "content_html": "<h1>Drawing a bell curve</h1>\n<p>I’ve got to Illustrate why questions on a questionnaire need to be of a range of difficulties. If they are all too hard then the distribution of answers will all be pushed up to one end, and too easy, the opposite. So I needed to <a href=\"http://en.wiktionary.org/wiki/yak_shaving\">shave a yak</a> until I had a good way to show this.</p>\n<p>I parallel-posted this on the GC forum too, so if I’m going to be forced to open IE to post to the GC forum, I thought I’d do a decent job of it.</p>\n<p>Below is the GCscript that draws a bell curve. It is almost entirely based on Daniel Shiffman’s processing code on his website at  <a href=\"http://www.shiffman.net/teaching/nature/week-1/\">http://www.shiffman.net/teaching/nature/week-1/</a></p>\n<p>It is driven by a point that controls the standard deviation (<strong>?</strong><sup><strong>2</strong> </sup>width of the bell) and the offset from zero (<strong>?</strong>) .</p>\n<p>There are a few other variables, but these just change the size of the curve.</p>\n<p>See how you get on with it and if it is at all useful.</p>\n<p><img title=\"Bell Curve\" src=\"https://notionparallax.co.uk/assets/original.aspx\" border=\"0\" alt=\"this is a few versions of the bell curve under different transformations\" width=\"490\" /></p>\n<p>the code is after the fold </p>\n<pre name=\"code\" class=\"c-sharp\">\ntransaction modelBased 'draw a bell curve'\n{\n    feature User.Objects.baseCS Bentley.GC.CoordinateSystem\n    {\n        SymbolSize                = 10;\n    }\n    feature User.Objects.width Bentley.GC.GraphVariable\n    {\n        Value                     = 100;\n    }\n    feature User.Objects.point02 Bentley.GC.Point\n    {\n        CoordinateSystem          = baseCS;\n        XTranslation              = <free> (51.55);\n        YTranslation              = <free> (-3.22);\n        ZTranslation              = 0.0;\n    }\n    feature User.Objects.point01 Bentley.GC.Point\n    {\n        Function                  = \n    function (CoordinateSystem CS, double varX, double width, double xcoord, double amplification, double widthAmp)\n    {\n       /* 2010 01 24 Ben Doherty \n        * This function draws a bell curve\n        * it is based on Daniel Shiffman's processing code\n        * http://www.shiffman.net/teaching/nature/week-1/\n        * the comments are his*/\n\n        //\"e\", see http://mathforum.org/dr.math/faq/faq.e.html for more info\n        double e = 2.71828183;\n        //a list to store all the \"y\" values\n        double normal = {};\n        //default mean of 0\n        double m = 0;\n        //standard deviation based on varX, driven here by the position of a point\n        double sd = (0.5 + varX)/width;\n\n        //double xcoord = -3;\n        //uncomment to start the graph at -3, i.e. centred\n        for (int i = 0; i &lt; ToInt(width); ++i)\n        {\n            //square root of 2 * PI\n            double sq2pi = Sqrt(2*PI);\n            //-(x - mu)^2\n            double xmsq = -1*(xcoord-m)*(xcoord-m);\n            //variance (standard deviation squared)\n            double sdsq = sd*sd;\n            //P(x) function\n            normal[i] = (1 / (sd * sq2pi)) * (Pow(e, (xmsq/sdsq)));\n           //increment x coordinate\n            xcoord += 6 / width;\n        }\n        //breakpoint;\n        Point graphPoints = new Point();\n        graphPoints.ByCartesianCoordinates(CS,Series(0,width,1)*widthAmp,normal*amplification,0);\n        return graphPoints;\n    };\n        FunctionArguments         = {baseCS,point02.X,width, point02.Y, 100, 3};\n    }\n\n}\n</free></free></pre>\n",
 "content_hash": "sha256:23887f6b123ee7cb5d2b2a2310c136a47e71578b2d949a1b58b41caff3253757",
 "media": [],
 "changelog": [
  {
   "version": 1,
   "at": "2010-01-24T10:43:50Z",
   "note": null
  }
 ],
 "transclusions": []
}