Results 1 to 5 of 5

Thread: Finding Standard Deviation Using Array and Function

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2013
    Posts
    27

    Unhappy Finding Standard Deviation Using Array and Function

    Hello.
    I opened a topic before but people misunderstood my question.

    I have to create a program that computes Standard Deviation of a group of numbers when Button1 is clicked. On button click, Inputbox asks for how many numbers in the group and then the calculated stDev Result should be shown in textbox1.
    In the coding part, Calculation part should be made in function and the function should bring the answer in textbox1. ( Example: Textbox1.text = StDevFunc(array) )

    I managed to write a code without using Function. All I need to do is to create a function and bring the calculation part inside function and then call the function when textbox1.text = answer

    Obligations:
    1.Array must be used.
    2.Function must be used


    Dim a,sum,sserror,fvar,dSD As Decimal
    Integer.Tryparse(Inputbox("Enter number"),a)
    a = int(Rnd()*100)

    Dim array(a-1) As Integer

    For i=0 to a-1
    array(i) = 5
    Next

    For j=0 to a-1
    sum = sum + array(j)
    Next

    avg= sum/a

    For k=0 to a-1
    sserror = sserror + (array(k) - avg)*2
    Next

    dVar= sse / a 'calculates variance
    dSD = dVar / 2 ' calculates st.deviation
    ALL HELP APPRECIATED AND +++++++++++

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Finding Standard Deviation Using Array and Function

    I opened a topic before but people misunderstood my question.
    No they didn't and even if they had it wouldn't justify double posting. I provided a full working solution on the previous thread.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2013
    Posts
    27

    Re: Finding Standard Deviation Using Array and Function

    Quote Originally Posted by dunfiddlin View Post
    No they didn't and even if they had it wouldn't justify double posting. I provided a full working solution on the previous thread.
    The answer part should be something like this



    stDevFunction

    ---------------

    Dim a,sum,sserror,fvar,dSD As Decimal
    Integer.Tryparse(Inputbox("Enter number"),a)
    a = int(Rnd()*100)

    Dim array(a-1) As Integer

    For i=0 to a-1
    array(i) = 5
    Next

    Textbox1.text = stdevfunction(array)


    Why are you so mean man sorry If I made you angry

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Finding Standard Deviation Using Array and Function

    Textbox1.text = stdevfunction(array)
    Line 10 of the solution I posted ....

    vb.net Code:
    1. Me.Text = StandardDeviation(test).ToString ' function

    .. where Me is the form but could be any text control and test is the array. What did I miss?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2013
    Posts
    27

    Re: Finding Standard Deviation Using Array and Function

    I am a total idiot sorry. THANK YOU =)

    Quote Originally Posted by dunfiddlin View Post
    Line 10 of the solution I posted ....

    vb.net Code:
    1. Me.Text = StandardDeviation(test).ToString ' function

    .. where Me is the form but could be any text control and test is the array. What did I miss?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width