readme: update for changes to ex-1, ex-2

This commit is contained in:
Michele Guerini Rocco 2020-05-24 18:18:58 +02:00
parent 7cb1c20c2b
commit f6e048496f
3 changed files with 53 additions and 26 deletions

View File

@ -27,15 +27,28 @@ The programs used to solve the exercise are written in standard C99 (with the
only exception of the `#pragma once` clause) and require the following only exception of the `#pragma once` clause) and require the following
libraries to build: libraries to build:
- [GMP](https://gmplib.org/) - [GMP] (≥ 6.2)
- [GSL](https://www.gnu.org/software/gsl/) - [GSL] (≥ 2.6)
* [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) * [pkg-config] (≥ 0.29, build-time only)
(build-time only)
Additionally, Python (version 3) with `numpy` and `matplotlib` is required to To generate plots, Python (version 3) with
generate plots.
- [numpy] (≥ 1.18)
- [matplotlib] (≥ 2.2)
- [scipy] (≥ 1.4, optional)
is required to generate plots.
[GMP]: https://gmplib.org/
[GSL]: https://www.gnu.org/software/gsl/
[pkg-config]: https://www.freedesktop.org/wiki/Software/pkg-config/
[numpy]: https://numpy.org/
[scipy]: https://www.scipy.org/scipylib/index.html
[matplotlib]: https://matplotlib.org/
For convenience, a `shell.nix` file is provided to set up the build environment. For convenience, a `shell.nix` file is provided to set up the build environment.
See this [guide](https://nixos.org/nix/manual/#chap-quick-start) if you have See this [guide](https://nixos.org/nix/manual/#chap-quick-start) if you have
@ -54,7 +67,6 @@ To clean up the build results run:
$ make clean $ make clean
## Running the programs ## Running the programs
Notes: Notes:
@ -76,6 +88,11 @@ comparing the sample mode, FWHM and median, in this order.
`ex-1/bin.pdf` prints a list of x-y points of the Landau PDF to the `stdout`. `ex-1/bin.pdf` prints a list of x-y points of the Landau PDF to the `stdout`.
The output can be redirected to `ex-1/pdf-plot.py` to generate a plot. The output can be redirected to `ex-1/pdf-plot.py` to generate a plot.
(optional) `ex-1/plots/kde.py` makes the example plot (shown in exercises.pdf,
fig. 4) of the kernel density estimation used to compute a non-parametric FWHM
from a sample of random points. To run this program you must additionally
install [scipy].
### Exercise 2 ### Exercise 2
@ -95,6 +112,10 @@ take therefore the required number of decimal places as their only argument.
The exact γ digits (used in comparison) are limited to 50 and 500 places, The exact γ digits (used in comparison) are limited to 50 and 500 places,
respectively. respectively.
`ex-2/bin/fast` is a highly optimized version of `ex-2/bin/fancier`, meant to
compute a very large number of digits and therefore doesn't come with a
verified, fixed, approximation of γ.
### Exercise 3 ### Exercise 3
@ -133,12 +154,12 @@ and `-b`.
### Exercise 5 ### Exercise 5
`ex-5/main` compute estimations of the integral of exp(1) between 0 and 1 `ex-5/main` compute estimations of the integral of exp(x) between 0 and 1
with the methods plain MC, MISER and VEGAS with different number of points. with the methods plain MC, MISER and VEGAS with different number of points.
It takes no arguments in input. It takes no arguments in input.
It prints out eight columns: It prints out eight columns:
1. the number of sorted points; 1. the number of points;
2. the integral estimation with plain MC; 2. the integral estimation with plain MC;
@ -158,6 +179,7 @@ To plot the results do:
$ ex-5/main | ex-5/plot.py $ ex-5/main | ex-5/plot.py
### Exercise 6 ### Exercise 6
`ex-6/bin/main` simulates a Fraunhöfer diffraction experiment. The program `ex-6/bin/main` simulates a Fraunhöfer diffraction experiment. The program
@ -166,8 +188,8 @@ diffraction angle. To plot a histogram do:
$ ex-6/bin/main | ex-6/plot.py $ ex-6/bin/main | ex-6/plot.py
The program convolves the original signal with a Gaussian kernel (`-s` to The program convolves the original signal with a gaussian kernel (`-s` to
change the kernel σ), optionally adds a Gaussian noise (`-n` to change the change the kernel σ), optionally adds a gaussian noise (`-n` to change the
noise σ) and performs either a naive deconvolution by a FFT (`-m fft` mode) noise σ) and performs either a naive deconvolution by a FFT (`-m fft` mode)
or applying the Richardson-Lucy deconvolution algorithm (`-m rl` mode). or applying the Richardson-Lucy deconvolution algorithm (`-m rl` mode).
@ -176,27 +198,33 @@ deconvolved histogram counts should be printed to `stdout`. For more options
run the program with `-h` to see the usage screen. run the program with `-h` to see the usage screen.
`ex-6/bin/test` simulates a customizable number of experiments and prints `ex-6/bin/test` simulates a customizable number of experiments and prints
to `stdout` the histograms of the distribution of the EMD of the convolved to `stdout` the histograms of the distribution of the EMD from the original
signal together with the deconvolved signal EMD histograms with both FFT and signal to:
Richardson-Lucy procedures. It also prints to `stderr` the average, standard
deviation and skewness of the histograms. To plot the results, do: 1. the result of the FFT deconvolution
2. the result of the Richardson-Lucy deconvolution
3. the convolved signal (with noise if `-n` has been given)
It also prints to `stderr` the average, standard deviation and skewness of
each distribution. To plot the histograms, do:
$ ex-6/bin/test | ex-6/dist-plot.py $ ex-6/bin/test | ex-6/dist-plot.py
The program accepts some parameters to control the histogram and number of The program accepts some parameters to control the histogram and number of
events, run it with `-h` to see their usage. events, run it with `-h` to see their usage.
`ex-6/plots/emd.py` plots the content of the files `ex-6/plots/emd-noisy.txt` (optional) `ex-6/plots/emd.py` makes the plots of the EMD statistics of the RL
and `ex-6/plots/emd-noiseless.txt` depending on the argument passed to it from deconvolution (shown in excercies.pdf, section 6.6) as a function of the number
stdin. Do: of rounds. The programs sources its data from two files in the same directory,
these were obtained by running `ex-6/bin/test`. Do:
$ ex-6/plots/emd.py 'noisy' $ ex-6/plots/emd.py noisy
to plot the content of the first file and do: for the plots of the experiment with gaussian noise, and
$ ex-6/plots/emd.py 'noiseless' $ ex-6/plots/emd.py noiseless
to plot the content of the second file. for the experiment without noise.
### Exercise 7 ### Exercise 7

View File

@ -89,7 +89,7 @@ plt.plot(x, moyal.pdf(x, loc=4), c='xkcd:gray', label='true PDF')
plt.plot(x, f, '#92182b', label='empirical PDF') plt.plot(x, f, '#92182b', label='empirical PDF')
plt.plot(sample, np.zeros_like(sample), plt.plot(sample, np.zeros_like(sample),
'|', c='xkcd:navy') '|', c='xkcd:navy')
#plt.axvline(x=m.mean(), c='r') plt.axvline(x=m.mean(), c='r')
plt.axvline(x=M.mean(), c='xkcd:camel', label='mode') plt.axvline(x=M.mean(), c='xkcd:camel', label='mode')
plt.legend() plt.legend()
plt.show() plt.show()

View File

@ -1,7 +1,6 @@
- riscrivere il 2 - riscrivere il 2
- riscrivere il readme del 1
- riscrivere il readme del 2
- riscrivere il readme del 6 - riscrivere il readme del 6
- riscrivere il readme del 7 - riscrivere il readme del 7
- incolonnare bene ex-5
On the lambert W function, formula 4.19 Corless On the Lambert W function, formula 4.19 Corless