second lecture
This commit is contained in:
@@ -141,27 +141,9 @@ And a nice sideeffect: by doing this, we get rid of any specialized "serialized"
|
||||
| functions, macro | lowercase |
|
||||
| inplace / side-effects | `endwith!()` |
|
||||
|
||||
# Task 1.
|
||||
# Task 1
|
||||
Ok - lot of introduction, but I think you are ready for your first interactive task.
|
||||
|
||||
## Wait - how do I even run things in Julia/VScode?
|
||||
Typically, you work in a Julia script ending in `scriptname.jl`
|
||||
|
||||
You concurrently have a REPL open, to not reload all packages etc. everytime. Further you typically have `Revise.jl` running in the background to automatically update your custom Packages / Modules (more to that later).
|
||||
|
||||
You can mark some code and execute it using `ctrl` + `enter` - you can also generate code-blocks using `#---` and run a whole code-block using `alt`+`enter`
|
||||
|
||||
1. Open a new script `statistic_functions.jl` in VSCode in a folder of your choice.
|
||||
|
||||
2. implement a function called `rse_sum`^[rse = research software engineering, we could use `sum` in a principled way, but it requires some knowledge you likely don't have right now]. This function should return `true` if provided with the following test: `res_sum(1:36) == 666`. You should further make use of a for-loop.
|
||||
|
||||
3. implement a second function called `rse_mean`, which calculates the mean of the provided vector. Make sure to use the `rse_sum` function! Test it using `res_mean(-15:17) == 1`
|
||||
|
||||
4. Next implement a standard deviation function `rse_std`: $\sqrt{\frac{\sum(x-mean(x))}{n-1}}$, this time you should use elementwise/broadcasting operators. Test it with `rse_std(1:3) == 1`
|
||||
|
||||
5. Finally, we will implement `rse_tstat`, returning the t-value with `length(x)-1` DF, that the provided Array actually has a mean of 0. Test it with `rse_tstat(2:3) == 5`. Add the keyword argument `σ` that allows the user to optionally provide a pre-calculated standard deviation.
|
||||
|
||||
Well done! You now have all functions defined with which we will continue our journey.
|
||||
Follow [Task 1 here](tasks.qmd#1) )
|
||||
|
||||
# Julia Basics - II
|
||||
### Strings
|
||||
@@ -353,12 +335,7 @@ once defined, a type-definition in the global scope of the REPL cannot be re-def
|
||||
:::
|
||||
|
||||
# Task 2
|
||||
|
||||
1. Implement a type `StatResult` with fields for `x`, `n`, `std` and `tvalue`
|
||||
2. Implement an outer constructor that can run `StatResult(2:10)` and return the full type including the calculated t-values.
|
||||
3. Implement a function `length` for `StatResult` to multiple-dispatch on
|
||||
4. **Optional:** If you have time, optimize the functions, so that mean, sum, length, std etc. is not calculated multiple times - you might want to rewrite your type. Note: This is a bit tricky :)
|
||||
|
||||
Follow [Task 2 here](tasks.qmd#2) )
|
||||
# Julia Basics III
|
||||
## Modules
|
||||
```julia
|
||||
|
||||
Reference in New Issue
Block a user