Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
lecture
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pt1_hs20
lecture
Commits
997ed0c7
Commit
997ed0c7
authored
Dec 10, 2020
by
rworreby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add exercise 13
parent
33ad4a08
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
exercises/ex13/exercise13.pdf
exercises/ex13/exercise13.pdf
+0
-0
exercises/ex13/golf_reference.txt
exercises/ex13/golf_reference.txt
+37
-0
exercises/ex13/plot_skeleton.py
exercises/ex13/plot_skeleton.py
+51
-0
No files found.
exercises/ex13/exercise13.pdf
0 → 100644
View file @
997ed0c7
File added
exercises/ex13/golf_reference.txt
0 → 100644
View file @
997ed0c7
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz
-----------------------
| A a B b C c D d E e |
| F f G g H h I i J j |
| K k L l M m N n O o |
| P p Q q R r S s T t |
| U u V v W w X x Y y |
| Z z |
-----------------------
['a: ', 'apple']
['b']
['c']
['d']
['e']
['f']
['g: ', 'grape']
['h']
['i']
['j']
['k']
['l: ', 'lemon']
['m']
['n']
['o: ', 'olive']
['p']
['q']
['r']
['s']
['t']
['u']
['v']
['w']
['x']
['y']
['z']
apple begins with a, grape begins with g, lemon begins with l, olive begins with o
exercises/ex13/plot_skeleton.py
0 → 100755
View file @
997ed0c7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Programming Techniques for Scientific Simulations, HS 2020
# Exercise 13.2
from
__future__
import
(
division
,
print_function
)
import
numpy
as
np
import
scipy.stats
as
st
import
scipy.linalg
as
la
import
matplotlib.pyplot
as
plt
def
get_samples
(
n
=
500
):
return
np
.
random
.
rand
(
n
,
2
)
*
2
-
1
def
get_r
(
samples
):
return
la
.
norm
(
samples
,
axis
=
1
)
def
calculate_pi
(
samples
):
num_inside
=
np
.
sum
(
get_r
(
samples
)
<
1.
)
num_total
=
len
(
samples
)
return
4
*
num_inside
/
num_total
def
create_scatter_plot
(
samples
):
# TODO: Create a scatter plot of the samples.
pass
def
create_contour_plot
(
samples
):
density_func
=
st
.
gaussian_kde
(
samples
.
T
,
bw_method
=
0.2
)
# TODO: Create a contour plot showing the interpolated density.
pass
def
main
():
np
.
random
.
seed
(
42
)
samples
=
get_samples
()
pi_estimate
=
calculate_pi
(
samples
)
print
(
'Pi ~= {}'
.
format
(
pi_estimate
))
create_scatter_plot
(
samples
)
create_contour_plot
(
samples
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment