`__.
66 |
67 | .. _`CC-By-Nc-SA`: http://creativecommons.org/licenses/by-nc-sa/3.0/us/
68 |
69 |
--------------------------------------------------------------------------------
/website/static/03-odds-ii-errors.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luispedro/Programming-for-Scientists/e10ab2a83c9dd8eb2e9d4f0b1cd1bf527659199c/website/static/03-odds-ii-errors.pdf
--------------------------------------------------------------------------------
/website/static/E1-introprogramming.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luispedro/Programming-for-Scientists/e10ab2a83c9dd8eb2e9d4f0b1cd1bf527659199c/website/static/E1-introprogramming.pdf
--------------------------------------------------------------------------------
/website/static/bacteria.py:
--------------------------------------------------------------------------------
1 | import random
2 | from math import exp
3 | import math
4 |
5 | def exp_dist(d,L):
6 | '''
7 | p = exp_dist(x,lambda_)
8 |
9 | Returns the cpf the exponential distribution.
10 |
11 | See http://en.wikipedia.org/wiki/Exponential_distribution
12 | '''
13 | return 1-math.exp(-L*d)
14 |
15 | class Bacteria(object):
16 | '''
17 | Bacteria
18 |
19 | Implements a simple bacterium
20 |
21 | Functions:
22 | ---------
23 |
24 | * P_dead(self,e): probability of death in environment e
25 | * reproduce(): returns a new bacterium
26 | '''
27 | L=.95
28 | def __init__(self,adaptation,sigma):
29 | self.adaptation = adaptation
30 | self.sigma = sigma
31 | def P_dead(self,e):
32 | '''
33 | p = b.P_dead(e)
34 |
35 | Probability of death in environment e (which should be a number)
36 | '''
37 | return exp_dist(abs(self.adaptation - e),self.L)
38 | def reproduce(self):
39 | '''
40 | b1 = b.reproduce()
41 |
42 | Return a child of this bacterium
43 | '''
44 | return Bacteria(self.adaptation + random.normalvariate(0,self.sigma),self.sigma)
45 |
46 | class EvolveSigma(Bacteria):
47 | '''
48 | EvolveSigma
49 |
50 | EvolveSigma is a type of bacterium where the
51 | sigma parameter evolves at reproduction.
52 | '''
53 | def __init__(self,adaptation,sigma):
54 | Bacteria.__init__(self,adaptation,sigma)
55 |
56 | def reproduce(self):
57 | return EvolveSigma(self.adaptation + random.normalvariate(0,self.sigma),
58 | self.sigma+random.normalvariate(0.,self.sigma/2.))
59 |
60 | def simulate(population,environs,max_population,p_reprod):
61 | '''
62 | simulate(population,environs)
63 |
64 | Simulate iters iterations of evolution.
65 | '''
66 | for environ in environs:
67 | ai = 0
68 | while ai < len(population):
69 | if population[ai].P_dead(environ) < random.random():
70 | del population[ai]
71 | else:
72 | ai += 1
73 | N = len(population)
74 | for ai in xrange(N):
75 | if random.random() < p_reprod:
76 | population.append(population[ai].reproduce())
77 | if N >= max_population:
78 | random.shuffle(population)
79 | while len(population) >= max_population:
80 | population.pop()
81 |
82 |
83 |
--------------------------------------------------------------------------------
/website/static/pfs-hw-01.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luispedro/Programming-for-Scientists/e10ab2a83c9dd8eb2e9d4f0b1cd1bf527659199c/website/static/pfs-hw-01.pdf
--------------------------------------------------------------------------------
/website/static/pfs-hw-02.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luispedro/Programming-for-Scientists/e10ab2a83c9dd8eb2e9d4f0b1cd1bf527659199c/website/static/pfs-hw-02.pdf
--------------------------------------------------------------------------------
/website/static/simulatebac.py:
--------------------------------------------------------------------------------
1 | import random
2 | import bacteria
3 |
4 | def mean(values):
5 | '''
6 | mu = mean(values)
7 |
8 | Compute a mean value.
9 | '''
10 | return sum(values)/float(len(values))
11 |
12 | fixed = [.234]*200
13 | sharp = [.2] * 40 + [.4]*40 + [.6]*40 + [.8]*40 + [1.]*40
14 | very_sharp = [.0] * 40 + [.5]*40 + [1.]*40 + [.5]*40 + [0.]*40
15 | smooth = [.01*i for i in xrange(200)]
16 | p_reprod = .3
17 |
18 | experiments = [
19 | ('fixed env. no sigma evolution', 1000, 0,fixed),
20 | ('fixed env. w sigma evolution', 500,500,fixed),
21 | ('smooth changes env. w sigma evolution', 500,500,smooth),
22 | ('sharp changes env. w sigma evolution', 500,500,sharp),
23 | ('very sharp changes env. w sigma evolution', 500,500,very_sharp),
24 | ]
25 | for name, initial_fixed, initial_evolve, environs in experiments:
26 | print 'Experiment',name
27 | population = [bacteria.Bacteria(random.random(),random.random()) for i in xrange(initial_fixed)] +\
28 | [bacteria.EvolveSigma(random.random(),random.random()) for i in xrange(initial_evolve)]
29 | bacteria.simulate(population,environs,(initial_fixed+initial_evolve)*10,p_reprod)
30 | print 'Mean sigma:', mean([a.sigma for a in population])
31 | print 'Mean Adaptation:',mean([b.adaptation for b in population])
32 | print 'Fraction adaptative:', mean([type(b) == bacteria.EvolveSigma for b in population])
33 | print
34 |
35 |
--------------------------------------------------------------------------------
/website/templates/defindex.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 | {% set title = 'Overview' %}
3 | {% block body %}
4 | {{ docstitle }}
5 |
6 | Welcome! This is
7 | {% block description %}the documentation for {{ project }}
8 | {{ release }}{% if last_updated %}, last updated {{ last_updated }}{% endif %}{% endblock %}.
9 |
10 | {% block tables %}
11 | Indices and tables:
12 |
13 |
14 | Complete Table of Contents
15 | lists all sections and subsections
16 | Search page
17 | search this documentation
18 | |
19 | Global Module Index
20 | quick access to all modules
21 | General Index
22 | all functions, classes, terms
23 | |
24 |
25 | {% endblock %}
26 | {% endblock %}
27 |
--------------------------------------------------------------------------------
/website/templates/genindex-single.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 | {% set title = 'Index' %}
3 | {% block body %}
4 |
5 | Index – {{ key }}
6 |
7 |
8 |
9 | {%- set breakat = count // 2 %}
10 | {%- set numcols = 1 %}
11 | {%- set numitems = 0 %}
12 | {% for entryname, (links, subitems) in entries %}
13 | - {%- if links -%}{{ entryname|e }}
14 | {%- for link in links[1:] %}, [Link]{% endfor -%}
15 | {%- else -%}
16 | {{ entryname|e }}
17 | {%- endif -%}
18 | {%- if subitems %}
19 |
20 | {%- for subentryname, subentrylinks in subitems %}
21 | - {{ subentryname|e }}
22 | {%- for link in subentrylinks[1:] %}, [Link]{% endfor -%}
23 |
24 | {%- endfor %}
25 |
26 | {%- endif -%}
27 | {%- set numitems = numitems + 1 + len(subitems) -%}
28 | {%- if numcols < 2 and numitems > breakat -%}
29 | {%- set numcols = numcols+1 -%}
30 | |
31 | {%- endif -%}
32 | {%- endfor %}
33 | |
34 |
35 | {% endblock %}
36 |
37 | {% block sidebarrel %}
38 | Index
39 | {% for key, dummy in genindexentries -%}
40 | {{ key }}
41 | {% if not loop.last %}| {% endif %}
42 | {%- endfor %}
43 |
44 | Full index on one page
45 | {% endblock %}
46 |
--------------------------------------------------------------------------------
/website/templates/genindex-split.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 | {% set title = 'Index' %}
3 | {% block body %}
4 |
5 | Index
6 |
7 | Index pages by letter:
8 |
9 | {% for key, dummy in genindexentries -%}
10 | {{ key }}
11 | {% if not loop.last %}| {% endif %}
12 | {%- endfor %}
13 |
14 | Full index on one page
15 | (can be huge)
16 |
17 | {% endblock %}
18 |
19 | {% block sidebarrel %}
20 | {% if split_index %}
21 | Index
22 | {% for key, dummy in genindexentries -%}
23 | {{ key }}
24 | {% if not loop.last %}| {% endif %}
25 | {%- endfor %}
26 |
27 | Full index on one page
28 | {% endif %}
29 | {% endblock %}
30 |
--------------------------------------------------------------------------------
/website/templates/genindex.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 | {% set title = 'Index' %}
3 | {% block body %}
4 |
5 | Index
6 |
7 | {% for key, dummy in genindexentries -%}
8 | {{ key }} {% if not loop.last %}| {% endif %}
9 | {%- endfor %}
10 |
11 |
12 |
13 | {% for key, entries in genindexentries %}
14 | {{ key }}
15 |
16 |
17 | {%- set breakat = genindexcounts[loop.index0] // 2 %}
18 | {%- set numcols = 1 %}
19 | {%- set numitems = 0 %}
20 | {% for entryname, (links, subitems) in entries %}
21 | - {%- if links -%}{{ entryname|e }}
22 | {%- for link in links[1:] %}, [Link]{% endfor -%}
23 | {%- else -%}
24 | {{ entryname|e }}
25 | {%- endif -%}
26 | {%- if subitems %}
27 |
28 | {%- for subentryname, subentrylinks in subitems %}
29 | - {{ subentryname|e }}
30 | {%- for link in subentrylinks[1:] %}, [Link]{% endfor -%}
31 |
32 | {%- endfor %}
33 |
34 | {%- endif -%}
35 | {%- set numitems = numitems + 1 + len(subitems) -%}
36 | {%- if numcols < 2 and numitems > breakat -%}
37 | {%- set numcols = numcols+1 -%}
38 | |
39 | {%- endif -%}
40 | {%- endfor %}
41 | |
42 | {% endfor %}
43 |
44 | {% endblock %}
45 |
46 | {% block sidebarrel %}
47 | {% if split_index %}
48 | Index
49 | {% for key, dummy in genindexentries -%}
50 | {{ key }}
51 | {% if not loop.last %}| {% endif %}
52 | {%- endfor %}
53 |
54 | Full index on one page
55 | {% endif %}
56 | {% endblock %}
57 |
--------------------------------------------------------------------------------
/website/templates/modindex.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 | {% set title = 'Global Module Index' %}
3 | {% block extrahead %}
4 | {% if collapse_modindex %}
5 |
8 | {% endif %}
9 | {% endblock %}
10 | {% block body %}
11 |
12 | Global Module Index
13 | {% if builder == 'web' and freqentries %}
14 | Most popular modules:
15 |
20 | {% endif %}
21 | {% if builder == 'web' %}
22 |
32 | {% endif %}
33 |
34 | {%- for letter in letters %}
35 | {{ letter }} {% if not loop.last %}| {% endif %}
36 | {%- endfor %}
37 |
38 |
39 |
40 | {%- for modname, collapse, cgroup, indent, fname, synops, pform, dep in modindexentries %}
41 | {%- if not modname -%}
42 | | | |
43 | | {{ fname }} | |
44 | {%- else -%}
45 |
46 | {% if collapse -%}
47 |
49 | {%- endif %} |
50 | {% if indent %} {% endif %}
51 | {% if fname %}{% endif -%}
52 | {{ modname|e }}
53 | {%- if fname %}{% endif %}
54 | {%- if pform[0] %} ({{ pform|join(', ') }}){% endif -%}
55 | | {% if dep %}Deprecated:{% endif %}
56 | {{ synops|e }} |
57 | {%- endif -%}
58 | {% endfor %}
59 |
60 |
61 | {% endblock %}
62 |
--------------------------------------------------------------------------------
/website/templates/opensearch.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ project }}
4 | Search {{ docstitle }}
5 | utf-8
6 |
8 | {{ docstitle }}
9 | {% block extra %}{# Put e.g. an element here. #}{% endblock %}
10 |
11 |
--------------------------------------------------------------------------------
/website/templates/page.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 | {% set page_links = [
3 | (pathto('@rss/' + sourcename), 'application/rss+xml', 'Page Comments'),
4 | ] %}
5 | {% block body %}
6 | {% if oldurl %}
7 |
8 | Note: You requested an out-of-date URL from this server.
9 | We've tried to redirect you to the new location of this page, but it may not
10 | be the right one.
11 |
12 | {% endif %}
13 | {{ body }}
14 | {% endblock %}
15 |
--------------------------------------------------------------------------------
/website/templates/search.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 | {% set title = 'Search' %}
3 | {% block extrahead %}
4 |
5 | {% endblock %}
6 | {% block body %}
7 | Search
8 |
9 | From here you can search these documents. Enter your search
10 | words into the box below and click "search". Note that the search
11 | function will automatically search for all of the words. Pages
12 | containing less words won't appear in the result list.
13 |
14 |
18 | {% if search_performed %}
19 | Search Results
20 | {% if not search_results %}
21 | Your search did not match any results.
22 | {% endif %}
23 | {% endif %}
24 |
25 | {% if search_results %}
26 |
27 | {% for href, caption, context in search_results %}
28 | - {{ caption }}
29 |
{{ context|e }}
30 |
31 | {% endfor %}
32 |
33 | {% endif %}
34 |
35 | {% endblock %}
36 |
--------------------------------------------------------------------------------