Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com help in calculating mean, variance, standard deviation

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 11-22-2008, 03:57 AM PM User | #1 newbee_coder New Coder   Join Date: Nov 2008 Posts: 12 Thanks: 3 Thanked 0 Times in 0 Posts help in calculating mean, variance, standard deviation I am supposed to write a program that prompts user to enter the numbers separated by space and when user click "ok" button, it should display the numbers entered with its mean, and standard deviation and the window should ask if user wants to enter numbers again if yes then it should display the new numbers entered, with its mean and standard deviation. the report method should use dynamic HTML so that each new report overlays the old one. I created an external javascript file and embedded inside the strict XHTML file I think I got all my functions...Can anyone look into my codes once again!! FOR SOME REASON IT IS NOT WORKING Code: ```function NumberReader() { var i; this.n = prompt("Enter a list of numbers separated by spaces:", "").split(" "); for(i=0;i["+i+"] = "+this.n[i]); } }``` Code: ```function meanCalculation() { var i; var sum; var mean; for(int i = 0; i mean:"+ this.meanCalculation()+".

"); document.write("

variance:"+this.varianceCalculation()+".); document.write("

standard deviation:"+ this.stdDeviation()+".

"); }``` and here is html file:- Code: ``` Calculator

```
 11-22-2008, 09:07 AM PM User | #2 Philip M Supreme Master coder!     Join Date: Jun 2002 Location: London, England Posts: 17,489 Thanks: 200 Thanked 2,471 Times in 2,449 Posts If I may say so, far too complicated with many assorted errors. Try this:- Code: ``` Calculator

``` At least once per year, some group of scientists will become very excited and announce that whatever they announced last year about global warming is wrong. Last edited by Philip M; 11-22-2008 at 11:57 AM.. Reason: Improved
 11-22-2008, 04:52 PM PM User | #3 Philip M Supreme Master coder!     Join Date: Jun 2002 Location: London, England Posts: 17,489 Thanks: 200 Thanked 2,471 Times in 2,449 Posts Perhaps a little too complex and sophisticated for newbee_coder. His tutors will surely not believe that this script is his own work. One might suggest some sort of verification that the values entered by the user are in fact numbers, and that blank (null) entries are not made. As it is data 2, blank, 8, blank gives a mean of 2.50.
 11-22-2008, 06:20 PM PM User | #4 newbee_coder New Coder   Join Date: Nov 2008 Posts: 12 Thanks: 3 Thanked 0 Times in 0 Posts thank you for the help. But I am not supposed to use another function, Another(). The only functions I can use are numberReader(), meanCalculation(), varianceCalculation(), stdDeviation() and report(). I must use external javascript file, thats why I created external java script files. Can anyone help me rewriting my functions which I have already defined? report() should use dynamic HTML so that new report over lays the old report! Thanks again!!!
11-22-2008, 06:46 PM   PM User | #5
Philip M
Supreme Master coder!

Join Date: Jun 2002
Location: London, England
Posts: 17,489
Thanks: 200
Thanked 2,471 Times in 2,449 Posts
Quote:
 Originally Posted by newbee_coder I must use external javascript file, thats why I created external java script files.
You do not need multiple .js files - all your functions (which are not really necessary) can go into one single file.

If you want you can "reverse engineer" the script I gave you to separate out each section or code block into a separate function. Then you can place all these functions into one .js file. But make sure that values which are transferred from one function to another are global, that is declared outside the function.

 11-22-2008, 10:05 PM PM User | #6 newbee_coder New Coder   Join Date: Nov 2008 Posts: 12 Thanks: 3 Thanked 0 Times in 0 Posts sorry for the misunderstanding. I just need one .js external file with 5 functions in it. Seems like my report() is not working. Like I said it should print user entered numbers, mean variance, sd and it should prompt user if users want to enter more numbers. If user enter more numbers then report() should print new numbers entered with its mean, variance, sd. New report should over lay old report. Also, how do I call one function in another method in javascript? I need meanCalculation function in varianceCalculation() function since we need mean to calculate variance. Thanks for the help!!!
 11-23-2008, 09:04 AM PM User | #7 Philip M Supreme Master coder!     Join Date: Jun 2002 Location: London, England Posts: 17,489 Thanks: 200 Thanked 2,471 Times in 2,449 Posts As I say, you must make the variables mean, variance and stdDeviation global by declaring them outside any function. Then: document.write("

mean=: " + mean + ".

"); document.write("

variance=: " + variance + ".(/); document.write("

standard deviation = :" + stdDeviation + ".

")

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 08:24 AM.