45
MATH 1020: MATH 1020: Mathematics For Non-science Chapter 4: Chapter 4: Information in a networked age 1 Instructor: Prof. Ken Tsang Room E409-R9 Email: [email protected]

MATH 1020: Chapter 4: MATH 1020: Mathematics For Non-science Chapter 4: Information in a networked age 1 Instructor: Prof. Ken Tsang Room E409-R9 Email:

Embed Size (px)

Citation preview

MATH 1020: MATH 1020: Mathematics For Non-science

Chapter 4: Chapter 4: Information in a networked age

1

Instructor: Prof. Ken Tsang

Room E409-R9

Email: [email protected]

Transmitting Information

– Binary codes– Data compression– Encoding with parity-check sums– Cryptography– Model the genetic code

2

Information , data & numbersInformation , data & numbers

Today information are transmitted all over the world through the internet

Information is just collection of data– Pictures – jpg, tif …– Sound – mp3, mp4– Video – wmv, mvb

Data consisted of numbers

3

4

Decimal Number SystemDecimal Number System As human normally counts with hands and there are

totally 10 fingers on both hands, this probably explains the origin of the decimal number system.

10 digits:– 0,1,2,3,4,5,6,7,8,9

Also called base-10 number system, – Or Hindu-Arabic, or Arabic system

Counting in base-10– 1,2,…,9,10,11,…,19,20,21,…,99,100,…

Decimal number in expanded notation– 234 = 2 * 100 + 3 * 10 + 4 * 1

Hindu–Arabic numeral systemHindu–Arabic numeral system The Brahmi (ancient Indian) numerals at the basis of the system

predate the Common Era. The development of the positional decimal system occurred during the

Gupta period (笈多王朝 , 320 to 540 CE). Aryabhata, a Gupta period scholar, is believed to be the first to come up

with the concept of zero.

These Indian developments were taken up in Islamic mathematics in the 8th century.

A young Italian in the 12th century, Fibonacci, traveled throughout the Mediterranean world to study under the leading Arab mathematicians of the time, recognizing that arithmetic with Hindu-Arabic numerals is simpler and more efficient than with Roman numerals.

5

Fibonacci (1170-1250 CE)Fibonacci (1170-1250 CE) Italian mathematician, Leonardo Fibonacci

(through the publication in 1202 of his Book of Calculation, the Liber Abaci) introduced the Arabic numerals, the use of zero, and the positional decimal system to the Latin world.

Liber Abaci showed the practical importance of the new numeral system, by applying it to commercial bookkeeping.

6

The numeral system came to be called "Arabic" by the Europeans. It was used in European mathematics from the 12th century, and entered common use from the 15th century.Fibonacci significantly influenced the evolution of capitalist enterprise and public finance in Europe in the centuries that followed.

7

Positional Numbering SystemPositional Numbering SystemThe value of a digit in a number

depends on:– The digit itself– The position of the digit within the number

So 123 is different from 321– 123: 1 hundred, 2 tens, and 3 units– 321: 3 hundred, 2 tens, and 1 units

Roman numeralsRoman numeralsRoman numerals are numeral system of ancient

Rome based on the letters of the alphabetThe first ten Roman numerals are I, II, III, IV, V, VI,

VII, VIII, IX, and X. (no zero)Tens: X; hundreds: C; thousands: MNon-positional: e.g.

– 321 CCCXXI– 982 CMLXXXII– 2010 MMX

8

Non-decimal Number SystemsNon-decimal Number Systems

The Maya civilization and other civilizations of pre-Columbian Mesoamerica used base-20 (vigesimal), as did several North American tribes (two being in southern California).

Evidence of base-20 counting systems is also found in the languages of central and western Africa.

The Irish language also used base-20 in the past. Danish numerals display a similar base-20 structure.

9

10

Base Base rr Number System Number SystemFor any value For any value rrValue is based on the sum of a power

series in powers of rr

rr is called the base, or radix

11

Binary Number SystemBinary Number SystemBinary number system has only two digits

– 0, 1– Also called base-2 system

Counting in binary system– 0, 1, 10, 11, 100, 101, 110, 111, 1000,….

Binary number in expanded notation– (1011)2 = 1*23 + 0*22 + 1*21 + 1*20

– (1011)2 = 1*8 + 0*4 + 1*2 + 1*1 = (11)10

12

Why Binary? Why Binary? Computer is a Binary machine It knows only ones and zeroes Easy to implement in electronic

circuitsReliableCheap

13

Gottfried Leibniz (1646-1716)Gottfried Leibniz (1646-1716)Leibniz, German mathematician

and philosopher, invented at least two things that are essential for the modern world: calculus, and the binary system.

He invented the binary system around 1679, and published in 1701. This became the basis of virtually all modern computers.

Leibniz & Leibniz & I-Ching I-Ching (( 易经易经 ))

As a Sinophile, Leibniz was aware of the I-Ching and noted with fascination how its hexagrams correspond to the binary numbers, and concluded that this mapping was evidence of major Chinese accomplishments in the sort of philosophical mathematics he admired.

14

15

An ancient Chinese binary An ancient Chinese binary number system in Yi-Jing (number system in Yi-Jing ( 易经易经 ))

Two symbols to represent 2 digits Zero: represented by a broken line One: represented by an unbroken line “—” yan 阳爻,“ --” yin 阴爻。

16

HexadecimalHexadecimalHexadecimal number system has 16 digits

• 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F• Also called base-16 system

Counting in Hexadecimal– 0,1,…,F,10,11,…,1F,20,…FF,100,…

Hexadecimal number in expanded notation

– (FF)16 = 15*161 + 15*160 = (255)10

17

Conversion between binary & Conversion between binary & hexadecimal hexadecimal for the first 16 numbersfor the first 16 numbers

18

Why Hexadecimal?Why Hexadecimal?Hexadecimal is meaningful to humans, and

easy to work with for a computerCompact

– A BYTE is composed of 8 bits– One byte can thus be expressed by 2 digits in

hexadecimal– 11101111 EF– 11101111b EFh

Simple to convert them to binary

19

Binary to Decimal

Conversions Conversions Between Number SystemsBetween Number Systems

20

Conversions Conversions Between Number SystemsBetween Number Systems

Octal to Decimal

– (32)8 = (?)10

What’s wrong?

– (187)8 = 1*64 + 8*8 + 7*1

21

Conversions Conversions Between Number SystemsBetween Number Systems

Decimal to Binary

Reading the remainders from bottom to top, we have 32110 = 1010000012

remainderquotient

321 / 2 = 160 1 160 / 2 = 80 0 80 / 2 = 40 0 40 / 2 = 20 0 20 / 2 = 10 0 10 / 2 = 5 0 5 / 2 = 2 1 2 / 2 = 1 0 1 / 2 = 0 1

32110 = ?2

22

Analogue DataAnalogue Data Analogue: something that is analogous or

similar to something else (Webster) Analogue Data: The use of continuously

changing quantities to represent data. A mercury thermometer is an analogue device.

The mercury rises and falls in a continuous flow in the tube in direct proportion to the temperature.

The mathematical idealization of this smooth change as a continuous function leads to “Analogue Data”, an infinite amount of data

23

From Analogue to Digital dataFrom Analogue to Digital dataData can be represented in one of two ways:

analogue or digital:

Analogue data: A continuous representation (using mathematical function or smooth curve) , analogous to the actual information it represents

Digital data: A discrete representation, breaking the information up into separate elements (data)

24

Digitized InformationDigitized InformationComputers, cannot work with analogue

information So we digitize information by breaking it into

pieces and representing those pieces separatelyWhy do we use binary?

– Modern computers are designed to use and manage binary values because the devices that store and manage the data are far less expensive and far more reliable if they only have to represent one of two possible values.

25

Bit and Byte Bit and Byte BIT = Binary digIT, “0” or “1”State of on or off ( high or low) of a

computer circuitKilo 1K = 210 = 1024 ≈ 103 Mega 1M = 220 = 1,048,576 ≈ 106 Giga 1G = 230 = 1,073,741,824 ≈ 109

26

Bit and Byte Bit and Byte Byte is the basic unit of addressable memory 1 Byte = 8 BitsThe right-most bit is called the LSB

Least Significant BitThe Left-most bit is called the MSB

Most Significant Bit

27

Binary RepresentationBinary RepresentationOne bit can be either 0 or 1 (“on” & “off”

electronic signals)Therefore, one bit can represent only two things To represent more than two things, we need

multiple bitsTwo bits can represent four things because

there are four combinations of 0 and 1 that can be made from two bits: 00, 01, 10, 11

28

Binary RepresentationBinary RepresentationIn general, n bits can represent 2n things because there

are 2n combinations of 0 and 1 that can be made from n bits

Note that every time we increase the number of bits by 1, we double the number of things we can represent

Questions:– How many bits are needed to represent 128 things?– How many bits are needed to represent 67 things?

29

ASCIIASCIIASCII stands for American Standard

Code for Information InterchangeThe ASCII character set originally used

seven bits to represent each character, allowing for 128 unique characters

Later ASCII evolved so that all eight bits were used which allows for 256 characters

30

ASCII codeASCII code

31

Unicode charactersUnicode charactersExtended version of the ASCII character set is

not enough for international use The Unicode character set uses 16 bits per

character– Therefore, the Unicode character set can represent 216, or over

65 thousand, characters

Unicode was designed to be a superset of ASCII– The first 256 characters in the Unicode character set

correspond exactly to the extended ASCII character set

With the Unicode, all text (in most languages) information can be represented.

32

UnicodeUnicode4 Hex-numerals to represent 1 Unicode

33

To digitize the signal we periodically measure the voltage of the signal and record the appropriate numeric value– this process is called sampling

In general, a sampling rate of around 40,000 times per second is enough to create a reasonable sound reproduction

Representing Audio Representing Audio InformationInformation

34

Representing Audio Representing Audio InformationInformation

35

• A compact disk (CD) stores audio information digitally • On the surface of the CD are microscopic pits that represent Binary digits•A low intensity laser is pointed as the disc•The laser light reflects strongly if the surface is smooth and reflects poorly if the surface is pitted

Representing Audio Representing Audio InformationInformation

36

Audio Formats– WAV, AU, AIFF, VQF, and MP3

MP3 is dominant – MP3 is short for MPEG (Moving Picture Experts Group)

audio layer 3 file– MP3 employs both lossy and lossless compression– First it analyzes the frequency spread and compares it to

mathematical models of human psychoacoustics (the study of the interrelation between the ear and the brain), then it discards information that can’t be heard by humans

– Then the bit stream is compressed to achieve additional compression

Representing Audio Representing Audio InformationInformation

Image BasicsImage Basics

00000000000000000011110000000000000000 00000000000000001100001100000000000000 00000000000000010000000010000000000000 00000000000000100000000001000000000000 00000000000000100010001001000000000000 00000000000001000111011100100000000000 00000000000001000010001000100000000000 00000000000001000000000000100000000000 00000000000001000000000000100000000000 00000000000001001000000100100000000000 00000000000000100100001001000000000000 00000000000000100011110001000000000000 00000000000000010000000010000000000000 00000000000000001100001100000000000000 00000000000000000011110000000000000000 00011110010000000000000000000000000000 01100010010000000000000000000000000000 11000100100000000000000000000000000000 00000100100001110001011000101100100100 00111111110010010001101000110101100100 00001001000100100111001011100101001000 00010010000101101010010101001011011010 00010010000110110111111011111101101100 00000000000000000100000010000000011000 00000000000000001100000110000000110000 00000000000000001000000100000000100000

38

1-bit, black and white

8-bit grayscale

40

41

Representing ColorRepresenting ColorColor is often expressed in a computer as an

RGB (red-green-blue) value, which is actually three numbers that indicate the relative contribution of each of these three primary colours

For example, an RGB value of (255, 255, 0) maximizes the contribution of red and green, and minimizes the contribution of blue, which results in a bright yellow

RGB ModelRGB ModelRGB Color Model

– Red – Green – Blue– Additive model combines varying amounts of

these 3 colors

42

Image BasicsImage Basics

(0, 0, 0) is black

(255, 255, 255) is white

(255, 0, 0) is red

(0, 255, 0) is green

(0, 0, 255) is blue

(0, 255, 255) is cyan

(255, 0, 255) is magenta

(255, 255, 0) is yellow

45

46

DAC

Composing color imageComposing color imageStore the actual intensities of R, G, and B

individually in the framebuffer24 bits per pixel = 8 bits red, 8 bits green, 8

bits blue

49

Digitized Images and GraphicsDigitized Images and Graphics

Digitizing a picture is the act of representing it as a collection of individual dots called pixels

The number of pixels used to represent a picture is called the resolution

Several popular raster file formats including bitmap (BMP), GIF, and JPEG

Image BasicsImage Basics

Bitmap– Grid of pixels

50

51

BMPBMP