/*
* Copyright (c) 2009 Thomas Weise
* http://www.it-weise.de/
* tweise@gmx.de
*
* GNU LESSER GENERAL PUBLIC LICENSE (Version 2.1, February 1999)
*/
import java.util.Random;
/**
* A standardized implementation of the randomization of shift vectors and
* matrices used for the experiments. The implementation of the basic
* random methods is the same as in Java 1.6. By overriding these methods
* here, we basically ensure that the behavior of the randmizer is the same
* for all past and future versions of Java.
*
* @author Thomas Weise
*/
public class Randomizer extends Random {
/** use serialVersionUID y */
static final long serialVersionUID = 1;
/** M */
private static final long M = 0x5DEECE66DL;
/** a */
private static final long A = 0xBL;
/** mask */
private static final long MASK = (1L << 48) - 1;
/** The randomization seed */
private long m_seed;
/** the internal variable holding the next gaussian number */
private double m_nextNextGaussian;
/**
* the internal variable indicating whether there is a next gaussian
* number stored
*/
private boolean m_haveNextNextGaussian = false;
/**
* Creates a new random number generator.
*/
public Randomizer() {
this(0);
}
/**
* Creates a new random number generator using a single {@code long}
* seed.
*
* @param seed
* the initial seed
*/
public Randomizer(final long seed) {
super(seed);
this.m_seed = seed;
}
/**
* Sets the seed of this random number generator using a single {@code
* long} seed.
*
* @param seed
* the new seed
*/
//@Override
public final void setSeed(long seed) {
this.m_seed = seed;
super.setSeed(seed);
}
/**
* Generates the next pseudorandom number.
*
* @param bits
* random bits
* @return the random bits
*/
//@Override
protected final int next(final int bits) {
final long s;
this.m_seed = s = (((this.m_seed * M) + A) & MASK);
return (int) (s >>> (48 - bits));
}
/**
* Returns a pseudorandom, uniformly distributed {@code int} value
* between 0 (inclusive) and the specified value (exclusive), drawn from
* this random number generator's sequence.
*
* @param n
* the bound on the random number to be returned. Must be
* positive.
* @return the next pseudorandom, uniformly distributed {@code int} value
* between {@code 0} (inclusive) and {@code n} (exclusive) from
* this random number generator's sequence
*/
//@Override
public final int nextInt(final int n) {
int bits, val;
if ((n & (-n)) == n) {// i.e., n is a power of 2
return (int) ((n * (long) next(31)) >> 31);
}
do {
bits = next(31);
val = bits % n;
} while (bits - val + (n - 1) < 0);
return val;
}
/**
* Returns the next pseudorandom, uniformly distributed {@code double}
* value between {@code 0.0} and {@code 1.0} from this random number
* generator's sequence.
*
* @return the next pseudorandom, uniformly distributed {@code double}
* value between {@code 0.0} and {@code 1.0} from this random
* number generator's sequence
* @see Math#random
*/
//@Override
public final double nextDouble() {
return ((((long) (next(26)) << 27) + next(27)) / (double) (1L << 53));
}
/**
* Returns the next pseudorandom, Gaussian ("normally") distributed
* {@code double} value with mean {@code 0.0} and standard deviation
* {@code 1.0} from this random number generator's sequence.
*
* @return the next pseudorandom, Gaussian ("normally") distributed
* {@code double} value with mean {@code 0.0} and standard
* deviation {@code 1.0} from this random number generator's
* sequence
*/
//@Override
public final double nextGaussian() {
double multiplier, v1, v2, s;
if (this.m_haveNextNextGaussian) {
this.m_haveNextNextGaussian = false;
return this.m_nextNextGaussian;
}
do {
v1 = ((2d * this.nextDouble()) - 1d);
v2 = ((2d * this.nextDouble()) - 1d);
s = ((v1 * v1) + (v2 * v2));
} while ((s >= 1d) || (s == 0d));
multiplier = StrictMath.sqrt(-2.d * StrictMath.log(s) / s);
this.m_nextNextGaussian = (v2 * multiplier);
this.m_haveNextNextGaussian = true;
return (v1 * multiplier);
}
/**
* Create a new shifting vector
*
* @param dim
* the dimension of the vector
* @param min
* the minimum value a decision variable can take on
* @param max
* the maximum value a decision variable can take on
* @return the shift vector
*/
public final double[] createShiftVector(final int dim, final double min,
final double max) {
final double[] d;
final double hw, middle;
double s;
int i;
hw = (0.5d * (max - min));
middle = (min + hw);
d = new double[dim];
for (i = (dim - 1); i >= 0; i--) {
do {
s = (middle + (this.nextGaussian() * hw));
} while ((s < min) || (s > max));
d[i] = s;
}
return d;
}
/**
* Create a random permutation vector of the numbers 0 to dim-1
*
* @param dim
* the number of dimensions
* @return the permutation vector
*/
public final int[] createPermVector(final int dim) {
final int[] d;
int i, j, k, t;
d = new int[dim];
for (i = (dim - 1); i >= 0; i--) {
d[i] = i;
}
for (i = (dim << 3); i >= 0; i--) {
j = this.nextInt(dim);
do {
k = this.nextInt(dim);
} while (k == j);
t = d[j];
d[j] = d[k];
d[k] = t;
}
return d;
}
/**
* Create a random rotation matrix
*
* @param dim
* the number of dimensions
* @return the rotation matrix
*/
public final double[][] createRotMatrix(final int dim) {
final double[][] m;
int i, j, k;
double dp, t;
m = new double[dim][dim];
outer: for (;;) {
// initialize
for (i = (dim - 1); i >= 0; i--) {
for (j = (dim - 1); j >= 0; j--) {
m[i][j] = this.nextGaussian();
}
}
// main loop of gram/schmidt
for (i = (dim - 1); i >= 0; i--) {
//
for (j = (dim - 1); j > i; j--) {
// dot product
dp = 0d;
for (k = (dim - 1); k >= 0; k--) {
dp += (m[i][k] * m[j][k]);
}
// subtract
for (k = (dim - 1); k >= 0; k--) {
m[i][k] -= (dp * m[j][k]);
}
}
// normalize
dp = 0d;
for (k = (dim - 1); k >= 0; k--) {
t = m[i][k];
dp += (t * t);
}
// linear dependency -> restart
if (dp <= 0d) {
continue outer;
}
dp = (1d / Math.sqrt(dp));
for (k = (dim - 1); k >= 0; k--) {
m[i][k] *= dp;
}
}
return m;
}
}
/**
* Create a random rotation matrix
*
* @param dim
* the number of dimensions
* @return the rotation matrix
*/
public final double[] createRotMatrix1D(final int dim) {
final double[][] a;
final double[] b;
int i, j, k;
a = this.createRotMatrix(dim);
b = new double[dim * dim];
k = 0;
for (i = 0; i < dim; i++) {
for (j = 0; j < dim; j++) {
b[k++] = a[i][j];
}
}
return b;
}
/**
* The test function used to check whether the routines here have been
* implemented correctly.
*
* @param params
* the parameters
*/
public static final void mai
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 67 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- jian4567892023-07-23简直是宝藏资源,实用价值很高,支持!
![avatar](https://profile-avatar.csdnimg.cn/c7605ebd585249f1b630f560f4d9ba6f_weixin_42650811.jpg!1)
我虽横行却不霸道
- 粉丝: 77
- 资源: 1万+
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 建筑结构\施工图\A型施工图-建筑-空施08.dwg
- 建筑结构\施工图\A型施工图-建筑-空施07.dwg
- 视频下载神器-**猫抓**浏览器插件
- Java课程设计模板.docx
- com.whidev.mapchart.apk
- Delphi 12 控件之R121.patch1.zip
- Delphi 12 控件RADStudio-12-1-29-0-51961-7529-KeyPatch.rar
- Delphi 12 控件之Delphi 10.4.2 patch合并包.rar
- Delphi 12 控件之12.1Patch-Patch1.rar
- Delphi 12 控件之LMD.VCL.Full.Version.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)