Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
ae13ce2
Merge pull request #3 from DanielAubin/master
Jan 16, 2019
7b19f87
created README.md (automatically)
QuantLetTeam Jan 16, 2019
f0b01b7
Added MSMpdfmultinormal
lucas-valentin Nov 9, 2020
de06637
Delete MSMpdfmultinormal.pdf
lucas-valentin Nov 9, 2020
4b3775c
Add files via upload
lucas-valentin Nov 9, 2020
2148b2c
Merge pull request #4 from lucas-valentin/master
QuantLetTeam Nov 17, 2020
98aae04
created README.md (automatically)
QuantLetTeam Nov 17, 2020
d29c4a5
new python versions of MSMLLN and MSMasprob
stw2 Dec 14, 2020
edae64d
updated MSMLLN as a multi-language example'
stw2 Dec 15, 2020
f3e6d09
deleted the -py versions
stw2 Dec 15, 2020
e61017b
added R figure
stw2 Dec 15, 2020
d89bae6
updated MSMasprob as multi-language example
stw2 Dec 15, 2020
e3820cd
Merge pull request #6 from stw2/master
QuantLetTeam Dec 17, 2020
b01def2
created README.md (automatically)
QuantLetTeam Dec 17, 2020
8f7926c
created README.md (automatically)
QuantLetTeam Dec 17, 2020
43ffaf4
Delete existing MSMLLN/README.md
StefanGam Dec 19, 2024
8bfea1b
Create README.md in folder
StefanGam Dec 19, 2024
e8d40ca
Delete existing MSM_LIL/README.md
StefanGam Dec 19, 2024
974c7ba
Create README.md in folder
StefanGam Dec 19, 2024
a80d401
Delete existing MSM_VaRandES/README.md
StefanGam Dec 19, 2024
955daeb
Create README.md in folder
StefanGam Dec 19, 2024
70abe9c
Delete existing MSMasprob/README.md
StefanGam Dec 19, 2024
e9fff85
Create README.md in folder
StefanGam Dec 19, 2024
45b32bb
Delete existing MSMasymmetricnormal/README.md
StefanGam Dec 19, 2024
584b38f
Create README.md in folder
StefanGam Dec 19, 2024
421a4b8
Delete existing MSMasymptoticnormality1/README.md
StefanGam Dec 19, 2024
5afbba6
Create README.md in folder
StefanGam Dec 19, 2024
cb57a58
Delete existing MSMasymptoticnormality2/README.md
StefanGam Dec 19, 2024
c2dbe47
Create README.md in folder
StefanGam Dec 19, 2024
084cff8
Delete existing MSMcdfnormal/README.md
StefanGam Dec 19, 2024
430cd7f
Create README.md in folder
StefanGam Dec 19, 2024
abb268f
Delete existing MSMedgeworth/README.md
StefanGam Dec 19, 2024
ecf4d53
Create README.md in folder
StefanGam Dec 19, 2024
39d2aee
Delete existing MSMpdfasymmetric/README.md
StefanGam Dec 19, 2024
114a3d8
Create README.md in folder
StefanGam Dec 19, 2024
eafbe07
Delete existing MSMpdfbinomial/README.md
StefanGam Dec 19, 2024
dc33253
Create README.md in folder
StefanGam Dec 19, 2024
583212d
Delete existing MSMpdfmultinormal/README.md
StefanGam Dec 19, 2024
c937581
Create README.md in folder
StefanGam Dec 19, 2024
a08be24
Delete existing MSMpdfnormal/README.md
StefanGam Dec 19, 2024
9c5a13b
Create README.md in folder
StefanGam Dec 19, 2024
c20e6cf
Delete existing MSMLLN/README.md
StefanGam Jan 26, 2025
51646dd
Create README.md in folder
StefanGam Jan 26, 2025
b42763b
Delete existing MSM_LIL/README.md
StefanGam Jan 26, 2025
1ace62c
Create README.md in folder
StefanGam Jan 26, 2025
64d01bc
Delete existing MSM_VaRandES/README.md
StefanGam Jan 26, 2025
6a500b5
Create README.md in folder
StefanGam Jan 26, 2025
ed7d4c0
Delete existing MSMasprob/README.md
StefanGam Jan 26, 2025
6ada923
Create README.md in folder
StefanGam Jan 26, 2025
6151677
Delete existing MSMasymmetricnormal/README.md
StefanGam Jan 26, 2025
472ad9b
Create README.md in folder
StefanGam Jan 26, 2025
22ae321
Delete existing MSMasymptoticnormality1/README.md
StefanGam Jan 26, 2025
0ba5404
Create README.md in folder
StefanGam Jan 26, 2025
77a8915
Delete existing MSMasymptoticnormality2/README.md
StefanGam Jan 26, 2025
7156931
Create README.md in folder
StefanGam Jan 26, 2025
2ab7d21
Delete existing MSMcdfnormal/README.md
StefanGam Jan 26, 2025
e24d699
Create README.md in folder
StefanGam Jan 26, 2025
f9accd0
Delete existing MSMedgeworth/README.md
StefanGam Jan 26, 2025
5665748
Create README.md in folder
StefanGam Jan 26, 2025
bac6e92
Delete existing MSMpdfasymmetric/README.md
StefanGam Jan 26, 2025
9192bc8
Create README.md in folder
StefanGam Jan 26, 2025
abede9a
Delete existing MSMpdfbinomial/README.md
StefanGam Jan 26, 2025
ffeb446
Create README.md in folder
StefanGam Jan 26, 2025
e3132b0
Delete existing MSMpdfmultinormal/README.md
StefanGam Jan 26, 2025
5e1d3fd
Create README.md in folder
StefanGam Jan 26, 2025
9003f78
Delete existing MSMpdfnormal/README.md
StefanGam Jan 26, 2025
e50d204
Create README.md in folder
StefanGam Jan 26, 2025
47f8fa4
Add files via upload
StefanGam Jun 12, 2025
98b7b73
Create MSMcdfnormal.py
rahu12t111 Jun 12, 2025
3c586fd
Update Metainfo.txt
rahu12t111 Jun 12, 2025
b6defb2
Create MSMedgeworth.py
rahu12t111 Jun 12, 2025
5b49472
Update Metainfo.txt
rahu12t111 Jun 12, 2025
5753e7d
Create MSMpdfasymmetric.py
rahu12t111 Jun 12, 2025
30e509a
Update Metainfo.txt
rahu12t111 Jun 12, 2025
b8dcba5
Update Metainfo.txt
StefanGam Jun 14, 2025
716b243
Delete MSM_VaRandES/README.md
StefanGam Jun 14, 2025
6add901
Update Metainfo.txt
fulvior Jun 14, 2025
aaffe61
Update Metainfo.txt
fulvior Jun 14, 2025
c4c8d50
Create README.md in folder
StefanGam Jun 15, 2025
ceaba5e
Update Metainfo.txt
StefanGam Oct 20, 2025
982c264
Delete MSMasprob/README.md
StefanGam Oct 20, 2025
0a2bc2c
Update Metainfo.txt
StefanGam Oct 20, 2025
e5ed7f7
Delete MSMLLN/README.md
StefanGam Oct 20, 2025
fef7761
Create README.md in folder
StefanGam Oct 21, 2025
337618b
Create README.md in folder
StefanGam Oct 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions MSMLLN/MSMLLN.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# imports
import numpy as np
import matplotlib.pyplot as plt

# plotting settings
plt.style.use('seaborn')
plt.rcParams['figure.figsize'] = (16, 8)

np.random.seed(0)
mu, sigma = 0, 1 # mean, standard deviation
x = np.random.normal(mu, sigma, 1000)
cum_sum = np.cumsum(x)
sample_size = np.arange(1, len(x)+1)
averges = np.divide(cum_sum, sample_size)

plt.xlabel('Size of a sample', fontsize=16)
plt.ylabel('Average', fontsize=16)
plt.axhline(0, ls= '--', c='black', label='mean')
plt.plot(sample_size, averges,
c='r', lw=5, alpha=0.6, label='sample average')
plt.legend(loc="upper right", frameon=True, prop={'size': 14})
plt.title('Law of Large Numbers', fontsize=20);
File renamed without changes
Binary file added MSMLLN/MSMLLN_py.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 3 additions & 5 deletions MSMLLN/Metainfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ Name of QuantLet : MSMLLN

Published in : MSM

Description : 'Plots the points showing law of large numbers.
As the sample size becomes larger, the sample mean converges to
the theoretical (true) mean of the distribution.'
Description : 'Plots the points showing law of large numbers. As the sample size becomes larger, the sample mean converges to the theoretical (true) mean of the distribution.'

Keywords :
- pdf
Expand All @@ -21,8 +19,8 @@ See also :
- MSMpdfasymmetric
- MSMasprob

Author : Xiu Xu
Author : Xiu Xu, Jacek Wiland

Submitted : Thu, November 5 2015 by Chen Huang
Submitted : December 15 2020

Example : Plot of points presenting law of large numbers.
69 changes: 30 additions & 39 deletions MSMLLN/README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,42 @@
<div style="margin: 0; padding: 0; text-align: center; border: none;">
<a href="https://quantlet.com" target="_blank" style="text-decoration: none; border: none;">
<img src="https://github.com/StefanGam/test-repo/blob/main/quantlet_design.png?raw=true" alt="Header Image" width="100%" style="margin: 0; padding: 0; display: block; border: none;" />
</a>
</div>

[<img src="https://github.com/QuantLet/Styleguide-and-FAQ/blob/master/pictures/banner.png" width="888" alt="Visit QuantNet">](http://quantlet.de/)

## [<img src="https://github.com/QuantLet/Styleguide-and-FAQ/blob/master/pictures/qloqo.png" alt="Visit QuantNet">](http://quantlet.de/) **MSMLLN** [<img src="https://github.com/QuantLet/Styleguide-and-FAQ/blob/master/pictures/QN2.png" width="60" alt="Visit QuantNet 2.0">](http://quantlet.de/)

```yaml

Name of QuantLet : MSMLLN
```
Name of QuantLet: MSMLLN

Published in : MSM
Published in: MSM

Description : 'Plots the points showing law of large numbers. As the sample size becomes larger,
the sample mean converges to the theoretical (true) mean of the distribution.'
Description: Plots the points showing law of large numbers. As the sample size becomes larger, the sample mean converges to the theoretical (true) mean of the distribution.

Keywords : pdf, normal, distribution, mean, plot, parameter, visualization, discrete
Keywords:
- pdf
- normal
- distribution
- mean
- plot
- parameter
- visualization
- discrete

See also : MSMpdfasymmetric, MSMasprob
See also:
- MSMpdfasymmetric
- MSMasprob

Author : Xiu Xu
Author: Xiu Xu, Jacek Wiland

Submitted : Thu, November 5 2015 by Chen Huang
Submitted: December 15 2020

Example : Plot of points presenting law of large numbers.
Example: Plot of points presenting law of large numbers.

```
<div align="center">
<img src="https://raw.githubusercontent.com/QuantLet/MSM/master/MSMLLN/MSMLLN_R.png" alt="Image" />
</div>

![Picture1](MSMLLN.png)


### R Code:
```r
<div align="center">
<img src="https://raw.githubusercontent.com/QuantLet/MSM/master/MSMLLN/MSMLLN_py.png" alt="Image" />
</div>

# clear history
rm(list = ls(all = TRUE))
graphics.off()

n = 1000
mu = 0
sig = 1
y = rnorm(n, mu, sig)
x = matrix(0, nrow = n, ncol = 1)

for (i in 1:n) {
x[i] = mean(y[1:i])
}

# Plot
plot(x, col = "red3", type = "p", pch = 20, lwd = 2.5, ylab = "", xlab = "")
abline(h = 0, col = "blue", pch = 20, lwd = 3.5)

```
85 changes: 21 additions & 64 deletions MSM_LIL/README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,31 @@

[<img src="https://github.com/QuantLet/Styleguide-and-FAQ/blob/master/pictures/banner.png" width="888" alt="Visit QuantNet">](http://quantlet.de/)

## [<img src="https://github.com/QuantLet/Styleguide-and-FAQ/blob/master/pictures/qloqo.png" alt="Visit QuantNet">](http://quantlet.de/) **MSM_LIL** [<img src="https://github.com/QuantLet/Styleguide-and-FAQ/blob/master/pictures/QN2.png" width="60" alt="Visit QuantNet 2.0">](http://quantlet.de/)

```yaml

Name of QuantLet : MSM_LIL

Published in : MSM

Description : 'Plots the average of n Bernoulli trials (each taking a value of +/- 1, with
probability 0.5) to show the law of large numbers and the law of the iterated logarithm. Plots of
sample mean (red), its asymptotic standard deviation (dark-green) and its bound given by law of
iterated logarithm (blue).'

Keywords : bernoulli, random, random-number-generation, simulation, plot

Author : Chen Huang

Author [New] : Ya Qian

Submitted : Fri, October 16 2015 by Shi Chen
<div style="margin: 0; padding: 0; text-align: center; border: none;">
<a href="https://quantlet.com" target="_blank" style="text-decoration: none; border: none;">
<img src="https://github.com/StefanGam/test-repo/blob/main/quantlet_design.png?raw=true" alt="Header Image" width="100%" style="margin: 0; padding: 0; display: block; border: none;" />
</a>
</div>

```
Name of QuantLet: MSM_LIL

![Picture1](MSM_LIL.png)

Published in: MSM

### R Code:
```r
Description: Plots the average of n Bernoulli trials (each taking a

## clear history
rm(list = ls(all = TRUE))
graphics.off()
Keywords:
- bernoulli
- random
- random-number-generation
- simulation
- plot

## Initialize
y = 0
m = 0
N1 = 0
N2 = 0
Author: Chen Huang

for (n in 1:1e+04) {
## Simulate the paths of Bernoulli Distribution
y = c(y, (1 + (-1 - 1) * (runif(1) < 0.5)))
## Calculate the sample mean
m = c(m, mean(y[-1]))
## Calculate the asymptotic standard deviation
N1 = c(N1, sqrt(1/n))
## Calculate the bounds of the sample mean
N2 = c(N2, sqrt(2 * log(log(n))/n))
}
Author [New]: Ya Qian

## Remove the initial zeros of each vector
m = m[-1]
N1 = N1[-1]
N2 = N2[-1]

## Plot the sample mean
par(cex.lab = 1.5, cex.axis = 1.5, cex.main = 1.5, pch = 20)
plot(m, ylim = c(-0.2, 0.2), type = "p", col = "red", main = "Law
of the Iterated Logarithm", xlab = "Sample Size", ylab =
"Deviation from Mean", cex = 0.5, bty = "n")
legend(5000, 0.2, c("sqrt(1/n)", "sqrt(2 * log(log(n)) / n)"),
lty = c(1, 1), col = c("dark green", "blue"), box.col =
"white", pt.cex = 1.5 )

## Add the asymptotic standard deviation and bounds
lines(N1, lty = 1, lwd = 2, col = "dark green")
lines(-N1, lty = 1, lwd = 2, col = "dark green")
lines(N2, lty = 1, lwd = 2, col = "blue")
lines(-N2, lty = 1, lwd = 2, col = "blue")
Submitted: Fri, October 16 2015 by Shi Chen

```
<div align="center">
<img src="https://raw.githubusercontent.com/QuantLet/MSM/master/MSM_LIL/MSM_LIL.png" alt="Image" />
</div>

2 changes: 1 addition & 1 deletion MSM_VaRandES/Metainfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Keywords :
- cdf
- plot

Author : Chen Huang
Author : Chen Huang, Fulvio Raddi

Author [New] : Torsten Becker, Viktor Sandor

Expand Down
85 changes: 22 additions & 63 deletions MSM_VaRandES/README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,32 @@

[<img src="https://github.com/QuantLet/Styleguide-and-FAQ/blob/master/pictures/banner.png" width="888" alt="Visit QuantNet">](http://quantlet.de/)

## [<img src="https://github.com/QuantLet/Styleguide-and-FAQ/blob/master/pictures/qloqo.png" alt="Visit QuantNet">](http://quantlet.de/) **MSM_VaRandES** [<img src="https://github.com/QuantLet/Styleguide-and-FAQ/blob/master/pictures/QN2.png" width="60" alt="Visit QuantNet 2.0">](http://quantlet.de/)

```yaml

Name of QuantLet : MSM_VaRandES

Published in : MSM

Description : 'Plots Value at Risk and Expected Shortfall in one figure and shows the relationship
between VaR and ES.'

Keywords : VaR, expected shortfall, lognormal, pdf, cdf, plot

Author : Chen Huang

Author [New] : Torsten Becker, Viktor Sandor

Submitted : Thu, November 5 2015 by Chen Huang
<div style="margin: 0; padding: 0; text-align: center; border: none;">
<a href="https://quantlet.com" target="_blank" style="text-decoration: none; border: none;">
<img src="https://github.com/StefanGam/test-repo/blob/main/quantlet_design.png?raw=true" alt="Header Image" width="100%" style="margin: 0; padding: 0; display: block; border: none;" />
</a>
</div>

```
Name of QuantLet: MSM_VaRandES

![Picture1](MSM_VaRandES.png)


### R Code:
```r

# clear all variables
rm(list = ls(all = TRUE))
graphics.off()
Published in: MSM

dlognormalLoss = function(x) {
dlnorm(x, 0.5, 0.3) # the density function
}
Description: Plots Value at Risk and Expected Shortfall in one figure and shows the relationship between VaR and ES.

plognormalLoss = function(x) {
plnorm(x, 0.5, 0.3) # the distribution function
}
Keywords:
- VaR
- expected shortfall
- lognormal
- pdf
- cdf
- plot

curve(plognormalLoss, 0, 4, xlab = "Loss", ylab = "", lwd = 2)
curve(dlognormalLoss, 0, 4, col = " black", lty = 2, lwd = 2, add = TRUE)
Author: Chen Huang, Fulvio Raddi

# Fill in the part beyond VaR with shadow
x = seq(2.42, 4, length = 100)
y = dlognormalLoss(x)
x = c(2.42, x)
y = c(dlognormalLoss(4), y)
polygon(x, y, col = "grey", border = "grey")
text(3.5, 0.2, expression(P(S > VaR[alpha]) == alpha))
arrows(3, 0.2, 2.7, 0.05, lwd = 2)
Author [New]: Torsten Becker, Viktor Sandor

mtext(expression(VaR[alpha]), side = 1, at = 2.42)

# Mark the Expected shortfall
x = seq(2.42, 4, length = 100)
y = plognormalLoss(x)
x = c(0, x, 0)
y = c(0.9, y, plognormalLoss(4))
polygon(x, y, density = 20, col = "grey", border = "black", angle = 45)
text(0.3, 0.93, expression(1 - alpha == 0.9))
text(1.6, 0.95, expression(alpha * ES[alpha](X)))
curve(plognormalLoss, 0, 4, lwd = 2, add = TRUE)
curve(dlognormalLoss, 0, 4, col = "black", lty = 2, lwd = 2, add = TRUE)

segments(2.42, -0.25, 2.42, 0.9)
segments(-0.4, 0.9, 2.42, 0.9)

legend(x = 2.5, y = 0.5, c("PDF", "CDF"), lty = c(2, 1))
Submitted: Thu, November 5 2015 by Chen Huang

```
<div align="center">
<img src="https://raw.githubusercontent.com/QuantLet/MSM/master/MSM_VaRandES/MSM_VaRandES.png" alt="Image" />
</div>

110 changes: 110 additions & 0 deletions MSM_VaRandES/VaRandES.ipynb

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions MSMasprob/MSMasprob.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# imports
import numpy as np
import matplotlib.pyplot as plt

# plotting settings
plt.style.use('seaborn')
plt.rcParams['figure.figsize'] = (16, 8)

# parameters
n = 1000
k = np.floor(np.log(n)/np.log(2)) - 1
x = np.zeros([n, 10])
x[0] = 1
z = np.array([0.5, 0.2, 0.4, 0.6, 0.8])

for s in range(2, len(z)+1):
for i in range(1, int(k+1)):
for j in range(0, 2**i + 1):
t = 2**i + j
x[t, 1] = (j * 2**(-i) <= 0.5) & (0.5 < (j + 1) * 2**(-i))
x[t, s] = (j * 2**(-i) <= z[s-1]) & (z[s-1] < (j + 1) * 2**(-i))
x = x * 1

# Plot the time series
plt.plot(x[1:400, 1], 'o', c = 'b', ms=5)
plt.plot(x[1:400, 2], 'o', c = 'g', ms=5)
plt.plot(x[1:400, 5], 'o', c = 'r', ms=5);
File renamed without changes
Binary file added MSMasprob/MSMasprob_py.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 4 additions & 8 deletions MSMasprob/Metainfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ Name of QuantLet : MSMasprob

Published in : MSM

Description : 'Displays an example of which meets the convergence in
mean square but not convergence in almost sure series of the example.
We select n = 400 and plot three cases: the initial value of
Z = 0.5 (blue), 0.2 (green), and 0.8 (dark red).'
Description : 'Displays an example of which meets the convergence in mean square but not convergence in almost sure series of the example. We select n = 400 and plot three cases: the initial value of Z = 0.5 (blue), 0.2 (green), and 0.8 (dark red).'

Keywords :
- random-number-generation
Expand All @@ -21,9 +18,8 @@ See also :
- MSMpdfasymmetric
- SFSmsr1

Author : Xiu Xu
Author: Xiu Xu, Jacek Wiland

Submitted : Thu, November 5 2015 by Chen Huang
Submitted : December 15 2020

Example : 'Plot of the series of a random variable satisfying convergence
in mean square but not convergence in almost sure.'
Example : 'Plot of the series of a random variable satisfying convergence in mean square but not convergence in almost sure.'
Loading