SlideShare a Scribd company logo
1 of 21
https://github.com/DevStarSJ/Study/blob/master/Blog/Python/DoingMathWithPython/DoingMathWithPython.Ch06.ipynb
• 원서명 : Doing Math with Python: Use Programming to Explore Algebra,
Statistics, Calculus, More! (ISBN 9781593276409)
• 지은이 : 아미트 사하(Amit Saha)
• 원서 및 관련자료 : https://www.nostarch.com/doingmathwithpython
• 번역서 : http://www.acornpub.co.kr/book/doing-math-with-python
3
 figure 객체 얻어오기
- .figure() : 생성
- .gcf() : 현재 figure 객체
 axes 객체 얻어오기
- .axes() : 생성
- .gca() : 현재 axes 객체
4
 원 그리기
 사각형 그리기
5
6
• fig : 현 그림의 객체
• update_radius : 프레임 번호와 프레임마다 갱신하기를 바라는 패치 객체가 전달되어서
원하는 모양으로 변경한 뒤 패치 객체를 리턴
• fargs : update_radius()에게 전달되는 인자들의 목록 (프레임 번호는 제외)
• frames : 애니메이션의 프레임 개수. 여기에 적힌 수 만큼 update_radius()를 호출하게 됨
• interval : 프레임 간의 시간 간격 (밀리미터 단위)
• repeat : True, False 값을 가질 수 있으며 애니메이션의 반복 유무를 결정. (default는 True)
7
 전체 소스는 상세설명 링크 참조
8
단순한 구조가 끊임없이 반복되면서 복잡하고 묘한 전체 구조를 만드는 것으로, 즉 자기유사성(self-similarity)
와 순환성(recursiveness)라는 특징을 가지고 있다.
– 우리 생활 속 프랙탈 by 박희훈 ( https://prezi.com/gffdwoyxj7qd/presentation
9
 평면상 점 변환 (단순한 프랙탈 예제)
P(x, y) -> Q(x+1, y+1)
10
 2개의 룰 중 랜덤
P(x, y) -> Q(x+1, y+1) or Q(x+1, y-1)
11
 random.choice() : 입력된 리스트 중 동일한 확률로 랜덤으로 선택
P(x, y) -> Q(x+1, y+1) or Q(x+1, y-1)
12
 반즐리(Michael Barnsley)의 고사리
13
5x5 영역에 0 ~ 10의 색분포를 랜덤으로 색칠하는 프로그램 작성
(각각의 점의 색은 검은색을 0 흰색을 10으로 하여 그 사이 값을 가짐)
 2차원 List 생성하는 함수
14
 imshow() 함수를 이용하여 이미지 출력
15
 imshow() 주요 인자
- origin : lower인 경우 list2D[0][0] 값이 이미지 상 (0,0)으로 매칭
- extent : 이미지 좌측하단을 (0,0), 우측상단을 (5,5)로 설정
- cmap=cm.Greys_r : 회색스케일의 이미지를 생성
- interpolation=‘nearest’ : 가장 인접한 점과는 같은 색으로 그리지 않도록 설정
https://github.com/DevStarSJ/Study/blob/master/Blog/Python/DoingMathWithPython/DoingMathWithPython.Ch06.ipynb
https://www.nostarch.com/doingmathwithpython
17
1. 먼저 큰 사각형을 하나 그린 다음
2. 사각형 내에 반지름 0.5인 원을 채워 넣으세요.
18
폴란드 수학자 바츌라프 시어핀스키 (Waclaw Sierpinski)의 정삼각형 프렉탈을 그리세요.
(모든 확률은 1/3으로 동일합니다.)
19
1976년 마이클 헤논(Michael Henon) 함수를 애니메이션으로 작성하세요.
20
 (-2.5, -1.0) ~ (1.0, 1.0) 공간에 각 축을 400x400의 공간으로 나눈 곳에 점을 찍습니다.
1. 2개의 복소수를 생성
z1 = 0 + 0j
c = xi + ykj
2. 레이블 iteration을 생성하여 0으로 설정
3. 복소수 z1 = z1^2 + c
4. iteration 값을 1 증가
5. abs(z1) < 2 이며 iteration < max_iteration이면 3단계로 이동,
그렇지 않으면 6단계로 이동
(max_iteration을 1,000으로 설정, 더 커질수록 복잡한 이미지가 생성되나 계산 시간이 길어짐)
6. 점 (xi, yk)의 색상을 iteration으로 설정
Doing math with python.ch06

More Related Content

What's hot

Doing math with python.ch03
Doing math with python.ch03Doing math with python.ch03
Doing math with python.ch03Seok-joon Yun
 
2012 Dm C2 04
2012 Dm C2 042012 Dm C2 04
2012 Dm C2 04seonhyung
 
Doing mathwithpython.ch02
Doing mathwithpython.ch02Doing mathwithpython.ch02
Doing mathwithpython.ch02Seok-joon Yun
 
Doing math with python.ch04
Doing math with python.ch04Doing math with python.ch04
Doing math with python.ch04Seok-joon Yun
 
Doing math with python.ch05
Doing math with python.ch05Doing math with python.ch05
Doing math with python.ch05Seok-joon Yun
 
Doing math with python.ch01
Doing math with python.ch01Doing math with python.ch01
Doing math with python.ch01Seok-joon Yun
 
종이접기(fold) 프로그래밍
종이접기(fold) 프로그래밍종이접기(fold) 프로그래밍
종이접기(fold) 프로그래밍Kwang Yul Seo
 
Canvas_basic tutorial
Canvas_basic tutorialCanvas_basic tutorial
Canvas_basic tutorialfairesy
 
하스켈 프로그래밍 입문 2
하스켈 프로그래밍 입문 2하스켈 프로그래밍 입문 2
하스켈 프로그래밍 입문 2Kwang Yul Seo
 
2012 Dm C2 05
2012 Dm C2 052012 Dm C2 05
2012 Dm C2 05seonhyung
 

What's hot (12)

Doing math with python.ch03
Doing math with python.ch03Doing math with python.ch03
Doing math with python.ch03
 
2012 Dm C2 04
2012 Dm C2 042012 Dm C2 04
2012 Dm C2 04
 
Doing mathwithpython.ch02
Doing mathwithpython.ch02Doing mathwithpython.ch02
Doing mathwithpython.ch02
 
Doing math with python.ch04
Doing math with python.ch04Doing math with python.ch04
Doing math with python.ch04
 
Doing math with python.ch05
Doing math with python.ch05Doing math with python.ch05
Doing math with python.ch05
 
Doing math with python.ch01
Doing math with python.ch01Doing math with python.ch01
Doing math with python.ch01
 
종이접기(fold) 프로그래밍
종이접기(fold) 프로그래밍종이접기(fold) 프로그래밍
종이접기(fold) 프로그래밍
 
Canvas_basic tutorial
Canvas_basic tutorialCanvas_basic tutorial
Canvas_basic tutorial
 
하스켈 프로그래밍 입문 2
하스켈 프로그래밍 입문 2하스켈 프로그래밍 입문 2
하스켈 프로그래밍 입문 2
 
Matlab gui
Matlab guiMatlab gui
Matlab gui
 
Picking
PickingPicking
Picking
 
2012 Dm C2 05
2012 Dm C2 052012 Dm C2 05
2012 Dm C2 05
 

Viewers also liked

[C++ Korea] Effective Modern C++ Study item14 16 +신촌
[C++ Korea] Effective Modern C++ Study item14 16 +신촌[C++ Korea] Effective Modern C++ Study item14 16 +신촌
[C++ Korea] Effective Modern C++ Study item14 16 +신촌Seok-joon Yun
 
[C++ korea] effective modern c++ study item 1정은식
[C++ korea] effective modern c++ study item 1정은식[C++ korea] effective modern c++ study item 1정은식
[C++ korea] effective modern c++ study item 1정은식은식 정
 
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...Seok-joon Yun
 
[C++ korea] effective modern c++ study item 3 understand decltype +이동우
[C++ korea] effective modern c++ study   item 3 understand decltype +이동우[C++ korea] effective modern c++ study   item 3 understand decltype +이동우
[C++ korea] effective modern c++ study item 3 understand decltype +이동우Seok-joon Yun
 
SNA & R (20121011)
SNA & R (20121011)SNA & R (20121011)
SNA & R (20121011)주영 송
 
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...Seok-joon Yun
 
Pro typescript.ch07.Exception, Memory, Performance
Pro typescript.ch07.Exception, Memory, PerformancePro typescript.ch07.Exception, Memory, Performance
Pro typescript.ch07.Exception, Memory, PerformanceSeok-joon Yun
 
[C++ korea] effective modern c++ study item8~10 정은식
[C++ korea] effective modern c++ study item8~10 정은식[C++ korea] effective modern c++ study item8~10 정은식
[C++ korea] effective modern c++ study item8~10 정은식은식 정
 
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...Seok-joon Yun
 
C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부Gwangwhi Mah
 
병렬프로그래밍과 Cuda
병렬프로그래밍과 Cuda병렬프로그래밍과 Cuda
병렬프로그래밍과 CudaSeok-joon Yun
 
Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심흥배 최
 
ECS for Amazon Deep Learning and Amazon Machine Learning
ECS for Amazon Deep Learning and Amazon Machine LearningECS for Amazon Deep Learning and Amazon Machine Learning
ECS for Amazon Deep Learning and Amazon Machine LearningAmanda Mackay (she/her)
 
Deep learning with C++ - an introduction to tiny-dnn
Deep learning with C++  - an introduction to tiny-dnnDeep learning with C++  - an introduction to tiny-dnn
Deep learning with C++ - an introduction to tiny-dnnTaiga Nomi
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer VisionSungjoon Choi
 
Scaling Deep Learning with MXNet
Scaling Deep Learning with MXNetScaling Deep Learning with MXNet
Scaling Deep Learning with MXNetAI Frontiers
 
Top 5 Deep Learning 12/8
Top 5 Deep Learning 12/8Top 5 Deep Learning 12/8
Top 5 Deep Learning 12/8NVIDIA
 
Deep Learning Computer Build
Deep Learning Computer BuildDeep Learning Computer Build
Deep Learning Computer BuildPetteriTeikariPhD
 

Viewers also liked (20)

[C++ Korea] Effective Modern C++ Study item14 16 +신촌
[C++ Korea] Effective Modern C++ Study item14 16 +신촌[C++ Korea] Effective Modern C++ Study item14 16 +신촌
[C++ Korea] Effective Modern C++ Study item14 16 +신촌
 
[C++ korea] effective modern c++ study item 1정은식
[C++ korea] effective modern c++ study item 1정은식[C++ korea] effective modern c++ study item 1정은식
[C++ korea] effective modern c++ study item 1정은식
 
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
 
[C++ korea] effective modern c++ study item 3 understand decltype +이동우
[C++ korea] effective modern c++ study   item 3 understand decltype +이동우[C++ korea] effective modern c++ study   item 3 understand decltype +이동우
[C++ korea] effective modern c++ study item 3 understand decltype +이동우
 
SNA & R (20121011)
SNA & R (20121011)SNA & R (20121011)
SNA & R (20121011)
 
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
 
Cuda intro
Cuda introCuda intro
Cuda intro
 
Pro typescript.ch07.Exception, Memory, Performance
Pro typescript.ch07.Exception, Memory, PerformancePro typescript.ch07.Exception, Memory, Performance
Pro typescript.ch07.Exception, Memory, Performance
 
[C++ korea] effective modern c++ study item8~10 정은식
[C++ korea] effective modern c++ study item8~10 정은식[C++ korea] effective modern c++ study item8~10 정은식
[C++ korea] effective modern c++ study item8~10 정은식
 
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
 
C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부
 
병렬프로그래밍과 Cuda
병렬프로그래밍과 Cuda병렬프로그래밍과 Cuda
병렬프로그래밍과 Cuda
 
Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심
 
ECS for Amazon Deep Learning and Amazon Machine Learning
ECS for Amazon Deep Learning and Amazon Machine LearningECS for Amazon Deep Learning and Amazon Machine Learning
ECS for Amazon Deep Learning and Amazon Machine Learning
 
Deep learning with C++ - an introduction to tiny-dnn
Deep learning with C++  - an introduction to tiny-dnnDeep learning with C++  - an introduction to tiny-dnn
Deep learning with C++ - an introduction to tiny-dnn
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
 
Amazon Deep Learning
Amazon Deep LearningAmazon Deep Learning
Amazon Deep Learning
 
Scaling Deep Learning with MXNet
Scaling Deep Learning with MXNetScaling Deep Learning with MXNet
Scaling Deep Learning with MXNet
 
Top 5 Deep Learning 12/8
Top 5 Deep Learning 12/8Top 5 Deep Learning 12/8
Top 5 Deep Learning 12/8
 
Deep Learning Computer Build
Deep Learning Computer BuildDeep Learning Computer Build
Deep Learning Computer Build
 

More from Seok-joon Yun

Retrospective.2020 03
Retrospective.2020 03Retrospective.2020 03
Retrospective.2020 03Seok-joon Yun
 
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image ConverterAWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image ConverterSeok-joon Yun
 
아파트 시세,어쩌다 머신러닝까지
아파트 시세,어쩌다 머신러닝까지아파트 시세,어쩌다 머신러닝까지
아파트 시세,어쩌다 머신러닝까지Seok-joon Yun
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptSeok-joon Yun
 
C++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threadsC++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threadsSeok-joon Yun
 
Welcome to Modern C++
Welcome to Modern C++Welcome to Modern C++
Welcome to Modern C++Seok-joon Yun
 
[2015-07-20-윤석준] Oracle 성능 관리 2
[2015-07-20-윤석준] Oracle 성능 관리 2[2015-07-20-윤석준] Oracle 성능 관리 2
[2015-07-20-윤석준] Oracle 성능 관리 2Seok-joon Yun
 
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstatSeok-joon Yun
 
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4Seok-joon Yun
 
오렌지6.0 교육자료
오렌지6.0 교육자료오렌지6.0 교육자료
오렌지6.0 교육자료Seok-joon Yun
 
[2015-06-26] Oracle 성능 최적화 및 품질 고도화 3
[2015-06-26] Oracle 성능 최적화 및 품질 고도화 3[2015-06-26] Oracle 성능 최적화 및 품질 고도화 3
[2015-06-26] Oracle 성능 최적화 및 품질 고도화 3Seok-joon Yun
 
[2015-06-19] Oracle 성능 최적화 및 품질 고도화 2
[2015-06-19] Oracle 성능 최적화 및 품질 고도화 2[2015-06-19] Oracle 성능 최적화 및 품질 고도화 2
[2015-06-19] Oracle 성능 최적화 및 품질 고도화 2Seok-joon Yun
 
[2015-06-12] Oracle 성능 최적화 및 품질 고도화 1
[2015-06-12] Oracle 성능 최적화 및 품질 고도화 1[2015-06-12] Oracle 성능 최적화 및 품질 고도화 1
[2015-06-12] Oracle 성능 최적화 및 품질 고도화 1Seok-joon Yun
 
[2015-06-05] Oracle TX Lock
[2015-06-05] Oracle TX Lock[2015-06-05] Oracle TX Lock
[2015-06-05] Oracle TX LockSeok-joon Yun
 
[KOSSA] C++ Programming - 18th Study - STL #4
[KOSSA] C++ Programming - 18th Study - STL #4[KOSSA] C++ Programming - 18th Study - STL #4
[KOSSA] C++ Programming - 18th Study - STL #4Seok-joon Yun
 
[KOSSA] C++ Programming - 17th Study - STL #3
[KOSSA] C++ Programming - 17th Study - STL #3[KOSSA] C++ Programming - 17th Study - STL #3
[KOSSA] C++ Programming - 17th Study - STL #3Seok-joon Yun
 
[KOSSA] C++ Programming - 16th Study - STL #2
[KOSSA] C++ Programming - 16th Study - STL #2[KOSSA] C++ Programming - 16th Study - STL #2
[KOSSA] C++ Programming - 16th Study - STL #2Seok-joon Yun
 

More from Seok-joon Yun (20)

Retrospective.2020 03
Retrospective.2020 03Retrospective.2020 03
Retrospective.2020 03
 
Sprint & Jira
Sprint & JiraSprint & Jira
Sprint & Jira
 
Eks.introduce.v2
Eks.introduce.v2Eks.introduce.v2
Eks.introduce.v2
 
Eks.introduce
Eks.introduceEks.introduce
Eks.introduce
 
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image ConverterAWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
 
아파트 시세,어쩌다 머신러닝까지
아파트 시세,어쩌다 머신러닝까지아파트 시세,어쩌다 머신러닝까지
아파트 시세,어쩌다 머신러닝까지
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
 
C++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threadsC++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threads
 
Welcome to Modern C++
Welcome to Modern C++Welcome to Modern C++
Welcome to Modern C++
 
[2015-07-20-윤석준] Oracle 성능 관리 2
[2015-07-20-윤석준] Oracle 성능 관리 2[2015-07-20-윤석준] Oracle 성능 관리 2
[2015-07-20-윤석준] Oracle 성능 관리 2
 
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
 
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
 
오렌지6.0 교육자료
오렌지6.0 교육자료오렌지6.0 교육자료
오렌지6.0 교육자료
 
[2015-06-26] Oracle 성능 최적화 및 품질 고도화 3
[2015-06-26] Oracle 성능 최적화 및 품질 고도화 3[2015-06-26] Oracle 성능 최적화 및 품질 고도화 3
[2015-06-26] Oracle 성능 최적화 및 품질 고도화 3
 
[2015-06-19] Oracle 성능 최적화 및 품질 고도화 2
[2015-06-19] Oracle 성능 최적화 및 품질 고도화 2[2015-06-19] Oracle 성능 최적화 및 품질 고도화 2
[2015-06-19] Oracle 성능 최적화 및 품질 고도화 2
 
[2015-06-12] Oracle 성능 최적화 및 품질 고도화 1
[2015-06-12] Oracle 성능 최적화 및 품질 고도화 1[2015-06-12] Oracle 성능 최적화 및 품질 고도화 1
[2015-06-12] Oracle 성능 최적화 및 품질 고도화 1
 
[2015-06-05] Oracle TX Lock
[2015-06-05] Oracle TX Lock[2015-06-05] Oracle TX Lock
[2015-06-05] Oracle TX Lock
 
[KOSSA] C++ Programming - 18th Study - STL #4
[KOSSA] C++ Programming - 18th Study - STL #4[KOSSA] C++ Programming - 18th Study - STL #4
[KOSSA] C++ Programming - 18th Study - STL #4
 
[KOSSA] C++ Programming - 17th Study - STL #3
[KOSSA] C++ Programming - 17th Study - STL #3[KOSSA] C++ Programming - 17th Study - STL #3
[KOSSA] C++ Programming - 17th Study - STL #3
 
[KOSSA] C++ Programming - 16th Study - STL #2
[KOSSA] C++ Programming - 16th Study - STL #2[KOSSA] C++ Programming - 16th Study - STL #2
[KOSSA] C++ Programming - 16th Study - STL #2
 

Doing math with python.ch06

  • 1.
  • 2. https://github.com/DevStarSJ/Study/blob/master/Blog/Python/DoingMathWithPython/DoingMathWithPython.Ch06.ipynb • 원서명 : Doing Math with Python: Use Programming to Explore Algebra, Statistics, Calculus, More! (ISBN 9781593276409) • 지은이 : 아미트 사하(Amit Saha) • 원서 및 관련자료 : https://www.nostarch.com/doingmathwithpython • 번역서 : http://www.acornpub.co.kr/book/doing-math-with-python
  • 3. 3  figure 객체 얻어오기 - .figure() : 생성 - .gcf() : 현재 figure 객체  axes 객체 얻어오기 - .axes() : 생성 - .gca() : 현재 axes 객체
  • 4. 4  원 그리기  사각형 그리기
  • 5. 5
  • 6. 6 • fig : 현 그림의 객체 • update_radius : 프레임 번호와 프레임마다 갱신하기를 바라는 패치 객체가 전달되어서 원하는 모양으로 변경한 뒤 패치 객체를 리턴 • fargs : update_radius()에게 전달되는 인자들의 목록 (프레임 번호는 제외) • frames : 애니메이션의 프레임 개수. 여기에 적힌 수 만큼 update_radius()를 호출하게 됨 • interval : 프레임 간의 시간 간격 (밀리미터 단위) • repeat : True, False 값을 가질 수 있으며 애니메이션의 반복 유무를 결정. (default는 True)
  • 7. 7  전체 소스는 상세설명 링크 참조
  • 8. 8 단순한 구조가 끊임없이 반복되면서 복잡하고 묘한 전체 구조를 만드는 것으로, 즉 자기유사성(self-similarity) 와 순환성(recursiveness)라는 특징을 가지고 있다. – 우리 생활 속 프랙탈 by 박희훈 ( https://prezi.com/gffdwoyxj7qd/presentation
  • 9. 9  평면상 점 변환 (단순한 프랙탈 예제) P(x, y) -> Q(x+1, y+1)
  • 10. 10  2개의 룰 중 랜덤 P(x, y) -> Q(x+1, y+1) or Q(x+1, y-1)
  • 11. 11  random.choice() : 입력된 리스트 중 동일한 확률로 랜덤으로 선택 P(x, y) -> Q(x+1, y+1) or Q(x+1, y-1)
  • 13. 13 5x5 영역에 0 ~ 10의 색분포를 랜덤으로 색칠하는 프로그램 작성 (각각의 점의 색은 검은색을 0 흰색을 10으로 하여 그 사이 값을 가짐)  2차원 List 생성하는 함수
  • 14. 14  imshow() 함수를 이용하여 이미지 출력
  • 15. 15  imshow() 주요 인자 - origin : lower인 경우 list2D[0][0] 값이 이미지 상 (0,0)으로 매칭 - extent : 이미지 좌측하단을 (0,0), 우측상단을 (5,5)로 설정 - cmap=cm.Greys_r : 회색스케일의 이미지를 생성 - interpolation=‘nearest’ : 가장 인접한 점과는 같은 색으로 그리지 않도록 설정
  • 17. 17 1. 먼저 큰 사각형을 하나 그린 다음 2. 사각형 내에 반지름 0.5인 원을 채워 넣으세요.
  • 18. 18 폴란드 수학자 바츌라프 시어핀스키 (Waclaw Sierpinski)의 정삼각형 프렉탈을 그리세요. (모든 확률은 1/3으로 동일합니다.)
  • 19. 19 1976년 마이클 헤논(Michael Henon) 함수를 애니메이션으로 작성하세요.
  • 20. 20  (-2.5, -1.0) ~ (1.0, 1.0) 공간에 각 축을 400x400의 공간으로 나눈 곳에 점을 찍습니다. 1. 2개의 복소수를 생성 z1 = 0 + 0j c = xi + ykj 2. 레이블 iteration을 생성하여 0으로 설정 3. 복소수 z1 = z1^2 + c 4. iteration 값을 1 증가 5. abs(z1) < 2 이며 iteration < max_iteration이면 3단계로 이동, 그렇지 않으면 6단계로 이동 (max_iteration을 1,000으로 설정, 더 커질수록 복잡한 이미지가 생성되나 계산 시간이 길어짐) 6. 점 (xi, yk)의 색상을 iteration으로 설정