-
Notifications
You must be signed in to change notification settings - Fork 5
/
Ex_Sheet_3_Num_5.py
47 lines (34 loc) · 1.05 KB
/
Ex_Sheet_3_Num_5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Author: Gabriele Pompa
Identification Number: ABCXYZ [substitute with your Unisi Identification Number]
Date: 24-Mar-2020
File name: Ex_Sheet_3_Num_5.py
Description: This script computes the mean, standard deviation of the data of
a given log-normally-distributed series.
"""
import numpy as np
import pandas as pd
def main():
"""
Function main() computes the mean, standard deviation of the data of a
given log-normally-distributed series.
Parameters:
None
Returns:
None
"""
# parameters
mu = np.log(30)
sigma = np.log(1.1)
N = 10
# test series
s = pd.Series(data=np.random.lognormal(mean=mu, sigma=sigma, size=N))
# calculations (all calculations are one-line. No need for dedicated functions)
s_mean = s.mean()
s_std = s.std()
# Print section ('\n' is to print on the next line)
print("s: \n{}".format(s))
print("mean: {}".format(s_mean))
print("standard deviation: {}".format(s_std))
if __name__ == "__main__":
main()