Day3 Reflection

Question: Using specific examples from the last 3 days, in no fewer than 500-words, craft a reflection that addresses the following questions: Describe the importance of self-motivation and perseverance in a team setting. Describe the importance of teamwork and collaboration. Describe the importance of reflecting. Remember to give specific examples from these last 3 days. 

Alvin:In this remote learning environment, there is no restrictions, there is no guidance and there are lots of temptations. The only thing that make us to make outcomes is the willing to be great. At first, we just want to analyze the historical data of hypertension simply, I originally thought that we are going to collect the data and describe the pattern. But then, during the discussion with my groupmates, we started to push it forward by analyzing the different traits such age and lifestyle relating to hypertension. By incorporating physics knowledge, we are even able to predict one’s possibility of getting high blood pressure. This process was hard, compared to the original one, but we felt that only in this way can we make this project more meaningful. We are not just analyzing the data, we are actually using them to help with real life. So this is the aspiration of us, and I think if without this motivation to push harder, we would eventually get nothing from this project. Of course we have encountered many problems during these three days, such as we could not find proper data to link the height and hypertension, the programming process was really complicated and time-consuming given that the work  we want to do is difficult, and the real life blood in arteries is so complex that we need to search a lot and simplify the whole problem in order to achieve a reasonable model. But eventually we did it. 

As for teamwork and collaboration, they are super important in this project. As this is a interdisciplinary topic, we cannot rely purely on ourselves. So we basically use the skype all the time to communicate immediately when we have problems. This is super efficient, we reported our process and allocated workload at the beginning of each day.  In this way, we could make sure that we were on track and everyone had something to do. And after sometime, we would talk again about the latest situation. I think this is a good way to conduct teamwork, we would not interfere with each other and in the meanwhile we were aware of what others were doing and were able to provide help at once. We would not achieve anything without this efficient collaboration. 

About reflecting, I did reflection every day before I went to sleep. I thought about how I performance this day, was I efficient and so on. For example, in the first day, I felt I was not efficient in the afternoon when I looked back, so I identify the problem that I need to take a nap in the noon to keep energetic. So I slept a little bit in the next two days and it worked, I felt more efficient in the afternoons.

Tiger: In the past three days, I went to  a house on suburban areas of Beijing to participate the group four project. Because I am the only one in the house, I have to motivate myself to work, or I would have spend time on recreation. To only focus on the project, I set sub-goal with certain time nodes. For example, I set sub-goals such as downloading data by 12 am, disposing data by 17pm. Besides, I force myself to stay active in team collaboration so that I would not spend too much time on something else such as recreation. For example, in the first day of the project, I keep brain storming the idea and writing them all down and reading them to my teammate. In this process, since I don’t have time to pick up my phone, I was able to focus on the project. Also, I am very excited when I have the chance to use my CS skills to analyzing data and develop a GUI. So I stay up late to 2am to finish my work. 

As for the teamwork and collaboration, I believe the best team is not the team where every team member is super-student. Instead, the best team is the team where each member’s weakness is made up for by others. For example, I am not good at designing, so I may not be able to make a great poster. However, Wanda is very gifted on designing posters. Therefore, my weakness is made up by her. And that is how we collaborate: everyone does what he or she is best at. 

As for the reflection, I learned many important lessons. First, fancy algorithm does not mean “useful”. During the project, I had a task to find the trend and predict for the future. Even there was only twelve data points, I still insisted to use neural networks and random forest algorithm to predict. It turned out that the loss function the neural networks was incredibly big. At last, the simple algorithm, linear regression, make the best prediction. As Mr.Pete told me, stay simple, instead of using fancy algorithm,  I would use the most useful and applicable algorithm in the future. 

Wanda: In the past three days, our group did an excellent job in analyzing statistics and utilizing known knowledge to explain new information. Because we couldn’t communicate face-to-face, the efficiency has become a problem when there was no supervision. Accordingly, self-motivation and perseverance were the most crucial qualities that we should have during these days. Without self-motivation and perseverance, we would not be that productive and couldn’t accomplish targets we set previously. Thankfully, I had two great teammates who were very inspirational and helpful to me. Teamwork and collaboration were really important. Whenever I felt confused with the text I was research or the data that was sophisticated, they could reach out to help me immediately. Their expertise at different areas and their positive attitudes inspired me to challenge myself and solve problems confidently. For example, I was quite perplexed when I tried to understand the connection between blood flow and blood pressure, so I discussed with my teammates. Surprisingly, they immediately came up with many innovative and reliable ideas and even searched more contents to help me understand the logic behind. Thus, I found the error I made and quickly corrected it under the suggestion from my teammates. Furthermore, they did not only help me with discussions but also motivate me with their perseverance and preciseness. For example, I may be tired and gave up writing down the relationship between fluid mechanics and hypertension at night; however, my teammates were still discussing and analyzing data in the group chat at 11P.M. Their serious and diligent attitudes aspired and motivated me to do a perfect job with high quality and real implication. Additionally, reflecting was as necessary as doing the work because we could find out the errors we made and the flaws we needed to improve the next day. When I was writing blog reflection every time, I was astonished by the achievements we’ve accomplished and the imperfection that existed. Moreover, while recalling the targets we reached or not that day and setting targets the next day, I was amazed by the considerable progress we attained in just three days. Before reflecting and this project week, I would never imagine the progress I’ve done on researching and analyze hypertension. 

Day 2 Blog

Question 1:What were your contributions today to your group? How was your energy level throughout the day? 

Alvin: Today I basically worked with the presentation of data. Yesterday we collected a lot of data from various sources, and what I did today is mainly graphing. I drew the graphs about the situation of hypertension regarding different genders, races, ages, and lifestyles including food intake, smoking and drinking. Besides this, I also helped with the script of the final video presentation by writing out an outline of what we need to talk about. As for energy level, I though it was pretty great during the morning, but in the afternoon I just felt really sleepy.
Tiger:
Today, I made more analysis about the data we collected yesterday. Since our topic is about essential hypertension, I did data mining to find the which factors most strongly caused the essential hypertension. Because the data has 12 dimensions, I used Random Forest algorithm to categorize the data into a few groups and count which group of data contain the biggest number of essential hypertension cases. I was pretty energetic during the day since I drunk lot of tea. The following picture is an example.

The example of the Random Forest Algorithm and NeuralNetwork
This is the prediction about the percentage of essential hypertension(Side quests).

Wanda: Today, I analyzed how essential hypertension occurs by using physics knowledge I learnt, and I also enumerated physical factors that contributed to blood flow and blood pressure. Furthermore, I also listed the targets we reached today and the targets for tomorrow. I was pretty energetic and efficient in the morning, but I felt a little sleepy in the afternoon, so I took a nape in the lunch break to solve this problem.

Question2:Which area did you put the most motivated today? 

Alvin: outlining the basic structure of our video. At first, I felt kind of confused about what we should include, so I decided to generate a clear structure. I arranged the whole process including introduction, data presentation and analysis, conclusion, and reflection. And then I shared this with my teammate to get their agreement. Based on this, we can start to write our script.
Tiger:
I was  most motivated developing a GUI where users input their information such as their height, weight, sex, age, cholesterols level, and glucose level and the program would return their probability of having essential hypertension. I am really exited about developing a user-friendly GUI. 

Wanda: I was most motivated while doing my own analysis about the link between fluid dynamics knowledge and essential hypertension because it’s satisfactory to utilize knowledge I learnt to induce and explain a phenomenon that was new. Also, I found out that the logic between blood pressure, blood flow, and blood speed was sophisticated and needed to be explained by utilizing different concepts, including flow rate, B Bernoulli’s principle,and the Hagen–Poiseuille equation.

Question3:Which area did you feel the least motivated? Why? 

Alvin: Graphing. Because it is bored, all I have to do is simply copy and paste the data, choose a proper types of graph and draw them out.
Tiger:
The least motivated thing is probably tackling the data. It is because the cache of BlueJ is too small to handle 70 thousands lines of data, so I have to use another programming language to analyze the data. Therefore, I missed the chance of using knowledge I gained from CS class to use Java to handle the data.

Wanda: I felt the least motivated while facing modeling and data because I was not good at modeling and making graphs on the computer. Although I knew pretty well how to analyze the trend, I still didn’t want to confront with models and graphs by myself.

Question4:What are some ways you could have persevered through these times? What are your own personal goals for the final day?

Alvin: I think hanging on the Skype is really a good thing as once we have problems we can talk with teammates immediately. I remember when I find the data about gender is not correct, I was able to inform my teammates at once and find our the solution together. This just felt like we are working together. 

And for the final day, I think I can improve my efficiency, and be more focused on the work. I will finish the part of Biology, which is my assigned expertise, and also help my teammates if they have any problems.
Tiger: 
Firstly, I suggest that when we face some problems that confuse us, we should have a meeting to solve those problems together. Second, If I am stuck by some problem, I should not spend all the time I have on that problem. Instead, I should leave it and do something else to increase the efficiency. For example, I had some trouble with the data because the data is not clear. I don’t know what does “1” means. Instead of figuring it out by myself, I asked my teammate for help. After that, my teammate went to the original web and told me “1” stands for “women”. 

Wanda: First, I suggest everyone taking a nape during lunch break because we should let our brain rest in order to have a better efficiency and make fewer errors in the afternoon. Second, if modeling and making graphs are difficult, I will ask my group mates who are both very helpful, good at CS, and collaborative for help. Teamwork has a better strength than working individually, and different expertise can analyze the same problem from various perspectives.
My own personal goals for the final day are: first, I will finish a final draft of my own section and revise the whole research with my group mate; second, I will design the poster and make the final video with my group mates; third, I will write the blog reflection on time and remind my group mates to hand in every materials on time. 

Day1 reflection

Question1: What category and sets of database did your group decide on? 

We deicide to choose Healthcare. Our group is going to investigate in how to reduce the risk of getting essential hypertension. And we searched the website of WolframAlpha, WHO, American CDC and some other official government institute as we believe this will be reliable. The figure 1 exibits information related to Essential hypertension.

Figure 1(screenshot from WolframAlpha)

Question2:  What do you think can be the implications of your analysis specifically in your field? In the world? 

In biology, we are interested to find our the cause of different disease, find therapies and promote a better lifestyle to people. Using the data we have, we can conclude how does our daily behaviors like eating influence the probability of catching high blood pressure problem. High blood pressure is a widespread disease in our world, and lots of scientist are trying to find the medication. In this project,  we can show the people what can they do personally to prevent hypertension, which is cool.

By analyzing physical factors and behavioral factors, we can find out the relationship between essential hypertension and different factors, therefore suggesting people to control these factors by maintaining healthy habits. Our group will make a credible analysis with precise statistics that can be applied to both in the field of healthcare and our daily lives.

In CS, we could use programming skills to find the pattern inside a large amount of data and use correlation analysis to find the relationship between factors. In this project, We did find a great amount of data. If those data does not cover all range, we would use algorithm to grab the trend of data and make up for all the range. Beside, after the model for high blood pressure are constructed, we would use System Modeler to simulate the process of such fluid motion. the field of CS could provide statistical analysis that further validate the research, which is very useful.  

Question3:How do you feel about your group mates and the expertise that they will be bringing into the group? Are there possible conflicts? How does your group plan on resolving conflict?

Tiger: I think we made perfect cooperation. Though 10 minutes of discussion, we successfully settled down our topic and each one of us was assigned work to do. In 2 pm, we all finished the work assigned. It is my honor to have such two teammate. 

Wanda:My group mates are very efficient and innovative. They do not only come up with new ideas but also bring the knowledge they learned in CS, physics, and biology class into discussions. There are possible conflicts but are resolved by working as a team. For instance, I know physics knowledge but I don’t know how to model it on the computer; then, my group mate who learns CS will help me do this task together. 

Alvin: I think they are really good, and our different expertise fit well in the topic of hypertension. Physics can be used to explain the direct cause of hypertension using the knowledge of fluid mechanics. As for CS, we basically depend on it to analyze the data like making prediction and so on.

Reflection of this week

I learn a lot about array in this weeks. I used to be a Java beginner who have no idea about how to manipulate array in OOP. In this week, I learn how to use array in class, how to use array as instance variables, how to copy array, and how to change the array’s size.

The code that I list here is the methods to convert string into char, compare two array, and copy an array.

public class ArrayPart2

    public static char[] stgToCharArry(String something){

        char [] temp = new char[something.length()];

        for(int i=0;i<something.length();i++){

            temp[i]= something.charAt(i);

        }

        return temp;

    }

    public static String cpString(double [] a, double [] b){

        boolean isEqual = true;

        String result;

        if(a.length!=b.length){

            isEqual=false;

        }else{

            for(int i=0;i<a.length&&isEqual;i++){

                if(Math.abs(a[i]-b[i])>0.0001){

                    isEqual = false;

                }

            }

        }

        if(isEqual){

            result=”a and b are equal”;

        }else{

            result=”a and b are not equal”;

        }

        return result;

    }

    public static double [] CopyingArray(double [] c){

    double billBackup [] = new double [c.length];

    for(int i=0;i<c.length;i++){

    billBackup[i]=c[i];

    }

    return billBackup;

    }

}

Actually, before this lesson, I personally tried to compare two array without receiving parameters, here is what I got:

public class Convet

{

    public static void main(String args[]){

    String a = “sgsrg”;

    }

    public void convertString(String a){

    char [] array = new char [a.length()];

    for(int i=0;i<a.length();i++){

    array[i]=a.charAt(i);

    System.out.print(array[i]);

    }

    }

}

In the next step, I was asked to finish a project. Here is the code for CS_Gradebook

import java.util.Scanner;
/**

  • Write a description of class CS_Gradebook here.
    *
  • @author (your name)
  • @version (a version number or a date)
    */
    public class CS_Gradebook
    {
    public static void changeGN(int [] grade,String [] name){
    Scanner input = new Scanner(System.in);
    for(int i=0;iname.length){
    for(int i=0;i<size;i++){
    newarray[i]=name[i];
    }
    }
    name=newarray;
    newarray=null;
    }
    public static void print(String [] name, int [] grade,int size){
    for(int i=0;i<size;i++){
    System.out.println(name[i]+”:”+grade[i]);
    }
    }
    }

Here is the code for GradeBook client:

public class Gradebook_Client
{
public static void main(String args[]){
String [] name=new String[10];
int [] grade=new int[10];
int size=5;
CS_Gradebook book1 = new CS_Gradebook();
book1.changeGN(grade,name);

book1.print(name,grade, size);

}


Java method

This week, I keep gaining experience of Java. I get more idea about Java because I learn Objective, Oriented programming. I am going to mention following things in my blog post.

  1. Sequential search
  2. Binary search
  3. Bubble sort
  4. Selection sort
  5. One/two-dimensional array
  6. Methods
  7. Homework and activities
  8. Summary

Sequence search

Sequence search is used when we try to find the index of a value in an array. The computer would compare the target to all the numbers in that array one by one until the target is found. For example, 4,5,3,6,2 is an array. We hope to find 3 in this array. The computer would compare 3 with 4 then compare 3 with 5 then compare 3 with 3. Then 3 equals 3, the program would output the index of three in the array, which is 3. 

Pseudocode of sequence search

Java code for sequence search


Result

value:8

output:2

 Binary search

Binary search is a searching algorithm. It works more efficient than sequence search. It begins at the middle of an array. It would compare the number that is in the middle of unexamined array until the target is found. However, binary search require the array to be aligned from small to large.

Pseudocode of binary search

Java code for binary search

Result

Please input the value of the number: 9

output:3

Bubble sort

Bubble sort is a sorting algorithm. Bubble sort compare a group of numbers that are next to each other. Computer would swap them if they are in the wrong order. After grouping all the numbers, computer would loop these process over and over again until the array is ascending or descending.

Pseudocode of bubble sort

Java code for bubble sort

Result

output:4,5,6,7,8115,927,999

Selection sort

Selection sort is also a sorting algorithm. Selection sort find the smallest number in an array. Them the computer would swap it with the leftmost number. For each times of the sorting, the boundary would move one element to the right. 

Result

output:

Pseudocode of selection sort

Java code for selection sort

Result

output:1,6,7,811,15,31,49

Arrays

One-dimensional arrays

One dimensional array are a group of number that have special orders. It can be declared as datatype[] array name= new int [length], or datatype[] array name={numbers in order}.

Two dimensional arrays

Two dimensional arrays are arrays that have two dimension. In other word, it is matrix. It can be declared as datatype[] []array name= new int [length] [length], or datatype[] array name={numbers in order},{numbers in order}………{numbers in order}.

It can be visualized as a two-dimensional display with the first index giving the row, and the second index giving the column.

Methods

The methods implement the behavior of an object. They provides its functionality. They have header and body parts. They always include a pair of  parentheses. The body is always enclosed by a matching pair of curly bracket. Methods body contains the declaration and statement. 

Method structure

The header tells the visibility of objects of other classes and whether the methods would return a value and the name of the method and whether the method would takes parameters. The body encloses the methods’ statement. Method signature does not include the return type. 

Method classification 

Methods are classified as Constructor, Accessor, Mutator, and utility.

Constructor is to set up an object. 

Accessor includes get method. It return the current values of object data. The return type is written just before the method name. 

Mutator would set  the methods. It would change the value of the object data.

Benefit

I think the benefit of the methods is that it make the code to be more readable and changeable. Normally, or month ago, when we have no idea about the methods, probably I would write a long code. There would be too many parameters that alphabet is not enough. Situation is relived since I know to use method. I can just abstract my program and write the code for each abstract step. Then gathering them up using method structure. Things are getting much easier because if something wrong with the parts of the code I would easily know it and change it. Plus, the method could be used for more than one times, which increase the efficiency of coding. 

Homework

This is the my homework. It is a program of intelligence detector. By recording each person’s height, weight, and whether they are in relationship into a two dimensional array, the computer would do simple math to calculate individuals intelligence. And individuals’ intelligence are stored in an array. Then, I would use bubble sort to sort all those numbers of intelligence, and output the person who get the highest intelligence and the lowest intelligence. My coding ability is improved during this task which bring me joy.

Summary

This week, i learn many searching algorithm and sorting algorithm like sequence search, binary search, bubble sort and sequence sort. I also gain more depth inside java by learning method, which makes the code to be more readable, and modifiable. By accomplishing the mini project, not only my coding ability is improved, but also I get the idea that how coding or computational thinking works in real-life situation.

The start of programming!

This week is so interesting for me because I learn programming! I am going to mention following things in the blog:

  1. Algorithm
  2. Trace table
  3. Pseudocode
  4. Programming
  5. Activity and homework
  6. Summary

Algorithm

Algorithm is the core of a program. Its definition is that A set of step-by-step clear instructions to solve a problem, as what I have mentioned for many times in other blogs. It decides the syntax structure of the program, and the methods and key words that programmer used in the program.

Property of algorithm 

1.Finiteness

2.definiteness

3.Input 

4.Output

5.effectiveness

Expression of algorithm

  1. Natural language: simple english
  2. Flow chart: formalized graphic representation 
  3. Pseudocode:  generic artificial language.
  4. Programming language: artificial language that can communicate with the computer

How to make algorithm?

While, the use of algorithm is to solve the daily problems. Before that, a decision making process is necessary. Decision making is the process of making choices by identifying a decision, gathering information, and assessing alternative resolutions. Using a step-by-step decision-making process can help you make more deliberate, thoughtful decisions by organizing relevant information and defining alternatives.

Pseudocode

Pseudocode is a transition between natural language and programming language, so it’s necessary for me to learn before learning programming. I can say that it’s easy to create, because it hasn’t any grammar like programming language, but just adds logic and clean structure from the base of natural language.

Pseudocode notation

Pseudocode notations contains input, output, while, for, repeat-until, if-then-else, etc. Input indicates that a user will input something through typing or other ways. Output indicates that something as output will appear on the screen. While is the notation of loop (iteration that has a condition at the beginning), and for is notation of another kind of loop which is similar to while loop. Repeat-until is the notation of loop as well (iteration that has a condition in the end). Finally, if-then-else is the structure of selecting decision in which a choice is made.

Trace table

Trace table is a techniques used to test the algorithm. It can be used to record the result of the test. To make sure that no logical errors occur whilst, the algorithm is being processed. Here are steps of making trace table.

1. Write down all the variables as well as conditions, and output in the first row (I, X, NUM, X < 5, output, etc.)

2. Start filling in initial values in the second row

3. Input all loop values (i) vertically in rows after that

4. Follow each statement in the code and fill the respective values of the variables for each value change

5. Write down the final result

Programming

After gaining understanding of computational thinking, I can finally do the programming. We use BlueJ as our IDE. Because I was in USA attending IGEM competition, so I generally learnt it by myself, although my teacher gave me a lot of instructions and guidance. I found that programming is generally similar to the  Pseudocode though we need to remember special  language for programming. 

Programming structure

  1. Input some data (from keyboard, file, another process or program)
  2. Perform  some processing on the data
  3. Output the result to the computer

Here are the general step for the programming:

1. Identify the data we know 

2. Identify other data we will need

3. Declare variable names

4. Initialize the value of any possible identifiers

5. Perform the calculation (processing)

6. Output or return the result

Good programming conventions

Good programming conventions identify the rule that every program and programmer should follow. Firstly, every program should begin with: a comment that explains the purpose of the program, the author, the date and time the program was last modified. Secondly, each comment has specific notation to represent, two normal notation is // for single-line comment, and /* COMMENT */ format for multiple-line comment. Thirdly, using blank lines and space characters to make programs easy to read for other programmers. Finally, all class names in Java should start with a capital letter and capitalize the first letter of each word they contain. For example, “MakeFun” is a good class name, but “makefun” is not a  good name.

Important terms

Identifiers

1. Identifiers are used to name classes,  variables, and methods (as a place holder or container)

2. To declare a variable you will need:

  • Name (should be meaningful and reflect the data they will store)
  • Type (int, double, boolean, char, string)
  • Value (optional during declaration)

3. Variable names must begin with either a lowercase letter, an underscore ( _ ), or a dollar sign ($)

4. Every word in the name after the first word should begin with a capital letter (e.g., firstNumber)

5. After the first initial letter, variable names may also contain letters and the digits 0 to 9.

6. You cannot use a reserved word for a variable name

7. No spaces or special characters are allowed

Java keywords

1. Each high level linage has a unique syntax and a specific limited vocabulary

2. 50 keywords are currently defined in the Java language

3. These keywords cannot be used as names for a variable, class or method

Primitive data type

include byte, short, int, long, float, double, boolean and char.

Activities

  1. battleship game

In order to understand the searching algorithm, our teacher gave us an interesting task, called battle ship. On the paper, many hulls were printed with numbers on them. First, two people form a group and they fight. Then everyone chooses a ship and tells his opponent the ship number. Next, they can guess the position of the ship in letters. Finally, the first person who guessed the right one can win the game.

There are three papers, and each paper represent a searching algorithm. Without boasting, I am the one true king in this game—I never lose the game!

In this paper, the boats that represent files are randomly arranged, it is very hard to find out with one is the target, so searching it would waste a lot of time.

In this paper, the boats are arranged in some order least, the value of the boats are from the smallest to the largest. It took less time for me to search the target boat.

The boats in this paper are arranged into different categories, knowing the right categories of target, I spend less time finding the right number of the target boat.

We can see three algorithm from these three paper. The algorithm in the first paper aim at looking for all the files to the target one. The algorithm in the second paper aim at searching there files in a range that decrease the work of searching and saving the time. The Last paper is the best algorithm that could find the target file in the smallest time. The algorithm firstly categorizes the files, then finds the files in given category. Because files inside a category are much less than the overall files, time for searching is greatly reduced.

Basic programming exercise

HelloWorld programme
Program of calculating the area of circle

Summary

In this week, I finally step into the world of Java. From I young rookies who just know Pseudocode, flowchart, and trace table, to an old rookies who know how to print Hello World in Java language, I got a lot of progress. To reflect myself, I have to say that Java programming is very different from what I thought. Because I used to be a Python programmer and Wolfram Mathematica user, too abstract language discount the effect of computational thinking. Consequently, my algorithms always have bug. On the contrary, computational thinking is highly involved in Java programming, which would benefit me a lot although I have to remember a lot of terms.

Java looping

This week, we learn java looping, in which I am able to say that I am a Java learner. Sadly, I was still in America when Java looping was taught by my teacher. However, I caught up soon when I got back, thanks to my CS teacher. I am going to mention following things in my blog:

  1. Scanner class
  2. While, Do-while, and For loops
  3. Use of Scanner class and While loop for Type-Safe input
  4. Guessing game
  5. Logical operations
  6. Arithmetic operations
  7. Typing casting
  8. Exercise
  9. Summary

Scanner 

Scanner provides method for reading bytes, short, int, long, float, double, and String data types from Java console and other sources. Scanner is in the java.util package. Scanner spares input into sequence of characters called tokens. By defaults, tokens are separated by standard white space characters. In order to read this datatype, methods are needed. For example, nextDataType( ) can make the computer to return the next token and the datatype of it can be bytes, short, int, long, float, double. There are also next(), nextLine() that can make the  computer to return the token in the input stream as a string.

While, Do-while, and For loops

While loop is best used when the loop would repeat an unknown number of times. The condition of while loop is in the first bracket. The loop would go on as long as the condition is true.(the condition would be checked at first)

Do-while loop is different form while loop because the condition of the loop is at the end of the loop. Therefore, no matter what the condition is, the loop would be executed for at least one time. 

For loop is the third kind of loop. The condition of the loop is in the beginning of the loop. Therefore, only condition is true, the execution would go on. It is different form the While loop because the number of the loop repeated should be clear in the condition.

Type-Safe Input

Type safe input is very special because it can check whether the datatype the user input is the correct one accords with the right one. If not, the error would not happen, instead of that, it  would ask for another input.

Logical operation 

In the unit of logic gate, we have some idea about the logical operation, such as and, or, xor. However, there are logical operation in Java. “==” in Java means equal. “!=“means not equal. ‘!’means not obviously. And && means “and”. || means or. If && appear together with||, then && comes first, and || goes next, which is like the logic gate. 

Arithmetic operations

The basic arithmetic operations  contain add(+), subtract(-), multiplication(*),division(/),modulus(%),++,- -.

++, – – are short cut operators. ++ means plus one. – – means minus one.

There are also escape sequence. \t means inserting a tab in the text at this point. \b means inserting a backspace in the text at this point. \n means inserting a new line at this point. \r means inserting a carriage return in the text at this point. \f would insert a formatted in the text at this point. \’ would insert a single quote character in the text at this point. \” would insert a double quote characters in the text at this point. \\ would insert a backlash character in the text at this point. 

Type casting 

Implicit type casting

When performing calculations with operands of different data types, lower precision operands are promoted to higher-precision data types and then operands is performed. The Promotion is effective only for expression evaluation, not a permanent change. 

Explicit casting 

The intentional modulation is needed. The programmer should add data type in front of the a variable, therefore the result would be converted to such data type. For example, (double)1/2 = 0.5 the result won’t be 0 again.

Rules of promotion

  1. If either operand is a double, the other operand is converted to a double
  2. If either operand is a float, the other operand is converted to a float
  3. If either operand is a long, the other operand is converted to a long
  4. If either operand is an int, the other operand is promoted to an int
  5. If neither operand is a double, float, long, or an int, both operands are promoted to int

Exercise

This picture shows the program for the bubble sort. As for the name, it is about sorting due to the value of the numbers. The program is very simple, so so it saves a lot of time while sorting.

This picture shows the program for addition. The user could input two numbers, and computer would add them up and output the result. The thing is, if the use input other datatype instead of integers, the program would ask thee user to input again until user input integers.

This program shows the procedure calculating the area of the circle. It is very simple, but I learn that things like Pi need to add”final”and capitalize “pi”.

This picture shows the program for array. We learn how to create an array and add value into it.

This picture shows the introduction to Java looping. We learn how to use looping to output the value we want.

This picture shows one of the practice we did in the class. It is about finding the prime numbers within a boundary. I develop java programming skills.

Summary

In this week, I learn java looping. I feel like I can solve some problem in my real-life. For example, during the math modeling competition, I use java looping to find the abnormal value of the data set. Honestly, java is not very kind with importing the data comparing to Matlab, Mathematica, or Python. But java did run very fast, which help me a lot.

Computing component and instruction cycle

This week, we learnt about computing component and the way they execute instructions. I used to have no idea about how computer works, so I think computer is something magic. But having been taught, I think computer is logic that  it follows some of procedures when it is processing. 

I am going to mention following things in the blog post:

  1. IPO model 
  2. Main component of CPU
  3. Memory
  4. Instruction Cycle
  5. Activities
  6. Homework 
  7. Summary

IPO model

IPO is the fundamental model which describes the structure of an information processing program. The further instruction executing process inside CPU also bases on this basic model. Next, I will introduce input, process, output and storage separately. Input means that an input device offers available data to the process component. Process basically means manipulating data, which contains decoding the data into machine language and doing arithmetic or logical calculation in detail. Output means that processing unit sends the result of process, which contains number, graph, and words usually, to the output device. After that, output device demonstrates human then result. Storage can be considered as an extra part of IPO model, it usually means secondary memory (I will introduce it later), that can store data for long time.

Input: keyboard, mouse, scanner, punch cards. Processing: CPU executes the computer program. Output: monitor, printer, fax machine. Storage: hard drive, optical media, diskettes, magnetic tape. Chapter 1 Computer Systems.

Main component of CPU

The main components of CPU actually include ALU, CU, RAM, Cache, and Registers MAR, MDR and so on, which is very complicated.

CPU

CPU is the key component of computing system. It contains the circuitry which can interpret and execute the instructions.

CU, ALU, Register

CU is the acronym of of Control Unit. It decodes the instructions and controls other components of CPU. It can direct the data flow and operate the execution of the ALU.

ALU is the acronym of Arithmetic Logic Unit. It does all the arithmetic (+/-) and logical (AND/OR) calculations. It also referred to as ‘core’ of the CPU.

Registers are small and very fast temporary storage units inside the CPU. MAR and MDR are two kinds of registers, and they are very important in the instruction cycle.

Memory

All kinds of computers have memories to store a huge quantity of data. The memory of computer can be mainly divided into two large types —— primary and secondary memory. They have different properties separately. Primary memory is the only storage that is directly accessible by the CPU, and it always interacts with CPU when computer is executing instructions. Secondary or auxiliary storage is slow but has higher capacity compare with primary memory. People usually intentionally use it to store information for a long time.

Primary memory

According to detailed functions, primary memory contains three main types —— RAM, ROM and cache memory.

RAM is random access memory, it is widely used to contain the data (includes number, instruction, address, and letter), the computer has loaded since starting up and everything the user has opened/loaded. It’s volatile, in other words, its data will lose after people turning off the computer power.

ROM, read only memory, can’t be modified or rewritten by user originally, but currently, some specific ROM like EPROM (Erasable Programmable Read-Only Memory) and EEPROM (Electrically Erasable Programmable Read-Only Memory) can be rewritten. ROM is nonvolatile, that means data won’t be eliminated even if computer is turned off. Because of this property, people store BIOS (Basic Input Output System), the program which allows computer finding the operating system to “boost” computer after the power is restored, in ROM.

Cache memory has a definition: A type of small high-speed memory inside the CPU used to hold frequently used data. Computer can find the data which is frequently used, and store it in cache. When computer is executing instructions, it always finds data which is needed in the process in cache firstly. Only if it doesn’t find the data in cache, it will find data in RAM. Therefore, cache can rise up the working efficiency of computers a lot. People divide cache into different levels according to the using frequency of data. The first level stores the data which is used the most frequently. Chip of level 1 is the fastest, smallest, and is usually set in CPU. The caches of second and third level are usually out of CPU, and they are bigger and slower than that of level 1.

Secondary memory

The ability of primary memory is limited. Users need space to persistently store information like images, audios, videos, and texts in computer. So secondary memory which satisfied this demand is invented. Secondary memory contains HDD, SSD, Flash, CD, and DVD, and they have different properties and ways of storing and reading.

Instruction Cycle

Before learning the instruction cycle of computer, I predicted it should be difficult and complex. But I found that the general structure of instruction cycle is easy to understand after learning. The only difficulty is that some detailed points of executing are complicated and professional. I was confused because I haven’t seen the infrastructure of CPU before, so the knowledge is totally new and abstracted for me.

In order to form the machine instruction cycle, all the components of CPU need to work together, because all of them have different roles and functions in the cycle.

The image above shows the general steps of instruction cycle. People divide the instruction cycle into four parts, according to the purpose. The first part is fetch, it describes the process that CU fetches data from memory. In the process of fetching, data shifts from a component to another for many times, and finally arrives the Control Unit. The second part is decode. Control Unit decodes the data that is just fetched from memory, so the data can be understood by ALU after decoding. The third part is execute. ALU calculates decoded data according to the instruction, and gets and shows the result or output. The four part is store. ALU sends arithmetical results to memory, so the data can be stored. However, sometimes memory needn’t to store data, because if ALU gets a logical result, it will sends the result to CU directly.

Next, I will talk about the components which involve in the instruction cycle and their functions.

PC contains the address of the next instruction to be executed.

MAR(memory address register) contains an address in the main memory that is currently being read or written.

MDR(memory data register) is a two-way register that holds the data fetched from memory (RAM) or data waiting to be stored in memory (RAM).

IR(instruction register) holds the instruction currently being executed or decoded.

Accumulator register stores immediate result from ALU.

Activities

This week, we mainly did two activities. The  first is little man computer. The second is Designing my own PC.

Little man computer programming. 

We develop understanding of assembly language and appreciate the simplicity of assembly language by little man computer.

This is the picture that shows the program for four numbers’ sum. The program could be illustrated by formula sum=(a+b)+(c+d). I did not do well because the length of the code is huge. Actually storage step could be deleted but it would increase the change of making mistakes. 

This is the picture that shows three number’s sum. The program could be illustrated by formula sum=a+b+c.

The two picture above are multiplication and division. They are more complicated than adding task since I could not input two number and multiply them. I have to use loop. A times B equal to the sum of A numbers of B. After each step of adding, the remaining times would minus one. Similar things happen to division, where we could use subtract. 

Design your own computer

This project was held for gaining more understanding about computers because . It did work actually. Our computer is designed for gaming and 3D structuring. 

dav
dav

Reflection

I gain understanding of computer by knowing the component and constructing the computer. Because when I was finding the right choice for the  CPU, GPU, I have to equalize the performance of them to the aim we set. It turned out that 3D structuring do need strong performance and many thread but intel E7 CPU is too much. Besides, the computer also need to be good at playing games, so it need a graphic card. With thoughtful consideration and a mass of investigation, we did construct good computer. 

However, I can do better because I randomly choose a screen for the computer, which seems not to be the best options. If I have another change, I would bet willing to spend more time on choosing a better screen.

Summary

This week was very interesting for me because I learnt a lot about the computer. Computer used to be something magic to me as I did not know how  it works. But now, I know exactly how computers functions. Besides, I gain better understanding about the component of the computer, which is very beneficial.

Logic gate

This is a tough week, since we need to stay in school on Saturday. Not to mention, I could not stop writing blog. I am going to mention following things in the main paragraph.

  1. Data presentation poster
  2. Thinking of computers
  3. Boolean expressions
  4. How transistors  and combined gates work
  5. Boolean algebra
  6. How computers add numbers
  1. We made a poster 2 weeks ago. The topic is data representation, which links to previous blog. There are five parts in the poster, which are Number, Character, Image, Audio, Video. My idea here is that character, image, audio and video could be digitized into numbers using compression method. And numbers that are expressed into different base could be translated to each other. To reflection, I should say that I did not pay much attention on the terminologies and their definition because I spend too much time on the designing of the poster.

2.   Actually computers do not have their own thoughts. They just follow the instructions written by human. Those instructions are stored in the memories, and the core of computers—CPU— follow those instructions to “think”.

3. Computers are binary system, so human need to design a special computing system for them. George Boole, an English mathematician, introduced Boolean algebra, which is ideal for binary number system. Basically, the algebra are about answering questions “yes” or “no”. Logic gates are digital application of Boolean algebra, which is A device that performs a basic operation on electrical signals, accepting one or more input signals and producing a single output signal. I was taught with 6 gates, which are NOT gate, OR gate, AND gate, NAND gate, NOR gate, XOR gate. 

Not gates return opposite signals of input as output. An OR gate accepts two input signals
If both are 0, the output is 0; otherwise, the output is 1 At least one of the inputs needs to be 1. An AND gate accepts two input signals. If both are 1, the output is 1; otherwise, the output is 0. 

The NAND gate accepts two input signals. If both are 1, the output is 0; otherwise, the output is 1. The NOR gate accepts two input signals. If both are 0, the output is 1; otherwise, the output is 0. Note the difference between the XOR gate and the OR gate; they differ only in one input situation When both input signals are 1, the OR gate produces a 1 and the XOR produces a 0. XOR is called the exclusive OR because its output is 1 if either one input or the other is 1, excluding the case that they both are. 

4. A transistor acts like a switch. It has no moving parts and it’s made of a semiconductor material. A transistor has three terminals (source, base, and emitter) If the electrical signal is grounded, it is allowed to flow through an alternative route to the ground (literally) where it can do no harm. 

Gates are combined into circuits by using the output of one gate as the input for another. Three inputs require eight rows to describe all possible input combinations. This same circuit using a Boolean expression is (AB + AC). However, there are many ways of combination of the gates. For example, we did an activity that need us to create a truth table to justify the effect of the circuits. 

Pictures above are the activities we did in the class. I gain understanding of how logic gates work and how logic gates are combined into circuits because of the activities.

5. Commutative: The commutative property says that binary operations

AND and OR may be applied left to right or right to left. (A AND B is

the same as B AND A; A OR B is the same as B OR A.)

Associative: The associative property says that given three Boolean

variables, they may be ANDed or ORed right to left or left to right.

((A AND B) AND C is the same as A AND (B AND C); (A OR B) OR

C is the same as A OR (B OR C).)

Distributive: The distributive property says that given three Boolean

variables, the first AND the result of the second OR the third is the

same as the first AND the second OR the first AND the third. (A

AND (B OR C) = (A AND B) OR (A AND C). Also, the first OR the

result of second AND the third is the same as the first OR the second

AND the result of the first OR the third. (A OR (B AND C) = (A OR

B) AND (A OR C).)

Identity: The identity property says that any value A AND the OR

identity always returns A and that any value A OR the AND identity

always returns A. (A AND 1 = A; A OR 0 = A.)

Complement: The complement property says that any value AND the

compliment of that value equals the OR identity and that any value

OR the compliment of that value equals the OR identity. (A AND (A’)

= 0; A OR (A’) = 1.)

DeMorgan’s Law: DeMorgan’s Law says that the complement of A

AND B is the same as the complement of A OR the complement of B,

and the complement of A OR B is the same as the complement of B

AND the complement of A. ((A AND B)’ = A’ OR B’; (A OR B)’ = A’

AND B’).)

6. Computers use adder to add numbers. Adder are a kind of circuit that takes the carry-in value into account. For example, 

This is full adders, which is a combined circuit that uses a gate circuit to add two binary numbers and find the sum, called a full adder. A full adder can handle the low carry and output the local add carry. Multi-bit full adder can be obtained by cascading multiple one-bit adders. 

This is the example of full adder. In the class, we did an activity about the picture above. It is cut into many pieces and our job into put them back. During the activities, we gain knowledge and understanding of the function of adders because when we are put things back, we need to use the logic of adders to help us figure out in which order the pieces of the pictures should be put together.

The half adder does not receive the carry input, and the full adder has a carry input. When adding two multi-bit binary numbers, except for the lowest bit, each bit must consider the carry from the lower bit. 

The characteristic of XOR is the same as adding, but do not have carry-in function. 

These are the full adder that I created in the website. The upper output are the result of the computing and the other one is carry-in.

Conclusion, I learn lot about computers this week. Based on what I learned, I feel like computer is not magic to me any more, and it is just a machine that do what we order. Besides, I was shocked by how computer works. Logic as simple as Boolean algebra could create such machine that make human’s life a big difference!

Data representation

Data representation

I am going to mention following things in my blog.

  1. Bit, Byte, Binary and Hexadecimal
  2. Image and Sounds Representation
  3. Data Compression and Encoding

4.   Huffman Encoding

First, Bit, Byte, Binary and Hexadecimal

The positional notation. The base of a number determines the number of different digit symbols(numerals) and the values of digit positions.  

This formula shows the value of numbers in decimals

Binary numbers and Computers. Computers have storage units called binary digits or bits

It is the smallest unit of data in computing. Bits can be grouped together to make them easier to work with. And  one byte equals to eight bits. 

This picture shows the different  unit of data

This picture shows the different  unit of data

Hexadecimal. Hexadecimal is base 16 and has 16 digits: used to represent very large numbers quickly, such as those used in color representation. The digits are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E.   

The picture shows how to convert binary into hexadecimals. 
  The picture simplifies the converting between binary and hexadecimal 

 

Class activities. 

This activity trains my skill of converting hexadecimal into binary.

Human use two’s complement to represent negative values in computers. 

Second, Date representation 

Analog and digital information. Information can be divided into two ways, Analog data,A continuous representation, analogous to the actual information it represents, and digital data, A discrete representation, breaking the information up into separate elements. Because computer cannot work well with analog data, so we digitize the data, which breaking the data into pieces, and representing those pieces separately. 

Electronic signals. An analog signal continually fluctuates in voltage up and down.A digital signal has only a high or low state, corresponding to the two binary digits. All electronic signals (both analog and digital) degrade as they move down a line. The voltage of the signal fluctuates due to environmental effects Periodically, a digital signal is reclockedto regain its original shape. 

Representing text. There are a finite number of characters to represent, so list them all and assign each a binary string. Character set is a list of characters and the codes used to represent each one at which computer manufacturers agreed to standardize. 

Example of standard code

Representing of image. There are two kinds of image, bitmap and vector. Bitmap has resolution to measure if the picture is clear. Vector does not because vector is generated according to math equation by the computer. Usually human use RGB to represent pictures, because the combination of RGB could represent many colors. The color depth means how much red or green or blue does a dot of the picture contain. 

Representing audio. Pulse Code Modulation (PCM) is a method used to digitally represent sampled analog signals. It has three steps, sampling, quantizing and encoding. Sampling is a process of acquiring audio sampling rate, which is number of samples per second that are used to digitize a particular sound.Quantization is the process of converting a continuous range of values into a finite range of values. Encoding is a process of converting (information or an instruction) into a particular form. 

The picture shows how PCM goes

Third, Compression and encoding. 

Activities: in the class we did a interesting activity that we compress a files according to the knowledge we just learn.  

There are some characters that are repeated in the files. To minimize the space of the files, we could delete the repeated characters, only record how and what they are repeated. I have similar homework that need me to compress an article. I compressed an article from TOEFL reading. It turned out that I mastered compression skills, the compression rate of the article is surprisingly 10 percent. 

Last, Huffman coding. Given a weight of N as a leaf node, construct a binary tree. If the length of the weighted path of the tree is the smallest, the binary tree is called the optimal binary tree, also known as the Huffman Tree. The Huffman tree is the tree with the shortest weight path, and the node with larger weight is closer to the root. 

Conclusion, this week, I learn Bit, Byte, Binary and Hexadecimal, Image and Sounds Representation, and Data Compression and Encoding. Those knowledge are very important because the idea behind encoding and compression are very profound.