numeric

How do you install the blaze module (Continuum analytics) in Python?

让人想犯罪 __ 提交于 2019-12-03 20:36:27
How do you install blaze natively (i.e., not in a virtual environment) in Python? The only instructions I find are on in the package's doc (see link), and here , in a virtual environment. I didn't find any instructions anywhere online for this, but it's relatively straightforward. About my platform/tools I used: Mac OSX (Mountain Lion) Python 2.7.3 homebrew pip It looks like you might need to install Cython, not sure as I already had it installed. You can do this with pip install Cython . First, brew install llvm . Here are the packages you need. You can pip all of them: llvmpy numba meta ply

Quickly and efficiently calculating an eigenvector for known eigenvalue

痞子三分冷 提交于 2019-12-03 17:49:58
问题 Short version of my question : What would be the optimal way of calculating an eigenvector for a matrix A , if we already know the eigenvalue belonging to the eigenvector? Longer explanation : I have a large stochastic matrix A which, because it is stochastic, has a non-negative left eigenvector x (such that A^Tx=x ). I'm looking for quick and efficient methods of numerically calculating this vector. (Preferrably in MATLAB or numpy/scipy - since both of these wrap around ARPACK/LAPACK, any

Converting Character to Numeric without NA Coercion in R

心不动则不痛 提交于 2019-12-03 13:59:05
I'm working in R and have a dataframe, dd_2006, with numeric vectors. When I first imported the data, I needed to remove $'s, decimal points, and some blank spaces from 3 of my variables: SumOfCost, SumOfCases, and SumOfUnits. To do that, I used str_replace_all . However, once I used str_replace_all , the vectors were converted to characters. So I used as.numeric(var) to convert the vectors to numeric, but NAs were introduced, even though when I ran the code below BEFORE I ran the as.numeric code, there were no NAs in the vectors. sum(is.na(dd_2006$SumOfCost)) [1] 0 sum(is.na(dd_2006

Is there a fast product operation for PackedArrays?

那年仲夏 提交于 2019-12-03 09:51:11
问题 In Mathematica a vector (or rectangular array) containing all machine size integers or floats may be stored in a packed array. These objects take less memory, and some operations are much faster on them. RandomReal produces a packed array when possible. A packed array can be unpacked with the Developer function FromPackedArray Consider these timings lst = RandomReal[1, 5000000]; Total[lst] // Timing Plus @@ lst // Timing lst = Developer`FromPackedArray[lst]; Total[lst] // Timing Plus @@ lst /

More on generic Scala functions

余生长醉 提交于 2019-12-03 09:48:18
Trying to implement, in Scala, the following Haskell function (from Learn You a Haskell...) so that it works with Int, Double, etc. doubleUs x y = x * 2 + y * 2 Note that this is similar to Scala: How to define "generic" function parameters? Here's my attempt and error. Can someone explain what's happening and offer a solution. Thanks. scala> def doubleUs[A](x:A,y:A)(implicit numeric: Numeric[A]): A = numeric.plus(numeric.times(x,2),numeric.times(y,2)) <console>:34: error: type mismatch; found : Int(2) required: A def doubleUs[A](x:A,y:A)(implicit numeric: Numeric[A]): A = numeric.plus(numeric

3.days.ago, 2.hours.from_now etc without Rails?

蓝咒 提交于 2019-12-03 09:29:24
Some book mentioned some gem to decorate numbers with #days , #megabytes , #minutes etc. Is this only in ActiveSupport, or is there a smaller gem that provides this functionality for use in (small) non-rails gems? I want to use this functionality as part of a DSL in a tiny little gem. Michael Kohl I'm not sure if there's another gem available besides ActiveSupport , but it would be really straight-forward to make a small version yourself: class Fixnum SECONDS_IN_DAY = 24 * 60 * 60 def days self * SECONDS_IN_DAY end def ago Time.now - self end end 3.days.ago #=> 2011-06-18 08:45:29 0200 from

Merge pdf files with numerical sort

百般思念 提交于 2019-12-03 09:27:15
问题 I am trying to write a bash script to merge all pdf files of a directory into one single pdf file. The command pdfunite *.pdf output.pdf successfully achieves this but it merges the input documents in a regular order: 1.pdf 10.pdf 11.pdf 2.pdf 3.pdf 4.pdf 5.pdf 6.pdf 7.pdf 8.pdf 9.pdf while I'd like the documents to be merged in a numerical order: 1.pdf 2.pdf 3.pdf 4.pdf 5.pdf 6.pdf 7.pdf 8.pdf 9.pdf 10.pdf 11.pdf I guess a command mixing ls -v or sort -n and pdfunite would do the trick but I

how to combine vectors with different length within a list in R?

别说谁变了你拦得住时间么 提交于 2019-12-03 07:43:41
I have a problem when combining the following vectors included in the list: x <- list(as.numeric(c(1,4)),as.numeric(c(3,19,11))) names (x[[1]]) <- c("species.A","species.C") names (x[[2]]) <- c("species.A","species.B","species.C") which gives the following list: >x >[[1]] >species.A species.C > 1 4 >[[2]] >species.A species.B species.C > 3 19 11 combining them using the do.call function: y<- do.call(cbind,x) gives: >y > [,1] [,2] > species.A 1 3 > species.B 4 19 > species.C 1 11 while I would like to obtain this: > [,1] [,2] > species.A 1 3 > species.B NA 19 > species.C 4 11 You need to give R

Quickly and efficiently calculating an eigenvector for known eigenvalue

我的梦境 提交于 2019-12-03 06:32:28
Short version of my question : What would be the optimal way of calculating an eigenvector for a matrix A , if we already know the eigenvalue belonging to the eigenvector? Longer explanation : I have a large stochastic matrix A which, because it is stochastic, has a non-negative left eigenvector x (such that A^Tx=x ). I'm looking for quick and efficient methods of numerically calculating this vector. (Preferrably in MATLAB or numpy/scipy - since both of these wrap around ARPACK/LAPACK, any one would be fine). I know that 1 is the largest eigenvalue of A , so I know that calling something like

How to convert entire dataframe to numeric while preserving decimals?

大城市里の小女人 提交于 2019-12-03 04:54:17
问题 I have a mixed class dataframe (numeric and factor) where I am trying to convert the entire data frame to numeric. The following illustrates the type of data I am working with as well as the problem I am encountering: > a = as.factor(c(0.01,0.02,0.03,0.04)) > b = c(2,4,5,7) > df1 = data.frame(a,b) > class(df1$a) [1] "factor" > class(df1$b) [1] "numeric" When I try and convert the entire data frame to numeric, it alters the numeric values. For example: > df2 = as.data.frame(sapply(df1, as