由买买提看人间百态

topics

全部话题 - 话题: foreach
首页 上页 1 2 3 4 5 6 7 8 (共8页)
h****i
发帖数: 1674
1
来自主题: Economics版 - Help with Stata Macro
use loop foreach or forvar
I am not sure which one will fit your situation better. You should creat a
string matrix for this loop. Within the loop, you just do the label thing.
l***n
发帖数: 812
2
stata has loop function
you can loop by values/function/variables......you name it.
for your purpose:
forvalues i=1(1)500 {
bs "interest rate" "r(sd)",rep(1000)
}
you can check forvalues/foreach function in Stata's manual.
r*******s
发帖数: 303
3
来自主题: Quant版 - interview question
foreach ball in the box;do
push the color to a map.
if sizeof the map > 1000 then return true;
done;
return false;
a******t
发帖数: 100
4
来自主题: Science版 - Re: [转载] 动脑筋问题
perl script :
@history;
sub cal
{
my $n = shift @_;
my $m = shift @_;
my $a = $n;
return $history[$n][$m] if ($history[$n][$m] > 0);
return $a if ($m == 1);
return 10000 if ($m < 1);
return 1 if ($n == 1);
return 10000 if ($n < 1);
foreach my $k (2..$n-1)
{
my $b, $c;
$b = 1 + cal($k - 1, $m - 1);
$c = 1 + cal($n - $k, $m);
$b = $c if ($c >
b*******x
发帖数: 100
5
来自主题: Statistics版 - r和sas比较。
R有相应的包处理大数据比如
bigmemory,foreach,还有其他的平行运算用的包
或者选择
revolution R
这个东西我预计不出2年,在商业应用领域beat SAS,或者至少平起平坐
看看现在的ubuntu的风靡,就可以想象的出revo R的未来。
最后,至少R它是门正经的编程语言。
b*******x
发帖数: 100
6
来自主题: Statistics版 - r和sas比较。
I tried bigmemory and foreach before, unless it is really a big data set
and some computation really slow down your code, those package won't
increase the speed a lot, but if you have multiple core on your computer,
or you have access to clusters, that's another case.
I haven't try revolution R yet, it look like they already have a released
version for Ubunton, anyway, based on the purpose of this project, I
really have high expectation for this version of R in the following years.
g********r
发帖数: 8017
7
每个循环内部时间太长。如果多核,用foreach()比较划算。

sapply
s*r
发帖数: 2757
8
foreach已经可以利用多核啦?
g********r
发帖数: 8017
9
来自主题: Statistics版 - R doSNOW求教
怎么把主节点上的所有function的定义直接传给各个节点让foreach()调用?
现在我只会很土地在让所有节点重新load所有package和source所有code.很麻烦.
谢谢啦!
f***a
发帖数: 329
10
来自主题: Statistics版 - 【欢迎进来讨论】for loop in R
In general vectorized computation case, no double apply is faster than
regular for loop (as I stated in the beginning). But in case of my
questions, is the efficiency of apply still that significant? (BTW, what's
the internal procedure/algorithm that makes apply more efficient over for
loop?)
And to extend the discussion, "for loop" can be replaced by {foreach}
looping in sense of parallel computing. In this case, how efficient is it
comparing with parallel-type "apply" functions in {snow}, {mul... 阅读全帖
g********r
发帖数: 8017
11
来自主题: Statistics版 - 有没有用R做小规模并行计算的?
R用doSNOW+foreach那套还挺好使的。用着也方便,直接for换成for。。。dopar就完
了。只要loop里面工作够大,还是挺有效的。
刚仔细看了看结果,似乎snow还挺robust,我弄了两层dopar结果还是对的。
t****a
发帖数: 1212
12
来自主题: Statistics版 - R里如何加速convolution计算
我对傅立叶卷积没有什么经验。这里提到的你的傅立叶卷积的连续计算,是串行的,还
是可以并行的呢?如果是并行的,你的计算机是多核的么?如果是,可以尝试
multicore, foreach, doMC系列。如果你在cluster上做,可以尝试snow, snowfall,
doSnow系列的并行计算包。
祝你好运。
t****a
发帖数: 1212
13
去参考一下doMC, doMPI以及foreach包吧
r********0
发帖数: 65
14
来自主题: Statistics版 - 问个R的问题
apply什么的对vector list matrix很好用。
但凡能用这些运算的就很能容易进行并行。实在不是还用foreach可以用。
现在天天想着做并行啊。
貌似我用lapply还是比for能快一些
t****a
发帖数: 1212
15
来自主题: Statistics版 - 问个R的问题
Hadley Wickham的plyr包是apply以及aggregate系列函数在高维度数据上的延伸。它的
语法更加elegant,同时它可以使用foreach和DoMC包轻易的实现并行计算。plyr很值得
推荐。
o****o
发帖数: 8077
16
来自主题: Statistics版 - Help: cannot allocate memory block (in R)
我用32G的机器也会遇到这个问题,是跟R的indexing有关么?
并行计算就用过foreach包,还挺好用的,还有别的推荐么?
w******e
发帖数: 142
17
速度提高很明显,使用也很简单,一般的for循环稍微改一下就可以了,如果你是文艺
青年的mac os可以用doMC来代替doSNOW.
我把实验室的服务器24个线程的全部用起来过跑很多个lasso的循环,比单线程程快了
很多,直接从6分钟降到了46秒。
s*********e
发帖数: 1051
18
foreach(i = names(Boston[, -14])) %dopar% summary(lm(as.formula(paste("log(
medv) ~ ", i)), data = Boston))

发帖数: 1
19
来自主题: Statistics版 - 五月毕业的统计master求内推&建议
不好意思,回复晚了!收到第一个回复好开心~~
我感觉还可以,实习和上学一直用的R,stringr, dplyr, ggplot2, sqldf,
RandomForest, xgboost, foreach, apply之类的用的都挺熟。因为实习需要, 所以
需要读大量前人写的代码,并且写很多if else保证程序能跑过各种可能的情况,优化
算法提高速度这样,也经常帮老板debug,写function,写自动的小程序满足数据处理
和画图任务。课上会用R做数据处理和关于statistical learning的project。也用R做
过Kaggle的projects,成绩还行。
感觉现在接触的东西比较固定,还是有很多新的要学的~~您觉得R的水平对找工作很有
帮助吗?
g*******l
发帖数: 239
g*******l
发帖数: 239
t*********u
发帖数: 26311
22
来自主题: DataSciences版 - hadoop pig的问题
data3 = FOREACH data2 GENERATE group, SUM(data1.cpc) as cost:int;
data4 = ORDER data3 BY cost ASC;
如果
DESCRIBE data4;
不会报错
但是换成 DUMP data4;
就报错
2014-06-11 17:22:26,525 ERROR org.apache.pig.tools.pigstats.SimplePigStats:
ERROR: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.L
ong cannot be cast to java.lang.Integer
2014-06-11 17:22:26,525 ERROR org.apache.pig.tools.pigstats.PigStatsUtil: 1
map reduce job(s) failed!
2014-06-11 17:22:26,573 ERROR org.apache.pig.tools.grunt.Gru... 阅读全帖
t*********u
发帖数: 26311
23
那在原始的数据的层次
能不能在FOREACH GENERATE的时候用上Eval或者Filter类型的UDF
这样就是相当于直接对原始数据进行map操作
我的理解这个就是local运行的,对么?
w**********y
发帖数: 1691
24
rcpp. foreach. 并行计算又能解决loop 浪费时间的问题 而且选对了package 基本上
底层的代码都是Java c FORTRAN 这三个
速度秒杀python...
b***e
发帖数: 1419
25
来自主题: _FunctionalProgramming版 - 就FP而言lisp是不是已经很完美了,不说纯不纯
It really depends on your taste to say whether lisp is good enough or
not. lisp certainly has it strength:
+ It is much more flexible than almost any other languages. With the
powerful macro system, you can custom the language as much as you
want. Think of the possibility to define language construct such as
foreach by yourself.

+ There is no particular type system to fight against, as constract to
statically typed languages like ML/Ocaml/Haskell. This,
controversially, is good a
b***e
发帖数: 1419
26
来自主题: _FunctionalProgramming版 - 就FP而言lisp是不是已经很完美了,不说纯不纯
It really depends on your taste to say whether lisp is good enough or
not. lisp certainly has it strength:
+ It is much more flexible than almost any other languages. With the
powerful macro system, you can custom the language as much as you
want. Think of the possibility to define language construct such as
foreach by yourself.

+ There is no particular type system to fight against, as constract to
statically typed languages like ML/Ocaml/Haskell. This,
controversially, is good a... 阅读全帖
首页 上页 1 2 3 4 5 6 7 8 (共8页)