SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Oct 2004
    Location
    Romania
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    problems with JavaScript code for a normal distribution function

    Hi everyone,

    I am currently trying to write a script for a normal distribution function that I will use to model the user delays between transactions, in WebLoad application.
    I have actually found a formula for the normal distribution and I wrote a script, but the graphic does not look like a normal distribution curve.
    For the formula I got from http://davidmlane.com/hyperstat/norm...tribution.html here is the JavaScript code that I wrote.
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">function normdistrib(totusers, minim, maxim, stddev)
    {
    // normal distribution of user delays (think time)
    // minim - minimal value of delay (the users delay their action for a minimum of miliseconds)
    // maxim - maximum value of delay (the users delay their action for maximum of miliseconds)
    // stddev - standard deviation in miliseconds
    // totusers - the number of users

    mysleep = new Array(totusers)
    for (i=1; i&lt; totusers; ++i)
    {
    mean = ((minim + maxim)/2)
    epower = -Math.pow((i-mean), 2)/(2*Math.pow(stddev, 2))
    p1 = 2 * Math.PI * Math.pow(stddev, 2)
    mysleep[i] = (1/Math.sqrt(p1))*Math.pow(Math.E, epower)
    InfoMessage(mysleep[i].toString())
    }
    }</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">In the main script, I called the function with the following parameters:
    normdistrib(100,18000,25000,3000)
    But the curve that results from the 'mysleep' array above is rather linear that normal distribution alike.

    Does anyone know what I do wrong?
    Any other advice for me?

    Thanks, Ioana

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Location
    Charlotte, NC, USA
    Posts
    617
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: problems with JavaScript code for a normal distribution function

    Interesting approach.
    Why are you going through this effort? Is it not sufficient to identify the average user delay or perhaps use the average +/- some factor?

    Discussions on the topic of user time, think time, user latency, etc., would indicate this is perhaps overkill on your part.
    Resistance is futile.

    SuperK

  3. #3
    Moderator
    Join Date
    Mar 2002
    Location
    Tampa Bay
    Posts
    7,673
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: problems with JavaScript code for a normal distribution function

    Pretty darned slick, though. I was once in search of the same thing (but didn't find it) when I was trying to spiff up a college assignment involving "the sleeping barber" scenario.

  4. #4
    Junior Member
    Join Date
    May 2000
    Location
    White Plains, NY 10604
    Posts
    15
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: problems with JavaScript code for a normal distribution function

    Hi Ioana,

    I may be reading your question wrong but I think what you want to create is a javascript program that will generate random numbers (think time, wait time, etc...) with a normal distribution. The site and formulas you use are useful in computing the normal distribution characteristics from a set of numbers. What you really want is a javascript program that will generate these numbers for you.

    Here is a link that has the javascript source code to generate the random numbers (normally distributed).

    http://javascript.internet.com/calcu...tribution.html

    Good luck.

  5. #5
    Junior Member
    Join Date
    Oct 2004
    Location
    Romania
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: problems with JavaScript code for a normal distribution function

    Hello!,

    This is exactly what I was looking for.

    Thanks a lot.
    Ioana


    Originally posted by TFMiller:
    Hi Ioana,

    I may be reading your question wrong but I think what you want to create is a javascript program that will generate random numbers (think time, wait time, etc...) with a normal distribution. The site and formulas you use are useful in computing the normal distribution characteristics from a set of numbers. What you really want is a javascript program that will generate these numbers for you.

    Here is a link that has the javascript source code to generate the random numbers (normally distributed).

    http://javascript.internet.com/calcu...tribution.html

    Good luck.
    <font size="2" face="Verdana, Arial, Helvetica">

  6. #6
    Moderator
    Join Date
    Mar 2002
    Location
    Tampa Bay
    Posts
    7,673
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: problems with JavaScript code for a normal distribution function

    Just out of interest, are you the same person as "IoanaC"? Apart from the similarity of handles, (both of) you seem to have an unusual interest in "things mathematical."

  7. #7
    Junior Member
    Join Date
    Oct 2004
    Location
    Romania
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: problems with JavaScript code for a normal distribution function

    Hello!

    No, I am not the same person as "IoanaC".
    The similarity may come from the fact that "Ioana" is a Romanian first name.
    It seems we are two, here, in these forums.
    My interest in 'things mathematical' comes from the series of articles "User Experience, not Metrics Series" written by Scott Barber.
    I wanted to see if I can apply it using WebLoad.

    Although, it is funny the coincidence that you have noticed.

    Ioana S


    Originally posted by Peter Ruscoe:
    Just out of interest, are you the same person as "IoanaC"? Apart from the similarity of handles, (both of) you seem to have an unusual interest in "things mathematical."
    <font size="2" face="Verdana, Arial, Helvetica">

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 06:13 PM.

Copyright BetaSoft Inc.