## JavaScript

Moderators: None (Apply to moderate this forum)
Number of posts: 5164

This Forum Only

How do I make a historgram, find the mean & SD using an array??? Posted by Deuce613 on 27 Apr 2006 at 10:01 PM
Hi,
If someone can help me, Id really appreciate it. The task is to input numbers (seperated by commas) into a textarea and then when the user clicks "plot" the mean and standard deviation appear in the appropriate textareas. In addition, a histogram is constructed from the numbers in the array. I have some code but it does not seem to work.

Can someone give me some tips. I am new at all this stuff.

<html>
<title>
David's Computer Program
</title>

<script>

var A = new Array();
var freq = new Array();

var A = s.split(",");

var mean;
var sum=0;

A = document.davidForm.main1.value.split(",");

function clearMainScreen() {
window.document.david.main1.value = "";
}

fucntion displayAvg() {
var mean = document.davidForm.main1.value;
for (var i = 0; i = A.length-1; i++) {
A[i] = parseInt(A[i]);
sum = sum + A[i];
}
mean = (sum / A.length);
}

function standardDeviation (){
var smsq = sum+sum
var stdr = Math.sqrt((smsq-smsq/A.length)/A.length-1))

for (var i=0; i<A.length; i++){
sum=sum+A[i]
smsq+(A[i]*A[i])

var largest=freq[0]

for (var i=0; i<freq.length; i++){
document.images[i].width=30;
document.images[i]height=Math.floor(freq[i]*unit)

for (var i=0; i<freq.length; i++){
if (largest<freq[i]{
largest=freq[i]
}
}

for (var i=0; i<A.length; i++){
if(A[i}>=0 && A{i} <=9{
freq[0]=freq[0]+1
}
}

var bin = Math.floor(A[i]/10);

freq[bin] = freq[bin]+1

Math.random

for (var i=0; i<A.length; i++){
A[i]=Math.round(Math.round( )*100)
}

</script>

<body bgcolor="aqua">
<form name=david>

<tr>
<td> <h2>Welcome to David's Amazing Webpage</h2> </td>
</tr>
<tr>
<td> <textarea rows=10 cols=50 name=main1></textarea> </td>
</tr>
<tr>
<td>
<input type="button" name="plot" value="Plot" onClick="displayAvg();">
<input type="button" name="fill" value="Fill" onClick="fillRandom();">
<input type="text" name=filler>
<input type="button" value="Clear" onClick="clearMainScreen();"></td>
</tr>

<tr>
<td>
<img src=b.jpg height=1 width=40>
<img src=b.jpg height=1 width=40>
<img src=b.jpg height=1 width=40>
<img src=b.jpg height=1 width=40>
<img src=b.jpg height=1 width=40>
<img src=b.jpg height=1 width=40>
<img src=b.jpg height=1 width=40>
<img src=b.jpg height=1 width=40>
<img src=b.jpg height=1 width=40>
<img src=b.jpg height=1 width=40>
</td>
</tr>

<tr>
<td> Mean <input type="text" name="mean"> <br>
Standard Deviation <input type="text" name"sd">
</td>
</tr>
</table>
</form>
</body>
</html>

Re: How do I make a historgram, find the mean & SD using an array??? Posted by Ocelot on 28 Apr 2006 at 11:34 AM
Yeah I am also interested as to how to do this. So if anyone knows how to do this please reply!

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic