notion parallax

what happens when ideas slide past each other
  • Home
  • buy me books
  • i look at this
  • i read this
  • tutorials
24 Jan 2010

Drawing a bell curve

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 shave a yak until I had a good way to show this.

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.

Below is the GCscript that draws a bell curve. It is almost entirely based on Daniel Shiffman’s processing code on his website at  http://www.shiffman.net/teaching/nature/week-1/

It is driven by a point that controls the standard deviation (?2 width of the bell) and the offset from zero (?) .

There are a few other variables, but these just change the size of the curve.

See how you get on with it and if it is at all useful.

this is a few versions of the bell curve under different transformations

the code is after the fold

transaction modelBased 'draw a bell curve'
{
    feature User.Objects.baseCS Bentley.GC.CoordinateSystem
    {
        SymbolSize                = 10;
    }
    feature User.Objects.width Bentley.GC.GraphVariable
    {
        Value                     = 100;
    }
    feature User.Objects.point02 Bentley.GC.Point
    {
        CoordinateSystem          = baseCS;
        XTranslation              =  (51.55);
        YTranslation              =  (-3.22);
        ZTranslation              = 0.0;
    }
    feature User.Objects.point01 Bentley.GC.Point
    {
        Function                  =
    function (CoordinateSystem CS, double varX, double width, double xcoord, double amplification, double widthAmp)
    {
       /* 2010 01 24 Ben Doherty
        * This function draws a bell curve
        * it is based on Daniel Shiffman's processing code
        * http://www.shiffman.net/teaching/nature/week-1/
        * the comments are his*/

        //"e", see http://mathforum.org/dr.math/faq/faq.e.html for more info
        double e = 2.71828183;
        //a list to store all the "y" values
        double normal = {};
        //default mean of 0
        double m = 0;
        //standard deviation based on varX, driven here by the position of a point
        double sd = (0.5 + varX)/width;        

        //double xcoord = -3;
        //uncomment to start the graph at -3, i.e. centred
        for (int i = 0; i < ToInt(width); ++i)
        {
            //square root of 2 * PI
            double sq2pi = Sqrt(2*PI);
            //-(x - mu)^2
            double xmsq = -1*(xcoord-m)*(xcoord-m);
            //variance (standard deviation squared)
            double sdsq = sd*sd;
            //P(x) function
            normal[i] = (1 / (sd * sq2pi)) * (Pow(e, (xmsq/sdsq)));
           //increment x coordinate
            xcoord += 6 / width;
        }
        //breakpoint;
        Point graphPoints = new Point();
        graphPoints.ByCartesianCoordinates(CS,Series(0,width,1)*widthAmp,normal*amplification,0);
        return graphPoints;
    };
        FunctionArguments         = {baseCS,point02.X,width, point02.Y, 100, 3};
    }
}

Tags: GC

This entry was posted on Sunday, January 24th, 2010 at 9:43 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Click here to cancel reply.

« no overrides
Homage »
  • Recent Posts

    • Humility collection
    • a weekend on wheels
    • emotionality…0
    • graphing legend status
    • Public perceptions of energy consumption and savings
  • Recent Comments

    • Ben: http://cafehayek.com/2011/12/m an-bites-dog.html Two top hurricane predictors are leaving the field because they...
    • Ben: http://road.cc/content/blog/49 070-cycling-london-getting-saf er An article by Jenny Jones about how she...
    • Ben: There’s another video from the night here: http://www.youtube.com/watch?v =LrzKx3Kepws Lots of pictures of...
    • josh: Hey, great tutorial. I’m looking forward to reading more
    • Bethan: “The certificate claims that I’m not a “total legend”, yay!”. Do you mean “now a total...
  • Tags

    advertising architecture australia bikes books BVN climbing coffee collaborative cool links diploma economics eco stuff ecotect enhancement flying food future gardening GC geek hardware house keeping interaction Judit late night life major study masters music processing rmit scooter smart geometry studio surfing teaching thinking toys trips turning japanese tutorials UTS video writing
notion parallax is powered by WordPress
Theme Design by Generic Designer

Entries (RSS) and Comments (RSS)
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.