minor ch 14 exercises fixes

This commit is contained in:
Bogumił Kamiński 2022-10-14 12:39:14 +02:00
parent 6a8b3ae160
commit ae41462776

View File

@ -15,10 +15,9 @@ average number of items from this set that were drawn at least once.
Call the function running this simulation `boot`.
<details>
<summary>Solution</summary>
Solution (there are many other approaches you could use):
There are many other approaches you could use:
```
using Statistics
@ -45,11 +44,8 @@ Make this function single threaded. Check how long
this function runs for `n=1000` and `k=1_000_000`.
<details>
<summary>Solution</summary>
Solution:
```
function simboot(k::Integer, n::Integer)
result = [boot(n) for _ in 1:k]
@ -83,11 +79,8 @@ Call the function `simbootT`. Check how long this function runs for `n=1000` and
`k=1_000_000`.
<details>
<summary>Solution</summary>
Solution:
```
using ThreadsX
@ -125,11 +118,8 @@ does not do any allocations internally). Call these new functions `boot!` and
functions.
<details>
<summary>Solution</summary>
Solution:
```
function boot!(n::Integer, pool)
table = pool[Threads.threadid()]
@ -180,11 +170,10 @@ use the `@timed` macro in your solution.
Start the server.
<details>
<summary>Solution</summary>
Solution (I used the simplest single-threaded code here; this is a complete
code of the web service):
I used the simplest single-threaded code here; this is a complete
code of the web service:
```
using Genie
@ -234,11 +223,8 @@ the following parameters:
* `k=1.5` and `n=1000`
<details>
<summary>Solution</summary>
Solution:
```
julia> using HTTP
@ -279,11 +265,8 @@ Collect the data generated by a web service into the `df` data frame for
`k = [10^i for i in 3:6]` and `n = [10^i for i in 1:3]`.
<details>
<summary>Solution</summary>
Solution:
```
using DataFrames
@ -329,11 +312,8 @@ julia> df
Replace the `value` column in the `df` data frame by its contents in-place.
<details>
<summary>Solution</summary>
Solution:
```
julia> select!(df, :status, :time, :value => AsTable)
12×7 DataFrame
@ -362,11 +342,8 @@ Checks that execution time roughly scales proportionally to the product
of `k` times `n`.
<details>
<summary>Solution</summary>
Solution:
```
julia> using DataFramesMeta
@ -397,10 +374,8 @@ Plot the expected fraction of seen elements in the set as a function of
`n` by `k` along with 95% confidence interval around these values.
<details>
<summary>Solution</summary>
Solution:
```
using Plots
gdf = groupby(df, :k, sort=true)