Compare commits

...

51 Commits
v0.1 ... master

Author SHA1 Message Date
Nicolás A. Ortega
b9e7bb6b7d
Need an extra line there. 2016-07-13 22:22:40 +02:00
Nicolás A. Ortega
aaa653afcd
Added travis to README.md 2016-07-13 22:21:28 +02:00
Nicolás A. Ortega
147fc10bd8
Removed a couple problematic flags. 2016-07-13 22:13:05 +02:00
Nicolás A. Ortega
bf76b4a911
Added a build file.
Hope this works...
2016-07-13 22:07:15 +02:00
Nicolás A. Ortega
1685ecc1e9
Removed the binary (it was a test.) 2016-07-12 15:40:25 +02:00
Nicolás A. Ortega
c33919a3c6
Adding a temporary windows binary. 2016-07-08 20:01:33 +02:00
Nicolás A. Ortega
ecd4980ba2
Now reads a file and obtains its numbers. 2016-07-08 18:26:04 +02:00
Nicolás A. Ortega
e9bd5bcdd0
Now parsing commandline arguments. 2016-07-07 20:45:57 +02:00
Nicolás A. Ortega
156f8de5c0
Strict compiler with reldeb default build. 2016-07-04 16:17:16 +02:00
Nicolás A. Ortega
597fc22124
Added to the README.md 2016-07-04 12:52:40 +02:00
Nicolás A. Ortega
3675ee066f
Adding the C code.
I'm keeping the Java file for now as reference.
2016-07-04 12:43:19 +02:00
Nicolás A. Ortega
f7a0384ff3
Ignore the build directory. 2016-07-04 12:17:21 +02:00
Nicolás A. Ortega
19f9c3c333
Preparing for switch to C. 2016-07-04 12:16:35 +02:00
Deathsbreed
eebc90e392 Commented Q3 out. 2014-11-06 12:06:59 -06:00
Nicolás A. Ortega
5acd4908ab Update README.md 2014-10-30 15:45:22 -05:00
Deathsbreed
f022fda0d6 Fixed warning from build. 2014-10-10 11:55:19 -05:00
Deathsbreed
6d6ef03710 Simplifying comilation. 2014-10-08 19:47:21 -05:00
Nicolás A. Ortega
b5d0d55290 Update .gitignore 2014-09-21 11:25:47 -05:00
Deathsbreed
81548b20e6 Update README.md 2014-09-21 11:24:23 -05:00
Deathsbreed
ede6827cb6 Merge branch 'master' of https://github.com/Deathsbreed/MMMCalc 2014-09-21 11:22:57 -05:00
Deathsbreed
015da8fd34 Now using Apache Ant to compile. 2014-09-21 11:22:22 -05:00
Nicolás A. Ortega
326038107c Update README.md 2014-09-17 21:21:43 -05:00
Nicolás A. Ortega
a1b8f22383 Removed a comment. 2014-06-01 15:40:38 -05:00
Deathsbreed
fb4d81fe67 Removed FIXME from Q1 function. 2014-05-31 23:51:59 -05:00
Deathsbreed
497c7d0bea Fixed Q1 calculations (though they could be simplified). 2014-05-31 23:49:00 -05:00
Deathsbreed
b5db1fbdc2 Forgot to add the gitignore file. 2014-05-31 22:08:03 -05:00
Deathsbreed
1adc60c991 Added a gitignore file for the binary folder, and moved the manifest to that folder. 2014-05-31 22:06:43 -05:00
Deathsbreed
4980d8b57c Merge branch 'master' of https://github.com/Deathsbreed/MMMCalc 2014-05-07 15:42:40 -05:00
Deathsbreed
8d048e9a68 Trying to rever this. 2014-05-07 15:42:35 -05:00
Nicolás A. Ortega
f9a739f556 Added FIXME notices for Q1 and Q2
Q1 and Q2 are calculating incorrectly, specifically that they are ignoring the median value.
2014-05-07 11:03:00 -05:00
Deathsbreed
3b24d422d2 Preparing for version 0.4 2014-04-15 13:41:35 -05:00
Deathsbreed
e8b1d79f79 Oops, forgot to change the version. Oh well, minor details. 2014-04-14 17:50:36 -05:00
Deathsbreed
0ce346b714 There is now a verbose mode for Q1 and Q3. 2014-04-14 17:36:28 -05:00
Deathsbreed
cbe1aeb123 Now calculates Q1 and Q3. 2014-04-14 17:18:24 -05:00
Deathsbreed
da36eac98a Setting up for calculations of Q1 and Q3. 2014-04-14 12:02:36 -05:00
Deathsbreed
dec3bdca0a Added info on building information. 2014-04-14 11:57:29 -05:00
Deathsbreed
7d2cf7e91a Median is now better emphasized in verbose mode. 2014-04-10 19:28:56 -05:00
Deathsbreed
0cac8482b6 Fixed median verbose print. 2014-04-10 18:06:07 -05:00
Deathsbreed
62d4d703a8 Fixed median calculation for even array length. Verbose needs fix. 2014-04-10 17:24:08 -05:00
Deathsbreed
14ce9cdc3c There is now a verbose mode for median and mode. 2014-04-10 17:08:22 -05:00
Deathsbreed
67bf1b9936 Fixed some spelling errors. 2014-04-10 16:32:16 -05:00
Deathsbreed
7ab6041de2 Added verbose for standard deviation and varience. 2014-04-10 16:22:05 -05:00
Deathsbreed
c37263600a Added verbose for mean. 2014-04-10 12:12:59 -05:00
Nicolás A. Ortega
ed3960329d Added copyright and warranty options to help information. 2014-04-09 17:25:00 -05:00
Deathsbreed
30d9e1189c Added GNU GPLv3 copyright requirements to program. 2014-04-09 17:22:39 -05:00
Deathsbreed
7a2b0f6cf0 Now calculates varience. 2014-04-09 17:00:35 -05:00
Deathsbreed
fdc6f484ad Now calculates standard deviation. 2014-04-09 16:55:21 -05:00
Deathsbreed
1fae1332bd Fixed sorting. 2014-04-09 16:17:15 -05:00
Deathsbreed
b8e76b8e97 Setting up for verbose mode. 2014-04-09 11:59:26 -05:00
Deathsbreed
d7b8febf01 Now calculates range. 2014-04-09 10:30:04 -05:00
Deathsbreed
64174d5c8e Added help argument. 2014-04-08 22:02:56 -05:00
9 changed files with 534 additions and 95 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Ignore CMake files:
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
Makefile
# Ignore build files:
build/

13
.travis.yml Normal file
View File

@ -0,0 +1,13 @@
# Define the language
language: c
addons:
apt:
packages:
- build-essential
- cmake
script:
- cd build/
- cmake -DCMAKE_BUILD_TYPE=Release ..
- make

17
CMakeLists.txt Normal file
View File

@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 2.6)
project(MMMCalc)
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
set(CMAKE_C_FLAGS "-std=gnu99 -Wall -Wextra -Werror -Wfatal-errors -Wmissing-declarations -pedantic-errors")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O3")
set(CMAKE_C_FLAGS_MIN_SIZEREL "${CMAKE_C_FLAGS} -Os")
set(SRCS
src/main.c)
add_executable(mmmcalc ${SRCS})

View File

@ -1,6 +1,21 @@
MMMCalc MMMCalc
======= =======
[![Build Status](https://travis-ci.org/Deathsbreed/MMMCalc.svg?branch=master)](https://travis-ci.org/Deathsbreed/MMMCalc)
This is a very simple project, it was made for educational purposes (hence why it is open-source), and I encourage everyone to contribute if they have something to add. MMMCalc is a program I made after school one day after having to learn about Mean, Median, and Mode for the thousandth time. So instead of doing my actual homework I decided to make this program which would do it for me. Of course, the program with this is that your teachers often ask you to show your work. Well, fear not! For MMMCalc shows you **its** work. After it does its calculations, if you turn on _verbose mode_ (by using the `-v` argument) it will show you how MMMCalc got to that answer that it's giving you. After going through Mean, Median, and Mode (the reason why this program is called **MMM**Calc) I decided to add a few other basic statistical properties to it.
To contact me, send me an e-mail at <nicolas.ortega.froysa@gmail.com>. I hope this helps someone to make their millionth time of doing Mean, Median, and Mode in school a little less of a pain in the ass.
### Compiling
MMMCalc uses [CMake](http://cmake.org/) to compile. Please install the C development tools and CMake (along with whichever build script you plan on having CMake generate) in order to run this command.
```bash
$ cd build/
$ cmake ..
$ make
```
### Contributing
To contribute, simply open a pull request, however, be aware that this code is licensed under a GNU GPLv3 and so will yours.
### License
All code in this repository is under the [GNU GPLv3](/LICENSE).

0
build/.keep Normal file
View File

View File

@ -1,91 +0,0 @@
import java.util.HashMap;
import java.util.Map;
/**
* @author Nicolás A. Ortega
* @copyright (C) Nicolás A. Ortega
* @license GNU General Public License 3.0 (GPLv3)
* @year 2014
*
*/
public class MMMCalc {
private static float[] numArray;
public static void main(String[] args) {
System.out.println("Welcome to MMMCalc v0.1, a simple tool for basic statistics calculations.\n" +
"This software is licensed under the GNU GPLv3 license and comes WITHOUT WARRANTY.\n");
if(args.length > 0) {
float sNum = 0;
numArray = new float[args.length];
for(int i = 0; i < args.length; i++) {
numArray[i] = Float.parseFloat(args[i]) - 0f;
}
int nL = numArray.length;
float tmp = 0;
for(int i = 0; i < nL; i++) {
for(int j = 0; j >= (i+1); j--) {
if(numArray[j] < numArray[j-1]) {
tmp = numArray[j];
numArray[j] = numArray[j-1];
numArray[j-1] = tmp;
}
}
}
calcMean();
calcMedian();
calcMode();
} else {
System.out.println("You did not mention any variables.");
}
}
private static void calcMean() {
float mean = 0;
float sum = 0;
for(float i: numArray) {
sum += i;
}
mean = sum / (float)numArray.length;
System.out.println("Mean: " + mean);
}
private static void calcMedian() {
int midVar = 0;
midVar = numArray.length / 2;
System.out.println("Median: " + numArray[midVar]);
}
private static void calcMode() {
HashMap<Float, Float> fx = new HashMap<Float, Float>();
for(float x: numArray) {
Float f = fx.get(x);
if(f == null) {
fx.put(x, (float)1);
} else {
fx.put(x, f + 1);
}
}
float mode = 0;
float modeFreq = 0;
for(Map.Entry<Float, Float> entry: fx.entrySet()) {
float freq = entry.getValue();
if(freq > modeFreq) {
modeFreq = freq;
mode = entry.getKey();
}
}
System.out.println("Mode: " + mode + " (frequency: " + modeFreq + ")");
}
}

128
src/main.c Normal file
View File

@ -0,0 +1,128 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdbool.h>
#include <getopt.h>
#include <unistd.h>
// Version string
const char *version = "v0.5";
// Whether or not the calculations should be verbose
bool verboseFlag = false;
// Function that prints help info
inline void printHelp();
int main(int argc, char **argv) {
// There should always be at least be 2 arguments and no more than 4
if(argc <= 1) {
fprintf(stderr, "No arguments were provided. Use `-h' for help.\n");
return 1;
}
// Variable where the argument is stored
int arg;
// If help info should be printed
bool helpFlag = false;
// If version info should be printed
bool versionFlag = false;
// The file to read the numbers from
char *infile = NULL;
while((arg = getopt(argc, argv, "hvVf:")) != -1) {
switch(arg) {
case 'h':
// Only 2 arguments can be used
if(argc != 2) {
fprintf(stderr, "Invalid use of arguments. Use `-h' for help.\n");
return 1;
}
helpFlag = true;
break;
case 'v':
verboseFlag = true;
break;
case 'V':
// Only 2 arguments can be used
if(argc != 2) {
fprintf(stderr, "Invalid use of arguments. Use `-h' for help.\n");
return 1;
}
versionFlag = true;
break;
case 'f':
// There needs to be between 3 and 4 arguments
if(argc > 4 || argc < 3) {
fprintf(stderr, "Invalid use of arguments. Use `-h' for help.\n");
}
// Set the input file
infile = optarg;
break;
case '?':
if(optopt == 'f') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else if(isprint(optopt)) {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
} else {
fprintf(stderr, "Unknown character `\\x%x'.\n", optopt);
}
return 1;
default:
// If we get anything else that's weird just abort
abort();
}
}
if(helpFlag) {
printHelp();
return 0;
} else if(versionFlag) {
printf("%s\n", version);
return 0;
}
// Print copyright & license information
printf("MMMCalc %s, Copyright (c) 2016 Nicolás A. Ortega.\n", version);
printf("This program comes with ABSOLUTELY NO WARRANTY.\n");
printf("This program is free software and you are welcome to redistribute\n");
printf("under the terms and conditions of the GNU GPLv3 or higher.\n\n");
// Open a file as read only
FILE *numfile = fopen(infile, "r");
// Temporary variable to see how many numbers are in this file
double num;
// The size of the coming nums array
int size = 0;
// Get the size for the array
while(fscanf(numfile, "%lf", &num) == 1) size++;
rewind(numfile);
printf("There are %d numbers in the file.\n", size);
// Create the array with that size
double nums[size];
for(int i = 0; i < size; i++) {
// Store result of fscanf in err
int err = fscanf(numfile, "%lf", &nums[i]);
// If fscanf returned error exit out of here
if(err != 1) {
fprintf(stderr, "Error reading entire file.\n");
return 1;
}
// If not let's continue printing
printf("%f\n", nums[i]);
}
return 0;
}
void printHelp() {
printf("Usage: mmmcalc [options]\n");
printf("Options:\n");
printf(" -f <file> -- The file to read variables from.\n");
printf(" -h -- Show this help information.\n");
printf(" -v -- Be verbose, prints the equations used.\n");
printf(" -V -- Print the version number.\n");
}

View File

@ -1,2 +0,0 @@
Manifest-Version: 0.1
Main-Class: MMMCalc

351
src/mmmcalc/MMMCalc.java Normal file
View File

@ -0,0 +1,351 @@
package mmmcalc;
import java.lang.Math;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* @author Nicolás A. Ortega
* @copyright (C) Nicolás A. Ortega
* @license GNU GPLv3
* @year 2014
*
*/
public class MMMCalc {
private static boolean verbose = false;
private static float[] numArray;
private static float mean = 0;
private static float q1 = 0;
private static float median = 0;
private static float q3 = 0;
private static float mode = 0;
private static float range = 0;
private static float stdDev = 0;
private static float variance = 0;
public static void main(String[] args) {
System.out.println("MMMCalc v0.4, Copyright (C) 2014 Nicolás A. Ortega\n" +
"This program comes with ABSOLUTELY NO WARRANTY; for details use '-w'\n" +
"This is free software, and you are welcome to redistribute it\n" +
"under certain conditions; use '-c' for details.\n");
if(args.length > 0) {
if(args[0].equals("-h")) {
System.out.println("Usage:\n" +
" MMMCalc [options] [variables]\n\n" +
"Options:\n" +
" -v | -V -- Be verbose (show the work).\n" +
" -w -- Show warranty information.\n" +
" -c -- Show copyright information.\n" +
" -h -- Show this help information.\n");
} else if(args[0].equals("-w")) {
System.out.println("THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n" +
"APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n" +
"HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM 'AS IS' WITHOUT WARRANTY\n" +
"OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n" +
"THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n" +
"PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n" +
"IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n" +
"ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n");
} else if(args[0].equals("-c")) {
System.out.println("MMMCalc, a very basic statistics calculator.\n" +
"Copyright (C) 2014 Nicolás A. Ortega\n\n" +
"This program is free software: you can redistribute it and/or modify\n" +
"it under the terms of the GNU General Public License as published by\n" +
"the Free Software Foundation, either version 3 of the License, or\n" +
"(at your option) any later version.\n\n" +
"This program is distributed in the hope that it will be useful,\n" +
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +
"GNU General Public License for more details.\n\n" +
"You should have received a copy of the GNU General Public License\n" +
"along with this program. If not, see <www.gnu.org/licenses/>.");
} else if(args[0].equals("-v") || args[0].equals("-V")) {
verbose = true;
numArray = new float[args.length - 1];
for(int i = 0; i < numArray.length; i++) {
numArray[i] = Float.parseFloat(args[i+1]);
}
sortArray();
calcMean();
calcQ1();
calcMedian();
calcQ3();
calcMode();
calcRange();
calcStdDev();
calcVariance();
} else {
numArray = new float[args.length];
for(int i = 0; i < args.length; i++) {
numArray[i] = Float.parseFloat(args[i]) - 0f;
}
sortArray();
calcMean();
calcQ1();
calcMedian();
calcQ3();
calcMode();
calcRange();
calcStdDev();
calcVariance();
}
} else {
System.out.println("You did not mention any variables. Use the -h argument for help.");
}
}
private static void sortArray() {
int nL = numArray.length;
float tmp = 0;
for(int i = 0; i < nL; i++) {
for(int j = (nL-1); j >= (i+1); j--) {
if(numArray[j] < numArray[j-1]) {
tmp = numArray[j];
numArray[j] = numArray[j-1];
numArray[j-1] = tmp;
}
}
}
}
private static void calcMean() {
float sum = 0;
for(float i: numArray) {
sum += i;
}
mean = sum / (float)numArray.length;
System.out.println("Mean: " + mean);
if(verbose) {
System.out.print("(");
for(int i = 0; i < numArray.length; i++) {
System.out.print(numArray[i]);
if(i != numArray.length -1) {
System.out.print(" + ");
}
}
System.out.print(") / " + numArray.length + " = " + mean + "\n\n");
}
}
private static void calcQ1() {
int q1Pos;
// c stands for case... Cases correspond to their order in the following if statements (4 different cases).
int c;
if(numArray.length % 2.0 == 0) {
q1Pos = (int)(numArray.length / 4);
if(numArray.length % 4.0 == 0) {
q1 = (numArray[q1Pos] + numArray[q1Pos-1]) / 2;
c = 1;
} else {
q1 = numArray[q1Pos];
c = 2;
}
} else {
if(Math.ceil(numArray.length / 2.0) % 2.0 == 0) {
q1Pos = (int)(Math.ceil(numArray.length / 2.0) / 2.0);
q1 = (numArray[q1Pos] + numArray[q1Pos+1]) / 2;
c = 3;
} else {
q1Pos = (int)Math.ceil(numArray.length / 4.0);
q1 = numArray[q1Pos];
c = 4;
}
}
System.out.println("Q1: " + q1);
if(verbose) {
for(int i = 0; i < numArray.length; i++) {
if(c == 1) {
if(i == q1Pos - 1) {
System.out.print(">>" + numArray[i] + " !" + q1 + "! ");
} else if(i == q1Pos) {
System.out.print(numArray[i] + "<< ");
} else {
System.out.print(numArray[i] + " ");
}
} else if(c == 2) {
if(i == q1Pos) {
System.out.print(">>" + numArray[i] + "<< ");
} else {
System.out.print(numArray[i] + " ");
}
} else if(c == 3) {
if(i == q1Pos) {
System.out.print(">>" + numArray[i] + " !" + q1 + "! ");
} else if(i == q1Pos + 1) {
System.out.print(numArray[i] + "<< ");
} else {
System.out.print(numArray[i] + " ");
}
} else if(c == 4) {
if(i == q1Pos) {
System.out.print(">>" + numArray[i] + "<< ");
} else {
System.out.print(numArray[i] + " ");
}
}
}
System.out.print("\n\n");
}
}
private static void calcMedian() {
int midVar = numArray.length / 2;
boolean exact;
if(numArray.length % 2 == 0) {
median = (numArray[midVar] + numArray[midVar-1]) / 2;
exact = false;
} else {
median = numArray[midVar];
exact = true;
}
System.out.println("Median: " + median);
if(verbose) {
for(int i = 0; i < numArray.length; i++) {
if(!exact) {
if(i == midVar - 1) {
System.out.print(">>" + numArray[i] + " !" + median + "! ");
} else if(i == midVar) {
System.out.print(numArray[i] + "<< ");
} else {
System.out.print(numArray[i] + " ");
}
} else {
if(i == midVar) {
System.out.print(">>" + numArray[i] + "<< ");
} else {
System.out.print(numArray[i] + " ");
}
}
}
System.out.print("\n\n");
}
}
// FIXME: Needs to calculate haflway between the median value and the last value.
private static void calcQ3() {
/*int q3Pos = (numArray.length * 3) / 4;
boolean exact;
if((numArray.length * 3) % 4 != 0) {
q3 = (numArray[q3Pos+1] + numArray[q3Pos]) / 2;
exact = false;
} else {
q3 = numArray[q3Pos];
exact = true;
}
System.out.println("Q3: " + q3);
if(verbose) {
for(int i = 0; i < numArray.length; i++) {
if(!exact) {
if(i == q3Pos) {
System.out.print(">>" + numArray[i] + " !" + q3 + "! ");
} else if(i == q3Pos + 1) {
System.out.print(numArray[i] + "<< ");
} else {
System.out.print(numArray[i] + " ");
}
} else {
if(i == q3Pos) {
System.out.print(">>" + numArray[i] + "<< ");
} else {
System.out.print(numArray[i] + " ");
}
}
}
System.out.print("\n\n");
}*/
System.out.println("Q3 is not currently functional.\n");
}
private static void calcMode() {
HashMap<Float, Float> fx = new HashMap<Float, Float>();
for(float x: numArray) {
Float f = fx.get(x);
if(f == null) {
fx.put(x, (float)1);
} else {
fx.put(x, f + 1);
}
}
float modeFreq = 0;
for(Map.Entry<Float, Float> entry: fx.entrySet()) {
float freq = entry.getValue();
if(freq > modeFreq) {
modeFreq = freq;
mode = entry.getKey();
}
}
System.out.println("Mode: " + mode + " (frequency: " + modeFreq + ")");
if(verbose) {
for(Map.Entry<Float, Float> entry:fx.entrySet()) {
System.out.print(entry.getKey() + "(" + entry.getValue() + ") ");
}
System.out.print("\n\n");
}
}
private static void calcRange() {
int l = numArray.length -1;
range = numArray[l] - numArray[0];
System.out.println("Range: " + range);
if(verbose) {
System.out.println(numArray[l] + " - " + numArray[0] + " = " + range + "\n");
}
}
private static void calcStdDev() {
float difSum = 0;
for(int i = 0; i < numArray.length; i++) {
difSum += numArray[i] - mean;
}
stdDev = difSum / (float)Math.sqrt((double)numArray.length);
System.out.println("Standard Deviation: " + stdDev);
if(verbose) {
System.out.print("sqrt((");
for(int i = 0; i < numArray.length; i++) {
System.out.print(numArray[i] + " - " + mean);
if(i != numArray.length - 1) {
System.out.print(" + ");
}
}
System.out.print(")^2 / " + numArray.length + ") = " + stdDev + "\n\n");
}
}
private static void calcVariance() {
variance = stdDev * stdDev;
System.out.println("Variance: " + variance);
if(verbose) {
System.out.println(stdDev + "^2 = " + variance + "\n");
}
}
}