![]() |
|
[.NET] Needing help with my variance/standard deviation program - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Needing help with my variance/standard deviation program (/showthread.php?tid=3382508) |
Needing help with my variance/standard deviation program - Air X - Apr 4, 2013 I've been learning about this in math and thought I'd do a program to save me some time for class (since I don't have a fancy-pants TI Nspire), and so far it seems to be working, but my problem is.. I'm sort of stuck. :/ Here is the interface, which I'm content with at the moment. Sure, it could be improved, but I don't really care right now. ![]() When you enter each number into the textbox, and hitting the button, it adds the number imputed into the first listbox. Listbox1 will then sort the numbers in order (from smallest to largest) and also updates the average (x bar). My problem right now is, how can I get the numbers from the listbox1 to match up with the numbers from listbox2 and listbox3? (including their formulas) From that point, I can easily add the rest. Can someone help me out here please? I'd really appreciate it! ๐ Here is the code, which should help (please don't flame at me for the quality of my code ๐คจ): http://pastebin.com/angE5vZe * - H3x0S - Apr 4, 2013 What exactly do you want in ListBox2 and ListBox3. Let's say that you have "1,2,3,4,5" in ListBox1, what would ListBox2 and ListBox3 contain? * - Air X - Apr 4, 2013 (Apr 4, 2013 04:23 PM)H3x0S Wrote: What exactly do you want in ListBox2 and ListBox3. Let's say that you have "1,2,3,4,5" in ListBox1, what would ListBox2 and ListBox3 contain? Listbox2 contains the final answer from the formula above listbox2, so, the final product would be (for listbox2): 1 = -2 (because 1-3) 2 = -1 (because 2-3) 3 = 0 (because 3-3) 4 = 1 (because 4-3) 5 = 2 because 5-3) And then having each of those numbers from listbox2 corresponding with the numbers from listbox1 (1 from listbox1 would match up with -2 and so on). Listbox3 is essentially the same thing, with the same formula, only the numbers are squared. * - mardee001 - Apr 4, 2013 Just an idea. im no expect but i think this could work. you could define a global array for your form for the numbers you put in your textbox. then in your code in your button1.click event you add the values to the array as you add them to listbox1 You then add another button called something like calculate which will then use the array of your values to populate listbox 2 and 3 with the corresponding array values in listbox1. if you want them to change as you type you could do the whole thing in your button1.click just instead of adding your textbox number to listbox1 you add them to a global sorted array which you will then refer to when populating listbox1,2and 3 simultaneously. hope you understand my idea * - Air X - Apr 4, 2013 (Apr 4, 2013 04:58 PM)mardee001 Wrote: Just an idea. im no expect but i think this could work. That could possibly work. The listbox1 is technically an array though (seeing as it's a set of numbers stored into one thing). I get what you're saying. I have it set up currently where it calculates as you enter in the data, which is what I want. If I have to add in an extra button, it's not a huge deal. It just saves time from hitting another button (very lazy xD). * - mardee001 - Apr 4, 2013 Quote: after the above statements from your code thats when you are suppose to add the values for listbox2 and 3 for every number in listbox1 for y = 1 to listbox1.items.count ListBox2.Items.Add(ListBox1.Items.Item(y-1)-avgnum.Text) ListBox3.Items.Add(Math.Pow((ListBox1.Items.Item(y-1)-avgnum.Text),2)) next ๐ค * - Air X - Apr 4, 2013 (Apr 4, 2013 05:57 PM)mardee001 Wrote: after the above statements from your code thats when you are suppose to add the values for listbox2 and 3 for every number in listbox1 EXACTLY what I needed. Thank you SO much! ๐๐ * - mardee001 - Apr 5, 2013 you are welcome. forgot to mention that you have to clear listbox2 and listbox3 before the for loop... if you already havent figured that out ๐ค |