Advertisement

11.03.2005 at 06:33PM PST, ID: 21618942
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

help for a script

Asked by eminitta in JavaScript

Tags: , ,

Hi,

This full script not works fine reading data from <textarea>. Could you please
assist me for this script running ok reading data from <textarea>?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
      <title>Calculate Statistics</title>
      
<SCRIPT>
function ShowMenu(bMenu) {
document.statForm.idFinder.style.display = (bMenu) ? "none" : "block"
document.statForm.idMenu.style.display = (bMenu) ? "block" : "none"
idML.className = (bMenu) ? "cOn" : "cOff"
idRL.className = (bMenu) ? "cOff" : "cOn"
return false
}
</SCRIPT>

<SCRIPT language=JavaScript id=code>
      // Statistics methods. Do not call these directly.
      function _sum() {
        var sum = 0;
        for (var intLoop = 0; intLoop < document.statForm.value.length; intLoop++)
          sum+=document.statForm.value[intLoop]
        return sum
      }
      function _mean() {
        return (this.sum() / document.statForm.value.length)
      }
      function _pop(s) {
        var avg = s.mean(), pop=0
        for (var intLoop = 0; intLoop < s.values.length; intLoop++)
          pop+=Math.pow(s.values[intLoop]-avg,2)
        return pop

      }
      function _sampVar() {
         var cnt = document.statForm.value.length
         return ((1/(cnt-1))*_pop(this))
      }
      function _popVar() {
         var cnt = document.statForm.value.length
         return ((1/(cnt))*_pop(this))
      }
      function _sampStdDev() {
         var cnt = document.statForm.value.length
         return Math.sqrt(this.sampVar())
      }
      function _popStdDev() {
         var cnt = document.statForm.value.length
         return Math.sqrt(this.popVar())
      }
      function Statistics() {
        document.statForm.value = new Array()
        for (var intLoop = 0; intLoop < arguments.length; intLoop ++)
          document.statForm.value[intLoop] = arguments[intLoop]
      }

      function _min() {
        var small = null
        for (var item in document.statForm.value)
          if ((null==small) || (document.statForm.value[item]<small))
            small = document.statForm.value[item]
        return small
      }

      function _max() {
//        document.statForm.max.value
        var large = null
        for (var item in document.statForm.value)
          if ((null==large) || (document.statForm.value[item]>large))
            large = document.statForm.value[item]
        return large
      }
      function _range() {
        return (this.max()-this.min())
      }

      // Define prototype for all Statistic Objects
      Statistics.prototype.min = _min;
      Statistics.prototype.max = _max;
      Statistics.prototype.range = _range;
      Statistics.prototype.sum = _sum;
      Statistics.prototype.mean = _mean;
      Statistics.prototype.sampStdDev = _sampStdDev;
      Statistics.prototype.sampVar = _sampVar;
      Statistics.prototype.popVar = _popVar;
      Statistics.prototype.popStdDev = _popStdDev;
    </SCRIPT>

      

<SCRIPT language=JavaScript id=calc>
      function calcStats() {
     
        var stats = new Statistics();
       
        // Extract values from checkbox
        var dataPoints = document.statForm["vals"];
        for (var intLoop = 0; intLoop < dataPoints.length; intLoop++)
          if (!isNaN(dataPoints[intLoop].value) && (dataPoints[intLoop].value!=""))
            statForm.values[statForm.values.length] = parseInt(dataPoints[intLoop].value)

        // Output all statistics into document
        document.statForm.values.innerText = statForm.values;
        document.statForm.valuesLength.innerText = stats.values.length;
        document.statForm.min.innerText = stats.min();      
        document.statForm.max.innerText = stats.max();
        document.statForm.range.innerText = stats.range();

        document.statForm.sum.innerText = stats.sum();
        document.statForm.mean.innerText = stats.mean();
        document.statForm.sampStdDev.innerText = stats.sampStdDev();
        document.statForm.popStdDev.innerText = stats.popStdDev();
        document.statForm.sampVar.innerText = stats.sampVar();
        document.statForm.popVar.innerText = stats.popVar();
      }
    </SCRIPT>      
</head>

<body>

<form name=statForm>
<textarea name=vals rows=5 cols=20></textarea>


      <P><INPUT onclick=calcStats() type=button value="Calculate Statistics">
      <TABLE>
        <TBODY>
        <TR>
          <TD>values</TD>
          <TD id=values></TD></TR>
        <TR>
          <TD>values.length</TD>
          <TD id=valuesLength></TD></TR>
        <TR>
          <TD>min</TD>
          <TD id=min></TD></TR>
        <TR>
          <TD>max</TD>
          <TD id=max></TD></TR>
        <TR>
          <TD>range</TD>
          <TD id=range></TD></TR>
        <TR>
          <TD>sum</TD>
          <TD id=sum></TD></TR>
        <TR>
          <TD>mean</TD>
          <TD id=mean></TD></TR>
        <TR>
          <TD>Standard Deviation (Sample)</TD>
          <TD id=sampStdDev></TD></TR>
        <TR>
          <TD>Standard Deviation (Population)</TD>
          <TD id=popStdDev></TD></TR>
        <TR>
          <TD>Variance (Sample)</TD>
          <TD id=sampVar></TD></TR>
        <TR>
          <TD>Variance (Population)</TD>
          <TD id=popVar></TD></TR></TBODY></TABLE>
     
</form>

</body>
</html>


THANK YOU IN ADVANCE

ENitta
Start Free Trial
[+][-]11.03.2005 at 07:08PM PST, ID: 15222232

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.03.2005 at 07:12PM PST, ID: 15222249

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.03.2005 at 07:35PM PST, ID: 15222324

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.04.2005 at 04:45AM PST, ID: 15223935

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.04.2005 at 05:01AM PST, ID: 15224003

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.11.2005 at 12:23PM PST, ID: 15462940

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.12.2005 at 07:00AM PST, ID: 15466619

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: javascript, popstddev, popvar
Sign Up Now!
Solution Provided By: kandura
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.01.2006 at 07:00AM PST, ID: 15843611

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02.05.2006 at 08:58AM PST, ID: 15877021

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32