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);
    }
}
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

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.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Donald Trump Success Lessons

  1. 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.

  2. 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.

  3. 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.

  4. 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!

  5. 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.

  6. 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.

  7. 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.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Men With Sexual Exclusivity Are More Intelligent

February 25, 2010 2 Comments » Educational

More intelligent people are significantly more likely to exhibit social values and religious and political preferences that are novel to the human species in evolutionary history. Specifically, liberalism and atheism, and for men (but not women), preference for sexual exclusivity correlate with higher intelligence, a new study finds.

The study, published in the March 2010 issue of the peer-reviewed scientific journal Quarterly, advances a new theory to explain why people form particular preferences and values. The theory suggests that more intelligent people are more likely than less intelligent people to adopt evolutionarily novel preferences and values, but intelligence does not correlate with preferences and values that are old enough to have been shaped by evolution over millions of years.”

“Evolutionarily novel” preferences and values are those that humans are not biologically designed to have and our probably did not possess. In contrast, those that our ancestors had for millions of years are “evolutionarily familiar.”

“General intelligence, the ability to think and reason, endowed our ancestors with advantages in solving evolutionarily novel problems for which they did not have innate solutions,” says Satoshi Kanazawa, an evolutionary psychologist at the London School of Economics and Political Science. “As a result, more intelligent people are more likely to recognize and understand such novel entities and situations than less intelligent people, and some of these entities and situations are preferences, values, and lifestyles.”

An earlier study by Kanazawa found that more intelligent individuals were more nocturnal, waking up and staying up later than less intelligent individuals. Because our ancestors lacked artificial light, they tended to wake up shortly before dawn and go to sleep shortly after dusk. Being nocturnal is evolutionarily novel.

In the current study, Kanazawa argues that humans are evolutionarily designed to be conservative, caring mostly about their family and friends, and being liberal, caring about an indefinite number of genetically unrelated strangers they never meet or interact with, is evolutionarily novel. So more intelligent children may be more likely to grow up to be liberals.

Data from the National Longitudinal Study of Adolescent Health (Add Health) support Kanazawa’s hypothesis. Young adults who subjectively identify themselves as “very liberal” have an average IQ of 106 during adolescence while those who identify themselves as “very conservative” have an average IQ of 95 during adolescence.

In addition, humans have always been mildly polygynous in . Men in polygynous marriages were not expected to be sexually exclusive to one mate, whereas men in monogamous marriages were. In sharp contrast, whether they are in a monogamous or polygynous marriage, women were always expected to be sexually exclusive to one mate. So being sexually exclusive is evolutionarily novel for men, but not for women. And the theory predicts that more intelligent men are more likely to value sexual exclusivity than less intelligent men, but general intelligence makes no difference for women’s value on sexual exclusivity. Kanazawa’s analysis of Add Health data supports these sex-specific predictions as well.

One intriguing but theoretically predicted finding of the study is that more intelligent people are no more or no less likely to value such evolutionarily familiar entities as marriage, family, children, and friends.

More information: The article “Why Liberals and Atheists Are More Intelligent” will be published in the March 2010 issue of Social Psychology Quarterly.

Provided by American Sociological Association (news : web)

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

The 90/10 Principle

WHAT IS THIS PRINCIPLE?
10% of life is made up of what happens to you…
90% of life is decided by how you react.

WHAT DOES THIS MEAN?
We really have NO control over the 10% of what happens to us. The 90% is different. YOU determine the 90%
HOW?
By your reaction.
You cannot control a red light. However, you can control your reaction. Do not let people fool you. YOU can control how you react.
Let’s see this example:
You are having breakfast with your family.
Your daughter knocks over a  cup of coffee onto your business shirt.

Coffee

Coffee


YOU HAVE NO CONTROL over what has just happened. What happens next will be determined by HOW YOU REACT.
You curse. You harshly scold your daughter  for knocking the cup over. She breaks down in tears. After scolding her, you turn to your wife and criticize her for placing the cup too close to the edge of the table. A short verbal battle follows. You storm upstairs and change your shirt. Back downstairs, you find your daughter has been too busy crying to finish her breakfast and getting ready to go to school. She misses the bus. Your spouse must leave immediately for work. You rush to the car and drive your daughter to school. Because you are late, you drive 40 miles per hour in a 30 mph speed limit zone. After a 15-minute delay and throwing $60.00 traffic fine away, you arrive at school. Your daughter runs into the building without saying goodbye.
After arriving the office 20 minutes late, you realize your forgot your briefcase. Your day has started terrible. As it continues, it seems to get worse and worse. You look forward to coming home. When you arrive home, you find a small wedge in your relationship with your wife and daughter.
Why?
Because of how you reacted in the morning.
Why did you have a bad day?

A) Did the coffee cause it?
B) Did your daughter cause it?
C) Did the policeman cause it?
D) Did you cause it?

The answer is: D
-
You had NO CONTROL over what happened with the coffee.
How you reacted in those 5 seconds is what caused your bad day!
>>>
Here is what could have and should have happened.
<<<
Coffee splashes over you. Your daughter is about to cry. You gently say: “It’s okay, honey, you just need to be more careful next time.” Grabbing a towel, you go upstairs and change your shirt. You grab your briefcase, and come back down  in time to look through the window and see your child getting on the bus. She turns and waves. You arrive 5 minutes early and cheerfully greet the staff.
Notice the difference?
Two different scenarios.
Both started the same.
Both ended different.
WHY?
Because of how you reacted.
You really have no control over 10% of what happens in your life.
The other 90% is determined by your reaction.
—————————————-
Absolutely everything we do, give, say or even think, It’s like a Boomerang. It will come back to us. If we want to receive, we need to learn to give first… Maybe we will end with our hands half empty, but our hearts will be filled with love.
And those who love life, have that feeling marked in their hearts…
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)