我正在对sampleR 中的函数进行基准测试并将其与它进行比较igraph:sample_seq并遇到了一个奇怪的结果。
当我运行类似的东西时:
library(microbenchmark)
library(igraph)
set.seed(1234)
N <- 55^4
M <- 500
(mbm <- microbenchmark(v1 = {sample(N,M)},
v2 = {igraph::sample_seq(1,N,M)}, times=50))
Run Code Online (Sandbox Code Playgroud)
我得到这样的结果:
Unit: microseconds
expr min lq mean median uq max neval
v1 21551.475 22655.996 26966.22166 23748.2555 28340.974 47566.237 50
v2 32.873 37.952 82.85238 81.7675 96.141 358.277 50
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时,例如,
set.seed(1234)
N <- 100^4
M <- 500
(mbm <- microbenchmark(v1 = {sample(N,M)},
v2 = {igraph::sample_seq(1,N,M)}, times=50))
Run Code Online (Sandbox Code Playgroud)
我得到了更快的结果sample:
Unit: microseconds
expr min lq mean median uq …Run Code Online (Sandbox Code Playgroud) 我有一个我在Matlab写的类的对象.当我使用"whos"命令来确定它的大小时,它大约是720,000字节.当我将它保存在.mat文件中时,大约需要75MB.到底是怎么回事?
有没有一种在Matlab中保存和加载对象的有效方法?
编辑:这是属性及其大小的列表
CT_COL: 2
p: 5
d: 10
n: 37
N: 20
idx: [20x1 double]
Am: [4-D double]
X: [4-D double]
y: [37x1 double]
KGram: [20x20 double]
reWave: []
rpw: 2
grps: [1x37 double]
exIDX: [1 4 5 6 13]
nCV: 100
prIDX: [100x6 double]
trIDX: [100x26 double]
U: [5x100 double]
V: [10x100 double]
B: [20x100 double]
Yhat: [37x100 double]
Lam: [100x1 double]
peakRatio: [37x1 double]
Am和X都是20x10x5x37阵列(双倍)
顺便说一下,属性"reWave"用于保存另一个对象的方法的句柄.我认为这可能不是一个好主意(并且可能导致这个),所以我从类定义中删除了它的任何提及.但它似乎以某种方式出现在属性集中.(即使在我发出"明确的课程"之后.)
EDIT2:我正在使用命令 save('uvXbMod1.mat','ob') 来保存对象.令人费解的是:当我使用命令 whos -file uvXbMod1.mat 查看文件中保存的内容时,它会显示出来
Name Size Bytes Class …
我的帐户下的服务器上有一个文件,我需要下载它.让我们说网址是http://my.server/files/myfile.我需要使用用户名和密码进行身份验证.我可以这样做,wget如下
wget http://username:password@my.server/files/myfile
Run Code Online (Sandbox Code Playgroud)
它的工作原理.但是,尝试同样的事情aria2
aria2c http://username:password@my.server/files/myfile
Run Code Online (Sandbox Code Playgroud)
失败并显示错误消息
-> [HttpSkipResponseCommand.cc:211] errorCode=24 Authorization failed.
Run Code Online (Sandbox Code Playgroud)
有没有办法来解决这个问题?我也尝试过--http-user和--http-passwd没有运气选项.
是否有简明(但相当彻底)的教程,以使某人习惯在MATLAB中工作,快速编写R代码.
这是我想到的一个特殊问题:根据我对R文档和教程的有限经验,我对R中的数据类型以及如何操作它们留下了很多困惑.例如,什么是向量,矩阵,列表,数据框等,以及它们如何相关.我没有找到明确解释基本数据类型的来源,以至于我想知道语言是否因设计而模糊不清.
我有一个矩阵,一次绘制一列。是否可以向 MATLAB 图添加滑块(无需繁重的 GUI 编程),以便通过移动滑块,在当前轴中显示不同的列?
我有以下ggplot2代码,可以绘制不同程度的多个多项式拟合:
library(ggplot2)
set.seed(1234)
n = 400
x = rnorm(n, sd=0.4)
y = -x + 2*x^2 - 3*x^3 + rnorm(n,sd=0.75)
df = data.frame(x=x,y=y)
deg = c(1,2,3,10)
cols = c("red","green","blue","orange")
ggplot(df, aes(x=x,y=y)) +
geom_point() +
geom_smooth(method = "lm", formula= y~poly(x,deg[1]), se=F, col=cols[1]) +
geom_smooth(method = "lm", formula= y~poly(x,deg[2]), se=F, col=cols[2]) +
geom_smooth(method = "lm", formula= y~poly(x,deg[3]), se=F, col=cols[3]) +
geom_smooth(method = "lm", formula= y~poly(x,deg[4]), se=F, col=cols[4])
Run Code Online (Sandbox Code Playgroud)
我想避免geom_smooth在每个学位上都重复这条线。但我不知道如何geom_smooth理解通过变量传递的动态程度。对于上述问题有更优雅的解决方案吗?如果能够自动更改颜色而不需要显式传递cols向量,那就太好了。(默认配色方案就可以)。
我尝试as.formula(paste0("y~poly(x,",deg[i],")"))通过循环使用,但运气不佳(循环似乎不是正确的方法ggplot。)
使用" boxplot统计"工具箱中的命令时,轴属性会以奇怪的方式更改.例如,一个人得到
XTick = []
XTickLabel =
XTickLabelMode = manual
XTickMode = manual
轴上发生了什么以及如何重命名标签和/或丢弃一些标记?
我编写了一个Rcpp函数来计算矩阵列之间的余弦相似度:
#include <Rcpp.h>
using namespace Rcpp;
// Below is a simple example of exporting a C++ function to R. You can
// source this function into an R session using the Rcpp::sourceCpp
// function (or via the Source button on the editor toolbar)
// For more on using Rcpp click the Help button on the editor toolbar
// [[Rcpp::export]]
NumericMatrix mysimil(NumericMatrix X, NumericVector norms) {
int nrow = X.nrow(), ncol = X.ncol();
NumericMatrix out(nrow, ncol);
for (int i = 0; …Run Code Online (Sandbox Code Playgroud)