Tuesday, February 28, 2017

Using Computer Science to Improve Wind Power



Image result for wind power
        Imagine a future where billions shiver in darkness due to the scarcity and expense of fossil fuels. This dark dystopia could become reality without renewable energy. 
Image result for pollution image


Problem: We are embroiled in an energy crisis, and the clock is ticking for us to find a renewable alternative to fossil fuels. Fossil fuels are finite, and the combustion of fossil fuels creates pollution. Air pollution kills 7 million people per year -- 1 in 8 of total global deaths, according to the WHO. 
               While wind power is a feasible alternative, inaccurate predictions of turbine power output hinder the growth of wind power. Inaccurate predictions force utility companies to schedule backup power plants to account for wind intermittency. This can waste energy. Inaccurate predictions can cause utility companies to waste money because backup plants are expensive to maintain.


Image result for wind power

My Innovation: To address this problem, I used machine learning to create HAWC: Hybrid Algorithms for Wind-power Computation. Machine learning is a type of artificial intelligence that allows computers to learn from existing datasets and predict outcomes for new datasets.
 Traditional Programming vs Machine Learning


 
How HAWC Works: I divided my project into three steps: (1) testing the most basic machine learning algorithms; (2) coding the algorithms most widely used in the field, and (3) improving the existing algorithms. Each algorithm I tested predicts wind turbine power output given a dataset of wind speed from the NREL.
First, I coded linear regression and polynomial regression. Linear regression uses a linear function to make a prediction, generating a straight line that fits the data. Polynomial regression, similar to linear regression, generates a function that fits the data. However, it uses a polynomial function to create a curved line. This can be more effective on unpredictable data sets such as those of wind speed.
While these algorithms are accurate, they may have lower percent accuracy on extreme data values. Therefore, most scientists use 2-layer neural networks to predict turbine power output. Neural network algorithms imitate the decision-making process of the brain by using an iterative predicting procedure. Similar to neurons in the brain, neural network algorithms are organized into interconnected ‘layers’ that function together to make a prediction. A neural network often consists of an input layer, at least one hidden layer, and an output layer, where data enters through the input layer, is processed in the hidden layers, and is expressed in the output layer.
Although the 2-layer neural network is one of the most accurate algorithms, I thought I could do better. I coded a 3-layer neural network which has not previously been applied to the field.The 3-layer neural network was the most accurate with 97.65 percent accuracy! 


Image result for neural network
How HAWC Can Help Solve The Energy Crisis: 
      My innovation will help reduce the need for wasteful backup plants, saving utility companies energy and money. By reducing waste, my project can give utility companies a stronger incentive to use wind power. This can enable the growth of wind power. By enabling the growth of wind power, my innovation can decrease the demand for fossil fuels, reduce pollution, and save lives.

Sunday, January 8, 2017

Rule Your Room with LittleBits!


 

 Do you ever wish you could control objects in your room, set up wireless alert systems, or turn a bunch of bananas into a piano? You can create all of the above and more with the LittleBits Rule Your Room kit! This kit contains seven bits, or magnetic components that can be snapped together to form a circuit. Each bit performs a different function, and can be combined together to form a unique contraption. Rule Your Room kit contains a buzzer, sound trigger, dimmer, LED, motor, and the new Makey Makey bit.

Makey Makey is an invention kit that allows you to turn any conductive material into a sound-producing key. The Makey Makey bit captures that same function, but can be incorporated into any LittleBits circuit! What makes this added ability so extraordinary?


First, you can create devices that harness the function of Makey Makey and other Bits! With the Burglar Buzzer, you can protect any prized object from being stolen, be it a diary, your year's savings, or a piece of candy. Or, you can get creative with sounds by installing some software, plugging a USB cable from the Makey Makey bit into a computer, and connecting the alligator clips to fruits! Some other exciting projects from the Rule Your Room kit include spinning posters, sound-activated lights, and automatic projectile launchers.

 
Sound-activated Eyeballs!
 
As soon as I opened the kit, I could not wait to begin these projects, and was soon rewarded with functional circuits! Based on a quick look at the instructions, I could snap together the bits to create my circuit, and then connect the alligator clips where needed. I was impressed by the easy-to-follow layout of the instructions, and also the comprehensive explanations of each bit's function. It is an excellent way for a younger maker to understand circuits and electric current, and provides tinkerers of all ages with a foundation for creating their own inventions! The uses for this kit don't just stop at the end of the guidebook - there are more instructions online, and challenges to spark the engineering thought process.
Sample Page from the Guidebook 

                                      
                                               The Burglar Buzzer: stop a diary heist before it happens!

Example Circuit

Overall, this is a versatile and rewarding kit that I highly recommend!

Friday, June 10, 2016

Grace Hopper: Paving the Way Towards Modern Computers



Grace Hopper, known for her efforts in the US Navy and as a computer scientist, contributed to the development of computers as we know them by inventing the compiler. 
      Born in 1906, Grace Hopper was always fascinated with math and science. She studied at Yale, where she became one of the first women to earn a Ph.D in mathematics. However, when the U.S entered World War II, Hopper followed in her grandfather's footsteps and enlisted in the Navy. It was there that Hopper was first introduced to computer science.
       The navy assigned Hopper to the Bureau of Ships Computation project, where she learned to operate the Mark I computer - a colossal electro-mechanical computer that could only perform 3 additions a second. She learned to code, and wrote the first manual for the Mark I. In fact, it is believed that she was the first one to coin the term 'bug' to refer to an error in computer code!
         This happened when the Mark I kept spitting back incorrect numbers from multiplication. Hopper examined the behemoth computer, and discovered a live moth jammed between the contacts. This very moth remains preserved today in the Mark I log book, along with Hopper's note: "first ACTUAL bug found."







          However, in writing the manual for Mark I, Hopper found more than just bugs in the system. She realized that computers are symbol manipulators instead of giant calculators. This notion gave her a new view of coding, because it implies that computers can be used for a wide variety of applications. However, at the time, there was no way for computers to understand these symbols.
           To address this problem, Hopper wrote the A-0 compiler, a system that converts a programmer's input of code to binary instructions the computer can understand. Without a compiler, a computer would be no more than a giant simple calculator.
              Not only did Grace Hopper make a monumental contribution to the applications of computer science, but she also encouraged young people to pursue computer science. As she once said, "The most important thing I've accomplished, other than building the compiler, is training young people. They come to me, you know, and say, "Do you think we can do this?" I say, "Try it." 
                

Thursday, June 9, 2016

Computer Science Feature: Girl Knows Tech!

         If you want to follow another cool computer science website, check out Girl Knows Tech! This website features information about the computer code behind word processing and web developing software such as WordPress.
          You can learn the basics of HTML, a language used to code word processing software and websites. For instance, this post shows you how to write code to make words bold and italicized, display text to the screen, and to add functional links. If you want updates about her posts and interests, follow her on Twitter here: https://twitter.com/girlknowstech!
 

Wednesday, June 8, 2016

Arduino!

Want to try out some electronics programming? You can get started with Arduino, a programmable board able to read input! What can you do with an Arduino?
     The possibilities are endless! The Arduino board contains LEDs and sound output systems, so you can program the Arduino to synchronize flashing lights or compose tunes! Here is Arduino's guide page, and you can also choose from a selection of boards to  purchase on the website: https://www.arduino.cc/en/Guide/HomePage
 Once you have one, how do you use it? I used the fabulous introduction and instructions from the book Sylvia's Super-Awesome Project Book, by 'Super-Awesome' Sylvia! This book contains beginning tutorials for coding and creating Arduino projects that are super cool and easy to follow. If you want to learn Arduino, this is the place to start!

Find Your Perfect Pet Using Python!

           
If you're interested in learning Python, you're probably wondering what you can do with it. It is considerably harder to do a graphic project such as a video game or animation than it is in Scratch, but there are plenty of fabulous beginner projects that you can do!
               One of these projects is a simple quiz. You can use it to study for school, or make a fun personality quiz to give to your friends. I made a quiz that predicts your 'perfect pet' based on your input! I include my code below, and you can use it as a template for your own quiz. This code does not run properly in the browser environment CodeSkulptor because of minor differences in input syntax. However, you will be able to take the quiz if you enter it into the Python launcher on your computer. If you don't have Python, you can still take the quiz manually in the version above the code. 

As you are taking this quiz manually, consider how you might implement it in Python. Try it out, and then see the code below!
 Find Your Perfect Pet: Question 1

1. Where will you most likely want to keep your pet?
A. wherever it wants to go
B. Outdoors around my neighborhood
C. In a tank in my house
D. With me always
E. In the yard and in the house
F. Wherever there are ants

2.  You would ideally like your pet to be...
A. quiet and unobtrusive
B. not be a picky eater
C. fuzzy
D. be loyal
E. scare away burglars
F. eat ants

3. Your favorite thing to do with a pet is...
A. let it be
B. take it outdoors
C. pet it
D. have a close relationship with it
E. scare other people
F. watch it eat ants 

4. How much time per day are you willing to spend with your pet?
A. Whenever my pet wants to spend time with me
B. I don't have much time to spend with my pet
C. Whenever I want to spend time with my pet
D. All the time, whether I want to or not
E. I have a lot of time to spare
F. It depends on how many ants there are

5. How willing are you to provide special food for your pet?
A. Not very
B. My pet will probably eat lots of things it finds outside
C. I understand that my pet might need special food, and I will provide it
D. I am extremely willing to give my pet whatever food it needs, even if it is inconvenient for me
E. I prefer that my pet is a vegetarian
F. I have plenty of ants

6. What would you most likely name your pet?
A. Teeny, Moe, Cici
B. Blacky, Patches, Fred
C. Fluffy, Spot, Bob
D. Fido, Shadow, Ringo
E. Buster, Bruiser, Pebbles
F. Aardy, Varky, Antie


If you entered mostly A's, your perfect pet is...
A PARAMECIUM!

If you entered mostly B's, your perfect pet is...
A BUZZARD!

If you entered mostly C's, your perfect pet is...
BREAD MOLD!

If you entered mostly D's, your perfect pet is...
A LEECH!

If you entered mostly E's, your perfect pet is...
A STEGOSAURUS!

If you entered mostly F's, your perfect pet is...
AN AARDVARK! 


<Code Starts Here>

print ('This quiz shall tell you your ideal pet! Let\'s get started.')
print('First, what is your name?')
name = input()
print(name, ',here is your first question.')
print ('Where will you most likely want to keep your pet?')
print ('a. Wherever it wants to go.')
print ('b. Outdoors around my neighborhood.')
print ('c. In a tank in my house')
print ('d. With me always')
print ('e. in the yard and in the house ')
print ('f. Wherever there are ants.')

answer1 = input()
print('You would ideally like your pet to...')
print('a. quiet and unobtrusive.')
print('b. not be a picky eater. ')
print('c. be fuzzy.')
print('d. be loyal.')
print('e. scare away burglars.')
print('f. eat ants.')
answer2 = input()
print('Your favorite thing to do with a pet is...')
print('a. let it be.')
print('b. take it outdoors')
print('c. pet it.')
print('d. to have a close relationship with it.')
print('e. to scare other people.')
print('f. watch it eat ants.')
answer3 = input()
print('How much time per day are you willing to spend with your pet? ')
print('a. Whenever my pet wants to spend time with me.')
print('b. I don\'t have much time to spend with my pet.')
print('c. Whenever I want to spend time with my pet.')
print('d. All the time, whether I want to or not.')
print('e. I have a lot of time to spare.')
print('f. It depends on how many ants there are.')
answer4 = input()
print(' How willing are you to provide special food for your pet?')
print('a. Not very.')
print('b. My pet will probably eat lots of things it finds outside.')
print('c. I understnd that my pet might need special food, and I will provide it.')
print('d. I am extremely willing to give my pet whatever food it needs, even if it is inconvenient for me.')
print('e. I prefer that my pet is a vegetarian.')
print('f. I have plenty of ants.')
answer5 = input()
print('What would you most likely name your pet?')
print('a. Teeny, Moe, Cici')
print('b. Blacky, Patches, Fred')
print('c. Fluffy, Spot, Bob')
print('d. Fido, Shadow, Ringo ')
print('e. Buster, Bruiser, Pebbles')
print('f. Aardy, Varky, Antie')
answer6 = input()
mylist=[answer1, answer2, answer3, answer4, answer5, answer6]
na =0
nb = 0
nc = 0
nd = 0
ne = 0
for i in mylist:
    if (i == 'f'):
        print(' Your perfect pet is... an AARDVARK!')
        break
    elif (i == 'a'):
        na=na+1
    elif (i == 'b'):
        nb = nb + 1
    elif (i == 'c'):
        nc = nc + 1
    elif (i == 'd'):
        nd = nd + 1
    elif (i == 'e'):
        ne = ne + 1
    elif (na == nb) or (na == nc) or (na == nd) or (na == ne) or (nb == nc) or (nb == nd) or (nb == ne) or (nc == nd) or (nc == ne) or (nd == ne):
        print('Will your pet spend more time indoors or outdoors?')
        putin = input()
        if answer == 'indoors':
            print('Your perfect pet is... either a PARAMECIUM, BREAD MOLD, or LEECH!')
        else:
            print('Your perfect pet is... either a BUZZARD, STEGOSAURUS, or AARDVARK!')
           
       
if (na > nb) and (na > nc)and (na > nd) and (na > ne):
    print('Your perfect pet is... a PARAMECIUM!')
if (nb > na) and (nb > nc) and (nb > nd) and (nb > ne):
    print('Your perfect pet is... a BUZZARD!')
if (nc > na) and (nc > nb) and (nc > nd) and (nc > ne):
    print('Your perfect pet is... BREAD MOLD!')
if (nd > na) and (nd > nb) and (nd > nc) and (nd > ne):
    print('Your perfect pet is... a LEECH!')
if (ne > na) and (ne > nb) and (ne > nc) and (ne > nd):
    print('Your perfect pet is... a STEGOSAURUS!')

   

Tuesday, June 7, 2016

The Next Step: Scratch to Python

 
Once you've learned and experimented in Scratch, it's time to advance to the next level of programming! Python is a language that is both easy to learn and is used by computer scientists for real-world applications. Python shares certain aspects with Scratch, since it has output and input commands and ways to control time and repeat actions. 
      However, you can build more complex function structures with it and need to code commands yourself instead of dragging and dropping them. Though this allows for more interesting programs, it means that you need to translate what you want the computer to do into a form the computer can understand. This means that if you write code and the computer cannot understand it, you receive an error message and your program cannot run. However, don't let this deter you! There are plenty of easy ways to fix errors!
Let's get started!
         What can you do with Python? Python is not as visually oriented as Scratch, so it is considerably harder to create video games and animations. However, you can still create games such as quizzes and logic games, and learn how to do simple video games such as Pong and Asteroids.
          How can you learn Python? First, you need a way to start coding! There are two ways you can do this: download Python on your computer, or use a browser coding environment similar to how you coded in Scratch. If you want to download Python, you can choose the latest version. For the purpose of simple games, the version of Python you have does not matter. Now, you are probably thinking, why download Python when you can just code right in your browser? 
            While the browser environment, CodeSkulptor, is essentially Python, certain commands, particularly for user input, are different. This means there are fewer tutorials for CodeSkulptor. However, I took a great online class through Rice University on Coursera that used CodeSkulptor to create games such as Pong, Blackjack, a logic guessing game, and Asteroids. This class is meant for beginners who have no prior knowledge. At the end of the course, you can code and play your own Asteroids video game!
                However, I would suggest taking this class as an intermediate programmer instead of a beginner. To begin, check out my teacher's awesome online class here on FundaFunda!
 Happy coding!