2021, Winter semester, PBL report

PBL report (Final)

Introductory Mathematics for Artificial Intelligence

Professor: Sang-Gu LEE

 

2021 Winter Math4AI <Final PBL report>

 

Due Day :  Dec. 31, 2021  (in HW box in LMS)

Name/Major/Year(year): KANG MINJI /공학계열/1, SSYoon/Nano/2, Ng Zhi Wei/Software/3

E-mail: minjikang*@gmail.com, yss*@g.skku.edu, ngzhiwei**@hotmail.com

 

[PBL report Form Download(보고서 양식 다운로드)]

Korean (HWP) : http://matrix.skku.ac.kr/PBL/PBL-Report-Form-Korean.hwp  <- Modify this for this semester

English (MS Word) : http://matrix.skku.ac.kr/PBL/PBL-Report-Form-English.docx <-- Modify this form for your semester

We have learned Basic Mathematics(행렬도함수통계)

http://matrix.skku.ac.kr/intro-math4ai/W1/
http://matrix.skku.ac.kr/intro-math4ai/W2/

http://matrix.skku.ac.kr/intro-math4ai/W3/
http://matrix.skku.ac.kr/intro-math4ai/W4/
http://matrix.skku.ac.kr/intro-math4ai/W5/

http://matrix.skku.ac.kr/intro-math4ai/W6/
http://matrix.skku.ac.kr/intro-math4ai/W7/

http://matrix.skku.ac.kr/intro-math4ai/W8/ 
http://matrix.skku.ac.kr/intro-math4ai/W9/ 

http://matrix.skku.ac.kr/intro-math4ai/W10

http://matrix.skku.ac.kr/intro-math4ai/W11/ 
http://matrix.skku.ac.kr/intro-math4ai/W12/ 
http://matrix.skku.ac.kr/intro-math4ai/W13/ 
http://matrix.skku.ac.kr/intro-math4ai/W14/ 

to understand and can talk about the following concepts in 14 weeks(days) in this semester.

1. SVD(Singular Value Decomposition)

2. GDM(Gradient Descent Method)

3. Data and Covariance Matrix

4. PCA(Principal Components Analysis)

5. Rank Reduction and the role of SVD in PCA

6. BP(Back-Propagation) algorithm in ML(Machine Learning) and ANN(Artificial Neural Network)

 

l  Sample Students HW/Report [예시, 이전 학기 학생들의 질문/답변/활동 기록] 

Math4AI-Summary : http://matrix.skku.ac.kr/Math4AI-Summary/

2021 Fall PBL report by two Freshmen (English) : http://matrix.skku.ac.kr/2021-Math4AI-Fall-PBL/

2021 Summer PBL report (English) : http://matrix.skku.ac.kr/2021-Final-PBL-E/

2021 Summer PBL report (Korean) :http://matrix.skku.ac.kr/2021-Final-PBL/

2020 Fall PBL report (Korean) : http://matrix.skku.ac.kr/2020-Math4AI-PBL/ Basic Math for AI)

 

Sample 1 (도전학기 7주차 기말보고서) http://matrix.skku.ac.kr/2020-Math4AI-Final-pbl2/

Sample 2 (도전학기 7주차 기말보고서) http://matrix.skku.ac.kr/2020-math4ai-final-pbl/

Sample 3 (도전학기 4주차 중간보고서) http://matrix.skku.ac.kr/2020-Mid-PBL-2/

Sample 4 (도전학기 4주차 중간보고서) http://matrix.skku.ac.kr/2020-Mid-PBL-1/

English (Linear Algebra) English :  http://matrix.skku.ac.kr/2018-album/LA-PBL.htm (선형대수학)

English (Linear Algebra) (Korean PDF file):  http://matrix.skku.ac.kr/2015-album/2015-F-LA-Sep-Record.pdf

Calculus 1 PBL report http://matrix.skku.ac.kr/Cal-Book1/Calculus-1/ (미적분학 1)

Calculus 2 PBL report http://matrix.skku.ac.kr/Cal-Book1/Calculus-2/ (미적분학 2)

[ We could practice the our codes in http://matrix.skku.ac.kr/KOFAC/

 {High School Math Review} Math Lab Review (실습실)

 9th grade Math (수학)    http://matrix.skku.ac.kr/9th-Grade/  

 10th grade Math  (1  수학)    http://matrix.skku.ac.kr/10th-Grade/  

11th grade Math 1 (2, 수학 1)   http://matrix.skku.ac.kr/11th-Grade-1/  

 9th grade Math 2  (2, 수학 2)   http://matrix.skku.ac.kr/11th-Grade-2/  

 9th grade Math, Calculus  (3, 미적분)   http://matrix.skku.ac.kr/12th-Grade-1/  

 9th grade Math, Statistics  (3, 확률통계http://matrix.skku.ac.kr/12th-Grade-2/  ]

 

[Start to fill out the followings]

General Academic Knowledge  (10 points)

 (1) State more than 10 Math Definitions and concepts what you learned in the first 14 weeks (days).

http://matrix.skku.ac.kr/intro-math4ai/  

 

1.    Polynomial functions: A function f(x) that is a polynomial of x is called a polynomial function. Most well-known polynomial functions are as follows. Linear function, quadratic function, nth order polynomial.

2.    Rational functions: Rational functions f(x) are functions of x that are rational P(x)/Q(x) where P(x) and Q(x) are polynomials.

3.    Vector and scalar: A quantity which does not depend on direction is called a scalar quantity. Vector quantities have two characteristics, a magnitude and a direction. Scalar quantities have only a magnitude.

4.    Rules for Matrix Operations: A + B = B + A, 1A = A, (ab)C = aC + bC, …

5.    Classification: Classification is the problem of identifying to which category a new data belongs, based on the given data's characteristics.

6.    Gauss-Jordan elimination: Gaussian elimination is an algorithm for solving systems of linear equations. When we solve a system of linear equations using Gaussian elimination, the final form (of the augmented matrix) on the left side of the equation becomes the identity matrix.

7.    Least Squares Problem: Least-squares problems fall into two categories: linear or ordinary least squares and nonlinear least squares, depending on whether or not the residuals are linear in all unknowns. The linear least-squares problem occurs in statistical regression analysis; it has a closed-form solution.

8.    SVD: The SVD (singular value decomposition) always exists for any sort of rectangular or square matrices. It is the key feature of SVD. The singular value decomposition of m x n matrix A is the matrix factorization in the form of A = U x Sigma x V^T, where U is an m x m orthogonal matrix, V is an n x n orthogonal matrix, and sigma is an m x n rectangular (generalized) diagonal matrix with non-negative real numbers on the main diagonal.

9.    Limits of Functions: An optimal solution is a solution in which a function defined in a set has a maximum or minimum value. The problem of finding an optimal solution involves generalized concepts and operations of derivatives. Techniques used to find an approximate solution help when we find an optimal solution. 

10.  Local Maximum and Minimum: The derivative can be used to determine whether a function increases or decreases based on the sign of slope at a point (or on a given interval). There might be a changing point of the slope (e.g, decreasing to increasing, increasing to decreasing). We call it a critical point, and the derivative of the function will be zero at a critical point. The second derivative can be used to determine whether a given function has a local maximum or minimum value at a critical point. Using the second derivative, we can 'check that a function has the absolute maximum or minimum on a given interval'.

11.  Fermat's Theorem for Extrema: Fermat's theorem essentially says that every local extremum (i.e. local maximum or minimum) of the function that occurs at a point within the interval where the function is differentiable (i.e. the function has a derivative at that point) must be a stationary point.

12.  Gradient descent method: Gradient descent is an iterative optimization algorithm for finding the local minimum of a function. To find the local minimum of a function using gradient descent, we must take steps proportional to the negative of the gradient (move away from the gradient) of the function at the current point.

13.  Conditional probability: Conditional probability is an essential concept in data analysis, which is the probability that an event B occurs under the condition that an event A occurred.

14.  Bayes' theorem: Bayes' theorem describes the probability of an event based on prior knowledge of conditions related to the event.

15.  PCA: PCA converts a data set from high-dimensional space into low-dimensional, easy-to-handle spaces while preserving the distribution of the original data as much as possible.

16.  Artificial Neural Network: computing systems inspired by the biological neural networks that constitute animal brains. An ANN is based on a collection of connected units or nodes called artificial neurons, which loosely model the neurons in a biological brain.

17.  Backpropagation (BP): an algorithm for supervised learning of artificial neural networks using gradient descent. Given an artificial neural network and an error function, the method calculates the gradient of the error function with respect to the neural network's weights.

 

- Vector is a geometric object that has magnitude (or length) and direction. It can be represented as an ordered set of numbers arranged in columns.

- Matrix is a rectangular array or table of numbers, symbols, or expressions, arranged in rows and columns, which is used to represent a mathematical object or a property of such an object.

- Distance is a measure of data similarity using distance between two vectors. This is often used in data sets having similar values.

- Cosine similarity is a measure of data similarity using angle between two vectors. It is often used in data sets having trends.

- Least squares problem is minimizing the sum of the squares of the differences of data made in the results of each individual equation. It is often used in data fitting,

- QR decomposition is a decomposition of a matrix A into a product A = QR of an orthogonal matrix Q and an upper triangular matrix R.

- LU decomposition factors a matrix as the product of a lower triangular matrix and an upper triangular matrix.

- SVD: is a factorization of a real or complex matrix. It generalizes the diagonalization of a square normal matrix with an orthonormal eigenbasis to any rectangular matrix.

- Limit is the value that a function (or sequence) approaches as the input (or index) approaches some value.

- Derivative measures the sensitivity to change of the function value (output value) with respect to a change in its argument (input value).

- GDM is a first-order iterative optimization algorithm for finding a local minimum of a differentiable function.

- Expectation of a random variable X, often denoted E(X), is a generalization of the weighted average, and is intuitively the arithmetic mean of a large number of independent realizations of X.

- Variance is the expectation of the squared deviation of a random variable from its population mean or sample mean. Variance is a measure of dispersion, meaning it is a measure of how far a set of numbers is spread out from their average value.

- Standard deviation is a measure of the amount of variation or dispersion of a set of values. A low standard deviation indicates that the values tend to be close to the mean of the set, while a high standard deviation indicates that the values are spread out over a wider range.

- Bayes’ theorem describes the probability of an event, based on prior knowledge of conditions that might be related to the event.

텍스트이(가) 표시된 사진

자동 생성된 설명

- Covariance is a measure of the joint variability of two random variables. If the greater values of one variable mainly correspond with the greater values of the other variable, the covariance is positive. In the opposite case, when the greater values of one variable mainly correspond to the lesser values of the other, the covariance is negative. The sign of the covariance therefore shows the tendency in the linear relationship between the variables.

 

- Covariance matrix is a square matrix giving the covariance between each pair of elements of a given random vector.

 

- PCA is the process of computing the principal components and using them to perform a change of basis on the data, sometimes using only the first few principal components and ignoring the rest. It is commonly used for dimensionality reduction by projecting each data point onto only the first few principal components to obtain lower-dimensional data while preserving as much of the data's variation as possible.

 

- Linear regression is a linear approach for modelling the relationship between a scalar response and one or more explanatory variables. More simply, it can be understood as fitting the data by appropriate line.

 

- ANN are computing systems inspired by the biological neural networks that constitute animal brains. It consists of input layer, inner layer, output layer. Signals travel from the first layer (the input layer) to the last layer (the output layer), possibly after traversing the layers multiple times.

 

- Back Propagation is a widely used algorithm for training feedforward neural networks. In fitting a neural network, backpropagation computes the gradient of the loss function with respect to the weights of the network for a single input–output example, and does so efficiently, unlike a naive direct computation of the gradient with respect to each weight individually.

 

- MNIST is a large database of handwritten digits that is commonly used for training various image processing systems. The database is also widely used for training and testing in the field of machine learning.

MNIST sample images

 

 

(2) State more than 10 things that you know/can/find ...  after you studied the first 14 weeks (days).

·          

-       I learned how to plot complex functions using Sage commands.

-       I learned how to get approximate solution to complex equations.

-       I learned that vector and matrix can represent various data.

-       I learned what is matrix and how to do matrix operations.

-       I learned how to get solution set for linear system of equations using Gauss-Jordan elimination.

-       I learned how to fit curve by least square problem using Sage commands.

-       I learned to decompose matrix into QR, LU, SVD by Sage command.

-       I learned how to get derivative using Sage command.

-       I learned how to get local maximum or minimum of a complex function by Gradient Descent Method using Sage command.

-       I learned that learning rate and initial position matters a lot in GDM, and several methods to get appropriate learning rate.

-       I learned how to calculate expectation, variance, standard deviation of a given dataset.

-       I learned what is Bayes’ theorem and how and where it is used.

-       I learned what is covariance and how to calculate it when dataset is given.

-       I learned that covariance can be effectively expressed and processed using matrix.

-       I learned what is PCA and how and where it is used.

-       I learned what is linear regression and know exact meaning of it.

-       I can tell the difference between linear regression, PCA, least squares line.

-       I learned what is ANN and learned how and where it is used.

-       I learned what is Back Propagation and learned its algorithmic process.

-       I learned what is MNIST and learned several more examples where ANN is used.

-        

1.    Sketch graphs of polynomial functions

2.    Make a composite function

3.    Find solutions of equations

4.    Perform matrix operation by applying operations on vectors and matrices

5.    Check inverse and transpose of a matrix

6.    Find inner product and angle of two vectors

7.    Find system of linear equations

8.    Find SVD of a matrix

9.    Find derivative of a differentiable function using while loop

10.  Find local maximum, local minimum, absolute maximum, and absolute minimum of a function

11.  Find the minimum value of a function with the GDM code.

12.  Draw graphs for various differentiable functions and determine a small interval containing the local minimum identified from the figure, and apply the GDM code to each interval with a reasonable x1.

13.  Explain how SVD is used in PCA

14.  Take a data matrix and apply a PCA

15.  Process of dimension reduction by PC’s on the covariance matrix.

16.  Describe simply ANN and Backpropagation algorithm as you understand.

 

Participation Part (20 points)

Fill in the below for your self-assessment and your project/term paper

 

(A) Briefly describe your contributions through Q&A for yourself and fellow students in our "Basic Math4AI" classe! 

 

(A1)Quantity :

 

-       Check your participation numbers in QnA for each week (Saturday to Friday): 

 

 12/13:      0           12/14:          3     12/15:         3       12/16:    3

12/17:      2              12/18:          2     12/19:         0       12/20:    0

12/21:      5              12/22:          5     12/23:       1      12/24:    0

12/25:     1        12/26:       1    12/27:       0      12/28:    1

12/29:     0        12/30:       5

 

-       Total number of sessions (Q:     2   ,   A:   26     ,    Others:   4       )

-       Number of online attendances:     ( 34   / 34 )

-       Off-line attendance and number of absences:  (  3   /  3 ) (0 absence)

 

-       Check your participation numbers in QnA for each week (Saturday to Friday): 

 

 Week(day)  1:    0                Week  2:        3       Week  3:     0           Week  4:    0

Week  5:     10               Week  6:        1       Week  7:      3          Week  8:    0

Week  9:       1             Week 10:         0      Week 11:          0      Week 12:    2

Week 13:     0               Week 14:        3       Week 15: 0

 

-       Total number of sessions (Q:      1       ,   A:       13       ,    Others:    9       )

-       Number of online attendances:     (    35    / 35  )

-       Off-line attendance and number of absences:  (   3     /   3) (0 absence)

·         Others Include some announcements or course related posts.

 

 

·          (A2) What you contributed through this course so far (Q & A and/or In-class)?

·         I actively participated on Q&A open problems. I frequently shared my solution to the class.

·         I shared the study material I’ve found during studying about the concept to the class. This might helped some colleagues understand the concept better.

·         I actively commented on other colleagues’ solutions and contributed finalizing it.

 

Ng Zhi Wei Self Introduction / Motivation

[Question] Open problem 11 by 박우현

Problem 1 by Ng Zhi Wei

Problem 2 by Ng Zhi Wei

Problem 3 by Ng Zhi Wei

    Problem 14 by 안성준

    Problem 15 by 안성준

Problem 5 by random_matrix() by Ng Zhi Wei

Problem 6 by Ng Zhi Wei

Problem 1 by 남상현

Day 7 Open Problem 1 by Ng Zhi Wei 응즈웨이 (using while loop) [Comment by: 우건주, 고재윤, 남상현, 윤상수]

[News] The Future of Jobs in the Era of AI (인공지능 시대의 진로와 직업)

Explained SVD in class (2nd WebEx meeting)

[Question] What exactly does 'Linear Regression' mean?

Gradient Decent Method 관한 간략한 정리와 GDM 최초점과 관련해 윤상수 학우님께서 올려주신 질문 게시글과 댓글로부터 배운

Finalise Code a Neural Network with Backpropagation In Python by 이우흠

using SVD to perform PCA

 

 (A3) Number of Final OK by SGLee Problems (and/or Completed Discussion/Question) in QnA that your name is included. 

22 problems

Final OK by SGLee [Finalized by 이예진] Dec. 14th, Summary of 1st WebEx meeting - How this class will proceeds and Who will get A in this class. by 윤상수, 우건주, 김명규, 박우현, 고재윤, 안성준, 김지훈, 도경근, 이규리, 황세진, 응즈웨이, 이예진, 정운섭, 이우흠, 인유진, 김지훈, 신유정, 도경근, 남궁보민, 우건주, 강민지, 남상현, 이우흠, 인유진.

[Final OK by SGLee] open problem 4 solution by 정운섭, 황세진, 응즈웨이 (finding solutions to various equation using sage) and question

Open Problem 4 by Ng Zhi Wei (Cont. from [Final OK by SGLee] open problem 4 solution by 정운섭, 황세진 (finding solutions to various equation using sage) and question) [Comment by: 이예진]

ALL Must read This!! [Sample, Re-Finalized OK by SGLee] Open Problem 16 [Re-Finalized by Ng Zhi Wei(응즈웨이), 이규식, 남상현, 이예진, 고윤진, 고재윤, 도경은, 황세윤, 신유정, 박우현, 이예진, 남상현, 도경근, 이규식] (Solutions and Comments) Find SVD of a rectangular 4 by 5 matrix which is bigger than 3 by 3.

OK : the2nd WebEx meeting (처음 게시글을 작성한 인원이 자신의 글에 코멘트를 달아준 학우들의 이름을 포함하여 제목 내용을 수정 해주어야 다른 분들의 검색이 쉬어질 것입니다.) 고재윤/전자전기공학과, 우건주/신소재공학과 (Woo Gun Joo), 문헌정보학과 2018 이규리(Lee Kyuri), 시스템경영공학과 황세진 (Hwang Sejin), 전자전기공학과 김지훈 (Kim Jihoon), 기계공학과 박우현 (Park Woohyeon), 2019 응즈웨이, 2020 인유진, 2021 강민지, 2018 정운섭, 2020 윤상수, 2018 남상현, 2015 김명규, 이우흠-2018 (Yi) , 안성준 2016, 2016 안성준, 박우현_2016, 2018 이규식, 정운섭_2018, 2018 이규리, 2015_김명규, 고재윤 2020, 2015_ 황세진, 안성준 2016, 2015_김명규, 2018 이우흠, 안성준 2016, 2018 도경근, 김지훈_2020 

Open Problem 16 by 이우흠 Re-Finalized OK by SGLee] Open Problem 16 [Re-Finalized by Ng Zhi Wei(응즈웨이), 이규식, 남상현, 이예진, 고윤진, 고재윤, 도경은, 황세윤, 신유정, 박우현, 이예진, 남상현, 도경근, 이규식] (Solutions and Comments) Find SVD of a rectangular 4 by 5 matrix which is bigger than 3 by 3.

[Final OK by SGLee] Summary for 3rd Webex Meeting (12/28), Dear 응즈웨이 Ng Zhi Wei Software 3rd year and 이우흠/ LIYuxin/

(B)Quality of Your Participation: 

·         (B1) What did you especially remember while you are doing the first part 1, 2, 3, (4, 5-Final).

·                 I especially remember the SVD. When I first listened to the lecture, there were actually many parts I didn't understand. However, I understood many parts through the explanations and discussions of my classmates. In addition, the part that the professor explained additionally in the last Webex meeting helped complete the concept.

I especially remember Singular Value Decomposition and Gradient Descent Method. It was interesting to know that SVD is used in data compression, and GDM is used in optimization. It was good to relate it with practical examples.

I also remember Principal Component Analysis and dimension reduction. It is very interesting to know how the PCA works and why it is used to analyze data. It was good to know that dimension reduction is the key feature of PCA.

 

·         Sketch graphs of polynomial functions

·         Make a composite function

·         Find solutions of equations

·         Perform matrix operation by applying operations on vectors and matrices

·         Check inverse and transpose of a matrix

·         Find inner product and angle of two vectors

·         Find system of linear equations

·         Find SVD of a matrix

·         Find derivative of a differentiable function using while loop

·         Find local maximum, local minimum, absolute maximum, and absolute minimum of a function

·         Find the minimum value of a function with the GDM code.

·         Draw graphs for various differentiable functions and determine a small interval containing the local minimum identified from the figure, and apply the GDM code to each interval with a reasonable x1.

·         Explain how SVD is used in PCA

·         Take a data matrix and apply a PCA

·         Process of dimension reduction by PC’s on the covariance matrix.

·         Describe simply ANN and Backpropagation algorithm as you understand.

(B2) What did you learn or feel while learning Basic Math4AI (Action Learning/PBL) with your classmates?

I received great help in understanding the lecture by sharing opinions on the solution to the problem through discussions with my classmates. In addition, it was easy to understand problems that were difficult to understand alone. And it was good to receive opinions from my classmates on the solution I solved.

I learned that visualizing the example or process helps intuitive understanding on the problem or concept. I saw some of the colleagues did very well on visualizing what they are saying.

It was good experience to study mathematics with students from such a various backgrounds. I could learn from colleagues’ background knowledge on diverse field.

I think it is a good way to learn when we share our answer in QnA and discuss and ask questions so we get a better understanding on the concepts and also see how people approach the questions.

​(B3) Write names of YOUR PBL Team members and Team Leader. And Now I understand the concepts below

SVD Decomp, LU Decomp, QR Decomp, Euclidean Distance, Norm, Vector-Plane Projection, Determinants, Limits, Differentiation, Leact-Squares Solution, Matrix and Vector Actions.

 텍스트 상자:  REF, RREF, SVD Decomp., LU Decomp., QR Decomp., Euclidean Distance, Norm, Vector-Plane Projection, Determinants, Limits, Differentiation, Curve-Fitting Solution, Least-Squares Solution, Matrix and Vector Actions (multiplication, translation, inversion, transposition, scalar multiplication, etc.), Gradient Descent Method, Factorial, Permutations, Combinations, Probability, Bayes’ Theorem, Integration, Expectation, Variance, Standard Deviation, Standardized Random Variable, Different Probability
Distributions, Covariance, Covariance Matrix, Correlation Coefficient, Principal Components, Principal Component Analysis, ANN, Backpropagation, Activation Function Output …

... 함수, 벡터, 행렬, 텐서, 노름, 내적, 선형연립방정식, 가우스 소거법, RREF, 첨가행렬, 정사영, 최소제곱문제, LU분해, QR 분해, SVD, 도함수, 미분, 극대, 극소, 최대, 최소, 경사하강법, 학습률, 그래디언트, 순열, 조합, 베이즈 정리, 확률변수, 확률분포, 기댓값, 분산, 표준편차, 공분산, 상관계수, 주성분 분석(PCA), 인공신경망, 오차역전파법(Back propagation), MNIST ...

 

Self Evaluation (20 points)

Subject

Basic Math4AI

Major

Software

Name/ID

Ng Zhi Wei 2019313851

Year

3

Learning

contents

1. SVD(Singular Value Decomposition)

2. GDM(Gradient Descent Method)

3. Data and Covariance Matrix

4. PCA(Principal Components Analysis)

5. Rank Reduction and the role of SVD in PCA

6. BP(Back-Propagation) algorithm in ML(Machine Learning) and ANN(Artificial Neural Network)

Self-Checking

Activity

Excellent

Good

Fair

1.

I have contributed to generate ideas and facts needed to resolve the issue.

ü

 

 

2.

I proposed learning issues associated with learning.

ü

 

 

3.

When I study alone, I used a variety of learning materials.

ü

 

 

4.

I provide new information and knowledge in this class.

ü

 

 

5.

I was actively involved in the discussions. And I provided a lot of questions in order to understand these discussions.

ü

 

 

6.

I have made a contribution to the learning activities for our class.

ü

 

 

※ Please record the following items by considering your learning process.

1. Do you understand the most of contents of this learning process?

Yes

 

2. What kind of learning materials have you used to study?

The Lecture Notes and Lab.

 http://matrix.skku.ac.kr/intro-math4AI/

The lecture videos, QnA board, and online resources, lecture notes

 

3. What did you learn through the learning activities of this course?

Using coding, solve the equation and draw a graph. And I learned to generate matrices and vectors, and I learned to calculate the angle or distance between two data. I also learned about transpositions, inverse matrices, and reversible matrices. And I learned about SVD decomposition, which is the most important thing. Also, use code to find the limit and derivative of the function and draw a graph. And I learned how to find the local minimum value, local maximum value, absolute maximum value, absolute minimum value, and GDM to find the critical value.

I learned how AI technique finds the most efficient way to find equations, or solutions. I was able to learn the basics of current AI technology's data mining technology.

And also, I was able to learn various ways, such as learning, finding, and compressing data efficiently.  As I do the open problems, I learn the concepts and how to approach the questions in Sage.

 

4. What have you learned from the other colleagues?

I was able to find solutions to the solutions of problems I didn't know from the solutions of other classmates. In addition, I was able to learn how to solve various perspectives through discussion.

From the QnA board, I learn a lot from how people see the questions differently and how people approach the questions.

 

5. Self-Evaluation for Q/A Activities

My score: 7/10

I think I contributed a fair amount in terms of giving my answers, asking questions, and acknowledge other people answers when I understand them.

 

6. Evaluation for other students

Many students have actively participated. I personally think mr. 고재윤 did a great job in visualizing concepts.

. 남상현 학우님: I think he have the most number of useful QnA which I read and learnt from so I chose him as my first peer evaluation student. Thus, I think he is deserving to get extra points.

. 이규리 학우님: She explained to me the things needed in the midterm PBL report last week because a lot of the discussions were in Korean so I got her help for clarifications. Thus, I chose her as my 2nd peer evaluation student and she is deserving of extra points.

Many classmates' solutions helped me, but in particular, the solutions of 고재윤, 윤상수, and 응즈웨이 are memorable. In particular, 응즈웨이's SVD problem solution received a lot of help.

 

Self-Evaluation 2

Subject

Basic Math4AI

Major

Software

Name/ID

Ng Zhi Wei 2019313851

 

 

Evaluation Items

Strongly disagree

Disagree

Mostly disagree

Mostly agree

Agree

Strongly agree

1. I participated actively in both, online and offline classes.

 

 

 

 

 

ü

2. I participated actively on a Q&A activity.

 

 

 

 

ü

    

3. My question and replies made on Q&A are relevant.

 

 

 

 

ü

 

                            

4. Information provided by my activity was useful for other students in the class.

 

 

 

ü

 

   

5. I enthusiastically took into the consideration other students’ opinions or point of view.

 

 

 

 

ü

   

6. I contributed to class by participating on Q&A discussions.

 

 

 

 

ü

    

7. I am enthusiastic about taking other class with the same students I am taking this class.

 

 

 

 

ü

 

[Opinion]

Satisfaction according to the Self-Evaluation

I am satisfied that I took a lot of lectures in class and participated a lot in Q&A. Also, I am satisfied with my contribution to this class. 

I am very happy with the way this class is conducted. It is rather new to me but I think it is effective learning.

 

Sorrow according to the Self-Evaluation

There is still a lack of understanding. And although I am actively participating in the class, I want to participate more actively. Also, I want to contribute more to this class.

The QnA board is a little messy. Rather than using the QnA board, I think using the discussion board and splitting the discussion board into the different days will be better.

 

Self-Evaluation 3

Subject

Basic Math4AI

Colleague’s name

고재윤

Name of evaluator

윤상수, 강민지

Evaluation Items

Strongly disagree

Disagree

Mostly disagree

Mostly agree

Agree

Strongly agree

1. I participated actively in both, online and offline classes.

 

 

 

 

 

o

2. I participated actively on a Q&A activity.

 

 

 

 

o

    

3. My question and replies made on Q&A are relevant.

 

 

 

 

o

                            

4. Information provided by my activity was useful for other students in the class.

 

 

 

 

o

   

5. I enthusiastically took into the consideration other students’ opinions or point of view.

 

 

 

 

 

o

   

6. I contributed to class by participating on Q&A discussions.

 

 

 

 

o

    

7. I am enthusiastic about taking other class with the same students I am taking this class.

 

 

 

 

o

[Opinion]

Satisfaction according to the Self-Evaluation

고재윤 학우분께서 작성하신 솔루션들로 문제 풀이를 이해하는 도움을 많은 도움을 받았습니다. Well visualized his thoughts. It helped other colleagues.

 

Sorrow according to the Self-Evaluation

고재윤 학우분만큼 많은 솔루션을 작성하도록 앞으로 노력하고 싶습니다 There was no sorrow.

 

 

Self-Evaluation 3

Subject

Basic Math4AI

Major

Software

Name/ID

Ng Zhi Wei 2019313851

 

 

Evaluation Items

Strongly disagree

Disagree

Mostly disagree

Mostly agree

Agree

Strongly agree

1. I participated actively in both, online and offline classes.

 

 

 

 

 

ü

2. I participated actively on a Q&A activity.

 

 

 

 

ü

    

3. My question and replies made on Q&A are relevant.

 

 

 

 

ü

 

                            

4. Information provided by my activity was useful for other students in the class.

 

 

 

ü

 

   

5. I enthusiastically took into the consideration other students’ opinions or point of view.

 

 

 

 

ü

   

6. I contributed to class by participating on Q&A discussions.

 

 

 

 

ü

    

7. I am enthusiastic about taking other class with the same students I am taking Discrete Mathematics.

 

 

 

 

ü

 

[Opinion]

Satisfaction according to the Self-Evaluation

I am very happy with the way this class is conducted. It is rather new to me but I think it is effective learning.

 

Sorrow according to the Self-Evaluation

The QnA board is a little messy. Rather than using the QnA board, I think using the discussion board and splitting the discussion board into the different days will be better.

 

Self-Evaluation 4

자기소개/수강동기

안녕하세요. 저는 공학계열 21학번 강민지입니다.

저는 아직 전공진입을 하지 않은 상태에서 어떤 전공이  맞을까 탐색하던 인공지능에 대해 관심을 갖게 되었습니다. 비록 아직 미적분학 밖에 수강하지 않았지만이들을 토대로 인공지능에 기반이 되는 수학적 내용들을 탐구해보고 싶어이 강좌를 수강하게 되었습니다.

앞으로 성실하게 강의활동에 참여하여 여러 내용들을 학습하겠습니다 부탁드립니다.

 

·         State your meaningful Comment/Answer/Discussions in Discussion/QnA.

#Open Problem 1 (solved by 강민지)

http://matrix.skku.ac.kr/KOFAC/  에서 1주차 교재 http://matrix.skku.ac.kr/intro-math4ai/w1/  코드를 수정하여 풀어본/그려본 그래프를 공유합니다

<function of graph>

1.    plot function 이용하고,  

2.    이때 정의역 a<x<b f(x), plot(f(x), (x,a,b)) 형식으로 입력한다.

3.    기본 파란색으로 출력되며함수 끝에 color='' 형식으로 색을 지정할  있다.

4.    함수가 발산할 경우함수 끝에 ymin, ymax 통해 출력범위를 지정할  있다.

Q(강민지) detect_poles='show'  점근선을 출력한다는 의미가 맞을까요?

A(이상구 교수님) 맞습니다. detect_poles==’show’가 점근선을 출력한다는 의미입니다.

 

Comment : 강의를 처음 시작하며, 아직 낯선 강의 방식에 적응하는 단계에서 작성한 글이라, 처음에는 맞게 작성한 것인지 확신이 없었지만, 여러 학우분들의 도움이 되었다는 답변에 자신감을 갖고 QnA에 여러 글을 남기는 계기가 되었습니다.

 

Open Problem 1

#Open Problem 2(solved by 이예진)

 (수업 이해를 돕고자 교수님 강의 내용 일부를 요약 정리하였습니다.)

먼저 day 2 학습목표는 Tuple, Vectors, Matrix, Tensor 대한 이해입니다

나아가 행렬의 다양한 operation 의미와 쓰임을 이해하는 것입니다.

한편선형대수학은 행렬의 operation 방법을 다루는 수학의  branch, Artificial Intelligence 배우고자 하는 사람이라면 필수 수강해야 하는 과목 하나입니다

  1. Tuple 

tuple이란 data 정해진 짝으로 표현하는 방식으로이것을 n개의 tuple 나타낸다고 표현합니다

Ex) kim 신장체중연령성별에 대한 data = (160,80,19,1) (4-tuple)

  1. Vector operations

Vector 연산은 크게 벡터끼리의 , scalar값의 곱이 있습니다

텍스트이(가) 표시된 사진

자동 생성된 설명

다음은 벡터 연산의 성질입니다

텍스트이(가) 표시된 사진

자동 생성된 설명

 Open Problem 2

Sketch the graph for the function .

Cos 함수와 다항식의 곱으로 표현된 함수를 plot하였습니다.        

텍스트이(가) 표시된 사진

자동 생성된 설명

, HW1에서 x 범위를 지정해주었던 것과 달리 이번에는 x 아니라 y 범위를 넣어 plotting 보았습니다그런데 다음과 같이지정해준 ymin, ymax 초과하여 그래프가 도출되었습니다

이에 다음과 같이 y 범위를 조절해보았습니다.

그래프가 x기준 -0.3~0.3 사이, y 기준 -3~3 사이에서 진동하고 왼쪽으로는 0 수렴오른쪽으로는 발산함을 확인할 있었습니다다음 그림을 통해 그래프의 전체적인 형태를 파악할 있습니다

또한다음 x 범위를 조정한 다음 코드로 그린 그래프를 통해 x 원점 주변에서 굉장히 많은 해를 가짐을 있습니다.

 



감사합니다. 

 

Comment : x값의 범위를 좁혀 그래프를 표현해, 함수의 개형을 확실히 알아볼 있어 도움이 되었습니다. 함수 그래프 관련 예제들을 풀어볼 때는 단순히 코드 실행만 해보았었는데, 이 글을 본 후에 x값의 범위를 변경해가며, 함수의 개형을 좀 더 효율적으로 보게 되었습니다.

 

Open Problem 2

Open Problem 3

     

            

#Open Problem 3(solved by 고재윤)

 Open Problem 3

Make a composite function from the functions that you learned and draw a graph of it. [Hint: plot(sin(e^(1/3)^x), (x, -1.2, 10))]



 http://matrix.skku.ac.kr/KOFAC/  접속하여 sin(e^(1/3)^x) 식을 -1.2부터 10까지 나타내기 위해 아래와 같이 코딩하였습니다.

 plot ( sin(e^(1/3)^x), (x, -1.2, 10)) 

 in  http://matrix.skku.ac.kr/KOFAC/    gives  

보시는바와 같이 한줄로 간단하게 코딩되었습니다. 전체적인 형태는 plot( function, (variable, starting interval, finishing interval))입니다.

결과 아래와 같은 그래프가 결과값으로 출력되었습니다.

함수에 대해 이해하기 위해 e^(1.3)^x 그래프를 아래와 같이 코딩하고 출력값을 살펴보았습니다.

    plot (e^(1/3)^x)

in  http://matrix.skku.ac.kr/KOFAC/    gives 

e^(1/3)^x 그래프의 x>0 부분을 보면 y=1 부근으로 수렴하며 감소한다는 것을 있습니다.

이를 통해 sin(e^(1/3)^x) x>0 부분이 수렴하는 형태로 나왔는지 추론할 있었습니다.

반대로 x<0부분을 보면 exponential하게 y값이 증가한다는 것을 있습니다. 

sin 주기함수 이므로 sin(e^(1/3)^x) x<0 부분이 진동하는 형태로 그려졌는지 추론할 있었습니다.

Comment : 합성함수 문제를 단순히 합성함수의 그래프만 출력하고, 분석하는 식으로 접근하였었는데, 합성함수의 각 구성함수들을 분리하여 분석하는 것도 이해에 큰 도움이 된다는 것을 알게 되었습니다.

 

 

#Open Problem 4(solved by 안성준)

sin(x)+sin(x^2) =exp(x) 함수를 정해봤습니다.



코드를 다음과 같이 입력한 결과 너무 복잡한 식이라 교점이 바로 구해지지 않았습니다.

텍스트이(가) 표시된 사진

자동 생성된 설명

함수의 개형을 통해 근을 유추하고자 다음과 같이 입력하였습니다.

주기는 sin함수의 마디인  (-pi , pi) 설정하였습니다.

결과 흥미로운 그래프가 나왔습니다

근을 엄밀히 유추하기 위해 범위를 줄였습니다.

 범위를 줄인 결과 근이 명확히 있었습니다.

근이 -2.624 근접한 것을 확인할 있습니다.

마지막으로 find root 통해 근을 찾은 결과입니다.

텍스트이(가) 표시된 사진

자동 생성된 설명

이상입니다. 감사합니다!

Comment : Solve Equation을 할 때, 근이 sol_equation 함수로 구하기 어려울 때, 그래프를 통해 추정할 수 있다는 사실을 알고는 있었으나, 직접 코드를 통해 문제를 해결해 보니, 그 개념을 더 또렷하게 이해할 수 있었습니다. 단순히, 그래프만 그리는 것이 아니라 그래프를 그리는 최종 목표가 근을 구하고 후에 max/min값들을 분석하기 위함 이라는 생각도 해보았습니다.

Open Problem 4

   

#Open Problem 5(solved by 강민지)

<sol-equation>

solve function 사용하며, x 대한 방정식을 solve(equation, x)형태로 입력한다.



이때 출력값은 [x==]형태로 방정식의 근이 출력된다.



값이 크거나 복잡해 다루기 어려울 경우에는, 그래프를 그려 근사 값을 찾는 것이 효율적인 방법이다.



그래프는 저번 강의에서 처럼 plot function 이용해 그릴 있다.



<vector-operations>

데이터를 순서 쌍이나 튜플 형태로 나타낼 있을 , 이는 2차원 혹은 3차원 데이터 (  n 차원 데이터)  coordinate plane이나 coordinate space 위의  (  n 차원 공간안의  점으로 (표현할 수있다) 나타낼 있다.



point 다루기 위해서 vector 사용한다.

vector 이용해   쉽게 시각화   있고, vector 성질을 통해 다양한 계산을   있다.

vector function 이용하며, vector(좌표)형식으로 입력한다.

(vector print 함수) 혹은 (var plot3d 함수) 이용해, 이를 시각화 하여 출력값을 있다.





1) f(x)=5/1-x^2에 대하여 0.3~3^(1/2)+0.05 까지 붉은 선 그래프를 출력하고, 0.5~3^(1/2)까지 f(x) x축 까지 영역을 색칠하여 출력합니다.

 여기서, sqrt는 제곱근을 계산합니다.



2) f(x)에서 색칠 영역에 대하여 integral 합니다.



3) 해당 근사 값을 5자리 수로 출력합니다.



1) var function을 통해, 'x,y,z' 변수의 3차원 좌표를 설정합니다.



2) (x,-5,5),(y,-5,5),(z,-5,5) 영역 상의 x+y == 5 라는 graph plot3d 함수를 이용해 출력합니다.





Q(강민지) 첫 문제에서 simplify.full() 함수는 무엇을 의미할까요?

A(이상구 교수님) simplify.full() 명령어는 위의 복잡한 숫자를 ... 보기좋은 모습/이해하기쉬운/이용하기쉬운/간단한 숫자로 표현해 줍니다.

 

Comment : 첫 문제에서 integral을 그래프 상 영역으로 표시하여, 계산 과정을 시각화 해 더 쉽게 이해할 수 있었습니다. 두번째 문제에서는, vector operation이 하나의 point를 지정하고 이들이 모여 하나의 영역을 출력하는 과정을 코드를 통해 이해할 수 있었습니다. 또한 코드 실행 과정 중에 낯선 코드가 있어 교수님과의 질의응답을 통해 답을 얻어 궁금증을 해결할 수 있었습니다.

 

#Open Problem 6(solved by 강민지)

with 6x6 matrix

[000100]

[001000]

[414410]

[000001]

[223021]

[100100]

 6x6 행렬을 이용하여, 전치행렬이 존재하고 역행렬이 존재하지 않음을 확인했습니다.



-transposed matrix

테이블이(가) 표시된 사진

자동 생성된 설명

exists.



-inverse matrix

텍스트이(가) 표시된 사진

자동 생성된 설명

doesn't exist.

 

Comment : 6X6행렬을 만들고 이 행렬의 전치행렬, 역행렬의 존재여부를 확인해보았습니다. 아직 미분적분학 밖에 수강하지 않아, 행렬이라는 개념을 처음 접해 전치행렬과 역행렬에 대해 이해하는 것이 조금 어려웠지만, 강의와 인터넷 검색들을 통해 이해하고 문제도 해결할 수 있었습니다.

 

 

#Open Problem 7(solved by 고재윤)

Open Problem 7

What kinds of data can you apply the similarity measures we just discussed?



"What kinds of data can you apply the similarity measures we just discussed (Distance similarity)?"

Using the distance similarity, we can determine the color similarity. Defining the 3-dim vectors as an rgb pair, and later calculating Euclidean distance between them.



두가지 이상의 데이터를 비교하는 방법 하나로 데이터 사이의 거리를 구하는 방법이 있습니다

텍스트, 손목시계이(가) 표시된 사진

자동 생성된 설명

식은 'Euclidean distance' 대한 공식으로, 좌표에서 A(a1, a2) B(b1, b2)사이의 거리를 나타내는 공식입니다.

공식을 기초로 하여 데이터 사이의 연관성 또는 similarity 구할 있습니다. 대표적으로, RGB 표를 통해 두가지 이상의 빛들의 similarity 쉽게 알아낼 있습니다



 그림은 RGB 표를 나타낸 것입니다

우리가 전자기기를 통해 보는 빛의 색은 빛의 삼원색인 빨강 (R) , 초록 (G), 파랑(B) 세가지 색의 조합으로 그림과 같은 많은 종류의 색을 표현할 있습니다

, 데이터는 3-dim vector 표현됩니다. 우리는 데이터간의 거리로 데이터간의 similarity 판단할 있을 것입니다. (Distance Similarity)



color1 = [1, 2, 3], color2= [11, 22, 33], color3= [12, 23, 34]라는 가지 데이터가 있다고 가정해보도록 하겠습니다.

벡터의 성분은 [R,G,B]이고, 성분의 크기는 성분의 세기를 뜻합니다.

color1 color2 어떤 색이 color3 비슷한 색인지 알기 위해( Distance Similarity 구하기 위해아래와 같이 코딩하였습니다. 

텍스트이(가) 표시된 사진

자동 생성된 설명

여기서 bool() 명령어는 괄호 안의 조건문이 참이면 True, 거짓이면 False 출력하는 명령어입니다



위와 같이 코딩한 결과 아래와 같이 출력되었습니다.

따라서 Color2 Color1보다 Color3 비슷한, similarity 높은 데이터라는 것을 있었습니다.

 

Comment : RGB Color Similarity를 구하기 위해 vector operation을 도입해 Similarity를 구하는 과정을 이해할 수 있었습니다. Vector operation을 어떻게 실생활에 적용할까 하는 문제에 대해 답을 찾기 어려웠는데, 이 글을 보고 Similarity를 적용할 수 있는 데이터에 대한 개념을 완벽히는 아니지만, 어느정도 이해할 수 있었습니다.

 

 

 

#Open Problem 8(solved by 문태의)

[Open Problem 8]

What kind of data you cannot use this similarity measure using the distance? Any other measures that you can think of? (Hint: Vectors/Data in the same directions)

"Can you think of the data you cannot apply to the similarity measure we just discussed (Distance similarity)?"



데이터 유사성을 측정하기 위해 'Euclidean distance'방식을 적용할 없는 데이터는 문장입니다.



예를 들어 다음과 같은 문장이 있다고 생각해보겠습니다.

  1. 인공지능 수학 어려워
  2. 인공지능 과학 어려워
  3. 인공지능 수학 어려워 인공지능 수학 어려워 인공지능 수학 어려워

보기에 가장 유사한 문장은 1번과 3번입니다.



문장의 데이터 유사성을 측정하기 위해 'Euclidean distance'방식을 사용해보겠습니다.

우선  문장이 단어를 몇개나 갖고 있는지 표로 나타내보겠습니다.



인공지능

수학

과학

어려워

1

1

1

0

1

2

1

0

1

1

3

3

3

0

3





 문장을 벡터로 나타내고 데이터 간의 거리를 구하는 코드를 작성합니다.



결과는 다음과 같습니다.



값이 낮을수록 데이터가 유사도가 높은 것입니다.

2 문장과 3 문장이 가장 유사도가 떨어지는 것은 어느정도 예상한 결과이나,

1 문장이 3 문장보다 2 문장과 유사하다는 결과가 도출되었습니다.

단순히 데이터 간의 거리를 사용하기 때문에 일어난 결과라고 있습니다.

이러한 데이터의 경우 데이터의 거리를 비교하는 방법으로는 유사도를 비교하기 어려워 보입니다.



따라서 해당 데이터의 유사도를 측정하기 위해서는 코사인 유사도(Cosine Similarity) 방식을 사용해야 합니다.

코사인 유사도는 벡터가 이루는 각이 작을수록 유사도가 높은 것으로 보는 방식으로, 각이 작을수록 코사인 값이 1 가까워지고 각이 클수록 코사인 값이 -1 가까워집니다.

벡터의 코사인 값은 벡터의 내적을 이용해 다음과 같이 구할 있습니다.



아까 예시로 문장의 유사도를 이번엔 코사인 유사도 방식을 사용하여 구해보겠습니다.

결과는 다음과 같습니다.

아까 말했듯이 결과 값은 -1~1 범위를 가지며, 1 가까울수록 데이터 유사도가 높고, -1 가까울수록 데이터 유사도가 낮습니다.

이번 결과에서는 1 문장과 3 문장이 가장 유사하다는 결과를 도출하였습니다.

 문장의 벡터가 크기만 다를뿐 방향이 같기 때문에 도출되는 결과라고 생각할 있습니다.

Comment : Vector Similarity를 적용할 수 있는 데이터와 없는 데이터에 대해 완벽하게 이해하지 못한 상태였는데, 이글을 보고 조금 더 정확하게 이해할 수 있었습니다. 벡터 데이터를 문장으로 예시를 들어 설명을 해주셔서 이해에 큰 도움이 되었습니다.

 

 

#Open Problem 9(solved by 정운섭)

Open Problem 9 



Make (randomly generate) two 7-dimensional vectors and then calculate the distance between two vectors. [Hint: Lab <Distance similarity> ]



My code to solve this problem is shown below (and practiced in https://sagecell.sagemath.org/ )



v1= random_vector(QQ, 7, x=-10, y=10)
v2= random_vector(QQ, 7, x=-10, y=10)

print(v1)
print()
print(v2)
print()

dist= (v1-v2).norm()
print(dist)
print()
print(dist.numerical_approx().n(digits=3))



I generated two 7-dimensional vectors consisting of rational numbers by putting QQ in random_vector() function. 

Then I used norm() function to calculate the distance between v1 and v2. 

In order to find the exact numerical value of distance, I used print(dist.numerical_approx().n(digits=3)) code. 

The following is the result of this code





The result comes out as I expected. Hope this can help you





***

Open Problem 9 Solution by 고재윤 + about 'ZZ' and 'QQ'

Open Problem 9

Make (randomly generate) two 7-dimensional vectors and then calculate the distance between two vectors.

(Hint: Lab <Distance similarity>) http://matrix.skku.ac.kr/math4AI-tools/distance_similarity/ 

"Randomly generate two 7-dim vectors and then calculate the distance between two vectors."



저는 아래 정운섭 학우님의 Problem 6 Solution 질문글을 보고 random 함수에서 ZZ, QQ 의미를 새롭게 알게되었습니다.

주어진 값의 범위에 대하여 ZZ 정수값을 랜덤으로 입력한다는 뜻이었고, QQ 유리수, 정수를 포함한 분수값들도 랜덤으로 입력될 있다는 뜻입니다.

Open Problem 9에서 7-dimensional vector 2개를 만들어야 한다는 내용이 있는데, 새롭게 알게된 내용을 확인해볼겸 vector1 ZZ, vector2 QQ 이용하

랜덤함수로 나타내도록 하겠습니다.



문제를 풀이하기 위해 아래와 같이 코딩하였습니다

텍스트이(가) 표시된 사진

자동 생성된 설명

결과 아래와 같은 결과값이 출력되었습니다.

의도했던 것처럼 vector1 정수값으로만 이루어진 벡터로 랜덤하게 만들어졌고, vector2 정수가 아닌 유리수들로도 만들어 졌다는 것을 확인할 있었습니다.

결과값은 번째 줄처럼 출력되었는데, sqrt(5523309) 1/630 분모에 곱해지는 형태인지, 분자에 곱해지는 형태인지 헷갈리는 형태로 출력되었습니다.

계산기로 계산한 결과, sqrt(5523309) 분자에 곱해지는 형태였습니다.

제가 겪었던 것처럼 결과값의 출력이  헷갈리게 출력된 분들은 글을 참고하셨으면 좋겠습니다!! 

Comment : random_vector를 만드는 것에 있어서, ZZQQ의 차이를 간결하게 정리해주셔서 vector정의에 대해 정확한 이해를 할 수 있었습니다.

 

Open Problem 10

What kinds of data can you apply the cosine similarity to?

 A. 

We can use cosine similarity to analyze and classify data. For example, you can find people who are similar to you by specifying your personal preferences, and recommend a variety of things that people like you like. Recommended programs such as movies and clothes can be represented.

 

많은 학우님들이 이미 Open Problem 10 문제에 대해 풀이해 주셨습니다.

풀이해주신 내용을 보며 저도 많이 배워가던 도중, 윤상수 학우님의 Open Problem 10 풀이에서 BMI Cosine Similarity Similarity 판단할 있다는 글을

보게 되었습니다. 아래 사진은 윤상수 학우님의 Open Problem 10 solution 입니다.



#Open Problem 10(solved by 신유정, 남상현)

Q. What kinds of data can you apply a cosine similarity measure to?

A. 

We can use cosine similarity to analyze and classify data. For example, you can find people who are similar to you by specifying your personal preferences, and recommend a variety of things that people like you like. Recommended programs such as movies and clothes can be represented.

 

 

Open Problem 10

What kinds of data can you apply the cosine similarity to?



[Finalized by 신유정, 남상현] Open problem 10 solution



For analyzing the data of preference, it is a good way to apply the cosine similarity. To apply it, we should change the data to the vector, and then we can measure the cosine similarity.



I made a random data related to reference. There are three groups of different sizes, and different preferences at the three products, X, Y, Z.



테이블이(가) 표시된 사진

자동 생성된 설명



I could make three vectors of three groups, such as [138, 79, 187], [46, 27, 61], and [139, 81, 2960].



텍스트이(가) 표시된 사진

자동 생성된 설명



Using cosine similarity, similarity in preference between the three groups was derived.

텍스트이(가) 표시된 사진

자동 생성된 설명

By this method, we can analyze and classify data focusing on similarity.

Comment : 벡터 유사도를 적용하지 못하는 데이터들은 코사인 유사도 방식을 도입해볼 수 있다는 것까지 이해한 상태에서 이 문제를 접하게 되었습니다. 선호도를 코사인 유사도를 적용하여 유사도를 비교하는 과정을 보면서, 벡터 유사도, 코사인 유사도를 통해 데이터를 비교 분석하는 것에 대한 개념을 조금 더 이해할 수 있었습니다.

 

[HW4] Problem 10 (Solution) by 윤상수

Q. What kinds of data can you apply a cosine similarity measure to?

A. Cosine similarity measure can be applied to data concerining pattern or direction of vector.

  - BMI index(Body Mass Index): ratio between height ant weight. When weight and height is given as data, we can measure similarity between BMI index by comparing (weight, height) vector's direction.

  - GNI (Glycemic Index) per person (GNI/population): When GNI and population is given as data, we can measure similarity between GNI per person by comparing (GNI, population) vector's direction.


* The glycemic index (GI/ɡlaɪˈsiːmɪk/[1]) is a number from 0 to 100 assigned to a food, with pure glucose arbitrarily given the value of 100, which represents the relative rise in the blood glucose level two hours after consuming that food. FROM https://en.wikipedia.org/wiki/Glycemic_index 

1개의 댓글

고재윤(2020####97)12 16 오후 10:49

BMI 경우 몸무게와 키의 비율이므로, 각도로 비교하는 cosine similarity 방법에 적합한 예제인 같습니다. 좋은 예시 감사합니다!!





BMI 몸무게/(^2) 으로 나타낼 있는 식입니다. BMI 같거나 유사하려면, 몸무게와 키의 제곱의 비율이 같거나 유사한 값이어야 합니다.

y축을 몸무게, x축을 ^2이라고 놓았을 , BMI 값은 arctan(몸무게/(^2))으로 표현 가능하고, BMI 유사도는 각도에따라 결정되는 형태가 됩니다.

, cosine similarity 적용하여 판단할 있는 형태가 됩니다

개인적으로 cosine similarity 계산은 어느정도 익숙해졌지만, 실생활에 적용되는 경우를 찾기 어려웠기에 경우를 학우님들께 소개해드리고 싶었습니다.



아래 사진은 내용의 이해를 돕기 위하여 제가 그린 그림입니다.

보시는 바와 같이 y축이 몸무게, x축이 ^2 좌표평면에서, BMI similarity cos similarity 판단할 있기 때문에, 같은 각도를 가지고 있는 a1, a2, a3, a4

모두 같은 BMI값을 가지고 있다는 것을 있습니다.



실제 있을법한 사람의 키와 몸무게로 2-dim vector 4개를 아래 사진과 같이 만들어보았습니다. person1 person2,3,4와의 cosine similarity 

각각 구해보았습니다.

 

 

결과 아래와같은 결과값이 출력되었습니다.

 



BMI값은 x>0, y>0 구역에서만 위치하므로 person1 BMI값이 유사할수록 cos similarity 1 가까운 값이 출력됨을 있었습니다.

person4 경우 cos similarity값이 1 나왔는데, 실제로 person4 데이터로 BMI 계산한 결과, person1 같은 값으로 나왔습니다.



8개의 댓글

이상구(LEE SANGGU)12 17 오전 1:04

Supurb! Bonus +1

윤상수(2020####53)12 17 오전 1:41

제가 제시한 예시를 시각화하고 실제 코드로 실행한 예시까지 보여주셔서 감사합니다. 특히 그림으로 표현하니 글로만 설명하는 것보다 훨씬 전달력이 생기는 같습니다.

김지훈(2020####97)12 17 오전 1:46

비율이기에 방향성이 중요하다는 것은 알았지만 추상적인 이해였는데, 그리신 그래프를 통해 기울기에 대한 이해로 바뀌면서 방향이 유사성을 사용하는 것이 좀더 구체화되어서 좋았습니다!

이상구(LEE SANGGU)12 17 오전 11:39

Good. Final OK by SGLee

황세진(2015####21)12 17 오후 11:17

실생활에서 자주 사용하는 수치인 BMI 가지고 예시를 들어주셔서 COS similarity 대한 이해에 도움이 많이 되었습니다! 감사합니다

이상구(LEE SANGGU)12 18 오후 4:17

Finalized OK by SGLee

이규식(2018####70)12 18 오후 10:13

BMI 예시가 적절해서 좋은 이해가 되었습니다. 감사합니다.

이예진(2017####54)12 21 오전 11:52

수식으로만 배웠던 것을 이렇게 실생활 예시로 들어주시니 실제 활용에 대해 관심이 생겼습니다. 감사합니다 !

Comment : Data유사도와 비교방식들에 대한 이해를 하였습니다.

 

[Final OK by SGLee] Open problem12/ solution by 김지훈

작성자 : 김지훈(2020####97)작성일 : 12 16 오후 8:56

조회수 : 28



3x4 matrix   solution set 풀어보았습니다.



2x+2y-z+w=4

4x+3y-z+2w=6

8x+3y-3z+2=12



A = matrix([[2,2,-1,1],[4,3,-1,2],[8,5,-3,2]])
b = vector([4,6,12])
Ab = A.augment(b)

print(A)
print()
print(Ab)
print()
print(Ab.rref())
print()
print(A.solve_right(b))



x = 1/2 , y + w = 1 , z + w = -1 , w = w 결과가 나왔고 w 값이 0으로 도출되었습니다.

 

2개의 댓글

이상구(LEE SANGGU)12 16 오후 9:10

Good^^ 의미는 해가 무수히 많으며, 해집합은 { (x, y, z, w) = (1/2 , 1 , -1, r) : r is any real numbers } 라는 무수히 많은 해를 갖는 일차연립방정식이라는 의미입니다. 우리는 중에서 어떤 해가 최적해 인지를 찾는 것을 배워서, AI 에게 앞으로 그런 최적해를 찾으라고 ... 코딩을 하여 ... 시키는 것이랍니다. 이번학기에서 배우는 것이 그런 내용이랍니다.

 

이상구(LEE SANGGU)12 16 오후 9:12

아래 다른 학생들이 문제를 보고 ... 이해 되었으면 Comment 달아 두시고 ... 다른 학생의 좋은 답과 코드를 이용하여 이어지는 다음 문제들을 먼저 풀어서 공유하기 시작하시면, 중간고사에 내용이 많아 질것이고, 발표도 하실 것이고, 그러면 ... 궁극적으로 ... 좋은 성과를 얻을 것이랍니다.

Comment : Solution Set과 해의 종류에 대해 이해하였습니다.

 

Open Problem 5

Open Problem 6

 

 

[Final OK by SGLee] Open problem 14 solved and Finalized by 정운섭, 강민지, 김지훈, 이규식

작성자 : 정운섭(2018####88)작성일 : 12 17 오후 5:58

조회수 : 42

[Final OK by SGLee]   Open problem 14 solved and Finalized  by 정운섭, 강민지, 김지훈, 이규식





#Open Problem 10(solved by 신유정, 남상현)

Q. What kinds of data can you apply a cosine similarity measure to?

A. 

We can use cosine similarity to analyze and classify data. For example, you can find people who are similar to you by specifying your personal preferences, and recommend a variety of things that people like you like. Recommended programs such as movies and clothes can be represented.

 

 

Open Problem 10

What kinds of data can you apply the cosine similarity to?



[Finalized by 신유정, 남상현] Open problem 10 solution



For analyzing the data of preference, it is a good way to apply the cosine similarity. To apply it, we should change the data to the vector, and then we can measure the cosine similarity.



I made a random data related to reference. There are three groups of different sizes, and different preferences at the three products, X, Y, Z.



테이블이(가) 표시된 사진

자동 생성된 설명



I could make three vectors of three groups, such as [138, 79, 187], [46, 27, 61], and [139, 81, 2960].



텍스트이(가) 표시된 사진

자동 생성된 설명



Using cosine similarity, similarity in preference between the three groups was derived.

텍스트이(가) 표시된 사진

자동 생성된 설명

By this method, we can analyze and classify data focusing on similarity.

Comment : 벡터 유사도를 적용하지 못하는 데이터들은 코사인 유사도 방식을 도입해볼 수 있다는 것까지 이해한 상태에서 이 문제를 접하게 되었습니다. 선호도를 코사인 유사도를 적용하여 유사도를 비교하는 과정을 보면서, 벡터 유사도, 코사인 유사도를 통해 데이터를 비교 분석하는 것에 대한 개념을 조금 더 이해할 수 있었습니다.

 

#Open Problem 11(solved by 강민지)

Open Problem 11 : "Make two 5-dim vectors and find the inner product and the angle of two vectors."



먼저, v=[1,2,3,4,5], w=[-1,-2,-3,-4,-5] 개의 5-dimensional vectors들을 만들었습니다.

벡터의 내적vw inner_product function 이용해, vw=v.inner_product(w) 형식으로 입력하였습니다.

벡터의 사잇각은 코사인 유사도를 통해 구하였는데, 이는 아래 식을 통해 계산할 있습니다.

텍스트, 손목시계, 시계, 게이지이(가) 표시된 사진

자동 생성된 설명

마지막으로 유효숫자 3자리로 근삿값을 구해 출력하였습니다.

 

Comment : 코사인 유사도를 이용해 두 벡터 사이 각을 구하는 것을 직접 코드를 통해 실행해보며 이해할 수 있었습니다. 벡터의 내적함수와 코사인 유사도 함수를 이용해 코사인 유사도를 구하고, 이를 통해 각을 구하는 과정을 직접 보며 코사인 유사도의 쓰임을 이해할 수 있었습니다.

 

#Open Problem 12(solved by 윤상수)

Q. Find a system of linear equations from other textbooks. Find a solution to that by using the code that you learned.

This is an example from Engineering Mathematics textbook. I solved this linear system by using code I learned.

*Since the system is not invertible, multiplying the inverse matrix is impossible.

 

Comment : Linear Equation을 적용하는 하나의 예시를 볼 수 있어 이해에 도움이 되었습니다. 단순한 방정식이라고만 생각하던 것이 여러 계산의 기본이 된다는 생각을 하게 되었습니다.

 

 

 

#Open Problem 13(solved by 윤상수)

Q. Explain how and what we can determine for a given linear system of equations with a unique solution or infinitely many solutions, or no solutions. Use an RREF of [A : b] to do this. Explain to others what you understand.

A. As explained in the textbook, we can determine if the matrix has unique solution or infinitely many solutions, or no solutions like below.

 from http://matrix.skku.ac.kr/LA/Ch-3/ 

If there are no solutions, we can simply determine that we have no solution.

If there  is a unique solution, we can determine the  exact solution (vector).

If there are infinitely many solutions, we can determine the solution  set  by more than one vector. 

  (Only Ax=0 can have a solution space (.. Spanned by a basis of the solution space.) = the Solution set.)

Any vector from the solution set is also a solution of the linear system of equations.



Comment : Linear equation system RREF를 통해서, 해의 개수에 대한 정의를 할 수 있다는 것을 이해할 수 있었습니다. RREF라는 용어가 생소하였지만, 강의와 QnA들을 통해 이해할 수 있었습니다.

 

 

#Open Problem 14(solved by 정운섭)

Open Problem 14 



Discuss the conditions for the existence of the inverse matrix of (A^T)*A and find a least-squares solution for the given 6-points in R^2 to make the curve of y= a+bx+cx^2+dx^3





First, I set the given 6 points for the curve to be (xi, yi) = { (1,2), (2,4), (3,1), (4,-2), (5, 3), (6, 10) }. Then, A= [ [1, 1, 1, 1], [1, 2, 4, 8], [1, 3, 9, 27], [1, 4, 16, 64], [1, 5, 25, 125], [1, 6, 36, 216] ] ,  



u= (a, b, c, d),  y= (2, 4, 1, -2, 3, 10), where A*u = y.  To find a least-squares solution for this 6 points, I used equation u* = ((A^T)*A)^(-1)*(A^T)*y. 



The conditions for the existence of the inverse matrix of (A^T)*A 



if ( xi != xj ) for all ( i != j ), then inverse of (A^T)*A always exists

else if ( xi == xj ) for some ( i != j ), we need to check whether rref (reduced row echelon form) for the (A^T)*A is an identity matrix 



In this case, ( xi != xj ) for all ( i != j ), there is no need to check for the rref of (A^T)*A

The following is code I wrote to find least-squares solution 



A = matrix([[1, 1, 1, 1], [1, 2, 4, 8], [1, 3, 9, 27], [1, 4, 16, 64], [1, 5, 25, 125], [1, 6, 36, 216]])

y = vector([2, 4, 1, -2, 3, 10])

print("u* =", (A.transpose()*A).inverse()*A.transpose()*y)





The result showed values exactly same as the ones I calculated with my hands. 



Comment : Least Square Solution개념을 처음 접하여 이해하기 힘들었는데, 하나의 케이스를 두고 자세한 과정을 설명해주셔서 내용을 이해하는 데 도움이 되었습니다.

 

 

 

#Open Problem 15(solved by 고재윤, 남상현)

Open Problem 15

Find a system of linear equations problem from other textbooks. Then find that problem's least-squares solution using the same method as in example 4.



http://matrix.skku.ac.kr/intro-math4ai/W6/  example 4에서 사용한 least-squares solution 구하는 방법은  QR decomposition 이용한 방법입니다.

QR decomposition이란 mXn coefficient matrix A (m>=n) column 대하여 orthonormal mXn matrix Q , invertible upper triangular nxn matrix R 

분리하는 것입니다. 식으로 나타내면  A=Q*R 나타납니다.



Ax=b 형태의 식에서, QR decomposition 이용하면 Q*R*x=b 나타낼 있습니다. orthonormal matrix Q Q*(Q^T) = I 라는 특성이 있으므로, 방금 다뤘던 

식의 양변에 Q^T 곱하면 R*x=(Q^T)*b 나타낼 있습니다. 이번에는 양변에 R^(-1) 곱하면 x=( R^(-1) )*(Q^T)*b 나타낼 있습니다

최종적으로 Q, R 구해 각각 transpose, inverse 형태로 바꾼 값을 구하면, x 값을 있습니다.



아래 그림은 other text book에서 가져온 least-squares solution 구하는 문제 입니다.

텍스트, 시계, 다른이(가) 표시된 사진

자동 생성된 설명

위에서 설명한내용을 토대로 least squares solution 구하기 위해 아래와 같이 코딩하였습니다

텍스트이(가) 표시된 사진

자동 생성된 설명

실행한 결과 아래와 같이 결과가 출력되었습니다.

테이블이(가) 표시된 사진

자동 생성된 설명

textbook 해설 부분과 비교하니 같은 값으로 x 계산되었습니다.



이번 문제를 통해 헷갈렸던 QR decomposition 다시 살펴볼 있어서 뜻깊었다고 생각합니다. 익숙하지 않은 개념인 만큼 혹시 제가 실수한 부분이 있다면 

코멘트로 알려주시면 감사하겠습니다!!

 

밑의 코드를 응용하여 least-squares solution 통해 quadratic approximation 구하고 visualize하고자 하였습니다.

테이블이(가) 표시된 사진

자동 생성된 설명

다음과 같은 방법으로 Au = y form 나타내고, 이를 QR decomposition 이용하여 LLS 구한다면 suitable curve 역시 구할 있습니다.





텍스트이(가) 표시된 사진

자동 생성된 설명



4개의 데이터를 통해 suitable curve 구했으며, 이를 visualize하여 확인하였습니다.



실행 결과는 다음과 같습니다.



이상구(LEE SANGGU)12 17 오후 8:05

Good job!

강민지(2021####12)12 17 오후 11:55

개념이 복잡하여 이해하기 힘들었는데, 중요 부분을 정리해주셔서 내용 이해할 있었습니다. 감사합니다!

김지훈(2020####97)12 18 오후 12:52

실제 풀이과정을 보니까 이해하는데 도움이 많이 되었습니다. 감사합니다!

이규식(2018####70)12 18 오후 9:20

least-squares solution 공부하면서 어려웠던 내용이었는데 이해에 도움이 된것 같습니다. 감사합니다!

Comment : Least squares solution에 대해 이해하게 되었습니다.

Comment : Decomposition이라는 개념을 처음 배우면서, 헷갈리는 부분이 많았습니다. 문제들을 풀어도 이해가 되지 않았었는데, QnA에 올라오는 다른 학우분들의 풀이들을 보며 조금이나마 이해를 할 수 있었습니다.

#Open Problem 16(solved by 도경근, 응즈웨이)

Open Problem 16

Find the SVD for a matrix from the other textbook by using the codes above.



R 사용하여 martix svd값을 찾아보고 분석을 해보았습니다.

텍스트이(가) 표시된 사진

자동 생성된 설명

특잇값 분해는 데이터 정보를 압축해주는 기능이 있습니다. 여기서 확인할수 있는 점은 특잇값 벡터 d 첫번째 두번째 세번째 원소값에 비하여 4번째 원소 값이 비교적 작다는 것을 알수 있습니다.따라서원래 데이터의 3/4만큼의 데이터인 처음 3개의 특잇값과 U, V 1~3열만 사용하여도 원래 데이터에 대한 대표성이 충분하고 정보 손실이 작다고 판단할수 있습니다.



이것이 실제로 그런지 한번 확인 해보기 위해서 처음 3개의 특잇값과 U, V 1~3열만 사용하여 matrix reconstruct 해보았습니다.

테이블이(가) 표시된 사진

자동 생성된 설명

보시다시피 원래 데이터와 거의 유사하다는 점을 확인 있었습니다.



또한 처음 2개의 특잇값과 U, V 1~2열만 사용하여 matrix reconstruct 해보았습니다

테이블이(가) 표시된 사진

자동 생성된 설명

역시 원래 데이터와 유사하지만 중요할 가능성이 높은 마지막 행의 데이터들이 모두 사라진 모습이 눈에 띕니다.



이번 HW에서는 matrix svd값을 구해보고 그것이 어떤 의미를 가지고, 어떻게 쓰일수 있을지 고민해보는 시간을 가질수 있어서 유익했습니다. 감사합니다.

 

 

Find SVD of a rectangular 4 by 5 matrix which is bigger than 3 by 3.  

테이블이(가) 표시된 사진

자동 생성된 설명

테이블이(가) 표시된 사진

자동 생성된 설명



***

Comment : Decomposition에서도 SVD decomposition을 이해하는 데 가장 오랜 시간이 걸렸습니다. 낯선 개념이면서, 행렬에 대한 여러 개념이 없는 상태에서 이해하기가 조금 힘들었습니다. 그래도 QnA와 인터넷을 통해 이해할 수 있었습니다. 특히, 2번째 Webex 강의에서 교수님께서 보충설명해주신 부분이 이해에 큰 도움이 되었습니다.

 

open problem 16/ solution by 김지훈, Find the SVD of a large size matrix, How to compute Singular value decomposition of a large matrix

Find the SVD of a large size matrix



7 x 5 matrix

[0,0,0,2,2]

[0,0,0,3,3]

[0,0,0,1,1]

[1,1,1,0,0]

[2,2,2,0,0]

[5,5,5,0,0]

[1,1,1,0,0]





A = matrix(RDF, [[0,0,0,2,2], [0,0,0,3,3],[0,0,0,1,1],[1,1,1,0,0],[2,2,2,0,0],[5,5,5,0,0],[1,1,1,0,0]])  #Define A matrix
U, S, V = A.SVD()  # A = U*S*V' # A's SVD
print("U = ")
print(U)
print()
print("S = ")
print(S)
print()
print("V = ")
print(V)
print()
print("A = USV^T = ")
print(U*S*V.transpose())





 



대부분의 값이 근사치로 기존 행렬과 같은 나온것을 보게되었습니다.





*** How to compute Singular value decomposition of a large matrix



 https://scicomp.stackexchange.com/questions/36509/how-to-compute-singular-value-decomposition-of-a-large-matrix-with-python 

svd of very large matrix  

in https://examples.dask.org/machine-learning/svd.html 

Compute SVD of Tall-and-Skinny Matrix

For many applications the provided matrix has many more rows than columns. In this case a specialized algorithm can be used.

[2]:
import dask.array as da
 
X = da.random.random((200000, 100), chunks=(10000, 100)).persist()
[3]:
import dask
 
u, s, v = da.linalg.svd(X)
dask.visualize(u, s, v)
[3]:

../_images/machine-learning_svd_5_0.png

[4]:
v.compute()
[4]:
array([[ 0.09993234,  0.09995762,  0.10011045, ...,  0.09985778,
         0.10010164,  0.09989095],
       [-0.02177618, -0.01356872, -0.18910737, ..., -0.0258583 ,
        -0.17951209, -0.12678571],
       [ 0.03625153, -0.1048528 , -0.10448132, ...,  0.12855183,
        -0.03525576,  0.1437841 ],
       ...,
       [ 0.04582307, -0.0881445 ,  0.06870504, ...,  0.07030875,
        -0.07871533,  0.03790137],
       [-0.04886309, -0.14288723, -0.04492749, ..., -0.05153435,
         0.03370203, -0.06754169],
       [ 0.14041453, -0.04605695, -0.15269878, ...,  0.08523776,
        -0.01104652,  0.09100753]])

Compute SVD of General Non-Skinny Matrix with Approximate algorithm

이상구(LEE SANGGU)12 22 오전 10:15

OK^^ The First ^^ Others may improve this try~~

이상구(LEE SANGGU)12 22 오후 4:36

Note: How to compute Singular value decomposition of a large matrix the SVD of a large size matrix : It may use and ask a computer with more memory - a matrix of size 1,100,000 x 1,100 takes about 9GB of memory. *** https://scicomp.stackexchange.com/questions/36509/how-to-compute-singular-value-decomposition-of-a-large-matrix-with-python  svd of very large matrix in https://examples.dask.org/machine-learning/svd.html 

 

 

Comment : SVD의 특징을 이해하고 큰 행렬의 SVD를 구하였습니다.

 

Day 7 Open Problem 1

 

#Open Problem 1(solved by 남상현)

 Open Problem 1 

Find the third derivative of a differentiable function from the textbook.



First, I choose the differentiable function from the textbook,

The function is differentiable for every x, so we can define a derivative of f(x).

To find the third derivative of the function, first, we should check if the derivative is still differentiable. 

If it is checked, we can find the second derivative of the function. Also, we should check if the second derivative is differentiable. 

If it is checked, now we can find the third derivative of the function.



By using diff() function, we can find the third derivative of the function. And this is the result.



텍스트이(가) 표시된 사진

자동 생성된 설명

As we can see, they are differentiable, and I could find the third derivative of the function.

 

Comment : 함수의 도함수를 Sage언어를 사용하여, diff() function를 통해 구해볼 수 있었습니다. 단순 계산이라도, 코드를 통해 계산하는 과정이 색다른 경험이었습니다.

 

 

 

#Open Problem 2(solved by 고재윤)

Open Problem 2 



Find a complicated twice differentiable function in other textbooks, and use the code to find the local maximum, the local minimum,

the absolute maximum, and the absolute minimum of the function.





아래 식은 JAMES STEWART " CALCULUS Early Transcendentals for Scientists and Engineers"에서 찾은 입니다. 



f(x) x 대한 3rd order polynomial function이기 때문에, 두번 미분 가능한( twice differentiable function) 이라고 있습니다.

[-5, 5] 범위에서 f(x) local maximum, local minimum, absolute maximum, absolute minimum sage 이용하여 구해보도록 하겠습니다.



먼저 f(x) second differentiable function인지 알기 위하여, 만약 그렇다면 그것의 extreme point 구하기 위하여 다음과 같이 코딩하고

결과값을 출력하였습니다. 

텍스트이(가) 표시된 사진

자동 생성된 설명



extreme point에서 f(x) 모양을 자세히 보기 위해  코드 p =plot(f(x),(x,-5,5)) p=plot(f(x), (x,0,2)) 바꾸어 다시 출력하였습니다.





 결과 위와 같은 그래프가 그려졌고, x=2/3에서 local maximum, x=2에서 local minimum 갖는 다는 것을 있습니다.

번째 코딩에서 f(2/3) < f(5)  , f(2) > f(-5)라는 것을 확인할 있었기 때문에, 정리하면 [-5,5] 범위에서 f(x)

f(2/3) = local maximum, f(2) = local minimum, f(5) = absolute maximum, f(-5) = absolute minimum  갖는다는 것을 있습니다.



각각의 수치를 알기 위해 필요한 내용을 추가하여 다음과 같이 코딩하였고, 결과가 나왔습니다.

텍스트이(가) 표시된 사진

자동 생성된 설명

 

Comment : 함수의 그래프를 그리고, local min/max 찾는 과정을 코드를 통해 직접 실행하며 이해할 수 있었습니다. 이 문제에서도 x값의 범위를 조절해가며 그래프의 개형을 변경해보는 것이 유의미한지 분석해 보고 싶습니다.

 

 

 

#Open Problem 3(solved by 윤상수)

The code I've used is as below.

f(x) = 9*x^2 - 7*x + 6   # function
df(x) = diff(f(x), x)   # derivative
x0 = 0.0   # the initial iterate
tol = 1e-6   # the tolerance level
eta = 0.1    # the learning rate
for k in range(300):

    g0 = df(x0)

    if abs(g0) <= tol:

        print("Algorithm Succeed!")
        break

    x0 = x0 - eta*g0

print("x* =", x0)
print("|g*| =", abs(g0))
print("f(x*) =", f(x0))
print("iteration number  =", k + 1)



텍스트, 화이트보드이(가) 표시된 사진

자동 생성된 설명

---------------------------------------------

The result is as follows.

Algorithm Succeed!

x* = 0.388888940082364

|g*| = 9.21482552485031e-7

f(x*) = 4.63888888888891

iteration number  = 72



텍스트이(가) 표시된 사진

자동 생성된 설명

 

Comment : GDM 통해 최소값을 구하는 내용들을 정리해주셔서 이해하는 데 큰 도움이 되었습니다. GDM을 통해 최소값을 구하는 이유는 항상 최적을 구하는 것을 우선시 함이 이유라는 교수님의 말씀을 이해할 수 있었습니다. 또한, 최대값을 구할 때는 -를 곱하여 최소값을 구하는 방식을 사용할 수 있다는 내용을 이해할 수 있었습니다.

GDM(Gradient Descent Method)

Gradient descent is an iterative optimization algorithm for finding the local minimum of a function.

The goal of the gradient descent algorithm is to minimize the given function (say cost function). To achieve this goal, it performs two steps iteratively:

1.      Compute the gradient (slope), the first order derivative of the function at that point

2.      Make a step (move) in the direction opposite to the gradient, opposite direction of slope increase from the current point by alpha (learning rate) times the gradient at that point

Learning Rate: a tuning parameter in the optimization process. It decides the length of the steps.

[Final OK by SGLEE] Open problem3 by 김지훈

작성자 : 김지훈(2020####97)작성일 : 12 24 오전 2:28

조회수 : 36

GDM 코드를 Open problem3 통해 연습해보았습니다



f(x) = 9*x^2 - 7*x + 6   # function
show(plot(f(x), (x, -2, 2)))
df(x) = diff(f(x), x)   # derivative
x0 = 0.0   # the initial iterate
tol = 1e-6   # the tolerance level
eta = 0.1    # the learning rate
for k in range(300):

    g0 = df(x0)

    if abs(g0) <= tol:

        print("Algorithm Succeed!")
        break

    x0 = x0 - eta*g0

print("x* =", x0)
print("|g*| =", abs(g0))
print("f(x*) =", f(x0))
print("iteration number  =", k + 1)

 





값이 도출되는 것을 보게 되었습니다.

이상구(LEE SANGGU)12 25 오후 5:21

OK. ^^

이상구(LEE SANGGU)12 29 오후 3:27

Please Finalize this^^

남궁보민(2017####00)12 30 오전 6:10

Learning rate 0.11 되어도 주어진 Iteration(300) 내에 값을 찾을 없는데 적절한 값을 설정하신 같아요. 덕분에 간단하게 GDM 이용해 Local minimim 구하는 과정을 경험했습니다.

 

Comment : GDM에 대해 이해하였습니다.

 

GDM Algorithm with steps tracking

Choose a starting point, calculate gradient at point, make step in opposite direction, calculate gradient and make step unless max iteration reached or step size smaller than tolerance

Data and Covariance Matrix

Covariance Matrix is a measure of how much two random variables gets change together. It is actually used for computing the covariance in between every column of data matrix.

The covariance matrix provides a useful tool for separating the structured relationships in a matrix of random variables. This can be used to decorrelate variables or applied as a transform to other variables. It is a key element used in the Principal Component Analysis data reduction method.

V is a c x c variance-covariance matrix

N is the number of scores in each of the c data sets

xi is a deviation score from the ith data set

Σ xi2 / N is the variance of elements from the ith data set

Σ xi xj / N is the covariance for elements from the ith and jth data sets

PCA(Principal Components Analysis)

Principal component analysis (PCA) is a technique for reducing the dimensionality of such datasets, increasing interpretability but at the same time minimizing information loss. It does so by creating new uncorrelated variables that successively maximize variance.

Rank Reduction and the role of SVD in PCA

Dimensionality reduction. Matrix factorization methods can be used to reduce a dataset matrix into its constituent parts. Examples include the eigendecomposition and singular value decomposition. The parts can then be ranked and a subset of those parts can be selected that best captures the salient structure of the matrix that can be used to represent the dataset. The most common method for ranking the components is principal components analysis.

 

BP(Back-Propagation) algorithm in ML(Machine Learning) and ANN(Artificial Neural Network)

BP algorithm is used to effectively train a neural network through a method called chain rule. In simple terms, after each forward pass through a network, backpropagation performs a backward pass while adjusting the model’s parameters (weights and biases).

[Final OK by SGLee] open problem 4 solution by 정운섭, 황세진, 응즈웨이 (finding solutions to various equation using sage) and question

응즈웨이(2019####51)12 19 오전 6:16

Thank you for your answer for Open Problem 4. Since the graph will have infinite x solutions as the graph move towards negative infinity, I will look for other x values from interval -5 to -10. Thanks!

 

 

Open Problem 1 



Explain how a singular value decomposition (SVD) is used in the principal component analysis.



Through the process below, I tried to derive the PCA equation using SVD.





Based on what we discussed in SVD, let's think about the above conclusion.

Similar to SVD, the digonal matrix is arranged in order of size, so e1 is the direction with the largest variance,

e2 is the next to e1, and the direction perpendicular to e1....


One of the characteristics of SVD that we learned was dimension reduction.

Except for low-importance vectors, recombination results similar to the original matrix. This can also be applied to PCA.



***************

정운섭 학우님께서 잘못된 부분을 알려주셨습니다.

마지막 결론 식에서 PC SCORE이 잘못 표기되었습니다.

B= U*Σ*(V^T) 에서 U*Σ 가 PC SCORE 입니다.

이상구(LEE SANGGU)12 28 오전 3:19

Good point.

정운섭(2018####88)12 28 오후 12:18

공분산행렬을 직교대각화 했을 , 대각행렬의 성분이 가지는 의미와 직교행렬이 가지는 의미를 정리해주셔서 좋았습니다! 다만, 위의 note에서 공분산행렬을 직교대각화 하였을 앞의 행렬의 곱이 PC score 되는 것이 맞나요?? 제가 알기로는 B SVD분해 했을 나오는 B=USV^T 에서 행렬 U S 곱이 PC score 되는 것으로 알고 있어서요...

고재윤(2020####97)12 28 오후 1:07

학우님께서 생각하신 내용이 맞는 같습니다. 지금 바로 수정하도록 하겠습니다. 알려주셔서 감사합니다!! 수정하였습니다!!

위의 토론의 주요 부분만 요약하면 Finalize and Re-Finalize 있을 것입니다.

이규식(2018####70)12 28 오후 8:57

PCA 과정에 SVD 사용되는 방식을 설명해주신 같습니다. 감사합니다!

김지훈(2020####97)12 29 오전 1:33

PCA에서 SVD 통해 주축과 주성분점수를 구할수 있다는 것을 이해하는데 많은 도움이 되었습니다. 감사합니다!

우건주(2017####97)12 29 오전 11:23

교수님께서 PCA SVD 관계가 중요하다고 말씀하셨던 것이 어렵게 다가왔는데 이해에 도움이 같습니다. 감사합니다!

이규리(2018####45)12 29 오후 10:58

SVD PCA 관계가 이해가 어려웠는데, 식을 자세히 풀어써주셔서 PCA 도출 과정을 이해할 있었습니다. 감사합니다.

Comment : PCA에서 SVD가 사용되는 것을 학습하였습니다.

 

Open Problem 14 by 안성

응즈웨이(2019####51)12 21 오후 1:57

I understood. Thank you very much! :)

Open Problem 15 by 안성

응즈웨이(2019####51)12 21 오후 1:59

Thank you very much for your contribution! I understood your work. Thanks! :)

ALL Must read This!! [Sample, Re-Finalized OK by SGLee] Open Problem 16 [Re-Finalized by Ng Zhi Wei(응즈웨이), 이규식, 남상현, 이예진, 고윤진, 고재윤, 도경은, 황세윤, 신유정, 박우현, 이예진, 남상현, 도경근, 이규식] (Solutions and Comments) Find SVD of a rectangular 4 by 5 matrix which is bigger than 3 by 3.

Open Problem 1 by 남상

응즈웨이(2019####51)12 21 오전 00:22

Hi! Thank you very much and your codes work perfectly fine! :) However, just for sharing, I used a while loop to tackle this problem as I find it more efficient that way. If interested, do take a look at my post at "Day 7 Open Problem 1 by Ng Zhi Wei (using while loop)". Thanks!

[News] The Future of Jobs in the Era of AI (인공지능 시대의 진로와 직업)

응즈웨이(2019####51)12 21 오후 12:52

I am curious if is it possible for a Bachelor degree holder to find an AI-related job in Korea? Or do most AI companies in Korea require a Master or PhD degree as a requirement? Thanks!

[Final OK by SGLee] Summary for 3rd Webex Meeting (12/28), Dear 응즈웨이 Ng Zhi Wei Software 3rd year and 이우흠/ LIYuxin/

응즈웨이(2019####51)12 28 오후 12:53

I understood the above. Thank you very much!

[Question] What exactly does 'Linear Regression' mean?

응즈웨이(2019####51)12 31 오전 6:41

Linear regression is a linear approach for modelling the relationship between a scalar response and one or more explanatory variables (also known as dependent and independent variables). The case of one explanatory variable is called simple linear regression; for more than one, the process is called multiple linear regression. In linear regression, the relationships are modeled using linear predictor functions whose unknown model parameters are estimated from the data.

 

I think the link below is a good website to read about and gain knowledge on linear regression. Feel free to read it.

https://machinelearningmastery.com/linear-regression-for-machine-learning/

Gradient Decent Method 관한 간략한 정리와 GDM 최초점과 관련해 윤상수 학우님께서 올려주신 질문 게시글과 댓글로부터 배운

응즈웨이(2019####51)12 31 오전 6:38

Thank you for sharing the part on learning rate! :)

Finalise Code a Neural Network with Backpropagation In Python by 이우흠

응즈웨이(2019####51)12 31 오전 6:34

Thank you very much for the code and explanation! :)

using SVD to perform PCA

응즈웨이(2019####51)12 31 오전 6:35

Thank you for the code! I will test it out soon. ^^

 

·         그리고 (첨부한) PBL 보고서에 <자기평가>, <동료평가> + <자신이 QnA 업로드한 Question and Answer (Reply) 모아서주어진 첨부 형식에 맞추어 내용을 채워서 Due Day 전에 제출하시오. 양과 질을 평가하여 해당성적을 부여합니다.  [The First or The Best!]

 

그리고 중간고사와 기말고사에 여러분이 학습하고 PBL 보고서에 제출한 내용을 반영합니다.

PBL Participation Part (30 points) ß- Most important part

Number of your QnA participation up to the Due date. ( 23 total entries )

 

 

[Yours to be added]  -- 아래 공간에 여러분이 QnA 에 공개하여 답을 얻고 이해하였고, 중간/기말에 모아서 발표 할 수 있는 것들은 모두 모아서 윤문한 후 각 문제에 코멘트를 달아서 하나의 파일로 과제함에 전체 하나의 차일을 제출하시면 됩니다.

Self-Evaluation 4

PBL Participation Part (30 points) ß- Most important part

Number of your QnA participation up to the Due date. ( ** total entries )

 

TOTAL: 32

 

open problem 2 (solution) by 윤상수

작성자 : 윤상수(2020####53)작성일 : 12 14 오후 3:16

조회수 : 19

텍스트이(가) 표시된 사진

자동 생성된 설명

Above is an original graph I plotted. I magnified the graph to see it more close at the origin.

텍스트이(가) 표시된 사진

자동 생성된 설명

 

 

Finalized OK by SGLee Open problem #1 우건주,고재윤

작성자 : 우건주(2017####97)작성일 : 12 15 오후 1:25

조회수 : 35

1 문제는 다른 학생분들께서 많이 풀어주셨지만 

Sage 낯설어서 개인적인 연습차원으로 진행해보았습니다.



open problem1.png

다항함수 중에서 f(x)=f(-x) 특성을 가진 함수를 선택해서 plot하였습니다.



open problem1_2.png

다항함수 중에서 f(x)=-f(-x) 특성을 가진 함수를 선택해서 plot하였습니다.



open problem1_3.png

함수는 앞선 함수처럼 독특한 성질을 갖진 않지만,

개형이 직관적으로 다가오지 않아서 plot해보았습니다.



이상구(LEE SANGGU)12 15 오후 2:41

했습니다. 초보자면 연습삼아 보시고 ... 다른 학생 보고 ... Comment 달면서 배워 가세요^^

고재윤(2020####97)12 16 오후 10:31

y 대칭 그래프, 원점 대칭 그래프의 특성을 한눈에 있어서 좋았습니다. 나중에 sage 기억나지 않을 , 학우님이 보여주신 예제들을 한번씩 그려보면 도움이 같습니다. 좋은 예시 감사합니다!!

윤상수(2020####53)12 18 오후 11:48

여러가지 다양한 함수들의 개형을 프로그램으로 그려주셔서 공부하는 도움이 되었습니다.

남상현(2018####17)12 21 오전 10:55

종류별로 분류하여 함수들의 개형을 이해하기 쉽게 plot해주신 같습니다. 감사합니다!

이예진(2017####54)12 21 오후 12:08

저도 다양한 그래프를 통해 설명해주시니 직관적 이해에 도움이 되었습니다 .감사합니다 !

 

Finalized OK by SGLee Open Problem 7 Solution by 고재윤, 황세진, 이예진, 강민지, 이규식, 윤상수, 남상현, 박우현

작성자 : 고재윤(2020####97)작성일 : 12 15 오후 2:59

조회수 : 43

Finalized OK by SGLee  Open Problem 7 Solution by 고재윤, 황세진, 이예진, 강민지, 이규식, 윤상수, 남상현, 박우현

Open Problem 7

What kinds of data can you apply the similarity measures we just discussed?



"What kinds of data can you apply the similarity measures we just discussed (Distance similarity)?"

Using the distance similarity, we can determine the color similarity. Defining the 3-dim vectors as an rgb pair, and later calculating Euclidean distance between them.



두가지 이상의 데이터를 비교하는 방법 하나로 데이터 사이의 거리를 구하는 방법이 있습니다. 

텍스트, 손목시계이(가) 표시된 사진

자동 생성된 설명

식은 'Euclidean distance' 대한 공식으로, 좌표에서 A(a1, a2) B(b1, b2)사이의 거리를 나타내는 공식입니다.

공식을 기초로 하여 데이터 사이의 연관성 또는 similarity 구할 있습니다. 대표적으로, RGB 표를 통해 두가지 이상의 빛들의 similarity 쉽게 알아낼 있습니다. 



 그림은 RGB 표를 나타낸 것입니다. 

우리가 전자기기를 통해 보는 빛의 색은 빛의 삼원색인 빨강 (R) , 초록 (G), 파랑(B) 세가지 색의 조합으로 그림과 같은 많은 종류의 색을 표현할 있습니다.

, 데이터는 3-dim vector 표현됩니다. 우리는 데이터간의 거리로 데이터간의 similarity 판단할 있을 것입니다. (Distance Similarity)



color1 = [1, 2, 3], color2= [11, 22, 33], color3= [12, 23, 34]라는 가지 데이터가 있다고 가정해보도록 하겠습니다.

벡터의 성분은 [R,G,B]이고, 성분의 크기는 성분의 세기를 뜻합니다.

color1 color2 어떤 색이 color3 비슷한 색인지 알기 위해( Distance Similarity 구하기 위해 ) 아래와 같이 코딩하였습니다. 

텍스트이(가) 표시된 사진

자동 생성된 설명

여기서 bool() 명령어는 괄호 안의 조건문이 참이면 True, 거짓이면 False 출력하는 명령어입니다



위와 같이 코딩한 결과 아래와 같이 출력되었습니다.

따라서 Color2 Color1보다 Color3 비슷한, similarity 높은 데이터라는 것을 있었습니다.

 

이전

다음

10개의 댓글

고재윤(2020####97)12 15 오후 3:10

One of the ways to compare two or more data is to find the distance between the two data. (Equation Figure) The above equation is a formula for 'Euclidean distance', which represents the distance between points A(a1, a2) and B(b1, b2) at the coordinates. Based on this formula, the association or similarity between the two data can be obtained. Typically, RGB tables make it easy to find out the similarity of two or more lights. (RGB table ) The figure above shows the RGB table. The color of light we see through electronic devices is a combination of three primary colors, red (R), green (G), and blue (B), so we can express many kinds of colors like the picture above. In other words, color data is expressed as 3-dimvector. We will be able to determine the similarity between data by the distance between color data.(Distance Similarity)  Let's assume that there are three color data: color 1 = [1, 2, 3], color 2 = [11, 22, 33], and color 3 = [12, 23, 34]. The component of each vector is [R, G, B], and the size of the component means the strength of the component. To find out which color is more similar to color 3 (to obtain Distance Similarity), we coded as follows.  (Input Figure) Here, the bool() command is a command that outputs True if the conditional statement in parentheses is true and False if it is false. (Output Figure)  As a result of coding as above, it was printed as follows. Therefore, it was found that Color2 was more similar to Color3 than Color1.

이상구(LEE SANGGU)12 15 오후 4:42

Wonderful~~ You are the First on Day 3 problem^^ + 1

이예진(2017####54)12 15 오후 10:12

... 감사합니다 진짜 어려운 개념일 알았는데 이렇게 정리해주셔서 바로 이해되었습니다

강민지(2021####12)12 16 오후 9:52

RGB 벡터 개념이 복잡하여 이해하기 힘들었는데, 중요 부분을 정리해주셔서 내용 이해할 있었습니다. 감사합니다!

이상구(LEE SANGGU)12 17 오전 6:04

I am very happy that you got it^^ 단과대 1등은 모두 A 주려고 합니다^^

황세진(2015####21)12 17 오후 9:07

RGB 3차원 벡터로 표현하여 거리를 구하고 가까운 거리에 위치할수록 비슷한 색이라는 내용을 너무 정리해주셔서 이해하기 쉬웠습니다. 감사합니다!

이규식(2018####70)12 18 오후 8:07

데이터 간의 거리를 간의 유사도를 판별하는 지표로 활용하는 것이 인상적이었습니다. 좋은 이해가 되었습니다 감사합니다!

윤상수(2020####53)12 18 오후 11:50

실제 와닿는 예를 통해 개념을 확실히 공부할 있었습니다. 감사합니다.

남상현(2018####17)12 21 오전 10:47

Distance similarity color 통해 접근하신 방법이 참신하고 이해하기 쉬운 같습니다. 감사합니다!

박우현(2016####31)12 21 오전 10:56

단순 수학적인 접근 뿐만 아니라 RGB표를 이용한 해석이 흥미로운 같습니다

 

Finalized OK by SGLee Open Problem 8 Solution by 문태의, 김지훈, 깅민지

작성자 : 문태의(2016####21)작성일 : 12 15 오후 10:41

조회수 : 61

[Open Problem 8]

What kind of data you cannot use this similarity measure using the distance? Any other measures that you can think of? (Hint: Vectors/Data in the same directions)

"Can you think of the data you cannot apply to the similarity measure we just discussed (Distance similarity)?"



데이터 유사성을 측정하기 위해 'Euclidean distance'방식을 적용할 없는 데이터는 문장입니다.



예를 들어 다음과 같은 문장이 있다고 생각해보겠습니다.

1.     인공지능 수학 어려워

2.     인공지능 과학 어려워

3.     인공지능 수학 어려워 인공지능 수학 어려워 인공지능 수학 어려워

보기에 가장 유사한 문장은 1번과 3번입니다.



문장의 데이터 유사성을 측정하기 위해 'Euclidean distance'방식을 사용해보겠습니다.

우선  문장이 단어를 몇개나 갖고 있는지 표로 나타내보겠습니다.



인공지능

수학

과학

어려워

1

1

1

0

1

2

1

0

1

1

3

3

3

0

3





 문장을 벡터로 나타내고 데이터 간의 거리를 구하는 코드를 작성합니다.

텍스트이(가) 표시된 사진

자동 생성된 설명



결과는 다음과 같습니다.



값이 낮을수록 데이터가 유사도가 높은 것입니다.

2 문장과 3 문장이 가장 유사도가 떨어지는 것은 어느정도 예상한 결과이나,

1 문장이 3 문장보다 2 문장과 유사하다는 결과가 도출되었습니다.

단순히 데이터 간의 거리를 사용하기 때문에 일어난 결과라고 있습니다.

이러한 데이터의 경우 데이터의 거리를 비교하는 방법으로는 유사도를 비교하기 어려워 보입니다.



따라서 해당 데이터의 유사도를 측정하기 위해서는 코사인 유사도(Cosine Similarity) 방식을 사용해야 합니다.

코사인 유사도는 벡터가 이루는 각이 작을수록 유사도가 높은 것으로 보는 방식으로, 각이 작을수록 코사인 값이 1 가까워지고 각이 클수록 코사인 값이 -1 가까워집니다.

벡터의 코사인 값은 벡터의 내적을 이용해 다음과 같이 구할 있습니다.



아까 예시로 문장의 유사도를 이번엔 코사인 유사도 방식을 사용하여 구해보겠습니다.

텍스트이(가) 표시된 사진

자동 생성된 설명



결과는 다음과 같습니다.



아까 말했듯이 결과 값은 -1~1 범위를 가지며, 1 가까울수록 데이터 유사도가 높고, -1 가까울수록 데이터 유사도가 낮습니다.

이번 결과에서는 1 문장과 3 문장이 가장 유사하다는 결과를 도출하였습니다.

 문장의 벡터가 크기만 다를뿐 방향이 같기 때문에 도출되는 결과라고 생각할 있습니다.

 

이전

다음

10개의 댓글

김지훈(2020####97)12 15 오후 11:39

유사도측정 방식의 비교가 직관적으로 이해가 잘되는 예시인것 같아서 도움이 많이 됬습니다!! '유사하다' 의미는 같은 단어를 얼마나 공유하는지로 정의하신건가요?? 그러면 확실히 같은패턴을 분석하는 것이 초점인 데이터는 거리유사도보다 코사인유사도를 사용하는 것이 적절하다.... 라고 이해하면 될까요?

고재윤(2020####97)12 16 오전 2:30

'Euclidean distance'방식을 적용할 없는 데이터를 가정하는게 어렵다고 생각했었는데, 예시를 들어 설명해 주셔서 이해가 되었습니다. 다른 예시들도 생각해보도록 하겠습니다!!

문태의(2016####21)12 16 오후 6:28

김지훈님께, 문장이 같은 단어를 공유할수록 유사도가 높습니다. 이러한 방식을 사용해서 관련 검색과 같은 기능을 구현할 있지 않나 생각합니다.

강민지(2021####12)12 16 오후 9:58

Euclidean Distance 방식이 어려워 이해하기 힘들었었는데, 중요 부분을 정리해주셔서 내용 이해할 있었습니다. 감사합니다!

이상구(LEE SANGGU)12 17 오전 5:48

Good job.

이상구(LEE SANGGU)12 17 오전 11:45

Finilize this^^

이규식(2018####70)12 18 오후 8:46

유클리디안 거리를 이용한 유사도 측정에 대해 치밀하게 이해하게 되었습니다. 문제 제기와 그에 따른 해결법까지 제시해주셔서 매우 이해가 쉬웠습니다. 감사합니다.

윤상수(2020####53)12 18 오후 11:52

개념에 맞는 예시를 통해 효과적으로 내용을 보여주신 같습니다. 감사합니다.

남상현(2018####17)12 21 오전 10:53

Euclidean Distance Cosine Simiarity 대해 설명해주신 같습니다. 감사합니다!

이예진(2017####54)12 21 오후 12:11

ㅎㅎ 이렇게 문장 예시로 들어주시니 친근하고 이해가 되었습니다. 감사합니다 !

 

Finalized OK by SGLee [HW4] Problem 10 (Solution) by 윤상수, 고재윤,우건주, 이예진, 이규식, 남상현,

Finalized OK by SGLee [HW4] Problem 10 (Solution) by 윤상수, 고재윤,우건주, 이예진, 이규식, 남상현



Q. What kinds of data can you apply a cosine similarity measure to?

A. Cosine similarity measure can be applied to data concerining pattern or direction of vector.

  - BMI index(Body Mass Index): ratio between height ant weight. When weight and height is given as data, we can measure similarity between BMI index by comparing (weight, height) vector's direction.

  - GNI (Glycemic Index) per person (GNI/population): When GNI and population is given as data, we can measure similarity between GNI per person by comparing (GNI, population) vector's direction.


*
 The glycemic index (GI/ɡlaɪˈsiːmɪk/[1]) is a number from 0 to 100 assigned to a food, with pure glucose arbitrarily given the value of 100, which represents the relative rise in the blood glucose level two hours after consuming that food. FROM https://en.wikipedia.org/wiki/Glycemic_index 

5개의

고재윤(2020####97)12 16 오후 10:49

BMI 경우 몸무게와 키의 비율이므로, 각도로 비교하는 cosine similarity 방법에 적합한 예제인 같습니다. 좋은 예시 감사합니다!!

우건주(2017####97)12 17 오후 8:36

(height)^2 (weight) 비율을 나타낸 것이므로 x축에는 (height)^2, y축에는 (weight) 설정하여 다양한 표본들의 세타값을 구한다면 표본들끼리의 코사인 유사도를 알아볼 있을 같습니다. 좋은 예시를 제공해주셔서 감사합니다.

이예진(2017####54)12 18 오후 3:53

cosine similarity 벡터 관계에 대한 얘기로만, 수학책 예시로만 이해했는데 이렇게 친근한 예시를 들어주시니 더욱 흥미로운 같습니다. 감사합니다 !

이규식(2018####70)12 18 오후 10:30

코사인 유사도의 적절한 예시를 선택해주신 같습니다. 감사합니다!

남상현(2018####17)12 21 오전 10:58

Cosine similarity 적용되는 다양한 예시를 알게 되었습니다. 감사합니다!

Finalized OK by SGLee open problem 12 (solution) by 윤상수, 김지훈, 정운섭, 강민지, 이규식,

작성자 : 윤상수(2020####53)작성일 : 12 16 오후 5:22

조회수 : 45

Finalized OK by SGLee  open problem 12 (solution) by 윤상수, 김지훈, 정운섭, 강민지, 이규식, 



Q. Find a system of linear equations from other textbooks. Find a solution to that by using the code that you learned.

텍스트이(가) 표시된 사진

자동 생성된 설명

This is an example from Engineering Mathematics textbook. I solved this linear system by using code I learned.

텍스트이(가) 표시된 사진

자동 생성된 설명

*Since the system is not invertible, multiplying the inverse matrix is impossible.

이전

다음

6개의 댓글

이상구(LEE SANGGU)12 16 오후 5:49

What if we have a 3 by 4 matrix A and a 4 by 1 vector b as Ax = b. In that case, we have to find the Solution set. The SOLUTION set should be { bold x = (x, y, z, w) } in R^4. Hope someone add one more example of such case. (Finding a SOLUTION set problem.)

김지훈(2020####97)12 16 오후 9:14

교수님 3x4 matrix A 4x1 vector b 예시로 Backpropagation in neural network 수학적 계산과정을 생각해도 되나요?

이상구(LEE SANGGU)12 17 오전 5:40

아직은 그럴 필요까지는 없습니다. 쉽고 빠르게 진도 나가시면 됩니다.

정운섭(2018####88)12 17 오후 7:43

linear equations solution 코드로 구하는 방법을 이해하는 도움이 되었습니다!

강민지(2021####12)12 17 오후 11:55

개념이 복잡하여 이해하기 힘들었는데, 중요 부분을 정리해주셔서 내용 이해할 있었습니다. 감사합니다!

이규식(2018####70)12 18 오후 9:11

코딩을 활용하여 행렬을 Reduced Row Echelon Form으로 변환하는 좋은 예시를 들어주신 같습니다. 감사합니다.

 

Finalized OK by SGLee open problem 13 (solution) by 윤상수, 고재윤, 박우현, 이규식, 강민지, 남상현, 이예진,

Finalized OK by SGLee  open problem 13 (solution) by 윤상수, 고재윤, 박우현, 이규식, 강민지, 남상현, 이예진



Q. Explain how and what we can determine for a given linear system of equations with a unique solution or infinitely many solutions, or no solutions. Use an RREF of [A : b] to do this. Explain to others what you understand.

A. As explained in the textbook, we can determine if the matrix has unique solution or infinitely many solutions, or no solutions like below.

 from http://matrix.skku.ac.kr/LA/Ch-3/ 

텍스트이(가) 표시된 사진

자동 생성된 설명

If there are no solutions, we can simply determine that we have no solution.

If there are  is a unique solution, we can determine the an exact solution (vector).

If there are infinitely many solutions, we can determine the solution  set space spanned by more than one vector.

  (Only Ax=0 can have a solution space (.. Spanned by a basis of the solution space.) = the Solution set.)

Any vector from the solution set is also a solution of the linear system of equations.



고재윤(2020####97)12 16 오후 9:55

강의를 들으면서 암기하기 어려웠던 내용들을 보기 쉽게 정리해주셔서 도움이 되었습니다!!

박우현(2016####31)12 18 오후 3:19

augmented matrix RREF 통해 해의 존재 유무와 해의 갯수를 파악하는 과정이 설명된 같습니다.

이규식(2018####70)12 18 오후 9:17

이해에 도움이 되었습니다. 감사합니다!

강민지(2021####12)12 20 오후 7:24

개념이 복잡하여 이해하기 힘들었는데, 중요 부분을 정리해주셔서 내용 이해할 있었습니다. 감사합니다!

남상현(2018####17)12 21 오전 10:56

RREF 통해 해의 개수를 판별하는 방법을 쉽게 설명해주신 같습니다. 감사합니다!

이예진(2017####54)12 21 오후 12:06

부분이 특히 여러모로 중요한 같은데 정리해주셔서 감사합니다 !

문태의(2016####21)12 22 오후 2:45

덕분에 RREF 사용하여 선형 방정식의 해를 구하는 방법에 대해 쉽게 이해할 있었습니다!

 

Final OK by SGLee [Finalized by 윤상수, 고재윤] Open Problem 10 Solution...김지훈, 윤상수, 황세진, 이규

Final OK by SGLee [Finalized by 윤상수, 고재윤] Open Problem 10 Solution...김지훈, 윤상수, 황세진, 이규



Open Problem 10

What kinds of data can you apply the cosine similarity to?



많은 학우님들이 이미 Open Problem 10 문제에 대해 풀이해 주셨습니다.

풀이해주신 내용을 보며 저도 많이 배워가던 도중, 윤상수 학우님의 Open Problem 10 풀이에서 BMI Cosine Similarity Similarity 판단할 있다는

보게 되었습니다. 아래 사진은 윤상수 학우님의 Open Problem 10 solution 입니다.







[HW4] Problem 10 (Solution) by 윤상

Q. What kinds of data can you apply a cosine similarity measure to?

A. Cosine similarity measure can be applied to data concerining pattern or direction of vector.

  - BMI index(Body Mass Index): ratio between height ant weight. When weight and height is given as data, we can measure similarity between BMI index by comparing (weight, height) vector's direction.

  - GNI (Glycemic Index) per person (GNI/population): When GNI and population is given as data, we can measure similarity between GNI per person by comparing (GNI, population) vector's direction.


*
 The glycemic index (GI/ɡlaɪˈsiːmɪk/[1]) is a number from 0 to 100 assigned to a food, with pure glucose arbitrarily given the value of 100, which represents the relative rise in the blood glucose level two hours after consuming that food. FROM https://en.wikipedia.org/wiki/Glycemic_index 

고재윤(2020####97)12 16 오후 10:49

BMI 경우 몸무게와 키의 비율이므로, 각도로 비교하는 cosine similarity 방법에 적합한 예제인 같습니다. 좋은 예시 감사합니다!!



BMI 몸무게/(^2) 으로 나타낼 있는 식입니다. BMI 같거나 유사하려면, 몸무게와 키의 제곱의 비율이 같거나 유사한 값이어야 합니다.

y축을 몸무게, x축을 ^2이라고 놓았을 , BMI 값은 arctan(몸무게/(^2))으로 표현 가능하고, BMI 유사도는 각도에따라 결정되는 형태가 됩니다.

, cosine similarity 적용하여 판단할 있는 형태가 됩니다

개인적으로 cosine similarity 계산은 어느정도 익숙해졌지만, 실생활에 적용되는 경우를 찾기 어려웠기에 경우를 학우님들께 소개해드리고 싶었습니다.



아래 사진은 내용의 이해를 돕기 위하여 제가 그린 그림입니다.

보시는 바와 같이 y축이 몸무게, x축이 ^2 좌표평면에서, BMI similarity cos similarity 판단할 있기 때문에, 같은 각도를 가지고 있는 a1, a2, a3, a4

모두 같은 BMI값을 가지고 있다는 것을 있습니다.



실제 있을법한 사람의 키와 몸무게로 2-dim vector 4개를 아래 사진과 같이 만들어보았습니다. person1 person2,3,4와의 cosine similarity 

각각 구해보았습니다.

테이블이(가) 표시된 사진

자동 생성된 설명

 결과 아래와같은 결과값이 출력되었습니다.

테이블이(가) 표시된 사진

자동 생성된 설명



BMI값은 x>0, y>0 구역에서만 위치하므로 person1 BMI값이 유사할수록 cos similarity 1 가까운 값이 출력됨을 있었습니다.

person4 경우 cos similarity값이 1 나왔는데, 실제로 person4 데이터로 BMI 계산한 결과, person1 같은 값으로 나왔습니다.

이상구(LEE SANGGU)12 17 오전 1:04

Supurb! Bonus +1

윤상수(2020####53)12 17 오전 1:41

제가 제시한 예시를 시각화하고 실제 코드로 실행한 예시까지 보여주셔서 감사합니다. 특히 그림으로 표현하니 글로만 설명하는 것보다 훨씬 전달력이 생기는 같습니다.

김지훈(2020####97)12 17 오전 1:46

비율이기에 방향성이 중요하다는 것은 알았지만 추상적인 이해였는데, 그리신 그래프를 통해 기울기에 대한 이해로 바뀌면서 방향이 유사성을 사용하는 것이 좀더 구체화되어서 좋았습니다!

이상구(LEE SANGGU)12 17 오전 11:39

Good. Final OK by SGLee

황세진(2015####21)12 17 오후 11:17

실생활에서 자주 사용하는 수치인 BMI 가지고 예시를 들어주셔서 COS similarity 대한 이해에 도움이 많이 되었습니다! 감사합니다

이상구(LEE SANGGU)12 18 오후 4:17

Finalized OK by SGLee

이규식(2018####70)12 18 오후 10:13

BMI 예시가 적절해서 좋은 이해가 되었습니다. 감사합니다.

이예진(2017####54)12 21 오전 11:52

수식으로만 배웠던 것을 이렇게 실생활 예시로 들어주시니 실제 활용에 대해 관심이 생겼습니다. 감사합니다 !

 

Final OK by SGLee Open Problem 15 Solution by 고재윤, 문태의, 이예진, 정운섭, 강민지, 남상현, 이규식, 윤상

Final OK by SGLee  Open Problem 15 Solution by 고재윤, 문태의, 이예진, 정운섭, 강민지, 남상현, 이규식, 윤상



Open Problem 15

Find a system of linear equations problem from other textbooks. Then find that problem's least-squares solution using the same method as in example 4.



http://matrix.skku.ac.kr/intro-math4ai/W6/  example 4에서 사용한 least-squares solution 구하는 방법은  QR decomposition 이용한 방법입니다.

QR decomposition이란 mXn coefficient matrix A (m>=n) column 대하여 orthonormal mXn matrix Q , invertible upper triangular nxn matrix R

분리하는 것입니다. 식으로 나타내면  A=Q*R 나타납니다.



Ax=b 형태의 식에서, QR decomposition 이용하면 Q*R*x=b 나타낼 있습니다. orthonormal matrix Q Q*(Q^T) = I 라는 특성이 있으므로, 방금 다뤘

식의 양변에 Q^T 곱하면 R*x=(Q^T)*b 나타낼 있습니다. 이번에는 양변에 R^(-1) 곱하면 x=( R^(-1) )*(Q^T)*b 나타낼 있습니다

최종적으로 Q, R 구해 각각 transpose, inverse 형태로 바꾼 값을 구하면, x 값을 있습니다.



아래 그림은 other text book에서 가져온 least-squares solution 구하는 문제 입니다.

텍스트, 시계, 다른이(가) 표시된 사진

자동 생성된 설명

위에서 설명한내용을 토대로 least squares solution 구하기 위해 아래와 같이 코딩하였습니다

텍스트이(가) 표시된 사진

자동 생성된 설명

실행한 결과 아래와 같이 결과가 출력되었습니다.

테이블이(가) 표시된 사진

자동 생성된 설명

textbook 해설 부분과 비교하니 같은 값으로 x 계산되었습니다.



이번 문제를 통해 헷갈렸던 QR decomposition 다시 살펴볼 있어서 뜻깊었다고 생각합니다. 익숙하지 않은 개념인 만큼 혹시 제가 실수한 부분이 있다

코멘트로 알려주시면 감사하겠습니다!!

고재윤(2020####97)12 17 오전 5:58

문제풀이에 사용된 코드입니다!! def gs_orth(A): m, n = A.nrows(), A.ncols() r = A.rank() if m < n: raise ValueError("The number of rows must be larger than the number of columns.") elif r < n: raise ValueError("The matrix is not full column rank.") [G, mu] = A.transpose().gram_schmidt() Q1 = matrix([G.row(i) / G.row(i).norm() for i in range(0, n)]) R1 = Q1*A Q = simplify(Q1.transpose()) R = simplify(R1) return Q, R A = matrix([[1, 3, 5], [1, 1, 0], [1, 1, 2], [1, 3, 3]]) b = vector([3, 5, 7, -3]) Q, R = gs_orth(A) print("x =", R.solve_right(Q.transpose()*b))

이상구(LEE SANGGU)12 17 오전 5:59

고재윤 , 아주 이해하셨습니다. 이제 SVD 이해 하실 준비가 되었습니다. You are a good student.

고재윤(2020####97)12 17 오전 6:02

감사합니다!!

정운섭(2018####88)12 17 오후 5:08

글을 보니 least squares solution QR decomposition 으로 구하는 과정이 확실하게 이해되었습니다!

문태의(2016####21)12 17 오후 11:45

덕분에 QR decomposition least square solution 해결하는 방법에 대해 확실히 이해할 있게 되었습니다.

강민지(2021####12)12 17 오후 11:56

QR decomposition 개념이 복잡하여 이해하기 힘들었는데, 중요 부분을 정리해주셔서 내용 이해할 있었습니다. 감사합니다!

남상현(2018####17)12 18 오전 00:14

QR decomposition 통해 보다 쉽게 LLS 구하신 같고 ValueError function으로 예외 경우까지 고려하셔서 너무 좋은 코드 같습니다. 감사합니다!

이예진(2017####54)12 18 오후 4:27

- 감사합니다. 덕분에 이해에 도움이 되었습니다 !

이규식(2018####70)12 18 오후 9:23

이해에 도움이 되었습니다. 감사합니다!

윤상수(2020####53)12 18 오후 11:58

좋은 예시 덕분에 공부하는데 도움이 되었습니다. 감사합니다.

 

Finalized OK by SGLee [Finalized by 도경근, 고재윤 . . . 이예진,이규식, 남상현, 박우현, 신유정, 윤상수] Open Problem 16 Solution

Finalized OK by SGLee [Finalized by 도경근, 고재윤 . . .  이예진,이규식, 남상현, 박우현, 신유정, 윤상수] Open Problem 16 Solution

저는 도경근 학우님의 open problem 16 solution 글을 보고 굉장히 쓰셨다는 생각이 들었고, 새로운 내용에 대해서 생각해보게 되었습니다. SVD 개념이 

어려우신 학우님들의 도경근 학우님께서 작성하신 내용에 대한 이해를 도와드리기 위하여 문제에 대해 finalize 하게 되었습니다.



먼저, 선형 변환 (linear transformation) 대한 개념이 SVD 이해에 도움이 것이라고 생각하여, 선형 변환에 대해 설명드리겠습니다

선형 변환이란 간단히 말해, 자료의 분포는 동일하게 하되 어떤 변수를 사칙연산을 통해 다른 값으로 변환하는 것을 뜻합니다.

여기서 변수는 vector, 사칙연산은 matrix 통해 다른 vector값으로변환할 있습니다.

http://matrix.skku.ac.kr/2012-Album/13.html  링크는 교수님께서 올려주신 자료 선형 변환에 해당하는 내용입니다.



이번에는 아래의 2차원 그림에 대해서 살펴보도록 하겠습니다. 검은 원은 선형변환 하기 전의 x vector (x) y vector (y) 모습이고, 빨간

coefficient matrix A 곱한 A*x vector (Ax) A*y vector (Ay) 모습입니다.

y x 대하여 90도가 되도록 하는 vector라면, 선형 변환 하기 전의 상태에서 y x 대해 모든 direction에서 90도를 유지합니다.

하지만, 선형 변환이 일어난 Ax Ay 사이의 각도는 모든 direction에서 90도라고 보장하지 못합니다.

그림을 가지고 SVD 식을 이해할 있습니다.



우리는 강의를 통해 SVD 식을 A=U*∑*V^T 배웠습니다. 그림을 가지고 각각의 연산자에 대해 살펴보도록 하겠습니다.

A coefficient matrix      

V 선형 변환 서로 직교하던[ x,y] 열벡터     

U Ax, Ay 서로 90도를 이루는 direction에서 각각의 단위 열벡터 [u1, u2] ,

scaling factor 역할을 하는 diagonal matrix라고 두겠습니다.

그렇다면 AV=∑U 라는 식은 션형 변환의 관점에서 생각해보면, 변환 직교했던 벡터가 변환 후에도 직교할 때의 direction 찾는 식이 됩니다.

V orthogonal matrix 이므로 A=U*∑*V^T 나타낼 있고, 이는 강의 시간에 배웠던 SVD 형태가 됩니다.





아래 사진은 도경근 학우님이 작성하셨던 Open Problem 16 solution 입니다.

Open Problem 16 (Solution) by 도경

Open Problem 16

Find the SVD for a matrix from the other textbook by using the codes above.



R 사용하여 martix svd값을 찾아보고 분석을 해보았습니다.

텍스트이(가) 표시된 사진

자동 생성된 설명

특잇값 분해는 데이터 정보를 압축해주는 기능이 있습니다. 여기서 확인할수 있는 점은 특잇값 벡터 d 첫번째 두번째 세번째 원소값에 비하여 4번째 원소 값이 비교적 작다는 것을 알수 있습니다.따라서원래 데이터의 3/4만큼의 데이터인 처음 3개의 특잇값과 U, V 1~3열만 사용하여도 원래 데이터에 대한 대표성이 충분하고 정보 손실이 작다고 판단할수 있습니다.



이것이 실제로 그런지 한번 확인 해보기 위해서 처음 3개의 특잇값과 U, V 1~3열만 사용하여 matrix reconstruct 해보았습니다.

보시다시피 원래 데이터와 거의 유사하다는 점을 확인 있었습니다.



또한 처음 2개의 특잇값과 U, V 1~2열만 사용하여 matrix reconstruct 해보았습니

역시 원래 데이터와 유사하지만 중요할 가능성이 높은 마지막 행의 데이터들이 모두 사라진 모습이 눈에 띕니다.



이번 HW에서는 matrix svd값을 구해보고 그것이 어떤 의미를 가지고, 어떻게 쓰일수 있을지 고민해보는 시간을 가질수 있어서 유익했습니다. 감사합니다.

이상구(LEE SANGGU)12 16 오후 10:30

Very good^^ Share your text code, so others can check your output amd improve it.

도경근(2018####55)12 17 오후 4:08

m1 <- c(0,0,4,0,0,0,1,0, 0,0,0,2,0,0,5,0, 0,1,0,0,1,1,1, 0,3,1,0,0,0,2,2,1) dim(m1) <- c(4,8) m1 cross_svd <- svd(m1) str(cross_svd) cross_svd$d cross_svd$u cross_svd$v round(cross_svd$u[,c(1,2)] %*% diag(cross_svd$d[c(1,2)]) %*% t(cross_svd$v[,c(1,2)])) round(cross_svd$u[,c(1,2,3)] %*% diag(cross_svd$d[c(1,2,3)]) %*% t(cross_svd$v[,c(1,2,3)])) round(cross_svd$u[,c(1,2)] %*% diag(cross_svd$d[c(1,2)]) %*% t(cross_svd$v[,c(1,2)])) text code 입니

고재윤(2020####97)12 17 오후 7:43

학우님의 코딩 방식이 처음보는 방식이어서 처음엔 낯설었는데, text code 매우 간결하게 써진 것을 보고 놀랐습니다. 방식대로 했다면 학우님의 길이의 코딩을 했을텐데, 코딩공부도 해야겠다는 생각이 들었습니다. 또한, 학우님께서 하신 문제풀이 U, V 1,2,3번째 column으로 다시 A 조합하여 원래 A 비교하는 방식이 매우 흥미로웠습니다. 학우님께서 U,V 1,2 번째 column만을 이용하여 A 재조합 하셨을 '중요할 가능성이 높은 마지막 행의 데이터들이 모두 사라진 모습' 이라고 서술해 주셨는데 마지막 행의 데이터가 가장 중요할 가능성이 높은 데이터인지 여쭈어봐도 될까요? 좋은 problem solution 감사합니다!!

이상구(LEE SANGGU)12 17 오후 8:58

12 rank reduction 에서 배울 내용 입니다^^

고재윤(2020####97)12 17 오후 10:17

답변 감사합니다 교수님!!

황세진(2015####21)12 17 오후 11:22

주어진 데이터를 통해 합리적인 추론을 통해 벡터값이 가장 작은 곳을 제외하고 계산했을 때에 원래 데이터에서 손실이 많이 나지 않는 것을 소프트웨어를 통해 간결하게 확인시켜주셔서 한눈에 이해가 되었습니다! 도움이 많이 되었습니다.



도경근 학우님께서는 중요성이 가장 낮은 U V column 제거하고 재조합한 결과, decomposition 하기 전의 matrix 비슷한 값이 나옴

보여주시면서 SVD 특성에 대해 작성해주셨습니다. 방식이 성립하는지 알기 위해 SVD 식을 다시 살펴보도록 하겠습니다.





아래 사진은 SVD A=U*∑*V^T 보다 자세히 서술한 입니다. 

앞서 살펴보았듯이, U*V^T 성분의 크기는 모두 -1에서 1 사이의 값이기 때문에 ∑ 마치 scaling factor 같은 역할을 한다고 있습니다.

 ∑ diagonal matrix이기 때문에 A σ1*u1*v1^T +σ2*u2*v2^T*+..... 쪼개서 나타낼 있습니다

 k번째 σ 값이 다른 σ 값들에 비해 작은 값이라면, 부분은 A라는 데이터를 이루는데에 중요성이 낮다는 것을 뜻함을 있습니다.

따라서 중요성이 낮은 부분, σ 값이 상대적으로 작은 column A 이루는데 부분을 차지하지 않을 것이고, 부분을 제외하고 A 계산해

비슷한 값이 나올 것이라고 생각할 있습니다.



이런 SVD 특성을 이용하면 중요성이 낮은 데이터를 제거함으로써, 압축된 데이터를 표현할 있을 것입니다

반대로, 중요성이 높은 데이터 몇개를 가지고 원래 데이터를 부분복원 하는 것이 가능할 같습니다.

이상구(LEE SANGGU)12 18 오전 5:21

Good job. Great. 다른 학생들도 모두 읽어야 여러분 동료의 SVD 설명 내용입니다.

윤상수(2020####53)12 18 오전 10:42

선형 변환을 함께 설명해주신 것이 이해에 한결 도움이 되는 같습니다. 감사합니다.

신유정(2016####90)12 18 오후 2:35

svd 이해에 막혀 있었는데, 이해하는데 도움이 되었습니다. 감사합니다!

박우현(2016####31)12 18 오후 2:36

SVD 이해하는데 도움이 되었습니다 감사합니

이예진(2017####54)12 18 오후 4:01

인터넷으로 뒤져가며 어렴풋하게 이해한 선형변환, SVD 등의 내용을 이렇게 문서에 일목요연하게 정리해주셔서 정말 도움이 크게 되었습니다. 감사합니다 !

남상현(2018####17)12 18 오후 5:49

시각적 효과와 더불어서 너무 간결하고 쉽게 SVD 관해 정리해주신 같습니다. 감사합니다!

도경근(2018####55)12 18 오후 7:17

안녕하세요 학우님. 제가 작성해주신 글을 finalize 해주셔서 감사합니다. 마지막 행의 데이터가 중요하다고 질문을 해주셨는데, 이부분에서는 제가 설명이 부족했던것 같습니다. 제가 하고싶었던 말은 '데이터를 복원했을때 마지막 행이 아예 사라졌다. 데이터로 어떤 insight 뽑아낼건지에 따라서 결과에 안좋은 영향이 있을 있다' 입니다. SVD 대해서 정성스럽게 요약해주시고 추가적인 설명을 해주셔서 감사합니다. 좋은 연말 보내십시오.

이규식(2018####70)12 18 오후 9:54

SVD 대해 매우 정리해주신 같습니다. 감사합니다!

 

Final OK by SGLee] Open Problem 16 Solution by 남상현 (SVD 동한 데이터 압축의 이해) with 도경근, 고재윤, 황세진, 윤상수, 신유정, 박우현, .남상현, 이규리, 문태의, 이예

[Final OK by SGLee] Open Problem 16 Solution by 남상현 (SVD 동한 데이터 압축의 이해) with 도경근, 고재윤, 황세진, 윤상수, 신유정박우현, .남상현, 이규리, 문태의, 이예진  



도경근 학우님과 고재윤 학우님의 Finalized Open Problem 16 보고 쉽고 정확하게 SVD 이를 이요한 데이터 압축에 관해 이해할 있었으며, 이에 관련하여 깊게 생각해 보게 되었습니다. 데이터 압축에 관하여 세부적인 개념과 이해를 돕고자 Open Problem 16 finalized해보았습니다.



우선 SVD 응용하여 데이터의 연산량을 줄여 데이터 압축을 있는데, 이는 truncated SVD로의 변환을 통해 응용할 있습니다.

m x n matrix SVD 경우, m n보다 작거나 같다면 Σ행렬의 마지막 행에는 singular value 마지막 값이 들어가게 됩니다.

하지만, m>n이라면 m x n size Σ행렬의 아랫부분에는 0으로 구성된 성분이 들어가게 됩니다. 이를 Full SVD라고 합니다.

(Image by : http://matrix.skku.ac.kr/2020-Math4AI-Final-pbl2/ )

singular value 갯수를 s라고 합시다. Σ행렬은 밑에서부터 m-s 만큼의 행이 0으로 구성됩니다. 행렬의 곱을 생각해본다면, U Σ행렬을 곱할 부분은 제거하여도 상관 없는 부분, 크기가 0 데이터가 됩니다. 예시를 들면 다음과 같습니다.

테이블이(가) 표시된 사진

자동 생성된 설명

-> 원래 행렬이 5x3 size이며 singular value 3개이므로 S행렬의 아래 행이 0 되었습니다. , U행렬의 오른쪽 열을 지우고 계산하더라도 SVD 같은 값이 나오게 됩니다. 이렇게 하여 데이터를 지운 SVD Thin SVD라고 합니다.

텍스트, 실내, 시계이(가) 표시된 사진

자동 생성된 설명

아직까지는 SVD 값이 일치합니다. 또한 값이 0 singular value 존재한다면 역시 제거할 있습니다. 가령 2번째 singular value 값이 0이라면, S행렬의 2번째 열과 2번째 행이 모두 0으로 구성되어 있으므로, U행렬의 2번째 열을 제거할 있고, V^T행렬의 2번째 행을 제거할 있습니다.

이렇게 하여 0 singular value까지 모두 지운 SVD Compact SVD 하며, 아직까지는 데이터 껍데기만 제거하여 실질적으로 데이터 크기가 압축되진 않았습니다.

그리고, 본격적으로 데이터를 압축하는 방법은 Truncated SVD 이용한 방법입니다. Singular value 내림차순으로 나열하여 SVD 만든다면 오른쪽 아래로 내려갈수록 singular value 값이 감소하며, 이들은 제거되어도 SVD 값에 영향을 주지 않습니다. 이렇게 하여 0 아닌 singular value까지 제거해준 SVD Truncated SVD 부릅니다.

이러한 방법을 데이터 압축에 응용할 있으며, singular value 제거하여 노이즈 역시 감소시킬 있습니다.



다음 6x5 행렬을 통해 예시를 만들어 보았습니다.

테이블이(가) 표시된 사진

자동 생성된 설명

우선 Full SVD 구하면 다음과 같습니다.

테이블이(가) 표시된 사진

자동 생성된 설명



0 singular value 없으므로, S행렬의 마지막 행만 제거하여 Compact SVD 구해보았습니다.

테이블이(가) 표시된 사진

자동 생성된 설명

SVD 값은 데이터 손실 없이 일치하는 것을 확인할 있습니다. 이제 5번째 singular value(1.306) 제거하여 Truncated SVD 구해보겠습니다.

테이블이(가) 표시된 사진

자동 생성된 설명

테이블이(가) 표시된 사진

자동 생성된 설명

다음 truncated SVD 통해 데이터를 압축할 있습니다. 여기서 데이터를 압축함이라 함은, U, S, V^T 행렬을 일렬로 하여 크기를 구했을 값이 감소했음을 의미합니다.

, 위와 같은 경우에선 Full SVD에서의 행렬이 각각 6x6, 6x5, 5x5 size로서 36+30+25=91Byte라고 있습니다.

하지만, Truncated SVD 크기는 6x4+4x4+4x5=60Byte로서, 66% 정도의 메모리만을 사용하였지만 원래의 데이터와 거의 일치함을 확인할 있습니다



해당 내용을 visualize하여 이미지 파일을 통해 확인해보고 싶었으나, 아직 sage 코딩에 대한 이해도가 부족하여 직접 해보지 못했습니다

하지만 이는 이상구 교수님 선형대수학 연구실에서 제공하는 "Matrix Decomposition and Image Processing via MATHEMATICA" 논문을 통해 정확하고 자세히 이해할 있었으며, 해당 논문을 통해 학우분들 모두 SVD 데이터 압축 노이즈 캔슬을 쉽게 이해하실 있을 거라고 생각합니다.

http://matrix.skku.ac.kr/sglee/03-Note/IP/ImageProcessing.htm



혹시 잘못된 점이나 추가하고 싶으신 점이 있으시다면 지적 부탁드립니다!



Finalized OK by SGLee [Finalized by 도경근, 고재윤 . . . 이예진] Open Problem 16 Solution

저는 도경근 학우님의 open problem 16 solution 글을 보고 굉장히 쓰셨다는 생각이 들었고, 새로운 내용에 대해서 생각해보게 되었습니다. SVD 개념이 

어려우신 학우님들의 도경근 학우님께서 작성하신 내용에 대한 이해를 도와드리기 위하여 문제에 대해 finalize 하게 되었습니다.



먼저, 선형 변환 (linear transformation) 대한 개념이 SVD 이해에 도움이 것이라고 생각하여, 선형 변환에 대해 설명드리겠습니다

선형 변환이란 간단히 말해, 자료의 분포는 동일하게 하되 어떤 변수를 사칙연산을 통해 다른 값으로 변환하는 것을 뜻합니다.

여기서 변수는 vector, 사칙연산은 matrix 통해 다른 vector값으로변환할 있습니다.

http://matrix.skku.ac.kr/2012-Album/13.html  링크는 교수님께서 올려주신 자료 선형 변환에 해당하는 내용입니다.



이번에는 아래의 2차원 그림에 대해서 살펴보도록 하겠습니다. 검은 원은 선형변환 하기 전의 x vector (x) y vector (y) 모습이고, 빨간

coefficient matrix A 곱한 A*x vector (Ax) A*y vector (Ay) 모습입니다.

y x 대하여 90도가 되도록 하는 vector라면, 선형 변환 하기 전의 상태에서 y x 대해 모든 direction에서 90도를 유지합니다.

하지만, 선형 변환이 일어난 Ax Ay 사이의 각도는 모든 direction에서 90도라고 보장하지 못합니다.

그림을 가지고 SVD 식을 이해할 있습니다.



우리는 강의를 통해 SVD 식을 A=U*∑*V^T 배웠습니다. 그림을 가지고 각각의 연산자에 대해 살펴보도록 하겠습니다.

A coefficient matrix      

V 선형 변환 서로 직교하던[ x,y] 열벡터     

U Ax, Ay 서로 90도를 이루는 direction에서 각각의 단위 열벡터 [u1, u2] ,

scaling factor 역할을 하는 diagonal matrix라고 두겠습니다.

그렇다면 AV=∑U 라는 식은 션형 변환의 관점에서 생각해보면, 변환 직교했던 벡터가 변환 후에도 직교할 때의 direction 찾는 식이 됩니다.

V orthogonal matrix 이므로 A=U*∑*V^T 나타낼 있고, 이는 강의 시간에 배웠던 SVD 형태가 됩니다.





11. [Final OK by SGLee] Open Problem 16 Solution by 남상현 (SVD를 동한 데이터 압축의 이해) with 도경근, 고재윤, 황세진, 윤상수, 신유정, 박우현, 남상현, 이규리, 문태의, 이예진, 정운섭



도경근 학우님과 고재윤 학우님의 Finalized Open Problem 16을 보고 쉽고 정확하게 SVD와 이를 이용한 데이터 압축에 관해 이해할 수 있었으며, 이에 관련하여 좀 더 깊게 생각해 보게 되었습니다. 데이터 압축에 관하여 좀 더 세부적인 개념과 이해를 돕고자 Open Problem 16 finalized해보았습니다.



우선 SVD를 응용하여 데이터의 연산 량을 줄여 데이터 압축을 할 수 있는데, 이는 truncated SVD로의 변환을 통해 응용할 수 있습니다.

m x n matrix SVD의 경우, m n보다 작거나 같다면 Σ행렬의 마지막 행에는 singular value의 마지막 값이 들어가게 됩니다.

하지만, m>n이라면 m x n size Σ행렬의 아랫부분에는 0으로 구성된 성분이 들어가게 됩니다. 이를 Full SVD라고 합니다.

(Image by : http://matrix.skku.ac.kr/2020-Math4AI-Final-pbl2/ )

singular value의 갯수를 s라고 합시다. 이 때 Σ행렬은 밑에서부터 m-s 개 만큼의 행이 0으로 구성됩니다. 행렬의 곱을 생각해본다면, U Σ행렬을 곱할 때 이 부분은 제거하여도 상관 없는 부분, 즉 크기가 0인 빈 데이터가 됩니다. 예시를 들면 다음과 같습니다.

-> 원래 행렬이 5x3 size이며 singular value 3개이므로 S행렬의 아래 두 행이 0이 되었습니다. , U행렬의 오른쪽 두 열을 지우고 계산하더라도 SVD는 같은 값이 나오게 됩니다. 이렇게 하여 빈 데이터를 지운 SVD Thin SVD라고 합니다.

아직까지는 SVD의 값이 일치합니다. 또한 값이 0singular value가 존재한다면 이 역시 제거할 수 있습니다. 가령 2번째 singular value의 값이 0이라면, S행렬의 2번째 열과 2번째 행이 모두 0으로 구성되어 있으므로, U행렬의 2번째 열을 제거할 수 있고, V^T행렬의 2번째 행을 제거할 수 있습니다.

이렇게 하여 0 singular value까지 모두 지운 SVD Compact SVD라 하며, 아직까지는 빈 데이터 껍데기만 제거하여 실질적으로 데이터 크기가 압축되진 않았습니다.

그리고, 본격적으로 데이터를 압축하는 방법은 Truncated SVD를 이용한 방법입니다. Singular value를 내림차순으로 나열하여 SVD를 만든다면 오른쪽 아래로 내려갈수록 singular value의 값이 감소하며, 이들은 제거되어도 SVD의 값에 큰 영향을 주지 않습니다. 이렇게 하여 0이 아닌 singular value까지 제거해준 SVD Truncated SVD라 부릅니다.

이러한 방법을 데이터 압축에 응용할 수 있으며, singular value를 제거하여 노이즈 역시 감소시킬 수 있습니다.



다음 6x5 행렬을 통해 예시를 만들어 보았습니다.

우선 Full SVD를 구하면 다음과 같습니다.



0 singular value는 없으므로, S행렬의 마지막 행만 제거하여 Compact SVD를 구해보았습니다.

SVD의 값은 데이터 손실 없이 일치하는 것을 확인할 수 있습니다. 이제 5번째 singular value(1.306)를 제거하여 Truncated SVD를 구해보겠습니다.

다음 truncated SVD를 통해 데이터를 압축할 수 있습니다. 여기서 데이터를 압축함이라 함은, U, S, V^T 행렬을 일렬로 하여 크기를 구했을 때 그 값이 감소했음을 의미합니다.

, 위와 같은 경우에선 Full SVD에서의 세 행렬이 각각 6x6, 6x5, 5x5 size로서 36+30+25=91Byte라고 할 수 있습니다.

하지만, Truncated SVD의 크기는 6x4+4x4+4x5=60Byte로서, 66% 정도의 메모리만을 사용하였지만 원래의 데이터와 거의 일치함을 확인할 수 있습니다



해당 내용을 visualize하여 이미지 파일을 통해 확인해보고 싶었으나, 아직 sage 코딩에 대한 이해도가 부족하여 직접 해보지 못했습니다

하지만 이는 이상구 교수님의 선형대수학 연구실에서 제공하는 "Matrix Decomposition and Image Processing via MATHEMATICA" 논문을 통해 정확하고 자세히 이해할 수 있었으며, 해당 논문을 통해 학우분들 모두 SVD와 데이터 압축 및 노이즈 캔슬을 쉽게 이해하실 수 있을 거라고 생각합니다.

http://matrix.skku.ac.kr/sglee/03-Note/IP/ImageProcessing.htm



혹시 잘못된 점이나 추가하고 싶으신 점이 있으시다면 지적 부탁드립니다!

 

아래 사진은 도경근 학우님이 작성하셨던 Open Problem 16 solution 입니다.

Open Problem 16 (Solution) by 도경

Open Problem 16

Find the SVD for a matrix from the other textbook by using the codes above.



R 사용하여 martix svd값을 찾아보고 분석을 해보았습니다.

텍스트이(가) 표시된 사진

자동 생성된 설명

특잇값 분해는 데이터 정보를 압축해주는 기능이 있습니다. 여기서 확인할수 있는 점은 특잇값 벡터 d 첫번째 두번째 세번째 원소값에 비하여 4번째 원소 값이 비교적 작다는 것을 알수 있습니다.따라서원래 데이터의 3/4만큼의 데이터인 처음 3개의 특잇값과 U, V 1~3열만 사용하여도 원래 데이터에 대한 대표성이 충분하고 정보 손실이 작다고 판단할수 있습니다.



이것이 실제로 그런지 한번 확인 해보기 위해서 처음 3개의 특잇값과 U, V 1~3열만 사용하여 matrix reconstruct 해보았습니다.

보시다시피 원래 데이터와 거의 유사하다는 점을 확인 있었습니다.



또한 처음 2개의 특잇값과 U, V 1~2열만 사용하여 matrix reconstruct 해보았습니

역시 원래 데이터와 유사하지만 중요할 가능성이 높은 마지막 행의 데이터들이 모두 사라진 모습이 눈에 띕니다.



이번 HW에서는 matrix svd값을 구해보고 그것이 어떤 의미를 가지고, 어떻게 쓰일수 있을지 고민해보는 시간을 가질수 있어서 유익했습니다. 감사합니다.

이상구(LEE SANGGU)12 16 오후 10:30

Very good^^ Share your text code, so others can check your output amd improve it.

도경근(2018####55)12 17 오후 4:08

m1 <- c(0,0,4,0,0,0,1,0, 0,0,0,2,0,0,5,0, 0,1,0,0,1,1,1, 0,3,1,0,0,0,2,2,1) dim(m1) <- c(4,8) m1 cross_svd <- svd(m1) str(cross_svd) cross_svd$d cross_svd$u cross_svd$v round(cross_svd$u[,c(1,2)] %*% diag(cross_svd$d[c(1,2)]) %*% t(cross_svd$v[,c(1,2)])) round(cross_svd$u[,c(1,2,3)] %*% diag(cross_svd$d[c(1,2,3)]) %*% t(cross_svd$v[,c(1,2,3)])) round(cross_svd$u[,c(1,2)] %*% diag(cross_svd$d[c(1,2)]) %*% t(cross_svd$v[,c(1,2)])) text code 입니

고재윤(2020####97)12 17 오후 7:43

학우님의 코딩 방식이 처음보는 방식이어서 처음엔 낯설었는데, text code 매우 간결하게 써진 것을 보고 놀랐습니다. 방식대로 했다면 학우님의 길이의 코딩을 했을텐데, 코딩공부도 해야겠다는 생각이 들었습니다. 또한, 학우님께서 하신 문제풀이 U, V 1,2,3번째 column으로 다시 A 조합하여 원래 A 비교하는 방식이 매우 흥미로웠습니다. 학우님께서 U,V 1,2 번째 column만을 이용하여 A 재조합 하셨을 '중요할 가능성이 높은 마지막 행의 데이터들이 모두 사라진 모습' 이라고 서술해 주셨는데 마지막 행의 데이터가 가장 중요할 가능성이 높은 데이터인지 여쭈어봐도 될까요? 좋은 problem solution 감사합니다!!

이상구(LEE SANGGU)12 17 오후 8:58

12 rank reduction 에서 배울 내용 입니다^^

고재윤(2020####97)12 17 오후 10:17

답변 감사합니다 교수님!!

황세진(2015####21)12 17 오후 11:22

주어진 데이터를 통해 합리적인 추론을 통해 벡터값이 가장 작은 곳을 제외하고 계산했을 때에 원래 데이터에서 손실이 많이 나지 않는 것을 소프트웨어를 통해 간결하게 확인시켜주셔서 한눈에 이해가 되었습니다! 도움이 많이 되었습니다.



도경근 학우님께서는 중요성이 가장 낮은 U V column 제거하고 재조합한 결과, decomposition 하기 전의 matrix 비슷한 값이 나옴

보여주시면서 SVD 특성에 대해 작성해주셨습니다. 방식이 성립하는지 알기 위해 SVD 식을 다시 살펴보도록 하겠습니다.





아래 사진은 SVD A=U*∑*V^T 보다 자세히 서술한 입니다

앞서 살펴보았듯이, U*V^T 성분의 크기는 모두 -1에서 1 사이의 값이기 때문에 ∑ 마치 scaling factor 같은 역할을 한다고 있습니다.

 ∑ diagonal matrix이기 때문에 A σ1*u1*v1^T +σ2*u2*v2^T*+..... 쪼개서 나타낼 있습니다

 k번째 σ 값이 다른 σ 값들에 비해 작은 값이라면, 부분은 A라는 데이터를 이루는데에 중요성이 낮다는 것을 뜻함을 있습니다.

따라서 중요성이 낮은 부분,  σ 값이 상대적으로 작은 column A 이루는데 부분을 차지하지 않을 것이고, 부분을 제외하고 A 계산해

비슷한 값이 나올 것이라고 생각할 있습니다.



이런 SVD 특성을 이용하면 중요성이 낮은 데이터를 제거함으로써, 압축된 데이터를 표현할 있을 것입니다

반대로, 중요성이 높은 데이터 몇개를 가지고 원래 데이터를 부분복원 하는 것이 가능할 같습니다.

이상구(LEE SANGGU)12 18 오전 5:21

Good job. Great. 다른 학생들도 모두 읽어야 여러분 동료의 SVD 설명 내용입니다.

윤상수(2020####53)12 18 오전 10:42

선형 변환을 함께 설명해주신 것이 이해에 한결 도움이 되는 같습니다. 감사합니다.

신유정(2016####90)12 18 오후 2:35

svd 이해에 막혀 있었는데, 이해하는데 도움이 되었습니다. 감사합니다!

박우현(2016####31)12 18 오후 2:36

SVD 이해하는데 도움이 되었습니다 감사합니

이예진(2017####54)12 18 오후 4:01

인터넷으로 뒤져가며 어렴풋하게 이해한 선형변환, SVD 등의 내용을 이렇게 문서에 일목요연하게 정리해주셔서 정말 도움이 크게 되었습니다. 감사합니다 !

남상현(2018####17)12 18 오후 5:49

시각적 효과와 더불어서 너무 간결하고 쉽게 SVD 관해 정리해주신 같습니다. 감사합니다!

도경근(2018####55)12 18 오후 7:17

안녕하세요 학우님. 제가 작성해주신 글을 finalize 해주셔서 감사합니다. 마지막 행의 데이터가 중요하다고 질문을 해주셨는데, 이부분에서는 제가 설명이 부족했던것 같습니다. 제가 하고싶었던 말은 '데이터를 복원했을때 마지막 행이 아예 사라졌다. 데이터로 어떤 insight 뽑아낼건지에 따라서 결과에 안좋은 영향이 있을 있다' 입니다. SVD 대해서 정성스럽게 요약해주시고 추가적인 설명을 해주셔서 감사합니다. 좋은 연말 보내십시오.

남상현(2018####17)12 18 오후 8:29

M = matrix(RDF,[[1, 2, 1, 4, -2],[2, 4, 4, -6, -8], [1, 2, -2, 4, 6], [-2, -1, 1, 4, 3], [-2, 0 ,0, 1, 1], [2, 5, 4, -3, -1]]) U, S, V = M.SVD() # A = U*S*V' # A's SVD Ut = matrix(RDF, [[U[i][j] for j in range(4)] for i in range(6)]) St = matrix(RDF, [[S[i][j] for j in range(4)] for i in range(4)]) Vt = matrix(RDF, [[V[i][j] for j in range(4)] for i in range(5)]) show("U = ") show(Ut.n(digits=4)) show("S = ") show(St.n(digits=4)) show("V = ") show(Vt.n(digits=4)) show("M = ") show(M) show("USV^T = ") show(Ut*St*Vt.transpose().n(digits=4)) Truncated SVD 구할 사용한 코드입니다!

이상구(LEE SANGGU)12 18 오후 8:42

했습니다. 서로 다르게 생각하는 부분이 있어 보입니다. 결론은 마지막행의 데이터가 특별히 중요하지는 않습니다. 분석에서는 특이값들과 그에 대응하는 singular vectors 다른 보다 영향을 준다 정도로 이해하시고. 자세한 것은 12-13 th day 배울 rank reduction PCA 에서 SVD 이용 에서 배울 입니다.

남상현(2018####17)12 18 오후 8:49

감사합니다!

도경근(2018####55)12 18 오후 9:45

정리해주셔서 감사합니다 학우님. SVD 대해 이해하는데 도움이 많이 되었습니다.

고재윤(2020####97)12 18 오후 9:49

설명해주신 모든 내용에 대응되는 예시들을 코딩해주시고, 알맞은 그림으로 식을 표현해주시니 제가 작성한 글보다 SVD 대해서 이해할 있는 글인 같습니다!! 교수님께서 말씀하신 12-13th day 배우는 내용에 대해서도 나중에 토론할 있었으면 좋겠습니다. 좋은 감사합니다!!

이규리(2018####45)12 19 오전 7:47

SVD 그저 수학적 개념에서 끝나지 않고 데이터에서는 이를 어떤 식으로 있는지, 어떻게 이해하면 되는지를 자세히 설명해주셔서 이해에 많은 도움이 되었습니다. 감사합니다!

문태의(2016####21)12 19 오후 4:29

SVD 이해하는데 도움이 되었습니다! 감사합니다.

정운섭(2018####88)12 20 오전 00:54

부분은 몰랐던 부분인데 이렇게 정리해주셔서 SVD 대해서 깊이 이해할 있게 되었습니다! 감사합니다!

이예진(2017####54)12 21 오후 12:02

덕분에 SVD 관한 더욱 구체적 이해를 있었습니다. 감사합니다 !

 

The function I chose is same as the one I used in

[Finalized by 정운섭, SGLee, 김지훈, 고재윤, 우건주, 안성준인유진, 윤상수]Open problem 2 solution by 정운섭   (3변수 함수의  Find Gradient 찾는 법,  Find Critical points 임계점을 찾는법.)

And the result for local minimum and maximum are shown below 



This time, I want to calculate local minimum point by using gradient descent method(GDM).

The interval where local minimum is located is x= (0.5, 1.0), so I set x0= 0.7, eta=0.1, tolerance=10^-6

The code I wrote is shown below. (you can practice at http://matrix.skku.ac.kr/KOFAC/)



f(x) = (x^9 - x^7)/sqrt(1+x^6+x^10)  # function
df(x) = diff(f(x), x)   # derivative
x0 = 0.7   # the initial iterate
tol = 1e-6   # the tolerance level
eta = 0.1    # the learning rate
for k in range(300):

    g0 = df(x0)
    
    if abs(g0) <= tol:
        
        print("Algorithm Succeed!")
        break
    
    x0 = x0 - eta*g0

print("x* =", x0)
print("|g*| =", abs(g0))
print("f(x*) =", f(x0))
print("iteration number  =", k + 1)



This result shows that after 26 repetition of the process, the code has succeeded to find the local minimum point at x*= 0.858,  f(x*)= -0.07106.. 

The local minimum value -0.07106 is almost equal to the value I got in open problem 2 solution -0.0711. -> GDM is working well. 



Then, I wanted to increase the precision of the local minimum value, so I decreased the tolerance from 10^-6 to 10^-8, which means the process will stop when df(x0)<= 10^-8

The result is shown below 

The value |g*| has decreased to 5.8 x 10^-9, which means closer to zero. -> more precision. However, the change in f(x*) value is very very small, almost meaningless. 

Therefore, in this case, I concluded that tolerance value 10^-6 is enough to calculate local minimum point. 

10개의 댓글

이상구(LEE SANGGU)12 24 오전 10:34

Good job.

고재윤(2020####97)12 24 오후 12:33

tolerance 크기를 달리하면서 결과값 비교를 하는 부분이 도움이 되었습니다. 감사합니다!!

강민지(2021####12)12 24 오후 11:11

GDM 이용해 local minimum 구하는 내용이 정리되어 있어 이해하는 도움이 되었습니다. 감사합니다!

이규식(2018####70)12 25 오후 4:37

정리를 잘해주셔서 GDM 공부에 도움이 되었습니다. 감사합니다.

우건주(2017####97)12 25 오후 11:53

tolerance 크기를 줄임으로써 |g*| 감소하는 것을 있었고 궁극적으로 more precision 얻을 있다는 것을 실제로 확인할 있었습니다. 감사합니다.

남상현(2018####17)12 26 오후 3:18

Tolerance 크기를 변화시키는 부분이 인상적입니다. GDM 이해하는데 도움이 되었습니다. 감사합니다.

이규리(2018####45)12 28 오전 9:52

local minimum maximum GDM 연결시켜 이해하는 것에 어려움이 있었는데 전반적인 내용 연결 고리에 도움이 되었습니다. 감사합니다.

이상구(LEE SANGGU)12 28 오후 6:44

You may Finalize this^^

인유진(2020####32)12 29 오후 2:14

그려주신 그래프를 참고하여 같이 보니 local minimum maximum 눈으로 쉽게 확인할 있어 이해가 더욱 되었습니다.

박우현(2016####31)12 30 오전 2:01

tolerance iteration횟수간의 관계가 흥미롭습니다

 

-> Comment: 도함수가 복잡한 함수의 local minimum pointGDM을 사용해서 구했을 때, 그 결과값이 이전에 다른 방법으로 구했던 결과와 일치하게 되는 것을 확인할 수 있었습니다. 또한 직접 코드로 구현해보면서 GDM이 어떻게 동작하는지 더 잘 이해할 수 있게 되었고, 개인적으로 궁금했던 tolerance를 바꾸게 되면 어떻게 되는 지도 직접 확인하여 tolerance로 어떤 값을 넣어야 적절한지에 대해서도 알게 되었습니다.

 

Chapter 2 Open Problems:

I wrote another convenient interactive sagemath module, so everyone can easily play with the values and adapt for their particular equations.

Note: I modified the algorithm, that was in the video. The reason is, that in this case, Python loops perform slower (for i in range(x)), in comparison with C loops (while x).

 

# W9 (Kim Daniil) Chapter 2 Open Problem 3 and 4

 

# Making it interactive

@interact

def _(  temp1 = input_box(9*x^2-7*x+6,label="f(x)=", width=30),

        threshold = slider(0.000001, 2, step_size=0.000001, default=0.000001, label="Threshold/Tolerance:", display_value=True),

        l_rate = slider(0.00001, 1, step_size=0.00001, default=0.1, label="Learning Rate:", display_value=True),

        base_point = input_box(0.0, label="Base Point:", width=20),

        terminator = slider(100, 10000, step_size=1, default=300, label="Terminate after:", display_value=True),

        zoomX = slider(1, 100, step_size=0.5, default=5, label="Zoom X:", display_value=True),

        zoomY = slider(1, 100, step_size=0.5, default=30, label="Zoom Y:", display_value=True),

        scale = slider(4, 40, step_size=1, default=15, label="Graph Scale:", display_value=True)):

    # Converting a temp1 input to a function.

    f(x) = temp1

 

    show("Equation: f(x)=", f(x))

    df(x) = diff(f(x),x)

    show("Slope: f'(x)=", df(x))

   

    # GDM implementation

    i_points = []

    iterator = 0

    my_x = base_point #Starting point

    g = threshold+1

    while ( iterator < terminator and g > threshold ):

        g = df(my_x)

        i_points.append(vector([my_x, g]))

        my_x = my_x - l_rate*g

        g = abs(g)

        iterator +=1

       

    final_point = vector([my_x, f(my_x)])

    show("x* = ", final_point[0])

    show("|g*| = ", g)

    show("f(x*) = ", final_point[1])

    show("Achieved in '", iterator, "' attempts.")

   

    plot_f = plot(f(x), x, color="green", xmin=-zoomX, ymin=-zoomY, xmax=zoomX, ymax=zoomY, legend_label="Function", figsize=(scale,scale))

    plot_df = plot(df(x), x, color="blue", xmin=-zoomX, ymin=-zoomY, xmax=zoomX, ymax=zoomY, legend_label="1st Derivative", figsize=(scale,scale))

    plot_i_points = list_plot(i_points, color="red", legend_label="Iteration Points")

    plot_final_point = list_plot([final_point], color="purple", legend_label="Result")

   

    show( plot_f + plot_df + plot_i_points + plot_final_point )

We can practice the above code in http://matrix.skku.ac.kr/KOFAC/  and in  https://sagecell.sagemath.org/ 

 Day 7 Open Problem 1 by Ng Zhi Wei 응즈웨이 (using while loop) [Comment by: 우건주, 고재윤, 남상현, 윤상수]

작성자 : 응즈웨이(2019####51)작성일 : 12 21 오전 00:15

조회수 : 33

Day 7 Open Problem 1 by Ng Zhi Wei 응즈웨이 (using while loop) [Comment by: 우건주, 고재윤, 남상현, 윤상수]

I recommend using a while loop to tackle Day 7 Open Problem 1 as it is more code efficient compared to hard coding each derivative. As the question only asked for the third derivative, it is still possible to hard code; but using a while loop will be more efficient as it can handle a larger number of derivatives. Besides, it is also easier to edit the code if a larger number of derivatives is needed (simply change the 4 from line 12). The 4 should be changed to 'the number of derivatives + 1'. For example, 4 for the 3rd derivative and 101 for the 100th derivative.   

텍스트이(가) 표시된 사진

자동 생성된 설명

텍스트이(가) 표시된 사진

자동 생성된 설명



Open Problem 1 by 남상현

작성자 남상현(2018####17)작성일 : 12 20 오후 6:19

조회수 : 41



Open Problem 1 

Find the third derivative of a differentiable function from the textbook.



First, I choose the differentiable function from the textbook,

The function is differentiable for every x, so we can define a derivative of f(x).

To find the third derivative of the function, first, we should check if the derivative is still differentiable.

If it is checked, we can find the second derivative of the function. Also, we should check if the second derivative is differentiable.

If it is checked, now we can find the third derivative of the function.



텍스트이(가) 표시된 사진

자동 생성된 설명

By using diff() function, we can find the third derivative of the function. And this is the result.



텍스트이(가) 표시된 사진

자동 생성된 설명

As we can see, they are differentiable, and I could find the third derivative of the function.



6개의 댓글

고재윤(2020####97)12 20 오후 7:28

작성하신 글을 읽고 diff() function 대한 이해에 도움이 되었습니다. 감사합니다!!

정운섭(2018####88)12 20 오후 7:31

diff() function 대한 좋은 예시를 들어주셔서 이해에 도움이 되었습니다!

이상구(LEE SANGGU)12 20 오후 8:19

Good job^^ Others may try the same job (with the same code) for a couple more complicated or composite functions.

박우현(2016####31)12 20 오후 11:58

diff()함수의 활용에 대한 보기 좋은 예시인 같습니다

응즈웨이(2019####51)12 21 오전 00:22

Hi! Thank you very much and your codes work perfectly fine! :) However, just for sharing, I used a while loop to tackle this problem as I find it more efficient that way. If interested, do take a look at my post at "Day 7 Open Problem 1 by Ng Zhi Wei (using while loop)". Thanks!

남상현(2018####17)12 21 오전 00:46

I will :) Thanks a lot!



우건주(2017####97)12 21 오전 00:27

Thank you for your creative answer. I agree with the idea that using while loop will be faster. I only thought about it and couldn't apply it, but it was very helpful to understand because you actually showed it.

고재윤(2020####97)12 21 오전 00:39

It's an efficient way that I couldn't think of. Thank you. I learned a lot.

남상현(2018####17)12 21 오전 00:50

Very efficient way! It would be better to choose the developed code by using while loop. Thanks a lot:)

윤상수(2020####53)12 21 오전 1:01

Thank you for sharing your efficient method.

이상구(LEE SANGGU)12 21 오전 5:27

Dear Ng Zhi Wei , share the text code in QnA. So others can check whether it really works or not.

응즈웨이(2019####51)12 21 오후 1:11

As requested, below is the code in text. Fellow classmates can test out the code or test out his or her code simply by changing the f(x)'s function at line 3 of the code. Also, one can play around with the number of derivatives by changing the number '4' at line 12 of the code. Also, please remember to indent the last 4 lines of code so it is inside the while loop (I cannot indent the last 4 lines here in iCampus). Thanks! #Compiler: Sage f(x) = sin(sqrt(e^x)/2) #Function print ("f(x) =", f(x)) print() print("After 1 differentiation = ") print(diff(f(x), x)) #Results of first differentiation print() i = 2 #Starting from 2nd differentiation while i < 4: #Loops twice for 2nd and 3rd differentiation print("After ", i, " differentiation = ") print(diff(f(x), x , i)) #Results of i-th differentiation print() i += 1 #Increase i by 1 a.k.a go to next differentiation

안성준(2016####47)12 22 오후 2:47

It is a well-organized code! Thanks for sharing

이우흠(2018####75)12 22 오후 8:40

thanks for sharing! Already tried. it is very efficient indeed.

 

Open problem 3 (solution) by 윤상수

작성자 : 윤상수(2020####53)작성일 : 12 21 오전 00:56

조회수 : 26

The code I've used is as below.

f(x) = 9*x^2 - 7*x + 6   # function
df(x) = diff(f(x), x)   # derivative
x0 = 0.0   # the initial iterate
tol = 1e-6   # the tolerance level
eta = 0.1    # the learning rate
for k in range(300):

    g0 = df(x0)

    if abs(g0) <= tol:

        print("Algorithm Succeed!")
        break

    x0 = x0 - eta*g0

print("x* =", x0)
print("|g*| =", abs(g0))
print("f(x*) =", f(x0))
print("iteration number  =", k + 1)



텍스트, 화이트보드이(가) 표시된 사진

자동 생성된 설명

---------------------------------------------

The result is as follows.

Algorithm Succeed!

x* = 0.388888940082364

|g*| = 9.21482552485031e-7

f(x*) = 4.63888888888891

iteration number  = 72



텍스트이(가) 표시된 사진

자동 생성된 설명

                

이전

다음

3개의 댓글

고재윤(2020####97)12 21 오전 1:35

덕분에 GDM 이해하는데 도움이 되었습니다. 감사합니다!!

이상구(LEE SANGGU)12 21 오전 5:24

Very good.

강민지(2021####12)12 22 오후 10:39

GDM 통해 최소 값을 구하는 내용들을 정리해주셔서 학습에 도움이 되었습니다. 감사합니다!

 

Finalized by 고재윤, 윤상수 Useful Sage Command to visualize graph and course of GDM + Graph at "Open problem 3 (solution) by 윤상수"

Finalized by 고재윤, 윤상수  Useful Sage Command to visualize graph and course of GDM +  Graph at "Open problem 3 (solution) by 윤상수"

In the course of learning about differentiation and GDM,  new sage commands for visualizing graph are appeared in the lecture note. 

I will summary these commands, and I will add a graph at "open problem 3 (solution) by 윤상수" .



1) plot3d in http://matrix.skku.ac.kr/KOFAC/ 

'plot3d' is used to draw function which has two variable like f(x,y)

'plot3d' is similar to 'plot'. ex)  p = plot3d( f(x, y), (x, -2, 2), (y, -2, 2) )        show(p)



f(x, y) = 2*x^2+3*y+5
p = plot3d( f(x, y), (x, -2, 2), (y, -2, 2) )        
show(p)



'plot' is used to draw a two-dimensional graph, but  the result of 'plot3d' is three-dimensional graph like graph below

[ 2*x^2+3*y+5 ]



2) opacity

'opacity' is a function that can control the degree of opacity(불투명함) of the three-dimensional overlapping place.

Below is a picture of adjusting the 'opacity' of the three-dimensional graph used in the lecture note to 0.6 and 6 respectively.

This command will help you to recognize 3-dimensional graph at a glance.





3) aspect_ratio

'aspect_ratio' is used to magnify the desired axis. 

Local maximum or Local minimum can be easily inquired by using this command.

Below is a picture of adjusting the 'aspect_ratio' of the three-dimensional graph used in the lecture note

to [1,1,10]and [1,1,50] respectively.



4) line(line3d), point(point3d)

These two commands are used to observe the course of GDM.

ex) p = line3d(r, color = 'red') + point3d(r, color = 'black', size = 500)  # r is the place to check tolerance (course of GDM).

       show(p)

Below is a example of using 'line3d', 'point3d' command to observe the GDM course. This graph is in the lecture note.



At "open problem 3 (solution) by 윤상수" , the problem function is one variable fuction. 

So we can express the course of GDM by using 'line' and 'point'.

To do this, I used the code written by '윤상수' and added extra code.

텍스트이(가) 표시된 사진

자동 생성된 설명

Now, we can see the course of GDM.  



ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ



open problem 3 (solution) by 윤상

The code I've used is as below.

f(x) = 9*x^2 - 7*x + 6   # function
df(x) = diff(f(x), x)   # derivative
x0 = 0.0   # the initial iterate
tol = 1e-6   # the tolerance level
eta = 0.1    # the learning rate
for k in range(300):

    g0 = df(x0)

    if abs(g0) <= tol:

        print("Algorithm Succeed!")
        break

    x0 = x0 - eta*g0

print("x* =", x0)
print("|g*| =", abs(g0))
print("f(x*) =", f(x0))
print("iteration number  =", k + 1)



텍스트, 화이트보드이(가) 표시된 사진

자동 생성된 설명

---------------------------------------------

The result is as follows.

Algorithm Succeed!
x* = 0.388888940082364
|g*| = 9.21482552485031e-7
f(x*) = 4.63888888888891
iteration number  = 72



텍스트이(가) 표시된 사진

자동 생성된 설명

  고재윤(2020####97)12 21 오전 1:35

덕분에 GDM 이해하는데 도움이 되었습니다. 감사합니다!!

고재윤(2020####97)12 21 오전 4:03

f(x) = 9*x^2 - 7*x + 6 # function df(x) = diff(f(x), x) # derivative x0 = 0.0 # the initial iterate tol = 1e-6 # the tolerance level eta = 0.1 # the learning rate r=[] for k in range(300): g0 = df(x0) # tap once in front of this line r.append((x0,f(x0))) # tap once in front of this line if abs(g0) <= tol: # tap once in front of this line print("Algorithm Succeed!") # tap twice in front of this line break # tap twice in front of this line x0 = x0 - eta*g0 # tap once in front of this line print("x* =", x0) print("|g*| =", abs(g0)) print("f(x*) =", f(x0)) print("iteration number =", k + 1) p1=plot(f(x),(x,0,1)) p2=line(r,color='red')+point(r,color='black',size=50) show(p1+p2) # before you execute this code, please check 'tap' sign

이상구(LEE SANGGU)12 21 오전 5:24

Dear 고재윤, check your code in http://matrix.skku.ac.kr/KOFAC/ once again^^ See why your code is not working (not like the above) and say something~~

고재윤(2020####97)12 21 오전 11:38

댓글창으로 코드를 복사하는 과정에서 tap 적용되지 않은 같습니다. 댓글에 있는 코드에 tap 표시를 해두도록 하겠습니다!! 혹시 다른 문제점을 말씀하신 것이라면 알려주시면 감사하겠습니다!! 제가 해보았을 때는 tap 적용시키고 실행하니 결과처럼 실행되었습니다.

이상구(LEE SANGGU)12 21 오후 5:11

초보자가 많으니 ... 사용자 편의를 고려하여 바로 복사하여 사용하게 주시면 좋고, 아니면 적어도 tap 표시를 해두시면 됩니다.

고재윤(2020####97)12 22 오전 1:18

알겠습니다!! 감사합니다.

윤상수(2020####53)12 22 오후 4:49

고재윤님의 visualization 통해 gradient descent method 직관적으로 이해할 있었습니다. 감사합니다!

 

[Finalized by 정운섭, SGLee, 김지훈, 고재윤, 우건주, 안성준, 인유진, 윤상수]Open problem 2 solution by 정운섭 (3변수 함수의 Find Gradient 찾는 , Find Critical points 임계점을 찾는법.)



[Finalized by 정운섭, SGLee, 김지훈, 고재윤, 우건주, 안성준,  인유진, 윤상수]Open problem 2 solution by 정운섭   (3변수 함수의  Find Gradient 찾는 법,  Find Critical points 임계점을 찾는법.)



Open Problem 2 



Find a complicated twice differentiable function in other textbooks, and use the code to find the local maximum, the local minimum,

the absolute maximum, and the absolute minimum of the function.



제가 선택한 함수는 아래에 보이는 함수입니다. 저는 이 함수의 x= (-1.5, 1.5) 구간에서의 local minimum, local maximum, absolute maximum, absolute minimum을 구해보았습니다. 

 텍스트, 시계이(가) 표시된 사진

자동 생성된 설명



먼저, 그래프의 개형을 보기 위해서 아래의 코드를 사용해서 x= (-1.5, 1.5) 구간에서의 그래프를 출력해봤습니다.



f(x) = (x^9 - x^7)/sqrt(1+x^6+x^10)

show(plot(f(x), (x,-1.5,1.5), ymin=-1, ymax=1))



그랬더니 이러한 그래프의 형태를 얻을 수 있었습니다. 이를 통해 알 수 있는 점은 Absolute maximum x=1.5 에서, 그리고 Absolute minimum x=-1.5에서 발생한다는 것을 확인할 수 있었습니다. 

이를 코드를 사용하여 구해보면 아래와 같은 결과를 얻을 수 있습니다. 



f(x) = (x^9 - x^7)/sqrt(1+x^6+x^10)
show("Absolute max= ",f(1.5).n(digits=3))
show("Absolute min= ",f(-1.5).n(digits=3))

텍스트이(가) 표시된 사진

자동 생성된 설명



위의 그래프에서 가지 있는 점은, 3군데의 critical points 있는데 x= (-1, -0.5) 구간에 local maximum 위치하고, x= (0.5, 1) 구간에 local minimum 위치해 있다는 것을 확인할 있습니다

x=0 critical point 속하지만 local maximum이나 local minimum 어느 것에도 해당하지 않습니다.

따라서 f'(x)=0 되는 x값을 찾아서 f(x) 대입해 주어야 합니다. 이를 코드로 구현하면 아래와 같은 출력이 나옵니다.



f(x) = (x^9 - x^7)/sqrt(1+x^6+x^10)
df(x)= diff(f(x), x)

show(solve(df(x)==0, x))  

r1= find_root(df(x), 0.5, 1)   # local minimum x=(0.5, 1)
r2= find_root(df(x), -1, -0.5)  # local maximum x=(-1, -0.5)
show("local minimum= ", f(r1).n(digits=3))
show("local maximum= ", f(r2).n(digits=3))



텍스트이(가) 표시된 사진

자동 생성된 설명

위의 코드를 설명하자면 solve 함수를 사용하여서 df(x)=0 x값을 구할 경우 solve 함수의 computing power(?) 복잡한 연산을 감당을 못하기 때문에 위와 같이 복잡한 식의 형태로 나오게 됩니다

따라서 위의 그래프에서 얻은 정보를 이용해서 find_root 함수로 x=(0.5, 1) 범위에서 df(x)=0 되는 x 값을 r1 저장하고, x=(-1, -0.5) 범위에서 df(x)=0 되는 x 값을 r2 저장하였습니다.

따라서 local minimum= f(r1) = -0.0711,  local maximum= f(r2) = 0.0711 됩니다



결론: 이러한 방법으로 하는 것은 답은 구해지나, 과정이 너무 복잡하고 시간이 오래 걸리는 같습니다. 왜냐하면 모든 df(x)=0 되는 x값에 대하여 하나하나씩 구해보아야 하기 때문입니다

Gradient descent method 이러한 문제점에 해결책을 제시해 같습니다



***  3변수 함수의 Gradient 찾는 법도 같습니다.  Reference in http://matrix.skku.ac.kr/math4ai/part2/ 





정의.

방향도함수(directional derivative), 그래디언트(gradient), 헤시안(Hessian)

(1) 를 단위벡터(크기가 1인 벡터)라 하자.  그러면 점 에서  방향으로의  방향도함수(directional derivative)는 다음과 같이 정의된다.



                 



 일 때 이고, 일 때 이다.



 가 점 를 지나고, 에 평행한 직선이라 하자.



                         



그러면 다음이 성립한다.

                        .



(2)  그래디언트(gradient) 의 편도함수를 성분으로 갖는 벡터로 다음과 같이 정의된다.

                         grad 



[ 그래디언트(gradient)의 시각적 의미 ]

                       옅은이(가) 표시된 사진

자동 생성된 설명

 는 미분가능함수   점에서의 접선벡터와 직교인 벡터. 접선벡터는 표면 위에 있다.

(3)  헤시안(Hessian)  2계 편도함수를 성분으로 갖는 행렬로 다음과 같이 정의된다.

                         

 

 의 이계 편도함수가 연속인 경우에는 이므로 이 대칭행렬이 된다.

▪ 같은 방법으로 독립변수가 개 이상인 다변수함수 에 대하여도 의 그래디언트와 헤시안이 정의된다.  변수 함수 에 대하여 의 그래디언트와 헤시안은 다음과 같다.



  그래디언트(gradient): grad 

 헤시안(Hessian): 





정리.

 방향도함수(directional derivative)



가 점 에서 미분가능하고 가 단위벡터라 하면 다음이 성립한다.

         ,  



사각형입니다.   에서 축의 양의 방향과 이루는 각(angle) 인 단위벡터

방향으로의 함수 의 방향도함수를 구하여라.

[Find ]



https://sagecell.sagemath.org/

1

var('x, y')                    #  https://sagecell.sagemath.org/ 

2

f(x, y) = x^3 - 3*x*y + 4*y^2

3

u = vector([cos(pi/6), sin(pi/6)])

4

gradf = f.gradient()  # 함수 f 그래디언트

5

print("Duf(1,2) =", gradf(1, 2).dot_product(u))

Evaluate

내적의 성질을 이용하면 다음을 있다.



        



여기서   의 사잇각이다. 따라서 의 그래디언트  방향이 점 에서 가 가장 가파르게 증가하는 방향이고, 음의 그래디언트  방향이 점 에서 가 가장 가파르게 감소하는 방향이다. 이는 이후에 학습하게 되는 경사하강법(gradient descent method) Key idea를 제공합니다.



▪ 다변수 함수 에 대한 Taylor 정리는 다음과 같다. 이는 한 점  근방에서  선형근사(linear approximation)  이차근사식(quadratic approximation)을 구성하는데 사용된다.





정리.

 Taylor 정리



  다변수 함수 가 연속인 편도함수를 가지면, 적당한 가 존재하여 다음이 성립한다.

                        

만일 연속인 2계 편도함수를 가지면, 적당한 가 존재하여 다음이 성립한다.

                 



▪ 점  근방에서  선형근사식(벡터형식 표현)은 다음과 같다.



                       



▪ 점  근방에서  이차근사식은 다음과 같다.



                



2.4 함수의 극대(Local Maximum), 극소

참고 동영상: http://youtu.be/oDZUkOEszOQ

실습 사이트: http://matrix.skku.ac.kr/Cal-Book1/Ch13/

            http://matrix.skku.ac.kr/Cal-Book/part2/CS-Sec-13-8-Sol.html

15강 동영상, 극대, 극소 https://youtu.be/nR9it9cBjDk  (21:25)

...





 Find Critical points 임계점을 찾는법.

http://matrix.skku.ac.kr/PBL2/



http://math1.skku.ac.kr/home/skku/3465/

13.6 #7 Find the gradient of 

sol) 

var('x,y,z')

f(x,y,z)=(x+y+z)*exp(x*y*z)

f.gradient()

137 3   http://math1.skku.ac.kr/home/pub/1430/

..

 

13.6.4 최주영 이인행   Solved by 최주영 Revised by 이인행


4. If  , find 
..



Sol) .

 

http://math1.skku.ac.kr/home/skku/3345/





var('x, y, z');

f(x, y, z)=1/sqrt(x^2+y^2+z^2);

f.gradient();





http://matrix.skku.ac.kr/Cal-Book/CS-Sec-14-1-Sol.htm 



이상구(LEE SANGGU)12 21 오후 6:29

맞습니다. Gradient descent method 1변수 함수 아니라 2변수 함수는 물론, <다변수 함수 Local minimum 값을 구해줍니다>^^

김지훈(2020####97)12 21 오후 11:13

Gradient descent method 배우기전에 방법이 가진 의미에 대해 고민해볼수 있어서 도움이 됬습니다.

고재윤(2020####97)12 22 오전 1:34

문제를 풀어주신 뿐만 아니라 GDM 필요성에 대해 언급해주신 덕분에 개념과 개념 사이의 연관성에 대해서도 생각해보게 되었습니다. 감사합니다!!

우건주(2017####97)12 22 오후 2:47

find root함수의 활용을 있었고 Gradient descent method 필요성을 느낄 있었습니다. 감사합니다.

안성준(2016####47)12 22 오후 2:50

본래에 이용했던 방법과 GDM 비교해주신 덕분에 GDM 유용성을 있었습니다. 감사합니다!

인유진(2020####32)12 22 오후 4:23

단순한 식보다 본래의 개념들을 보고 예시까지 들어주셔서 GDM 대해 감을 잡을 있었습니다! 감사합니다.

윤상수(2020####53)12 22 오후 4:43

"결론: 이러한 방법으로 하는 것은 답은 구해지나, 과정이 너무 복잡하고 시간이 오래 걸리는 같습니다. 왜냐하면 모든 df(x)=0 되는 x값에 대하여 하나하나씩 구해보아야 하기 때문입니다. Gradient descent method 이러한 문제점에 해결책을 제시해 같습니다." 부분에서 GDM 필요한 이유에 대해 언급해주신 부분이 정말 좋았습니다. 감사합니다!

남상현(2018####17)12 22 오후 5:47

critical points 찾는 과정을 통해 GDM 필요성까지 알게 되어 다음 강의 도움이 같습니다. 감사합니다!

도경근(2018####55)12 22 오후 11:48

GDM 설명하시기 위하여 다양한 예시들을 코드로 정리해주셔서 조금더 이해 있었습니다 감사합니다!

 

Open problem 16 (solution) by 윤상수, show("MUSV^T = ", (M - U*S*V.transpose()).norm(p='frob'))

작성자 : 윤상수(2020####53)작성일 : 12 22 오후 4:41

조회수 : 18

Open problem 16 (solution) by 윤상수, show("MUSV^T = ", (M - U*S*V.transpose()).norm(p='frob'))

I share my solution of open problem 16

(doing SVD on large rectangular matrix).

The code I've used is as belows.

-------------------------------------------------------------------------------------------------------------

M = matrix(RDF, [[1,1,1,0,0],

                              [2,2,2,0,0],

                              [1,1,1,0,0],

                              [5,5,5,0,0],

                              [0,0,0,2,2],

                              [0,0,0,3,3],

                              [0,0,0,1,1]])

U, S, V = M.SVD() # A = U*S*V' # A's SVD
show("U = ", U.n(digits = 3))
show("S = ", S.n(digits = 3))
show("V = ", V.n(digits = 3))
show("M = ", M.n(digits = 3))
show("USV^T = ", U*S*V.transpose().n(digits = 3))
show("
MUSV^T = ", (M - U*S*V.transpose()).norm(p='frob'))
show("=> M = USV^T")

The Result is as follows.

-테이블이(가) 표시된 사진

자동 생성된 설명테이블이(가) 표시된 사진

자동 생성된 설명



이상구(LEE SANGGU)12 22 오후 4:49

Very good^^

고재윤(2020####97)12 22 오후 6:56

복잡한 matrix 일치 여부를 확인하기 위해 matrix 간의 크기 비교를 하신 것이 정말 좋은 방법이라고 생각합니다. 도움을 주셔서 감사합니다!!

신유정(2016####90)12 22 오후 9:06

svd 계산을 한눈에 있어서 이해하는데 도움이 되었습니다. 감사합니다!

 

Question about GDM: learning rate and initial position (by 윤상수)

작성자 : 윤상수(2020####53)작성일 : 12 22 오후 5:01

조회수 : 15

In running Gradient Descent Method, the resulting cost function(the measure of optimization) varies with initial position and learning rate.



That is, we are likely to fall on different local minimum if we choose different learning rate and initial position.

If we choose too large learning rate, we might escape form any local minimum and therefore the optimization process fails.

If we choose too small learning rate, we might get trapped in local minimum that is not so small and therefore optimization process terminates even of it is not sufficiently optimized.



Initial position also influences our final value of cost function.



Regarding this, is there any method or algorithm to manipulate learning rate or initial position to maximize optimization?

Or can we do nothing but simply put random values and pick the best one?

이전

다음

3개의 댓글

이상구(LEE SANGGU)12 22 오후 5:28

Answer (1) Thewre is no just one way to choose the best learning rate or initial position for ALL problems. (2) But, each of us deals with only a few type of optimization problems from the business that he/she works, So for each type of problems, we should be able to find a way to start (with a reasonable learning rate or an initial position) for a particular problem. Read < How to Configure Learning Rate > in https://machinelearningmastery.com/learning-rate-for-deep-learning-neural-networks/ It is important to find a good value for the learning rate for your model on your training dataset. The learning rate may, in fact, be the most important hyperparameter to configure for your model. The initial learning rate [… ] This is often the single most important hyperparameter and one should always make sure that it has been tuned […] …” shape, where loss decreases (performance improves) as the learning rate is decreased with a fixed number of training epochs to a point where loss sharply increases again because the model fails to converge. If you need help experimenting with the learning rate for your model, see the post: Understand the Impact of Learning Rate on Model Performance With Deep Learning Neural Networks Hope this answer helps.

이상구(LEE SANGGU)12 22 오후 5:32

https://machinelearningmastery.com/learning-rate-for-deep-learning-neural-networks/ How to Configure the Learning Rate When Training Deep Learning Neural Networks by Jason Brownlee on January 23, 2019 in Deep Learning Performance After completing this tutorial, you will know: Learning rate controls how quickly or slowly a neural network model learns a problem. How to configure the learning rate with sensible defaults, diagnose behavior, and develop a sensitivity analysis. How to further improve performance with learning rate schedules, momentum, and adaptive learning rates. Kick-start your project with my new book Better Deep Learning, including step-by-step tutorials and the Python source code files for all examples. Tutorial Overview This tutorial is divided into six parts; they are: What Is the Learning Rate? Effect of Learning Rate How to Configure Learning Rate Add Momentum to the Learning Process Use a Learning Rate Schedule Adaptive Learning Rates

윤상수(2020####53)12 22 오후 10:33

교수님 답변 감사드립니다. LR 대해 이해하게 같습니다.

 

 

[Question] The Value Difference between Original Matrix and USV^T in SVD

작성자 : 고재윤(2020####97)작성일 : 12 22 오후 6:30

조회수 : 19

저는 SVD 과정을 통해 계산된 U, S, V '조정 없이' 그대로 재조합하여 U*S*V^T 다시 original matrix M 나타내면,

처음 M 정확히 같은 값으로 나타나야한다고 알고있었습니다.

다른 학우님들께서 올려주시는 Open problem 16 대한 글을 보다가, U,S,V 값을 조정 없이 그대로 재조합 하였는데도

아주 작은 오차가 발견된다는 것을 알게 되었습니다.

아래 사진은 예시로 윤상수 학우님께서 7X5 matrix 대하여 SVD 적용하시고, USV^T 식으로 재조합하신 모습입니다.

테이블이(가) 표시된 사진

자동 생성된 설명

'오차가 아주 작은 값이라서 Original matrix 비슷하다고 있다' 라고 생각할 수는 있지만 어느 과정에서 오차가 발생한 것인지 의문이 들었습니다.

오차가 발생한 이유에 대해 알려주시면 감사하겠습니다!!

이전

다음

4개의 댓글

이상구(LEE SANGGU)12 22 오후 6:42

당연히 컴퓨터가 실수를 표현하는 방식 때문에 생기는 <floating point error , 부동 소수점(Floating Point) 에러, 플로팅에러> 때문입니다. 분수가 나오면 컴퓨터는 무한소수의 일부를 또는 몇자리 이하의 수를 무시하고 다음 단계로 나가니까 ... 소숫점이하 5자리 이하에서의 아주 미세한 (무시해도 좋은) 에러는 항상 저절로 생겨납니다. https://steemit.com/kr/@modolee/floating-point 보세요^^

고재윤(2020####97)12 22 오후 6:54

감사합니다 교수님!! 궁금했던 내용이 해결되었습니다.

남상현(2018####17)12 22 오후 10:11

저도 항상 어느 정도 오차가 발생해서 소수점 세자리까지만 표현했었는데 덕분에 이유를 알게 되었습니다. 감사합니다!

윤상수(2020####53)12 22 오후 10:30

저도 오차가 발생하는 이유를 정확히 알지 못했는데 질문해주신 덕분에 알게 되었습니다. 감사합니다.

 

Open Problem 2 Solution by 이우흠 [Finalized by 정운섭, SGLee, 김지훈, 고재윤, 우건주, 안성준, 인유진, 윤상수]Open problem 2 solution by 정운섭 (3변수 함수의 Find Gradient 찾는 , Find Critical points 임계점을 찾는법.)

Open Problem 2

Sketch the graph for the function .

[ Hint: plot(x*sin(1/x), (x, -2, 2), ymin = -1.5, ymax = 1.5) ]

Practice in http://matrix.skku.ac.kr/KOFAC/



Sketch the graph for variety kinds of functions using matlab

collection of different kinds of function graphs

From basics to complicated functions



y=x

x = [0:5:100];

y = x;

plot(x, y)





y = x2

x = [-100:5:100];

y = x.^2;

plot(x, y)

 



y = sin(x)

x = [0:0.01:10];

y = sin(x);

plot(x, y), xlabel('x'), ylabel('Sin(x)'), title('Sin(x) Graph'),

grid on, axis equal





y = sin(x) & y = cos(x)



x = [0 : 0.01: 10];

y = sin(x);

g = cos(x);

plot(x, y, x, g, '.-'), legend('Sin(x)', 'Cos(x)')





f(x) = 3x4 + 2x3+ 7x2 + 2x + 9

g(x) = 5x3 + 9x + 2

x = [-10 : 0.01: 10];

y = 3*x.^4 + 2 * x.^3 + 7 * x.^2 + 2 * x + 9;

g = 5 * x.^3 + 9 * x + 2;

plot(x, y, 'r', x, g, 'g')



x = [0 : 0.01: 10];

y = exp(-x).* sin(2*x + 3);

plot(x, y), axis([0 10 -1 1])





x = [0:0.01:5];

y = exp(-1.5*x).*sin(10*x);

subplot(1,2,1)

plot(x,y), xlabel('x'),ylabel('exp(–1.5x)*sin(10x)'),axis([0 5 -1 1])

y = exp(-2*x).*sin(10*x);

subplot(1,2,2)

plot(x,y),xlabel('x'),ylabel('exp(–2x)*sin(10x)'),axis([0 5 -1 1])







이상구(LEE SANGGU)12 22 오후 11:57

Now we are working on Part 3 Calculus and Part 4. Statistics. Try to Do that~~

 

[Final OK by SGLee] Open Problem 2 Solution by 이우흠 [Finalized by 정운섭, SGLee, 김지훈, 고재윤, 우건주, 안성준, 인유진, 윤상수]Open problem 2 solution by 정운섭 (3변수 함수의 Find Gradient 찾는 , Find Critical points 임계점을 찾는법.)

Open Problem 2

Sketch the graph for the function .

[ Hint: plot(x*sin(1/x), (x, -2, 2), ymin = -1.5, ymax = 1.5) ]

Practice in http://matrix.skku.ac.kr/KOFAC/



Sketch the graph for variety kinds of functions using matlab

collection of different kinds of function graphs

From basics to complicated functions



y=x

x = [0:5:100];

y = x;

plot(x, y)





y = x2

x = [-100:5:100];

y = x.^2;

plot(x, y)

 



y = sin(x)

x = [0:0.01:10];

y = sin(x);

plot(x, y), xlabel('x'), ylabel('Sin(x)'), title('Sin(x) Graph'),

grid on, axis equal





y = sin(x) & y = cos(x)



x = [0 : 0.01: 10];

y = sin(x);

g = cos(x);

plot(x, y, x, g, '.-'), legend('Sin(x)', 'Cos(x)')





f(x) = 3x4 + 2x3+ 7x2 + 2x + 9

g(x) = 5x3 + 9x + 2

x = [-10 : 0.01: 10];

y = 3*x.^4 + 2 * x.^3 + 7 * x.^2 + 2 * x + 9;

g = 5 * x.^3 + 9 * x + 2;

plot(x, y, 'r', x, g, 'g')



x = [0 : 0.01: 10];

y = exp(-x).* sin(2*x + 3);

plot(x, y), axis([0 10 -1 1])





x = [0:0.01:5];

y = exp(-1.5*x).*sin(10*x);

subplot(1,2,1)

plot(x,y), xlabel('x'),ylabel('exp(–1.5x)*sin(10x)'),axis([0 5 -1 1])

y = exp(-2*x).*sin(10*x);

subplot(1,2,2)

plot(x,y),xlabel('x'),ylabel('exp(–2x)*sin(10x)'),axis([0 5 -1 1])







이상구(LEE SANGGU)12 22 오후 11:57

Now we are working on Part 3 Calculus and Part 4. Statistics. Try to Do that~~

이우흠(2018####75)12 23 오전 1:23

Thank you professor. I will share the statistical examples.

이상구(LEE SANGGU)12 28 오후 6:45

You may Finalize this^^

 

[Final OK by SGLee] Open Problem 2 Solution by 이우흠 [Finalized by 정운섭, SGLee, 김지훈, 고재윤, 우건주, 안성준, 인유진, 윤상수]Open problem 2 solution by 정운섭 (3변수 함수의 Find Gradient 찾는 , Find Critical points 임계점을 찾는법.)

Open Problem 2

Sketch the graph for the function .

[ Hint: plot(x*sin(1/x), (x, -2, 2), ymin = -1.5, ymax = 1.5) ]

Practice in http://matrix.skku.ac.kr/KOFAC/ (외부 사이트로 연결합니다.)

 

Example of plotting statistical data 

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from plotly.offline import init_notebook_mode, iplot
import plotly.figure_factory as ff
import cufflinks
cufflinks.go_offline()
cufflinks.set_config_file(world_readable=True, theme='pearl')
import plotly.graph_objs as go
import plotly.plotly as py
import plotly
from plotly import tools
plotly.tools.set_credentials_file(username='XXX', api_key='XXX')
init_notebook_mode(connected=True)
pd.set_option('display.max_columns', 100)
df = pd.read_csv('house_train.csv')
df.drop('Id', axis=1, inplace=True)
df.head()

table_cat = ff.create_table(df.describe(include=['O']).T, index=True, index_title='Categorical columns')
iplot(table_cat)


sns.set_theme(style="darkgrid")



테이블이(가) 표시된 사진

자동 생성된 설명



Histogram



df['SalePrice'].iplot(
    kind='hist',
    bins=100,
    xTitle='price',
    linecolor='black',
    yTitle='count',
    title='Histogram of Sale Price')





Boxplot

df['SalePrice'].iplot(kind='box', title='Box plot of SalePrice')





scatter plot



df.iplot(
    x='GrLivArea',
    y='SalePrice',
    xTitle='Above ground living area square feet',
    yTitle='Sale price',
    mode='markers',
    title='Sale Price vs Above ground living area square feet')





2D Density Joint plot



trace1 = go.Scatter(
    x=df['GrLivArea'], y=df['SalePrice'], mode='markers', name='points',
    marker=dict(color='rgb(102,0,0)', size=2, opacity=0.4)
)
trace2 = go.Histogram2dContour(
    x=df['GrLivArea'], y=df['SalePrice'], name='density', ncontours=20,
    colorscale='Hot', reversescale=True, showscale=False
)
trace3 = go.Histogram(
    x=df['GrLivArea'], name='Ground Living area density',
    marker=dict(color='rgb(102,0,0)'),
    yaxis='y2'
)
trace4 = go.Histogram(
    y=df['SalePrice'], name='Sale Price density', marker=dict(color='rgb(102,0,0)'),
    xaxis='x2'
)
data = [trace1, trace2, trace3, trace4]

layout = go.Layout(
    showlegend=False,
    autosize=False,
    width=600,
    height=550,
    xaxis=dict(
        domain=[0, 0.85],
        showgrid=False,
        zeroline=False
    ),
    yaxis=dict(
        domain=[0, 0.85],
        showgrid=False,
        zeroline=False
    ),
    margin=dict(
        t=50
    ),
    hovermode='closest',
    bargap=0,
    xaxis2=dict(
        domain=[0.85, 1],
        showgrid=False,
        zeroline=False
    ),
    yaxis2=dict(
        domain=[0.85, 1],
        showgrid=False,
        zeroline=False
    )
)

fig = go.Figure(data=data, layout=layout)
py.iplot(fig)





Heterogeneity and stratification



trace0 = go.Scatter(x=df.loc[df['BldgType'] == '1Fam']['GrLivArea'], y=df.loc[df['BldgType'] == '1Fam']['SalePrice'], mode='markers', name='1Fam')
trace1 = go.Scatter(x=df.loc[df['BldgType'] == 'TwnhsE']['GrLivArea'], y=df.loc[df['BldgType'] == 'TwnhsE']['SalePrice'], mode='markers', name='TwnhsE')
trace2 = go.Scatter(x=df.loc[df['BldgType'] == 'Duplex']['GrLivArea'], y=df.loc[df['BldgType'] == 'Duplex']['SalePrice'], mode='markers', name='Duplex')
trace3 = go.Scatter(x=df.loc[df['BldgType'] == 'Twnhs']['GrLivArea'], y=df.loc[df['BldgType'] == 'Twnhs']['SalePrice'], mode='markers', name='Twnhs')
trace4 = go.Scatter(x=df.loc[df['BldgType'] == '2fmCon']['GrLivArea'], y=df.loc[df['BldgType'] == '2fmCon']['SalePrice'], mode='markers', name='2fmCon')

fig = tools.make_subplots(rows=2, cols=3)

fig.append_trace(trace0, 1, 1)
fig.append_trace(trace1, 1, 2)
fig.append_trace(trace2, 1, 3)
fig.append_trace(trace3, 2, 1)
fig.append_trace(trace4, 2, 2)

fig['layout'].update(height=400, width=800, title='Sale price Vs. Above ground living area square feet' +
                                                  ' by building type')
py.iplot(fig)





Mixed categorical and quantitative data



        

data = []
for i in range(0,len(pd.unique(df['BldgType']))):
    trace = {
            "type": 'violin',
            "x": df['BldgType'][df['BldgType'] == pd.unique(df['BldgType'])[i]],
            "y": df['SalePrice'][df['BldgType'] == pd.unique(df['BldgType'])[i]],
            "name": pd.unique(df['BldgType'])[i],
            "box": {
                "visible": True
            },
            "meanline": {
                "visible": True
            }
        }
    data.append(trace)


fig = {
    "data": data,
    "layout" : {
        "title": "",
        "yaxis": {
            "zeroline": False,
        }
    }
}


py.iplot(fig)









이상구(LEE SANGGU)12 23 오전 1:29

Add the source and web address of the data. And add your own statement saying what you want to say with this.

이상구(LEE SANGGU)12 28 오후 6:45

You may Finalize this^^

 

[Final OK by SGLee][Discuss, Monty Hall problem] Day 10 - Open Problem 1 MONTY HALL PROBLEM, Solution by 이규식,

 [Discussion, Monty Hall problem]  Day 10 - Open Problem 1   Solution by 이규식, Monty Hall problem of conditional probabilities. (베이즈 정리, 조건부 확률과 몬티 문제)

Open Problem 1

Discuss the Monty Hall problem of conditional probabilities. It is one of the examples in which Bayes' theorem can be applied.

 어떤 게임 쇼에서 출연자에게 2개의 문 뒤에는 염소가, 1개의 문 뒤에는 자동차가 놓인 3개의 문을 보여준 후, 1개를 고르도록 합니다. 진행자는 출연자가 고르지 않은 문 중 염소가 들어있는 문을 하나 열어 보여주고 선택을 바꿀지를 물어봅니다. 이 때 바꾸는 것이 이득이냐 아니냐를 가리는 것이 몬티 홀 문제입니다. 결론부터 말하자면 바꾸는 것이 이득입니다. 이를 베이즈 정리를 활용하여 증명해보겠습니다.

각 문을 A, B, C라고 하겠습니다. 출연자가 A문을 고른다고 가정하겠습니다. 그렇다면 확률은 다음과 같습니다.

A문 뒤에 자동차가 있을 확률 P(A)=1/3

B문 뒤에 자동차가 있을 확률 P(B)=1/3

C문 뒤에 자동차가 있을 확률 P(C)=1/3

진행자가 여는 문에 관한 확률은 다음과 같습니다.

진행자가 A문을 열 확률 P(Ao)=0

진행자가 B문을 열 확률 P(Bo)=1/2

진행자가 C문을 열 확률 P(Co)=1/2

진행자가 B문을 열어 염소를 보여주었을 때, A문이 자동차일 조건부 확률 P(A I Bo) 는 베이즈 정리에 의해 P(A I Bo)=P(Bo I A)P(A)/P(Bo)입니다.

차가 A에 있을 때 진행자가 B문을 열 확률 P(Bo I A)은 직관적으로 1/2입니다. (B C문 둘 다 염소가 있으므로)

따라서 P(A I Bo) = ( (1/2) x (1/3) )/(1/2) = 1/3 입니다. 

진행자가 B문을 열어 염소를 보여주었을 때 C문이 자동차일 조건부 확률 P(C I Bo) 는 베이즈 정리에 의해 P(C I Bo)=P(Bo I C)P(C)/P(Bo)

차가 C에 있을 때 진행자가 B문을 열 확률 P(Bo I C)은 직관적으로 1입니다. (A문을 선택했는데 C에는 자동차가 있으므로 반드시 B문을 열어야만 합니다.)

따라서 P(C I Bo) = ( 1x(1/3))/(1/2) = 2/3입니다.

따라서 A를 골랐을 때 B를 열어 염소를 보여준다면, 바꾸지 않는 쪽이 1/3, 바꾸는 쪽이 2/3으로 바꾸는 쪽이 이득임을 보여줍니다. 이는 진행자가 C문을 열든, 출연자가 어떤 문을 고르든 똑같이 적용됩니다.


*****************

This is an interesting issue to discuss.

Read 
http://matrix.skku.ac.kr/2021-Final-PBL/   on  Monty Hall problem of conditional probabilities. 

박준호

Open Problem 1.

A : A 당첨인 사건(처음 고르는 )

B : B 당첨인 사건

C : C 당첨인 사건

b : B 공개되는 사건

c : c 공개되는 사건

b 공개되고 바꾸지 않았을  당첨확률

P(A|b) = P(A)*P(b|A) / (P(A)*P(b|A) + P(B)*P(b|B) + P(C)*P(b|C)) = (1/3 * 1/2) / (1/3 * 1/2 + 1/3 * 0 + 1/3 * 1) = 1/3 

P(A) = P(B) = P(C) = 1/3

P(b|A) = 1/2 (A 선택 - A 당첨 -> B 또는 C 공개)

P(b|B) = 0 (A선택 - B 당첨 -> C 공개)

P(b|C) = 1 (A선택 - C 당첨 -> 반드시 B 공개)

b 공개되고 바꾸었을 ( 경우 반드시 C 선택/ ( P(B|b) = P(B)*P(b|B) = 1/3 * 0 = 0 )) 당첨확률

P(C|b) = P(C)*P(b|C) / (P(A)*P(b|A) + P(B)*P(b|B) + P(C)*P(b|C)) = 2/3

c 공개되고 바꾸지 않았을  당첨확률

P(A|c) = P(A)*P(c|A) / (P(A)*P(c|A) + P(B)*P(c|B) + P(C)*P(c|C)) = 1/3

c 공개되고 바꾸었을  당첨확률

P(B|c) = P(B)*P(c|B) / (P(A)*P(b|A) + P(B)*P(b|B) + P(C)*P(b|C)) = 2/3



**************************

2. 베이즈 정리가 인공지능에서 어떻게 활용되나요

:이상구(LEE SANGGU)

2. [Discussion]
베이즈 정리, 조건부 확률과 몬티 문제https://m.blog.naver.com/slayerseo/221995935407  답이 있습니다.대부분의 기계학습과 패턴인식 교재는 첫장에서 베이즈 정리(Bayes’ Theorem) 베이즈 분류를 다룬다. 이유로는첫째, 베이즈 정리(Bayes’ Theorem) 이용한 베이즈 분류(Bayes Classification) 다른 기계학습 방법론들에 비해 상대적으로 알고리즘이 간단함에도 불구하고 현실세계의 많은 문제를 효과적으로 있다는 장점이 있다....18세기에 등장한 베이즈정리(조건부확률). 최근에 다시 부상하고 있다. ​. 머신러닝과 딥러닝 으로 대표되는. 인공지능에 기반한 빅데이터산업이. ...한번 보시고 요약하세요^^ 


이상구(LEE SANGGU)8 2 오후 6:02 

 

Monty Hall Problem: Solution Explained Simply

https://www.statisticshowto.com/probability-and-statistics/monty-hall-problem/ 

   
Contents 

What is the Monty Hall Problem?
A More Intuitive Way to Look at the Monty Hall Problem
Why Does Switching Work?
1975 Version of The Monty Hall Problem
The Media Furor
Using Bayes’ Theorem to Solve the Monty Hall Problem



1. 표본분산은 n 나누는 모분산과 다르게 n-1 나누는 이유가 뭔가요?http://matrix.skku.ac.kr/2020-math4ai-final-pbl/  설명이 있으니 참고하세요^^



작성자 : 이상현(2020****98)작성일 : 8 13 오후 8:21 조회수 : 40표본분산은 n 나누는 모분산과 다르게 n-1 나누는 이유가 뭔가요?확률밀도함수의 모든 구간에서의 정적분의 값이 1 아닌 경우도 있나요?

8 13 오후 8:471. 표본분산을 n 아닌 n-1 나누는 이유는 n-1 나누었을 때의 기대값이 모분산과 가깝기 때문입니다https://blog.naver.com/ptm0228/221984817258  위의 글에 증명이 있습니다.

2. 확률밀도함수는 확률변수의 분포를 나타내는 함수로, 가지 조건을 만족해야 합니다. 그중 하나가 모든 구간의 정적분 값이 1이라는 것이기 때문에 아닌 경우는 없다고 생각합니다http://matrix.skku.ac.kr/math4ai/part3/ 8 13 오후 9:14

천가영 , 훌륭합니다^^ 표본분산을 n 아닌 n-1 나누는 이유는 n-1 나누었을 때의 기대값이 모분산과 가깝기 때문입니다. 입니다.



8 14 오전 1:54 천가영 학우분의 댓글에 증명을 보니 되게 어렵네요. 저도 뜬금없이 n 아닌 n-1 나누는 이유가 궁금했어도 찾아보지를 않았네요. 좋은 정보 감사합니다.



8 14 오전 2:08 저도 궁금했던 부분인데 증명 올려주셔서 감사합니다. 증명을 완전히 이해하기에는 제가 아직 공부가 부족한 같네요. 학습을 하고나서 다시 읽어봐야겠습니다. 감사합니다.



8 14 오전 10:45 예전에 그냥 표본분산을 n-1 나누는 이유는 불편추정치를 만들기 위함 정도로 간단하게 넘어갔었는데, 그걸 증명하는 방식이 있었네요.



8 14 오후 8:37 저도 이에 대해 유사한 의문을 가지고 있었는데, 답변해주시고, 질의 해주셔서 감사드립니다. 덕분에 표본 분산에 대한 이해와 확률 밀도 함수에 대한 이해를 심화 시킬 있었습니다.



8 14 오후 10:18 자유도의 개념으로 봐도 됩니다. 예를 들어 x+y+z=3이라고 할때 x y 값을 알면 z 값의 정해지는 것이니까 종속변수가 되는 것이죠. 그러므로 독립변수는 n-1 됩니다.



8 15 오후 9:20 생각도 못해봤던 개념이네요. 감사합니다.comment :표본분산을 n-1 나누는 이유는 그래야 기댓갑이 모분산과 가깝기 때문이라는 것특히 이에 대한 증명 내용을 천가영 학우분이 올려주신 블로그에서 자세히 있었고 정확하게 이해할 있었습니다.



이상구(LEE SANGGU)8 27 오전 9:20아주 이상적으로 5주차 동료들의 학습 내용을 모으고 학습한 , 본인이 학습한 내용을 추가한 ... Final comment 추가한 이상적인 모델 입니다.



5 내용 에서 평가한다면 A 입니다. 모든 chpater 이렇게 정리하고 보고서 제출하고 발표 한다면 ... 우리 강좌 학기 성적은 당연히 A 입니다.

손원식(2019****98) 8 27 오전 9:58 글이 도움이 되셨다니 진심으로 감사합니다!! 그리고 제가 작성한 comment 오타가 있었네요 ㅠㅠ 수정하도록 하겠습니다.



정원철(2017****79)8 27 오후 3:56 정리된 글과 함께 다른 분들의 반응까지 한번에 있어서 굉장히 만족스럽습니다.

감사합니다 !관련 과정을 순서대로 설명해주시며 나타내주신 정말 감사하게 생각합니다.

[5주차] 이항분포 실습 작성자 : 한수현(2019****61) 작성일 : 8 23 오후 4:13 조회수 : 17... 

이상구(LEE SANGGU)8 2 오후 6:07 

2. [Discussion]
베이즈 정리, 조건부 확률과 몬티 문제 https://m.blog.naver.com/slayerseo/221995935407  답이 있습니다.

대부분의 기계학습과 패턴인식 교재는 첫장에서 베이즈 정리(Bayes’ Theorem) 베이즈 분류를 다룬다.

이유로는첫째, 베이즈 정리(Bayes’ Theorem) 이용한 베이즈 분류(Bayes Classification) 다른 기계학습 방법론들에 비해 상대적으로 알고리즘이 간단함에도 불구하고 현실세계의 많은 문제를 효과적으로 있다는 장점이 있다....

18세기에 등장한 베이즈정리(조건부확률). 최근에 다시 부상하

있다. ​. 머신러닝과 딥러닝 으로 대표되는. 인공지능에 기반한 빅데이터산업이. ...한번 보시고 요약하세요^^그리고 아래 내용도 도움이 것입니다.

http://matrix.skku.ac.kr/2020-math4ai-final-pbl/  토론 참고^^



Q : [Discussion] 베이즈 정리, 조건부 확률과 몬티 문제답:



A : 몬티홀 문제란 개의 문들 중에 하나를 선택하여 뒤에 있는 선물을 가질 있는 게임쇼에 참가했다.



뒤에는 자동차가 있고, 나머지 뒤에는 염소가 있다. 이때 어떤 사람이 예를 들어 1번문을 선택했을 ,

게임쇼 진행자는 3번문을 열어 뒤에 염소가 있음을 보여주면서 1 대신 2번을 선택하겠냐고 물었다.

참가자가 자동차를 가지려할 원래 선택했던 번호를 바꾸는 것이 유리할까? 라는 내용이다.



1. 경우의 수를 하나하나 따져보면, 처음의 선택을 바꾸는 것이 유리하다.



2. 조건부 확률이나 베이즈 정리를 적용했을 때도 선택을 바꾸는 것이 유리하다.



2. 문의 개수를 훨씬(100만개까지) 늘려보면, 직관적으로 생각했을 때도 처음의 선택을 바꾸는 것이 유리함을 있다.



3. ‘선택하지 않은 문들 염소가 있는 하나를 공개해주겠다.



처음 선택을 바꿀 것인가?’ 대신선택을 바꾼다면 처음에 선택하지 않은 뒤에 있는 모든 물건들을 주겠다.

처음 선택을 바꿀 것인가?’라고 생각한다면, 선택지를 조금 다르게 해석하면 확률 계산도 필요 없이 문을 두개 고른다는 생각에 쉽게 선택을 바꿀 있다.



느낀 : 몬티 문제는 정말 유명하다. 그에 대한 해설도 당연히 알려져 있다. 하지만 조건부확률과 베이즈 정리에 대해 처음 수업에서 배웠을 나는 문제를 떠올리지 못했다. 질문자님의 새로 배운 내용과 알고 있는 지식을 연결하는 능력이 뛰어나다고 느꼈다.



 박정호(2014****10)8 12 오후 6:50상세한 설명 감사합니다 

이지용(2021####83)8 2 오후 6:33 

1
번의 답이 왜그런지 전개해보았더니분산=1/(n-1)*∑k=1n(x(k)-a)^2=σ^2 ,(σ 표주편차,a 평균)라고 하면 분산을 전개해보면1/(n-1)*∑(x-a)^2=1/(n-1)*∑(x^2-2xa+a^2)=1/(n-1)*∑x^2 –2a/(n-1)*∑x +n/(n-1)*a^22=1/(n-1)*∑(a+b(k))^2 –2na^2/(n-1)+n/(n-1)*a^2=1/(n-1)*∑(a^2 +ab(k) +b(k)^2) -n/(n-1)xa^2 #(∑b(k)=0,1/(n-1)*∑b(k)^2=σ^2 )=n/(n-1)xa^2 + 0 +σ2 –n/(n-1)xa^2=σ^2 이기 때문이 라고 합니다

권서영(2020####27)8 2 오후 9:58 

1
번에 덧붙여서, 만약 the sample variance n 분모로 놓고 계산했다면, 계산된 통계값은 biased estimator of the population 것이고 특히 parameter보다 작은 값을 추정치로 놓을 것이기 때문입니다. 코멘트들이 깔끔하게 정리해 같습니다

박정현(2018####21)8 2 오후 10:04 

첨언하자면, 모집단과 달리 표본에서는 표본평균 x bar 정해져있기 때문에 n개의 표본 자유변수( 자유롭게 값을 가질 있는 경우) n-1개입니다. 합이 정해져 있기 때문입니다.

이를 자유도라고 하는데 때문에 모분산에 대한 추정량으로 편차제곱합/n 대신 편차제곱합/n-1 많이 씁니다.앞서 말씀해주신 것처럼 편차제곱합/n-1 모집단의 분포와 상관없이 모분산에 대한 불편추정량(unbiased estimator)입니다.

추정량의 불편성(unbiasedness) E(theta hat)=theta 임을 말합니다, , 추정량의 기댓값이 추정하고자 하는 모수임을 말합니다. 랜덤표본을 뽑아 표본의 표본표준편차를 계산하는 상황을 가정해 보시면, 표본표준편차의 평균을 계산했을 이것이 모분산과 근접하다고 생각하시면 되겠습니다.

이는 앞서 이지용 학우님이 계산해주신 수식을 풀어 보시면 됩니다.하지만 불편추정량이라고 해서 항상 좋은 것은 아닙니다.

모수에 대한 특정 추정량을 평가할 경우에 E[(theta-theta hat)^] 편차제곱합의 평균을 평가 기준으로 삼는데,이는 편향의 제곱과 추정량의 분산의 합입니다. 따라서 불편추정량이더라도 분산이 경우에,

추정량으로서의 성능이 좋지 않을 있으므로 이것의 분산을 함께 고려해야 합니다. 때문에 추정량의 편향을 조금 허용하는 대신 분산을 현저히 줄인 추정량들도 많이 쓰입니다.

Ridge, lasso estimator 등등이 예입니다.한편, 편차제곱합/n 자체를 sigma^2 추정량으로 직접 사용할 수도 있는데, 경우 모분산의 식을 그대로 표본의 식으로 대체한 것으로 MoM(method of moment estimator;적률방법추정량)이라고 부릅니다.추가적으로 Sigma^2 hat = 편차제곱합/n-1 이용하여 모집단의 분포가 정규분포인 상황에서 (n-1)s^2/sigma^2~Chisq(n-1)임을 이용, variable transformation 이용하여 T-test 수도 있습니다

권서영(2020####27)8 2 오후 10:14 

2
질문에 대해 이상구 교수님께서 남겨두신 링크의 글을 읽고 요약을 해봤습니다.우리 세계는 매순간 선택의 기로에 있다. 특히 정보가 홍수처럼 쏟아질 사람들은 새로운 정보를 습득해 불확실성을 낮추기 위해 노력한다. 베이즈 정리는 새로운 정보가 추가됐을 정보를 반영해 확률을 수정해 나간다. 사전확률과 사후확률이라는 개념이 있다. 어떤 실험결과에서 나온 정보를 얻기 확률을 사전, 반대를 사후라고 한다. 베이즈 이론은 과거 데이터를 기반으로 미래를 예측하기에 데이터가 많을수록 확률도 정확해진다. 특히 빅데이터 시대에서 베이즈 정리가 더욱 주목을 받는 원인이기도 하다.베이즈 정리는 주관이 분포와 확률에 영향을 미친다고 생각한다. 그래서 복잡한 상호작용들이 반복되는 현실세계를 설명하는 사전분포라고 칭해지기도 한다.사전분포를 바탕으로 새로 취득한 정보를 더해가는 베이즈통계의 분석방식은 인공지능의 핵심인 자가학습과 연관성이 깊다.실제로 개인은 무의식 속에서 조건부확률에 의한 의사결정을 실제로 하고 있으며 개개인의 조건부 확률계산에 타인의 것이 결합되면서 심리학에서 말하는 편향이 나타난다고 미루어 있다. 그래서 기계학습에 의해 숙련된 인공지능이 각광받는다

동나(2017####99)8 3 오전 3:34 

Bayes Algorithm& Natural Language Processing(Application of AI)Natural Language Processing is one of the applications of AI, which can be solved by using Naive Bayes Algorithm. The reason is that Speech recognition is something like according to received signal sequence to conjecture the signal sequence actually emitted by the speaker. Moreover, the signal sequence contained the sentences that the speaker spoke and the meanings what he or her would to express. Therefore, the problems of speech recognition can be transformed into the problems of communication recognition which can to be further simplified mathematics problem. Moreover, this mathematics problems can be solved by using Bayes Algorithm.

or  Read the following  in  
https://medium.com/@JS_Kowontan/monty-hall-problem-bayes-rule-4c6f9612dcaa   


MONTY HALL PROBLEM & BAYES’ RULE

“…no other statistical puzzle comes so close to fooling all the people all the time.”
— Massimo Piattelli-Palmarini

“After the MONTY HALL PROBLEM appeared in Parade magazine, approximately 10,000 readers,

including nearly 1,000 with PhDs, wrote to the magazine claiming Marilyn vos Savant was wrong.”


—  John Tierney, The New York Times


I. Introduction

Monty Hall problem is a brain teaser, in form of a probability puzzle, loosely based on the American TV game show Let’s Make a Deal and named after its original host, Monty Hall.
On September 9, 1990, Craig F. Whitaker, a reader of Marilyn vos Savant’s Parade Magazine column, “Ask Marilyn”, stated the Monty Hall problem in a letter to her:

Vos Savant correctly answered the question. Her response was that:
the contestant should switch to the other door. Under the standard assumptions, contestants who switch have a 2/3 chance of winning the car, while contestants who stick to their choice have only a 1/3 chance.
But her counter-intuitive solution was generally not accepted by mathematicians and everyday problem solvers around the world. In particular, Scott Smith, PhD holder from the University of Florida, presented the view of the general public:
“After the host reveals a goat, you now have a one-in-two (1/2) chance of being correct. Whether you change your selection or not, the odds are the same.”
It is therefore the main objective of this article . . .



12개의

이상구(LEE SANGGU)12 25 오후 5:27

This is an interesting issue to discuss. Read http://matrix.skku.ac.kr/2021-Final-PBL/ on Monty Hall problem of conditional probabilities. 2. 베이즈 정리가 인공지능에서 어떻게 활용되나요?

:이상구(LEE SANGGU)8 2 오후 6:07 2.

 [Discussion] 베이즈 정리, 조건부 확률과 몬티 문제https://m.blog.naver.com/slayerseo/221995935407 답이 있습니다.대부분의 기계학습과 패턴인식 교재는 첫장에서 베이즈 정리(Bayes’ Theorem) 베이즈 분류를 다룬다. 이유로는첫째, 베이즈 정리(Bayes’ Theorem) 이용한 베이즈 분류(Bayes Classification) 다른 기계학습 방법론들에 비해 상대적으로 알고리즘이 간단함에도 불구하고 현실세계의 많은 문제를 효과적으로 있다는 장점이 있다....18세기에 등장한 베이즈정리(조건부확률). 최근에 다시 부상하고 있다. ​. 머신러닝과 딥러닝 으로 대표되는. 인공지능에 기반한 빅데이터산업이. ...한번 보시고 요약하세요^^

9개의 댓글 이상구(LEE SANGGU)8 2 오후 6:02 1. 표본분산은 n 나누는 모분산과 다르게 n-1 나누는 이유가 뭔가요?http://matrix.skku.ac.kr/2020-math4ai-final-pbl/ 설명이 있으니 참고하세요^^작성자 : 이상현(2020****98)작성일 : 8 13 오후 8:21 조회수 : 40표본분산은 n 나누는 모분산과 다르게 n-1 나누는 이유가 뭔가요?확률밀도함수의 모든 구간에서의 정적분의 값이 1 아닌 경우도 있나요? 8 13 오후 8:471. 표본분산을 n 아닌 n-1 나누는 이유는 n-1 나누었을 때의 기대값이 모분산과 가깝기 때문입니다. https://blog.naver.com/ptm0228/221984817258 위의 글에 증명이 있습니다. 2. 확률밀도함수는 확률변수의 분포를 나타내는 함수로, 가지 조건을 만족해야 합니다. 그중 하나가 모든 구간의 정적분 값이 1이라는 것이기 때문에 아닌 경우는 없다고 생각합니다. http://matrix.skku.ac.kr/math4ai/part3/8 13 오후 9:14 천가영 , 훌륭합니다^^ 표본분산을 n 아닌 n-1 나누는 이유는 n-1 나누었을 때의 기대값이 모분산과 가깝기 때문입니다. 입니다.8 14 오전 1:54 천가영 학우분의 댓글에 증명을 보니 되게 어렵네요. 저도 뜬금없이 n 아닌 n-1 나누는 이유가 궁금했어도 찾아보지를 않았네요. 좋은 정보 감사합니다.8 14 오전 2:08 저도 궁금했던 부분인데 증명 올려주셔서 감사합니다. 증명을 완전히 이해하기에는 제가 아직 공부가 부족한 같네요. 학습을 하고나서 다시 읽어봐야겠습니다. 감사합니다.8 14 오전 10:45 예전에 그냥 표본분산을 n-1 나누는 이유는 불편추정치를 만들기 위함 정도로 간단하게 넘어갔었는데, 그걸 증명하는 방식이 있었네요.8 14 오후 8:37 저도 이에 대해 유사한 의문을 가지고 있었는데, 답변해주시고, 질의 해주셔서 감사드립니다. 덕분에 표본 분산에 대한 이해와 확률 밀도 함수에 대한 이해를 심화 시킬 있었습니다.8 14 오후 10:18 자유도의 개념으로 봐도 됩니다. 예를 들어 x+y+z=3이라고 할때 x y 값을 알면 z 값의 정해지는 것이니까 종속변수가 되는 것이죠. 그러므로 독립변수는 n-1 됩니다.8 15 오후 9:20 생각도 못해봤던 개념이네요. 감사합니다.comment :표본분산을 n-1 나누는 이유는 그래야 기댓갑이 모분산과 가깝기 때문이라는 것특히 이에 대한 증명 내용을 천가영 학우분이 올려주신 블로그에서 자세히 있었고 정확하게 이해할 있었습니다.이상구(LEE SANGGU)8 27 오전 9:20아주 이상적으로 5주차 동료들의 학습 내용을 모으고 학습한 , 본인이 학습한 내용을 추가한 ... Final comment 추가한 이상적인 모델 입니다. 5 내용 에서 평가한다면 A 입니다. 모든 chpater 이렇게 정리하고 보고서 제출하고 발표 한다면 ... 우리 강좌 학기 성적은 당연히 A 입니다.손원식(2019****98)8 27 오전 9:58 글이 도움이 되셨다니 진심으로 감사합니다!! 그리고 제가 작성한 comment 오타가 있었네요 ㅠㅠ 수정하도록 하겠습니다.정원철(2017****79)8 27 오후 3:56 정리된 글과 함께 다른 분들의 반응까지 한번에 있어서 굉장히 만족스럽습니다. 감사합니다 !관련 과정을 순서대로 설명해주시며 나타내주신 정말 감사하게 생각합니다.[5주차] 이항분포 실습 작성자 : 한수현(2019****61) 작성일 : 8 23 오후 4:13 조회수 : 17... 이상구(LEE SANGGU)8 2 오후 6:07 2. [Discussion] 베이즈 정리, 조건부 확률과 몬티 문제https://m.blog.naver.com/slayerseo/221995935407 답이 있습니다.대부분의 기계학습과 패턴인식 교재는 첫장에서 베이즈 정리(Bayes’ Theorem) 베이즈 분류를 다룬다. 이유로는첫째, 베이즈 정리(Bayes’ Theorem) 이용한 베이즈 분류(Bayes Classification) 다른 기계학습 방법론들에 비해 상대적으로 알고리즘이 간단함에도 불구하고 현실세계의 많은 문제를 효과적으로 있다는 장점이 있다....18세기에 등장한 베이즈정리(조건부확률). 최근에 다시 부상하고 있다. ​. 머신러닝과 딥러닝 으로 대표되는. 인공지능에 기반한 빅데이터산업이. ...한번 보시고 요약하세요^^그리고 아래 내용도 도움이 것입니다.http://matrix.skku.ac.kr/2020-math4ai-final-pbl/ 토론 참고^^Q : [Discussion] 베이즈 정리, 조건부 확률과 몬티 문제답: A : 몬티홀 문제란 개의 문들 중에 하나를 선택하여 뒤에 있는 선물을 가질 있는 게임쇼에 참가했다. 뒤에는 자동차가 있고, 나머지 뒤에는 염소가 있다. 이때 어떤 사람이 예를 들어 1번문을 선택했을 , 게임쇼 진행자는 3번문을 열어 뒤에 염소가 있음을 보여주면서 1 대신 2번을 선택하겠냐고 물었다. 참가자가 자동차를 가지려할 원래 선택했던 번호를 바꾸는 것이 유리할까? 라는 내용이다. 1. 경우의 수를 하나하나 따져보면, 처음의 선택을 바꾸는 것이 유리하다.2. 조건부 확률이나 베이즈 정리를 적용했을 때도 선택을 바꾸는 것이 유리하다.2. 문의 개수를 훨씬(100만개까지) 늘려보면, 직관적으로 생각했을 때도 처음의 선택을 바꾸는 것이 유리함을 있다.3. ‘선택하지 않은 문들 염소가 있는 하나를 공개해주겠다. 처음 선택을 바꿀 것인가?’ 대신선택을 바꾼다면 처음에 선택하지 않은 뒤에 있는 모든 물건들을 주겠다. 처음 선택을 바꿀 것인가?’라고 생각한다면, 선택지를 조금 다르게 해석하면 확률 계산도 필요 없이 문을 두개 고른다는 생각에 쉽게 선택을 바꿀 있다.느낀 : 몬티 문제는 정말 유명하다. 그에 대한 해설도 당연히 알려져 있다. 하지만 조건부확률과 베이즈 정리에 대해 처음 수업에서 배웠을 나는 문제를 떠올리지 못했다. …. 동나(2017####99)8 3 오전 3:34 Bayes Algorithm& Natural Language Processing(Application of AI)Natural Language Processing is one of the applications of AI, which can be solved by using Naive Bayes Algorithm. The reason is that Speech recognition is something like according to received signal sequence to conjecture the signal sequence actually emitted by the speaker. Moreover, the signal sequence contained the sentences that the speaker spoke and the meanings what he or her would to express. Therefore, the problems of speech recognition can be transformed into the problems of communication recognition which can to be further simplified mathematics problem. Moreover, this mathematics problems can be solved by using Bayes Algorithm. or the following in https://medium.com/@JS_Kowontan/monty-hall-problem-bayes-rule-4c6f9612dcaa MONTY HALL PROBLEM & BAYES’ RULE “…no other statistical puzzle comes so close to fooling all the people all the time.” — Massimo Piattelli-Palmarini “After the problem appeared in Parade magazine, approximately 10,000 readers, including nearly 1,000 with PhDs, wrote to the magazine claiming Marilyn vos Savant was wrong.” — John Tierney, The New York Times I. Introduction Monty Hall problem is a brain teaser, in form of a probability puzzle, loosely based on the American TV game show Let’s Make a Deal and named after its original host, Monty Hall. On September 9, 1990, Craig F. Whitaker, a reader of Marilyn vos Savant’s Parade Magazine column, “Ask Marilyn”, stated the Monty Hall problem in a letter to her: Vos Savant correctly answered the question. Her response was that: the contestant should switch to the other door. Under the standard assumptions, contestants who switch have a 2/3 chance of winning the car, while contestants who stick to their choice have only a 1/3 chance. But her counter-intuitive solution was generally not accepted by mathematicians and everyday problem solvers around the world. In particular, Scott Smith, PhD holder from the University of Florida, presented the view of the general public: “After the host reveals a goat, you now have a one-in-two (1/2) chance of being correct. Whether you change your selection or not, the odds are the same.” It is therefore the main objective of this article . . .

이상구(LEE SANGGU)12 25 오후 6:06

Monty Hall Problem: Solution Explained Simply https://www.statisticshowto.com/probability-and-statistics/monty-hall-problem/ Contents What is the Monty Hall Problem? A More Intuitive Way to Look at the Monty Hall Problem Why Does Switching Work? 1975 Version of The Monty Hall Problem The Media Furor Using Bayes’ Theorem to Solve the Monty Hall Problem

고재윤(2020####97)12 26 오전 3:47

Monty Hall problem of conditional probabilities에서 직관적인 예측과 실제 풀이 사이에서 어려움을 느꼈는데, 덕분에 이해하는데 도움이 되었습니다. 감사합니다.

정운섭(2018####88)12 26 오후 9:32

Monty Hall 역설을 조건부 확률을 사용하여 풀이하는 방법을 이해하고 그것이 성립되는 이유를 알게 되었습니다.

우건주(2017####97)12 27 오후 1:42

Monty Hall문제가 Bayes' theorem으로 어떻게 설명될 있는지 배울 있었습니다.

김지훈(2020####97)12 27 오후 2:53

조건부 확률과 Monty Hall 문제에 대해 확실하게 이해하는데 도움이 많이 되었습니다. 감사합니다! 나중에 친구랑 내기하다가 같은 상황이 온다면 선택을 바꿔야하겠군요.

남상현(2018####17)12 27 오후 11:04

몬티홀 문제가 Bayes' Theorem 무슨 연관이 있는지 이해하기 힘들었는데 덕분에 이해했습니다. 감사합니다!

강민지(2021####12)12 27 오후 11:06

조건부 확률을 통해 Month Hall 문제를 해결하는 과정을 보며, 구체적인 풀이를 이해할 있었습니다. 감사합니다!

윤상수(2020####53)12 27 오후 11:35

베이지안 정리가 정보의 업데이트에 따른 확률의 변화를 알려준다는 것을 간단한 몬티홀 예시를 통해 있었습니다. 인공지능도 끊임없이 학습을 반복하며 정보가 업데이트되기 때문에 베이지안 정리가 많이 쓰이는 같습니다.

이상구(LEE SANGGU)12 28 오후 6:43

You may Finalize this^^

이규리(2018####45)12 29

오후 11:16

Monty hall problem 베이즈 정리를 이용해서 각각의 확률이 이렇게 도출되는지 세세하게 설명해주셔서 이해할 있었습니다. 그리고 베이즈 정리가 많이 사용되는지도 있었습니다. 감사합니다!

박우현(2016####31)12 30 오전 2:19

Monty hall problem 헷갈릴만한 여지가 많은 문제인 같은데, 베이즈 정리를 통해 명확한 해석이 가능하다는 점이 놀라웠습니다. 이해하기 쉬운 설명 감사합니다.

 

Open problem 2 solution by 고재윤, (find the expected value, the variance, and the standard deviation for X)

작성자 : 고재윤(2020####97)작성일 : 12 26 오후 7:31

조회수 : 46

I assumed f(X)=( X^2+X )*( ( cos(X) )^2 )      (0<X<a) as a probability density function

At this interval, f(X) >=0. So above function is appropriate for probability density function.



The integral of probability density function for variable, from (- inf) to (+ inf) should be 1.

It means, integral of f(X) for X, from 0 to 'a' should be 1. 

To find real number a, I coded and check the value as below. 

텍스트이(가) 표시된 사진

자동 생성된 설명



Now I coded to find the expected value, the variance, and the standard deviation for X



텍스트이(가) 표시된 사진

자동 생성된 설명



Now, I evaluated the expected value, the variance, and the standard deviation for X.

We can evaluate  expected value, the variance, and the standard deviation for X for other probability density function easily just adjusting the code above .

It was difficult to find a way to check the answer, so if you find my error, please leave a comment.



ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ



f(x)=(x^2+x)*((cos(x))^2)  # If you want to work for other function, adjust only this line
plot(f(x))
var('t')
assume(t>0)
g(t)=integral(f(x),x,0,t)
a=find_root(g(t)-1,0,10)  # execute until here, result is 2.15737....


Ex = integral(x*f(x), x, 0, a)
Ex2 = integral((x^2)*f(x), x, 0, a)
print("Expected Value =",Ex)

print("Variance =",Ex2 - Ex^2)
print("Standard deviation =", sqrt(Ex2 - Ex^2))

이상구(LEE SANGGU)12 27 오전 10:21

Nice Try^^

이상구(LEE SANGGU)12 27 오전 10:23

<Week 11- Open Problem 2 Correction Using Kim Daniels Code- Pravas Giri> … 이상구(LEE SANGGU)December 4, 11:18 AM Good. You are back. PBL due was extended 24 hours. Good luck. 기리프라바스(2021####24)December 4, 12:06 PM Thank you sir. Open Problems: #2: # W11 (Kim Daniil) Chapter 3 Open Problem 2 # Probability Density Function f(x) = x^5+e^(3*x) xmin = -0.5 xmax = 1 show("Initial Probability Density Function: f(x)=", f(x)) # Expectation Ex = integral(x*f(x), x, xmin, xmax) tempEx = integral(x^2*f(x), x, xmin, xmax) show("Expectation: E(X)=", Ex) Var(X) = tempEx - Ex^2 show("Variance: Var(X)=", Var(X)) SD(X) = sqrt(Var(X)) show("Standard Deviation: SD(X)=", SD(X)) Code: We can practice the above code in http://matrix.skku.ac.kr/KOFAC/ and in https://sagecell.sagemath.org/

윤상수(2020####53)12 27 오후 11:45

구간의 오른쪽 끝이 정해지지 않은 함수를 적분값 1 고려하여 구하는 것이 인상깊었습니다. 양자역학에서도 wave equation 구할 비슷한 과정을 거치는데, eigenfunction coeffieient 구해주는 normalization 생각나서 흥미로웠습니다.