- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.mahout.math.random.WeightedThing
类的一些代码示例,展示了WeightedThing
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeightedThing
类的具体详情如下:
包路径:org.apache.mahout.math.random.WeightedThing
类名称:WeightedThing
[英]Handy for creating multinomial distributions of things.
[中]便于创建事物的多项式分布。
代码示例来源:origin: apache/mahout
public Multinomial(Iterable<WeightedThing<T>> things) {
this();
for (WeightedThing<T> thing : things) {
add(thing.getValue(), thing.getWeight());
}
}
代码示例来源:origin: apache/mahout
double sample(double u) {
if (u < limit) {
List<WeightedThing<Integer>> steps = Lists.newArrayList();
limit = 1;
int i = 0;
while (u / 20 < limit) {
double pdf = pd.probability(i);
limit -= pdf;
steps.add(new WeightedThing<>(i, pdf));
i++;
}
steps.add(new WeightedThing<>(steps.size(), limit));
partial = new Multinomial<>(steps);
}
return partial.sample(u);
}
}
代码示例来源:origin: org.apache.mahout/mahout-core
protected static WeightedThing<Vector> removeHash(WeightedThing<Vector> input) {
return new WeightedThing<Vector>(((HashedVector) input.getValue()).getVector(), input.getWeight());
}
代码示例来源:origin: org.apache.mahout/mahout-mr
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
int middle = Collections.binarySearch(currProjections,
new WeightedThing<Vector>(projection.get(i)));
if (middle < 0) {
middle = -(middle + 1);
if (currProjections.get(j).getValue() == null) {
continue;
candidates.add(currProjections.get(j).getValue());
Lists.newArrayListWithCapacity(candidates.size() + pendingAdditions.size());
for (Vector candidate : Iterables.concat(candidates, pendingAdditions)) {
top.add(new WeightedThing<>(candidate, distanceMeasure.distance(candidate, query)));
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
@Override
protected Vector computeNext() {
do {
if (!data.hasNext()) {
return endOfData();
}
WeightedThing<Vector> next = data.next();
if (next.getValue() != null) {
return next.getValue();
}
} while (true);
}
};
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
@Override
public boolean remove(Vector vector, double epsilon) {
WeightedThing<Vector> toRemove = searchFirst(vector, false);
if (toRemove.getWeight() < epsilon) {
Iterator<? extends Vector> basisVectors = basisMatrix.iterator();
for (TreeMultiset<WeightedThing<Vector>> projection : scalarProjections) {
if (!projection.remove(new WeightedThing<Vector>(vector, vector.dot(basisVectors.next())))) {
throw new RuntimeException("Internal inconsistency in ProjectionSearch");
}
}
return true;
} else {
return false;
}
}
代码示例来源:origin: org.apache.mahout/mahout-core
Vector projection = basisMatrix.times(pending);
for (int i = 0; i < numProjections; ++i) {
scalarProjections.get(i).add(new WeightedThing<Vector>(pending, projection.get(i)));
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
for (WeightedThing<Vector> v : currProjections) {
if (v.getValue() == null) {
v.setWeight(Double.POSITIVE_INFINITY);
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
protected boolean lessThan(WeightedThing<Vector> a, WeightedThing<Vector> b) {
return a.getWeight() > b.getWeight();
}
};
代码示例来源:origin: org.apache.mahout/mahout-mr
protected static WeightedThing<Vector> removeHash(WeightedThing<Vector> input) {
return new WeightedThing<>(((HashedVector) input.getValue()).getVector(), input.getWeight());
}
代码示例来源:origin: org.apache.mahout/mahout-core
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
int middle = Collections.binarySearch(currProjections,
new WeightedThing<Vector>(projection.get(i)));
if (middle < 0) {
middle = -(middle + 1);
if (currProjections.get(j).getValue() == null) {
continue;
candidates.add(currProjections.get(j).getValue());
Lists.newArrayListWithCapacity(candidates.size() + pendingAdditions.size());
for (Vector candidate : Iterables.concat(candidates, pendingAdditions)) {
top.add(new WeightedThing<Vector>(candidate, distanceMeasure.distance(candidate, query)));
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
protected Vector computeNext() {
do {
if (!data.hasNext()) {
return endOfData();
}
WeightedThing<Vector> next = data.next();
if (next.getValue() != null) {
return next.getValue();
}
} while (true);
}
};
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
public boolean remove(Vector vector, double epsilon) {
WeightedThing<Vector> toRemove = searchFirst(vector, false);
if (toRemove.getWeight() < epsilon) {
Iterator<? extends Vector> basisVectors = basisMatrix.iterator();
for (TreeMultiset<WeightedThing<Vector>> projection : scalarProjections) {
if (!projection.remove(new WeightedThing<Vector>(vector, vector.dot(basisVectors.next())))) {
throw new RuntimeException("Internal inconsistency in ProjectionSearch");
}
}
return true;
} else {
return false;
}
}
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
Vector projection = basisMatrix.times(pending);
for (int i = 0; i < numProjections; ++i) {
scalarProjections.get(i).add(new WeightedThing<Vector>(pending, projection.get(i)));
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
for (WeightedThing<Vector> v : currProjections) {
if (v.getValue() == null) {
v.setWeight(Double.POSITIVE_INFINITY);
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
protected boolean lessThan(WeightedThing<Vector> a, WeightedThing<Vector> b) {
return a.getWeight() > b.getWeight();
}
};
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
protected static WeightedThing<Vector> removeHash(WeightedThing<Vector> input) {
return new WeightedThing<Vector>(((HashedVector) input.getValue()).getVector(), input.getWeight());
}
代码示例来源:origin: org.apache.mahout/mahout-math
public Multinomial(Iterable<WeightedThing<T>> things) {
this();
for (WeightedThing<T> thing : things) {
add(thing.getValue(), thing.getWeight());
}
}
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
int middle = Collections.binarySearch(currProjections,
new WeightedThing<Vector>(projection.get(i)));
if (middle < 0) {
middle = -(middle + 1);
if (currProjections.get(j).getValue() == null) {
continue;
candidates.add(currProjections.get(j).getValue());
Lists.newArrayListWithCapacity(candidates.size() + pendingAdditions.size());
for (Vector candidate : Iterables.concat(candidates, pendingAdditions)) {
top.add(new WeightedThing<Vector>(candidate, distanceMeasure.distance(candidate, query)));
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
protected Vector computeNext() {
do {
if (!data.hasNext()) {
return endOfData();
}
WeightedThing<Vector> next = data.next();
if (next.getValue() != null) {
return next.getValue();
}
} while (true);
}
};
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
public boolean remove(Vector vector, double epsilon) {
WeightedThing<Vector> toRemove = searchFirst(vector, false);
if (toRemove.getWeight() < epsilon) {
Iterator<? extends Vector> basisVectors = basisMatrix.iterator();
for (TreeMultiset<WeightedThing<Vector>> projection : scalarProjections) {
if (!projection.remove(new WeightedThing<>(vector, vector.dot(basisVectors.next())))) {
throw new RuntimeException("Internal inconsistency in ProjectionSearch");
}
}
return true;
} else {
return false;
}
}
代码示例来源:origin: org.apache.mahout/mahout-mr
Vector projection = basisMatrix.times(pending);
for (int i = 0; i < numProjections; ++i) {
scalarProjections.get(i).add(new WeightedThing<>(pending, projection.get(i)));
List<WeightedThing<Vector>> currProjections = scalarProjections.get(i);
for (WeightedThing<Vector> v : currProjections) {
if (v.getValue() == null) {
v.setWeight(Double.POSITIVE_INFINITY);
在分析代码时,我偶然发现了以下代码段: msk = np.random.rand(len(df)) < 0.8 变量“msk”和“df”与我的问题无关。经过一些研究,我认为这种用法也与“随机”类有关。
出于几个合理的原因,我必须使用 BSD 的 random() 来生成非常大量的随机数,并且由于它的周期很短(~2^69,如果我没记错的话),这些数字的质量会降低对于我的用例来说很快。我可以使用我可以访
每种语言都有一个 random() 函数或类似的东西来生成伪随机数。我想知道下面会发生什么来生成这些数字?我没有编写任何需要这些知识的东西,只是想满足我自己的好奇心。 最佳答案 唐纳德·克努斯开创性的
我开发了一个简单的应用程序来生成测试数据系列,并且我使用随机种子将其构建为能够重复。我注意到以下情况并想知道为什么会这样: >>> random.seed(1) >>> [random.randint
random() * random() 和 random() ** 2 有区别吗? random() 从均匀分布中返回一个介于 0 和 1 之间的值。 在测试两个版本的随机平方数时,我注意到了一点不同
我发现 Python(及其生态系统)充满了奇怪的约定和不一致,这是另一个例子: np.random.rand Create an array of the given shape and popula
我想看看哪个随机数生成器包在我的神经网络中速度更快。 我目前正在从github上修改一段代码,其中numpy.random和random包都用于生成随机整数、随机选择、随机样本等。 我更改此代码的原因
我有一个 Python 大脚本。我在其他人的代码中启发了自己,所以我最终使用 numpy.random 模块来做一些事情(例如创建一个从二项分布中获取的随机数数组),在其他地方我使用模块 random
仅仅是因为“大型 API 综合症”还是生成在某些情况下更偏向的随机数?如果是……我认为控制偏见很重要。 最佳答案 他们是一样的,真的。只是一个方便的方法。检查 javadoc here .此外,您
我只是观察到,当使用 Python3 时,使用 random.shuffle 对列表进行洗牌需要大约一半的运行时间,而当为 显式提交函数 random.random >random 关键字参数。我检查
在python中随机模块,random.uniform()和random.random()有什么区别?它们都生成伪随机数,random.uniform() 生成均匀分布的数字,random.rando
是否可以在JMeter中生成“随机数”变量? 我已经记录了用户旅程 我已将旅程导入JMeter 我必须在用户旅程测试用例中输入一个唯一的4位数ID 在jmeter的当前默认值为2323 有没有一种方法
例如,如果我执行命令两次:ffmpeg -i input.mp4 -vf geq=r='random(1)*255':g='random(1)*255':b='random(1)*255' -stri
尽管随机生成器只创建一次,但输出始终是相同的随机结果(对于所有三个测试输出)。 来自稍大脚本的测试片段: let myRandGen = System.Random() let getRa
我正计划使用IntRange.random()(即(0..9999).random())在 Kotlin 中生成一个随机的5位代码。重要的是,恶意人员不能预测将要生成的数字的顺序。 IntRange.
您能否告诉我如何将 KDB 中的随机数生成器种子设置为或多或少的“随机”数? 我正在尝试执行以下操作: \S .z.i 但不知何故它不起作用。\S 似乎需要一个显式整数,而不是一个变量。 非常感谢!
我需要同时获得 /dev/random和 /dev/urandom在内核模块中。 get_random_bytes提供获取 /dev/urandom 的 API . 但是/dev/random 没有A
random.shuffle(lst_shuffle, random.random) 我知道后一部分是可选参数。但它究竟做了什么。我不明白这是什么意思。 这是来自文档。 random.random()
在树莓派 3 上: >>> import random >>> random.seed(0.9849899567458751) >>> random.random() 0.47871160253065
说我有一些python代码: import random r=random.random() r的值通常从哪里来? 如果我的操作系统没有随机数,那么它将在何处播种呢? 为什么不建议将其用于加密?有什么
我是一名优秀的程序员,十分优秀!