Skip to content
Snippets Groups Projects
Commit 541572c1 authored by Robert Lanzafame's avatar Robert Lanzafame
Browse files

WS 1.7 solution

parent dbaff573
No related branches found
No related tags found
No related merge requests found
Pipeline #251011 passed
Showing
with 37175 additions and 45 deletions
Source diff could not be displayed: it is too large. Options to address this: view the blob.
%% Cell type:markdown id:d260182d tags:
# WS 1.7: Modelling Uncertain Concrete Strength
<h1 style="position: absolute; display: flex; flex-grow: 0; flex-shrink: 0; flex-direction: row-reverse; top: 60px;right: 30px; margin: 0; border: 0">
<style>
.markdown {width:100%; position: relative}
article { position: relative }
</style>
<img src="https://gitlab.tudelft.nl/mude/public/-/raw/main/tu-logo/TU_P1_full-color.png" style="width:100px" />
<img src="https://gitlab.tudelft.nl/mude/public/-/raw/main/mude-logo/MUDE_Logo-small.png" style="width:100px" />
</h1>
<h2 style="height: 10px">
</h2>
*[CEGM1000 MUDE](http://mude.citg.tudelft.nl/): Week 1.7. Due: October 16, 2024.*
%% Cell type:markdown id:1db6fea9-f3ad-44bc-a4c8-7b2b3008e945 tags:
Assessing the uncertainties in the compressive strength of the produced concrete is key for the safety of infrastructures and buildings. However, a lot of boundary conditions influence the final resistance of the concrete, such the cement content, the environmental temperature or the age of the concrete. Probabilistic tools can be applied to model this uncertainty. In this workshop, you will work with a dataset of observations of the compressive strength of concrete (you can read more about the dataset [here](https://www.kaggle.com/datasets/gauravduttakiit/compressive-strength-of-concrete)).
**The goal of this project is:**
1. Choose a reasonable distribution function for the concrete compressive strength analyzing the statistics of the observations.
2. Fit the chosen distributions by moments.
3. Assess the fit computing probabilities analytically.
4. Assess the fit using goodness of fit techniques and computer code.
The project will be divided into 3 parts: 1) data analysis, 2) pen and paper stuff (math practice!), and 3) programming.
%% Cell type:code id:4fc6e87d-c66e-43df-a937-e969acc409f8 tags:
``` python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from scipy import stats
from math import ceil, trunc
plt.rcParams.update({'font.size': 14})
```
%% Cell type:markdown id:1ee42f39 tags:
## Part 1: Explore the data
%% Cell type:markdown id:27fd05f1 tags:
First step in the analysis is exploring the data, visually and through its statistics.
%% Cell type:code id:a2f08dc7 tags:
``` python
# Import
data = np.genfromtxt('dataset_concrete.csv', delimiter=",", skip_header=True)
# Clean
data = data[~np.isnan(data)]
# plot time series
plt.figure(figsize=(10, 6))
plt.plot(data,'ok')
plt.xlabel('# observation')
plt.ylabel('Concrete compressive strength [MPa]')
plt.grid()
weights = 5*np.ones(len(data))
plt.hist(data, orientation='horizontal', weights=weights, color='lightblue', rwidth=0.9)
```
%% Cell type:markdown id:ab503914 tags:
In the figure above, you can see all the observations of concrete compressive strength. You can see that there is no clear pattern in the observations. Let's see how the statistics look like!
%% Cell type:code id:a2a69142 tags:
``` python
# Statistics
df_describe = pd.DataFrame(data)
df_describe.describe()
```
%% Cell type:markdown id:bfadcf3f-4578-4809-acdb-625ab3a71f27 tags:
<div style="background-color:#AABAB2; color: black; width:95%; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px">
<p>
<b>Task 1.1:</b>
Using <b>ONLY</b> the statistics calculated in the previous lines:
<li>Choose an appropriate distribution to model the data between the following: (1) Gumbel, (2) Uniform, and (3) Gaussian. </li>
<li>Justiy your choice.</li>
</p>
</div>
%% Cell type:markdown id:a0f21639 tags:
_Your answer here._
%% Cell type:markdown id:d4886ae8 tags:
## Part 2: Use pen and paper!
%% Cell type:markdown id:0609e0a6 tags:
Once you have selected the appropriate distribution, you are going to fit it by moments manually and check the fit by computing some probabilities analytically. Remember that you have all the information you need in the textbook. Do not use any computer code for this section, you have to do in with pen and paper. You can use the notebook as a calculator.
%% Cell type:markdown id:b20641d9 tags:
<div style="background-color:#AABAB2; color: black; width:95%; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px">
<p>
<b>Task 2.1:</b>
Fit the selected distribution by moments.
</p>
</div>
%% Cell type:markdown id:3b589e37 tags:
_Your answer here._
%% Cell type:markdown id:bb364000 tags:
We can now check the fit by computing manually some probabilities from the fitted distribution and comparing them with the empirical ones.
%% Cell type:markdown id:8b40210f tags:
<div style="background-color:#AABAB2; color: black; width:95%; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px">
<p>
<b>Task 2.2:</b>
Check the fit of the distribution:
<li>Use the values obtained from the statistical inspection: the min, 25%, 50%, 75% and max values. What non-exceedance probabilities correspond to those values?</li>
<li>Compute the values of the random variable corresponding to those probabilities using the fitted distribution.</li>
<li>Compare the obtained values with the empirical ones and assess the fit.</li>
</p>
You can summarize you answers in the following table (report your values with 3-4 significant digits max, as needed).
</div>
%% Cell type:markdown id:86895e1d tags:
| |Minimum value|P25%|P50%|P75%|Maximum value|
|---|-------------|----|----|----|-------------|
|Non-exceedance probability| | | | | |
|Empirical quantiles| | | | | |
|Predicted quantiles||||||
%% Cell type:markdown id:850d6d0c tags:
## Part 3: Let's do it with Python!
%% Cell type:markdown id:288edd58 tags:
Now, let's assess the performance using further goodness of fit metrics and see whether they are consistent with the previously done analysis.
%% Cell type:markdown id:f364c8cd tags:
<div style="background-color:#AABAB2; color: black; width:95%; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px">
<p>
<b>Task 3.1:</b>
Prepare a function to compute the empirical cumulative distribution function.
</p>
</div>
%% Cell type:code id:3a47f881 tags:
``` python
def ecdf(YOUR_CODE_HERE):
YOUR_CODE_HERE # may be more than one line
return YOUR_CODE_HERE
```
%% Cell type:markdown id:cb1ebc0c tags:
<div style="background-color:#AABAB2; color: black; width:95%; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px">
<p>
<b>Task 3.2:</b>
Transform the fitted parameters for the selected distribution to loc-scale-shape.
</p>
</div>
Hint: the distributions are in our online textbook, but it is also critical to make sure that the formulation in the book is identical to that of the Python package we are using. You can do this by finding the page of the relevant distribution in the [Scipy.stats](https://docs.scipy.org/doc/scipy/reference/stats.html) documentation.
%% Cell type:markdown id:6a24dbfa tags:
<div style="background-color:#AABAB2; color: black; width:95%; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px">
<p>
<b>Task 3.3:</b>
Assess the goodness of fit of the fitted distribution by:
<li> Comparing the empirical and fitted PDF.</li>
<li> Using the exceedance plot in log-scale.</li>
<li> Using the QQplot.</li>
<li> Interpret them. Do you reach a conclusion similar to that in the previous section?</li>
</p>
</div>
Hint: Use [Scipy](https://docs.scipy.org/doc/scipy/reference/stats.html) built in functions (watch out with the parameters definition!).
%% Cell type:code id:31ef8aaf tags:
``` python
loc = YOUR_CODE_HERE
scale = YOUR_CODE_HERE
fig, axes = plt.subplots(1, 1, figsize=(10, 5))
axes.hist(YOUR_CODE_HERE,
edgecolor='k', linewidth=0.2, color='cornflowerblue',
label='Empirical PDF', density = True)
axes.plot(YOUR_CODE_HERE, YOUR_CODE_HERE,
'k', linewidth=2, label='YOUR_DISTRIBUTION_NAME_HERE PDF')
axes.set_xlabel('Compressive strength [MPa]')
axes.set_title('PDF', fontsize=18)
axes.legend()
```
%% Cell type:code id:a344a7cb tags:
``` python
fig, axes = plt.subplots(1, 1, figsize=(10, 5))
axes.step(YOUR_CODE_HERE, YOUR_CODE_HERE,
color='k', label='Empirical CDF')
axes.plot(YOUR_CODE_HERE, YOUR_CODE_HERE,
color='cornflowerblue', label='YOUR_DISTRIBUTION_NAME_HERE CDF')
axes.set_xlabel('Compressive strength [MPa]')
axes.set_ylabel('${P[X > x]}$')
axes.set_title('Exceedance plot in log-scale', fontsize=18)
axes.set_yscale('log')
axes.legend()
axes.grid()
```
%% Cell type:code id:93e05b9d tags:
``` python
fig, axes = plt.subplots(1, 1, figsize=(10, 5))
axes.plot([0, 120], [0, 120], 'k')
axes.scatter(YOUR_CODE_HERE, YOUR_CODE_HERE,
color='cornflowerblue', label='Gumbel')
axes.set_xlabel('Observed compressive strength [MPa]')
axes.set_ylabel('Estimated compressive strength [MPa]')
axes.set_title('QQplot', fontsize=18)
axes.set_xlim([0, 120])
axes.set_ylim([0, 120])
axes.set_xticks(np.arange(0, 121, 20))
axes.grid()
```
%% Cell type:markdown id:51382bf8 tags:
**End of notebook.**
<h2 style="height: 60px">
</h2>
<h3 style="position: absolute; display: flex; flex-grow: 0; flex-shrink: 0; flex-direction: row-reverse; bottom: 60px; right: 50px; margin: 0; border: 0">
<style>
.markdown {width:100%; position: relative}
article { position: relative }
</style>
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/">
<img alt="Creative Commons License" style="border-width:; width:88px; height:auto; padding-top:10px" src="https://i.creativecommons.org/l/by/4.0/88x31.png" />
</a>
<a rel="TU Delft" href="https://www.tudelft.nl/en/ceg">
<img alt="TU Delft" style="border-width:0; width:100px; height:auto; padding-bottom:0px" src="https://gitlab.tudelft.nl/mude/public/-/raw/main/tu-logo/TU_P1_full-color.png" />
</a>
<a rel="MUDE" href="http://mude.citg.tudelft.nl/">
<img alt="MUDE" style="border-width:0; width:100px; height:auto; padding-bottom:0px" src="https://gitlab.tudelft.nl/mude/public/-/raw/main/mude-logo/MUDE_Logo-small.png" />
</a>
</h3>
<span style="font-size: 75%">
&copy; Copyright 2024 <a rel="MUDE" href="http://mude.citg.tudelft.nl/">MUDE</a> TU Delft. This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">CC BY 4.0 License</a>.
......
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
<!DOCTYPE html>
<html>
<head>
<title>README.md</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<style>
/* https://github.com/microsoft/vscode/blob/master/extensions/markdown-language-features/media/markdown.css */
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
body {
font-family: var(--vscode-markdown-font-family, -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "Ubuntu", "Droid Sans", sans-serif);
font-size: var(--vscode-markdown-font-size, 14px);
padding: 0 26px;
line-height: var(--vscode-markdown-line-height, 22px);
word-wrap: break-word;
}
#code-csp-warning {
position: fixed;
top: 0;
right: 0;
color: white;
margin: 16px;
text-align: center;
font-size: 12px;
font-family: sans-serif;
background-color:#444444;
cursor: pointer;
padding: 6px;
box-shadow: 1px 1px 1px rgba(0,0,0,.25);
}
#code-csp-warning:hover {
text-decoration: none;
background-color:#007acc;
box-shadow: 2px 2px 2px rgba(0,0,0,.25);
}
body.scrollBeyondLastLine {
margin-bottom: calc(100vh - 22px);
}
body.showEditorSelection .code-line {
position: relative;
}
body.showEditorSelection .code-active-line:before,
body.showEditorSelection .code-line:hover:before {
content: "";
display: block;
position: absolute;
top: 0;
left: -12px;
height: 100%;
}
body.showEditorSelection li.code-active-line:before,
body.showEditorSelection li.code-line:hover:before {
left: -30px;
}
.vscode-light.showEditorSelection .code-active-line:before {
border-left: 3px solid rgba(0, 0, 0, 0.15);
}
.vscode-light.showEditorSelection .code-line:hover:before {
border-left: 3px solid rgba(0, 0, 0, 0.40);
}
.vscode-light.showEditorSelection .code-line .code-line:hover:before {
border-left: none;
}
.vscode-dark.showEditorSelection .code-active-line:before {
border-left: 3px solid rgba(255, 255, 255, 0.4);
}
.vscode-dark.showEditorSelection .code-line:hover:before {
border-left: 3px solid rgba(255, 255, 255, 0.60);
}
.vscode-dark.showEditorSelection .code-line .code-line:hover:before {
border-left: none;
}
.vscode-high-contrast.showEditorSelection .code-active-line:before {
border-left: 3px solid rgba(255, 160, 0, 0.7);
}
.vscode-high-contrast.showEditorSelection .code-line:hover:before {
border-left: 3px solid rgba(255, 160, 0, 1);
}
.vscode-high-contrast.showEditorSelection .code-line .code-line:hover:before {
border-left: none;
}
img {
max-width: 100%;
max-height: 100%;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:focus,
input:focus,
select:focus,
textarea:focus {
outline: 1px solid -webkit-focus-ring-color;
outline-offset: -1px;
}
hr {
border: 0;
height: 2px;
border-bottom: 2px solid;
}
h1 {
padding-bottom: 0.3em;
line-height: 1.2;
border-bottom-width: 1px;
border-bottom-style: solid;
}
h1, h2, h3 {
font-weight: normal;
}
table {
border-collapse: collapse;
}
table > thead > tr > th {
text-align: left;
border-bottom: 1px solid;
}
table > thead > tr > th,
table > thead > tr > td,
table > tbody > tr > th,
table > tbody > tr > td {
padding: 5px 10px;
}
table > tbody > tr + tr > td {
border-top: 1px solid;
}
blockquote {
margin: 0 7px 0 5px;
padding: 0 16px 0 10px;
border-left-width: 5px;
border-left-style: solid;
}
code {
font-family: Menlo, Monaco, Consolas, "Droid Sans Mono", "Courier New", monospace, "Droid Sans Fallback";
font-size: 1em;
line-height: 1.357em;
}
body.wordWrap pre {
white-space: pre-wrap;
}
pre:not(.hljs),
pre.hljs code > div {
padding: 16px;
border-radius: 3px;
overflow: auto;
}
pre code {
color: var(--vscode-editor-foreground);
tab-size: 4;
}
/** Theming */
.vscode-light pre {
background-color: rgba(220, 220, 220, 0.4);
}
.vscode-dark pre {
background-color: rgba(10, 10, 10, 0.4);
}
.vscode-high-contrast pre {
background-color: rgb(0, 0, 0);
}
.vscode-high-contrast h1 {
border-color: rgb(0, 0, 0);
}
.vscode-light table > thead > tr > th {
border-color: rgba(0, 0, 0, 0.69);
}
.vscode-dark table > thead > tr > th {
border-color: rgba(255, 255, 255, 0.69);
}
.vscode-light h1,
.vscode-light hr,
.vscode-light table > tbody > tr + tr > td {
border-color: rgba(0, 0, 0, 0.18);
}
.vscode-dark h1,
.vscode-dark hr,
.vscode-dark table > tbody > tr + tr > td {
border-color: rgba(255, 255, 255, 0.18);
}
</style>
<style>
/* Tomorrow Theme */
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
/* Tomorrow Comment */
.hljs-comment,
.hljs-quote {
color: #8e908c;
}
/* Tomorrow Red */
.hljs-variable,
.hljs-template-variable,
.hljs-tag,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class,
.hljs-regexp,
.hljs-deletion {
color: #c82829;
}
/* Tomorrow Orange */
.hljs-number,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params,
.hljs-meta,
.hljs-link {
color: #f5871f;
}
/* Tomorrow Yellow */
.hljs-attribute {
color: #eab700;
}
/* Tomorrow Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet,
.hljs-addition {
color: #718c00;
}
/* Tomorrow Blue */
.hljs-title,
.hljs-section {
color: #4271ae;
}
/* Tomorrow Purple */
.hljs-keyword,
.hljs-selector-tag {
color: #8959a8;
}
.hljs {
display: block;
overflow-x: auto;
color: #4d4d4c;
padding: 0.5em;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}
</style>
<style>
/*
* Markdown PDF CSS
*/
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "Ubuntu", "Droid Sans", sans-serif, "Meiryo";
padding: 0 12px;
}
pre {
background-color: #f8f8f8;
border: 1px solid #cccccc;
border-radius: 3px;
overflow-x: auto;
white-space: pre-wrap;
overflow-wrap: break-word;
}
pre:not(.hljs) {
padding: 23px;
line-height: 19px;
}
blockquote {
background: rgba(127, 127, 127, 0.1);
border-color: rgba(0, 122, 204, 0.5);
}
.emoji {
height: 1.4em;
}
code {
font-size: 14px;
line-height: 19px;
}
/* for inline code */
:not(pre):not(.hljs) > code {
color: #C9AE75; /* Change the old color so it seems less like an error */
font-size: inherit;
}
/* Page Break : use <div class="page"/> to insert page break
-------------------------------------------------------- */
.page {
page-break-after: always;
}
</style>
<script src="https://unpkg.com/mermaid/dist/mermaid.min.js"></script>
</head>
<body>
<script>
mermaid.initialize({
startOnLoad: true,
theme: document.body.classList.contains('vscode-dark') || document.body.classList.contains('vscode-high-contrast')
? 'dark'
: 'default'
});
</script>
<h1 id="ws-17-solution">WS 1.7 Solution</h1>
<p><em>For some reason the ipynb could not export to HTML, so this file was created to show the figures and code output that is missing from the &quot;real&quot; solution.</em></p>
<h2 id="task-1-output">Task 1 Output</h2>
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
<pre><code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</code></pre>
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>0</th>
</tr>
</thead>
<tbody>
<tr>
<th>count</th>
<td>772.000000</td>
</tr>
<tr>
<th>mean</th>
<td>35.724196</td>
</tr>
<tr>
<th>std</th>
<td>16.797389</td>
</tr>
<tr>
<th>min</th>
<td>2.331808</td>
</tr>
<tr>
<th>25%</th>
<td>23.677591</td>
</tr>
<tr>
<th>50%</th>
<td>33.870853</td>
</tr>
<tr>
<th>75%</th>
<td>46.232813</td>
</tr>
<tr>
<th>max</th>
<td>82.599225</td>
</tr>
</tbody>
</table>
</div>
<h2 id="task-3-figures">Task 3 Figures</h2>
<h3 id="pdf">PDF</h3>
<p><img src="./pdf.svg" alt="PDF"></p>
<h3 id="cdf">CDF</h3>
<p><img src="./cdf.svg" alt="CDF"></p>
<h3 id="ppf">PPF</h3>
<p><img src="./ppf.svg" alt="PPF"></p>
</body>
</html>
# WS 1.7 Solution
_For some reason the ipynb could not export to HTML, so this file was created to show the figures and code output that is missing from the "real" solution._
## Task 1 Output
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>0</th>
</tr>
</thead>
<tbody>
<tr>
<th>count</th>
<td>772.000000</td>
</tr>
<tr>
<th>mean</th>
<td>35.724196</td>
</tr>
<tr>
<th>std</th>
<td>16.797389</td>
</tr>
<tr>
<th>min</th>
<td>2.331808</td>
</tr>
<tr>
<th>25%</th>
<td>23.677591</td>
</tr>
<tr>
<th>50%</th>
<td>33.870853</td>
</tr>
<tr>
<th>75%</th>
<td>46.232813</td>
</tr>
<tr>
<th>max</th>
<td>82.599225</td>
</tr>
</tbody>
</table>
</div>
## Task 3 Figures
### PDF
![PDF](./pdf.svg)
### CDF
![CDF](./cdf.svg)
### PPF
![PPF](./ppf.svg)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
%% Cell type:markdown id: tags:
# Tips for Teachers: Week 1.7, Continuous Distributions
Book chapters [here](https://mude.citg.tudelft.nl/2024/book/probability/Reminder_intro.html).
[Location, shape and scale](https://mude.citg.tudelft.nl/2024/book/probability/Loc-scale.html)
%% Cell type:code id: tags:
``` python
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from scipy.stats import norm, gumbel_r
```
%% Cell type:code id: tags:
``` python
loc = 28.167
scale = 13.097
print(gumbel_r.pdf(30, loc, scale))
print(gumbel_r.cdf(30, loc, scale))
print(gumbel_r.ppf(0.4192, loc, scale))
print(gumbel_r.ppf(1/773, loc, scale))
```
%% Output
0.027827357842534345
0.4192043639942213
29.99984317624283
3.3526534870972142
%% Cell type:code id: tags:
``` python
dir(gumbel_r)
```
%% Output
['__call__',
'__class__',
'__delattr__',
'__dict__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getstate__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__lt__',
'__module__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__setstate__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'_argcheck',
'_argcheck_rvs',
'_attach_argparser_methods',
'_attach_methods',
'_cdf',
'_cdf_single',
'_cdfvec',
'_construct_argparser',
'_construct_default_doc',
'_construct_doc',
'_ctor_param',
'_delta_cdf',
'_entropy',
'_fit_loc_scale_support',
'_fitstart',
'_get_support',
'_isf',
'_logcdf',
'_logpdf',
'_logpxf',
'_logsf',
'_mom0_sc',
'_mom1_sc',
'_mom_integ0',
'_mom_integ1',
'_moment_error',
'_munp',
'_nlff_and_penalty',
'_nnlf',
'_nnlf_and_penalty',
'_open_support_mask',
'_param_info',
'_parse_arg_template',
'_parse_args',
'_parse_args_rvs',
'_parse_args_stats',
'_pdf',
'_penalized_nlpsf',
'_penalized_nnlf',
'_ppf',
'_ppf_single',
'_ppf_to_solve',
'_ppfvec',
'_random_state',
'_reduce_func',
'_rvs',
'_sf',
'_shape_info',
'_stats',
'_stats_has_moments',
'_support_mask',
'_unpack_loc_scale',
'_updated_ctor_param',
'a',
'b',
'badvalue',
'cdf',
'entropy',
'expect',
'fit',
'fit_loc_scale',
'freeze',
'generic_moment',
'interval',
'isf',
'logcdf',
'logpdf',
'logsf',
'mean',
'median',
'moment',
'moment_type',
'name',
'nnlf',
'numargs',
'pdf',
'ppf',
'random_state',
'rvs',
'sf',
'shapes',
'stats',
'std',
'support',
'var',
'vecentropy',
'xtol']
%% Cell type:code id: tags:
``` python
print(1/773, 772/773)
```
%% Output
0.00129366106080207 0.9987063389391979
%% Cell type:markdown id: tags:
Scipy.stats
[Homepage](https://docs.scipy.org/doc/scipy/reference/stats.html)
If you find yourself looking at documentation for something and there is no info, try the [`rv_continuous` page](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.html#scipy.stats.rv_continuous)
%% Cell type:code id: tags:
``` python
test = norm('m'=0, 'v'=1)
```
%% Output
Cell In[1], line 1
test = norm('m'=0, 'v'=1)
^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
This diff is collapsed.
File added
This diff is collapsed.
# WS 1.7 Solution
_For some reason the ipynb could not export to HTML, so this file was created to show the figures and code output that is missing from the "real" solution._
## Task 1 Output
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>0</th>
</tr>
</thead>
<tbody>
<tr>
<th>count</th>
<td>772.000000</td>
</tr>
<tr>
<th>mean</th>
<td>35.724196</td>
</tr>
<tr>
<th>std</th>
<td>16.797389</td>
</tr>
<tr>
<th>min</th>
<td>2.331808</td>
</tr>
<tr>
<th>25%</th>
<td>23.677591</td>
</tr>
<tr>
<th>50%</th>
<td>33.870853</td>
</tr>
<tr>
<th>75%</th>
<td>46.232813</td>
</tr>
<tr>
<th>max</th>
<td>82.599225</td>
</tr>
</tbody>
</table>
</div>
## Task 3 Figures
### PDF
![PDF](./pdf.svg)
### CDF
![CDF](./cdf.svg)
### PPF
![PPF](./ppf.svg)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment