Archive for Educational
JAVA Program For A.I. Data Normalization
I needed to normalize my data for the sake of machine learning – i.e. training a neural network for automatic classification of unseen data. The formula I used for the normalization is ((value – minimum value)/(maximum value – minimum value)). I then rounded this to 2 decimal places.
In order to actually round off, I did another JAVA class specifically for this and used it in the main class.
This is not the most elegant programs you will ever come across but at least it does the job for me and I am sure it will do the job for someone else. The argument needs to be a text file containing numbers that need to be normalized. The other argument is the name of the text file that you want the output to be written. When you run it, it does the job quietly and doesn’t notify you of success. (It may notify you of any errors!)
You can modify it to use a scanner to input the arguments or even develop it into an applet.
This is the main class then:
import java.util.*;
import java.io.*;
import java.math.*;
public class InputNormalization
{
public static void main(String[] args) throws IOException
{
String originalFile = "numbers.txt"; //PUT THE NAME OF YOUR TEXT FILE HERE
String endFile = "numbersnormalised.txt"; //AND THE TARGET TEXT FILE HERE
int count = 0;
int normalcount = 0;
double num = 0;
double min = 20;
double max = -20;
// double calculatedValue = 0.00;
Scanner fileScan = new Scanner (new File(originalFile));
while (fileScan.hasNext())
{
num = fileScan.nextDouble();
count++;
if (min > num) //Find the minimum value
{
min = num;
}
if (max < num)// Find the maximum value
{
max = num;
}
}
fileScan.close();
fileScan = new Scanner (new File(originalFile));
// new scanner to "rewind" the file
Writer output = null; //for writing to a text file
File file = new File(endFile);
output = new BufferedWriter(new FileWriter(file));
output.write("The number of values in "+originalFile+" is
"+count+"\r\n"); //Number of values in the text file
output.write("The minimum value is "+min+"\r\n");
output.write("The maximum value is "+max+"\r\n");
output.write("The following are the normalized values: \r\n");
double values[] = new double[count];
for (int i = 0; i < values.length; i++)
{
if (fileScan.hasNext())
{
num = fileScan.nextDouble();
if (num == min)
{
output.write("0.00 \r\n");
}
else
{
InputDecimalRounding normalisedValue =
new InputDecimalRounding((num - min)/(max - min));
//Normalize the Data and Round it to 2dp
output.write(normalisedValue+ "\r\n");
}
}
} //END FOR
fileScan.close();
output.close();
} //END MAIN
}//END CLASS
THE INPUTDECIMALROUNDING CLASS FOLLOWS:
import java.text.*;
public class InputDecimalRounding
{
double conversion;
public InputDecimalRounding (double conversion)
{
this.conversion = conversion;
}
public String toString()
{
DecimalFormat normalData = new DecimalFormat("#0.00");
return normalData.format(conversion);
}
}
How to Read Mathematics
(Shai Simonson and Fernando Gouvea)
Mathematics is “a language that can neither be read nor understood without initiation.” 1
A reading protocol is a set of strategies that a reader must use in order to benefit fully from reading the text. Poetry calls for a different set of strategies than fiction, and fiction a different set than non-fiction. It would be ridiculous to read fiction and ask oneself what is the author’s source for the assertion that the hero is blond and tanned; it would be wrong to read non-fiction and not ask such a question. This reading protocol extends to a viewing or listening protocol in art and music. Indeed, much of the introductory course material in literature, music and art is spent teaching these protocols.
Mathematics has a reading protocol all its own, and just as we learn to read literature, we should learn to read mathematics. Students need to learn how to read mathematics, in the same way they learn how to read a novel or a poem, listen to music, or view a painting. Ed Rothstein’s book, Emblems of Mind, a fascinating book emphasizing the relationship between mathematics and music, touches implicitly on the reading protocols for mathematics.
When we read a novel we become absorbed in the plot and characters. We try to follow the various plot lines and how each affects the development of the characters. We make sure that the characters become real people to us, both those we admire and those we despise. We do not stop at every word, but imagine the words as brushstrokes in a painting. Even if we are not familiar with a particular word, we can still see the whole picture. We rarely stop to think about individual phrases and sentences. Instead, we let the novel sweep us along with its flow and carry us swiftly to the end. The experience is rewarding, relaxing and thought provoking.
Novelists frequently describe characters by involving them in well-chosen anecdotes, rather than by describing them by well-chosen adjectives. They portray one aspect, then another, then the first again in a new light and so on, as the whole picture grows and comes more and more into focus. This is the way to communicate complex thoughts that defy precise definition.
Mathematical ideas are by nature precise and well defined, so that a precise description is possible in a very short space. Both a mathematics article and a novel are telling a story and developing complex ideas, but a math article does the job with a tiny fraction of the words and symbols of those used in a novel. The beauty in a novel is in the aesthetic way it uses language to evoke emotions and present themes which defy precise definition. The beauty in a mathematics article is in the elegant efficient way it concisely describes precise ideas of great complexity.
What are the common mistakes people make in trying to read mathematics? How can these mistakes be corrected?
Don’t Miss the Big Picture
“Reading Mathematics is not at all a linear experience …Understanding the text requires cross references, scanning, pausing and revisiting” 2
Don’t assume that understanding each phrase, will enable you to understand the whole idea. This is like trying to see a portrait painting by staring at each square inch of it from the distance of your nose. You will see the detail, texture and color but miss the portrait completely. A math article tells a story. Try to see what the story is before you delve into the details. You can go in for a closer look once you have built a framework of understanding. Do this just as you might reread a novel.
Don’t be a Passive Reader
“A three-line proof of a subtle theorem is the distillation of years of activity. Reading mathematics… involves a return to the thinking that went into the writing” 3
Explore examples for patterns. Try special cases.
A math article usually tells only a small piece of a much larger and longer story. The author usually spends months discovering things, and going down blind alleys. At the end, he organizes it all into a story that covers up all the mistakes (and related motivation), and presents the completed idea in clean neat flow. The way to really understand the idea is to re-create what the author left out. Read between the lines.
Mathematics says a lot with a little. The reader must participate. At every stage, he/she must decide whether or not the idea being presented is clear. Ask yourself these questions:
Why is this idea true?
Do I really believe it?
Could I convince someone else that it is true?
Why didn’t the author use a different argument?
Do I have a better argument or method of explaining the idea?
Why didn’t the author explain it the way that I understand it?
Is my way wrong?
Do I really get the idea?
Am I missing some subtlety?
Did this author miss a subtlety?
If I can’t understand the point, perhaps I can understand a similar but simpler idea?
Which simpler idea?
Is it really necessary to understand this idea?
Can I accept this point without understanding the details of why it is true?
Will my understanding of the whole story suffer from not understanding why the point is true?
Putting too little effort into this participation is like reading a novel without concentrating. After half an hour, you wake up to realize the pages have turned, but you have been daydreaming and don’t remember a thing you read.
Don’t Read Too Fast
Reading mathematics too quickly results in frustration. A half hour of concentration in a novel might net the average reader 20-60 pages with full comprehension, depending on the novel and the experience of the reader. The same half hour in a math article buys you 0-10 lines depending on the article and how experienced you are at reading mathematics. There is no substitute for work and time. You can speed up your math reading skill by practicing, but be careful. Like any skill, trying too much too fast can set you back and kill your motivation. Imagine trying to do an hour of high-energy aerobics if you have not worked out in two years. You may make it through the first class, but you are not likely to come back. The frustration from seeing the experienced class members effortlessly do twice as much as you, while you moan the whole next day from soreness, is too much to take.
For example, consider the following theorem from Levi Ben Gershon’s manuscript Maaseh Hoshev (The Art of Calculation), written in 1321.
“When you add consecutive numbers starting with 1, and the number of numbers you add is odd, the result is equal to the product of the middle number among them times the last number.” It is natural for modern day mathematicians to write this as:

A reader should take as much time to unravel the two-inch version as he would to unravel the two-sentence version. An example of Levi’s theorem is that 1 + 2 + 3 + 4 + 5 = 3×5.
Make the Idea your Own
The best way to understand what you are reading is to make the idea your own. This means following the idea back to its origin, and rediscovering it for yourself. Mathematicians often say that to understand something you must first read it, then write it down in your own words, then teach it to someone else. Everyone has a different set of tools and a different level of “chunking up” complicated ideas. Make the idea fit in with your own perspective and experience.
“When I use a word, it means just what I choose it to mean”
(Humpty Dumpty to Alice in Through the Looking Glass by Lewis Carroll)
“The meaning is rarely completely transparent, because every symbol or word already represents an extraordinary condensation of concept and reference” 4
A well-written math text will be careful to use a word in one sense only, making a distinction, say, between combination and permutation (or arrangement). A strict mathematical definition might imply that “yellow rabid dog” and “rabid yellow dog” are different arrangements of words but the same combination of words. Most English speakers would disagree. This extreme precision is utterly foreign to most fiction and poetry writing, where using multiple words, synonyms, and varying descriptions is de rigueur.
A reader is expected to know that an absolute value is not about some value that happens to be absolute, nor is a function about anything functional.
A particular notorious example is the use of “It follows easily that” and equivalent constructs. It means something like this:
One can now check that the next statement is true with a certain amount of essentially mechanical, though perhaps laborious, checking. I, the author, could do it, but it would use up a large amount of space and perhaps not accomplish much, since it’d be best for you to go ahead and do the computation to clarify for yourself what’s going on here. I promise that no new ideas are involved, though of course you might need to think a little in order to find just the right combination of good ideas to apply.
In other words, the construct, when used correctly, is a signal to the reader that what’s involved here is perhaps tedious and even difficult, but involves no deep insights. The reader is then free to decide whether the level of understanding he/she desires requires going through the details or warrants saying “Okay, I’ll accept your word for it.”
Now, regardless of your opinion about whether that construct should be used in a particular situation, or whether authors always use it correctly, you should understand what it is supposed to mean. “It follows easily that” does not mean
if you can’t see this at once, you’re a dope,
neither does it mean
this shouldn’t take more than two minutes,
but a person who doesn’t know the lingo might interpret the phrase in the wrong way, and feel frustrated. This is apart from the issue that one person’s tedious task is another person’s challenge, so the author must correctly judge the audience.
Know Thyself
Texts are written with a specific audience in mind. Make sure that you are the intended audience, or be willing to do what it takes to become the intended audience.
T.S.Eliot’s
A Song for Simeon:
Lord, the Roman hyacinths are blooming in bowls and
The winter sun creeps by the snow hills;
The stubborn season has made stand.
My life is light, waiting for the death wind,
Like a feather on the back of my hand.
Dust in sunlight and memory in corners
Wait for the wind that chills towards the dead land.
For example, Eliot’s poem pretty much assumes that its readers are going to either know who Simeon was or be willing to find out. It also assumes that its reader will be somewhat experienced in reading poetry and/or is willing to work to gain such experience. He assumes that they will either know or investigate the allusions here. This goes beyond knowledge of things like who Simeon was. For example, why are the hyacinths “Roman?” Why is that important?
Elliot assumes that the reader will read slowly and pay attention to the images: he juxtaposes dust and memory, relates old age to winter, compares waiting for death with a feather on the back of the hand, etc. He assumes that the reader will recognize this as poetry; in a way, he’s assuming that the reader is familiar with a whole poetic tradition. The reader is supposed to notice that alternate lines rhyme, but that the others do not, and so on.
Most of all, he assumes that the reader will read not only with the mind, but also with his/her emotions and imagination, allowing the images to summon up this old man, tired of life but hanging on, waiting expectantly for some crucial event, for something to happen.
Most math books are written with assumptions about the audience: that they know certain things, that they have a certain level of “mathematical maturity,” etc. Before you start to read, make sure you know what the author expects you to know.
Donald Trump Success Lessons
- Focus on the Present
“I try to learn from the past, but I plan for the future by focusing exclusively on the present. That’s were the fun is.”
Yesterday is buried, and tomorrow is not yet born; the only progress that can be made toward success has to be done in the present moment, so I recommend that you focus all of your energies into making the present moment as productive as possible. If you don’t, your past will duplicate itself into your future.
- Fail Forward
“Sometimes by losing a battle you find a new way to win the war.”
Never fear failure, failure is the path to success. If at first you don’t succeed, then … that makes sense. Success takes time and it requires failure, through the process of failing you will discover how to succeed. Don’t fear failing, fear not giving your all.
- Think Big
“As long as you’re going to be thinking anyway, think big.”
It takes no more time to think big as it does to think small. Plan for big things in your life, there’s always room at the top for the person who’s willing to think bigger. Leave “little thinking” for people who want to accomplish little things, but not you. Success begins with thinking big.
- Do What You Love
“If you’re interested in ‘balancing’ work and pleasure, stop trying to balance them. Instead make your work more pleasurable.”
I saw a billboard the other day that said, “Life is too short to eat oatmeal,” I don’t know about that, but I do know that life is too short to do work that you despise. Trump said, “I don’t make deals for the money. I’ve got enough, much more than I’ll ever need. I do it, to do it.” Whatever you do, you must do it, to do it, because you will only have success doing what you love!
- Stay Positive
“What separates the winners from the losers is how a person reacts to each new twist of fate.”
Nothing is more constant than “change.” What worked for someone else will not necessarily work for you on your path to success. Challenges that others did not have, you may have. What separates the winners from the losers is that winners react positively to unforeseen challenges. Winners go over the hurdles that stop others.
- Passion is Power
“Without passion you don’t have energy; without energy you have nothing.”
The main ingredient for success is energy. Nothing great can ever be accomplished without “amazing” levels of energy, and energy comes from passion, so what’s the lesson? Always follow your passion, and you will always have the energy to accomplish your dreams.
- Experience is Priceless
“Experience taught me a few things. One is to listen to your gut, no matter how good something sounds on paper. The second is that you’re generally better off sticking with what you know. And the third is that sometimes your best investments are the ones you don’t make.”
You need experience; there are things that experience will teach you that you can’t learn in any other way. Never underestimate the value of getting your hands dirty. With experience come priceless lessons that will position you for success.
The 90/10 Principle

Coffee













