Tool that outputs a random coordinates generator in n-th dimensions
GitHub: https://github.com/YujiSODE/nDRandom
Copyright (c) 2021 Yuji SODE <yuji.sode@gmail.com>
This software is released under the MIT License.
See LICENSE or http://opensource.org/licenses/mit-license.php
- It can generates a random coordinates in n-th dimensions employing a single random numbers.
- Generated elements in random coordinate may show spurious correlation, but they have no correlation with each other.
- Generated elements are not cryptographically secure.
nDRandom
is a tool that outputs a random coordinates generator in n-th dimensions.
tclsh nDRandom.tcl name option min1 max1 division1 ?min2 max2 division2 ?... minN maxN divisionN??;
$name
: a keyword to determine output file name and its functions$option
: a keyword to determine output type$min1, $max1 and $division1
: data range$min2, $max2 and $division2 (, ..., $minN, $maxN and $divisionN)
: optional data ranges$division
: number of divided ranges that are not less than 2
::nDRandom::setRange min max division;
: loads a variable range::nDRandom::output name ?option?;
: outputs a random coordinates generater in the current directory$min and $max
: minimum and maximum values$division
: number of divided ranges that are not less than 2$name
: a keyword to determine output file and its functions$option
: an optional keyword to determine output type, and default value istcl
keyword: output type
tcl: Tcl
js: JavaScript
The generated script is output in the current directory.
- Generated script format:
${name}_info()
and${name}_random(double)
in math functions ${name}_info()
: it returns preset data${name}_random(double)
: it returns a random coordinates in n-th dimensions$double
: a real number in range(0.0, 1.0)
- output coordinates:
{x1 dx1 x2 dx2 ... xn dxn}
whereXi = xi+c*dxi
andc
is a constant
2. Algorithm
To obtain random coordinates from a given space in n
-th dimensions.
Let variable elements be E
= (
e
0
,
e
1
,...,
e
n
)
where i
=0,...,
n
.
A range of a variable element e
i
is divided into d
i
intervals.
Let indices correspond to a specified intervals in divided elements as follows:
IDX
=(
IDX
0
,
IDX
1
,...,
IDX
n
)
.
A coordinate element value can be estimated as follows:
e
j
=
x
0
+
c
j
*
dx
,
where c
j
is constant,
x
0
=
e
j
[
IDX
j
]
and dx
=(
e
j
max
-
e
j
min
)/
d
j
.
It requires Tcl 8.6+.
nDRandom.tcl
: main script
ndrandomOutput_tcl.tcl
: module to output as Tcl filendrandomOutput_js.tcl
: module to output as JavaScript file
- Sode, Y. 2018. lSum_min.tcl: https://gist.github.com/YujiSODE/1f9a4e2729212691972b196a76ba9bd0