A Discrete-Event Network Simulator
QKDNetSim v2.0 (NS-3 v3.41) @ (+)
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
w
Enumerator
a
b
c
d
e
f
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Related Functions
:
a
b
c
d
e
g
h
i
j
l
m
n
o
p
q
r
s
t
u
w
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
c
e
i
l
o
r
s
t
v
Macros
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
sample-rng-plot.py
Go to the documentation of this file.
1
#
2
# This program is free software; you can redistribute it and/or modify
3
# it under the terms of the GNU General Public License version 2 as
4
# published by the Free Software Foundation
5
#
6
# This program is distributed in the hope that it will be useful,
7
# but WITHOUT ANY WARRANTY; without even the implied warranty of
8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
# GNU General Public License for more details.
10
#
11
# You should have received a copy of the GNU General Public License
12
# along with this program; if not, write to the Free Software
13
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
#
15
16
23
24
25
import
argparse
26
import
sys
27
28
import
matplotlib.pyplot
as
plt
29
import
numpy
as
np
30
31
32
try
:
33
from
ns
import
ns
34
except
ModuleNotFoundError:
35
raise
SystemExit(
36
"Error: ns3 Python module not found;"
37
" Python bindings may not be enabled"
38
" or your PYTHONPATH might not be properly configured"
39
)
40
41
42
def
main():
43
parser = argparse.ArgumentParser(
"sample-rng-plot"
)
44
parser.add_argument(
"--not-blocking"
, action=
"store_true"
, default=
False
)
45
args = parser.parse_args(sys.argv[1:])
46
47
# mu, var = 100, 225
48
49
50
rng = ns.CreateObject(
"NormalRandomVariable"
)
51
rng.SetAttribute(
"Mean"
, ns.DoubleValue(100.0))
52
rng.SetAttribute(
"Variance"
, ns.DoubleValue(225.0))
53
54
55
x = [rng.GetValue()
for
t
in
range(10000)]
56
57
# the histogram of the data
58
59
60
density = 1
61
62
facecolor =
"g"
63
64
alpha = 0.75
65
66
# We don't really need the plot results, we're just going to show it later.
67
# n, bins, patches = plt.hist(x, 50, density=1, facecolor='g', alpha=0.75)
68
n, bins, patches = plt.hist(x, 50, density=
True
, facecolor=
"g"
, alpha=0.75)
69
70
plt.title(
"ns-3 histogram"
)
71
plt.text(60, 0.025,
r"$\mu=100,\ \sigma=15$"
)
72
plt.axis([40, 160, 0, 0.03])
73
plt.grid(
True
)
74
plt.show(block=
not
args.not_blocking)
75
76
77
if
__name__ ==
"__main__"
:
78
main()
src
core
examples
sample-rng-plot.py
Generated on Sun Mar 3 2024 17:10:55 for ns-3 by
1.9.1