I'm trying to run a MATLAB script to reconstruct a point cloud in Octave. Unfortunately the functions ptCloud and pcwrite are not implemented in Octave. Is there a way to replace them in Octave?
My code looks like this.
rad = data(:,1).*3.14./180;
[x,y,z] = pol2cart(rad,data(:,2),data(:,3));
M = [x,y,z];
ptCloud = pointCloud(M);
pcwrite(ptCloud,'S4P1','PLYFormat','ascii');
Related
I'm using the package rdrobust in R and Stata. I planned to fully implement the analysis in R, but encountered a problem with the function rdbwselect. This function computes different bandwidths depending on the selection procedure. By default, the procedure is Mean Square Error bwselect=mserd. However, I'm interested in exploring other procedures and comparing them. I then tried ALL=true; which is the option that according to the package "if specified, rdbwselect reports all available bandwidth selection procedures"
My issue is that, in R, rdbwselect is not showing me the bandwidths, not with the default not with the 'all' option or any other specification
x<-runif(1000,-1,1)
y<-5+3*x+2*(x>=0)+rnorm(1000)
## With default mserd
rdbwselect(y,x,)
## All selection procedures
rdbwselect(y,x,all= TRUE)
Output rdwselect
The output of both lines of rdbwselect code is exactly the same (see image), and it should not. I also try replicating the script from the rdrobust article in The R Journal (Page 49) and I don't get the same output as in the paper.
Nevertheless, the function is working in Stata 16
clear all
set obs 1000
set seed 1234
gen x = runiform(-1,1)
gen y = 5+3*x+2*(x>=0)+rnormal()
rdbwselect y x
rdbwselect y x, all
Could someone provide me with some guidance on why R is not showing me the complete expected output of the function rdbwselect? I'm wondering if this is an issue related to my version of R? Could this be a bug with the R package or the specific function rdbwselect? How can I verify the computation behind rdbwselect?
I appreciate any advice or follow-up questions.
Found the solution. All I needed to do was to embed the function within the summary() function
summary(rdbwselect(y,x,))
or add a pipe and the summary function
rdbwselect(y,x,all= TRUE) %>%
summary()
I want to post it as this is nowhere mentioned in the package documentation nor the article in The R Journal.
I am trying to convert an iGraph object to a gexf object using the rgexf package so that I can write a file usable with Gephi, which I prefer for network visualization.
My iGraph object is created by reading in two CSVs: h.edges and h.nodes. There are both edge and node attributes. Once the files are read in, I create the iGraph object, calculate centrality measures and then attach the centrality measures as node attributes. The code looks like so:
iNet = graph_from_data_frame(d=h.edges, vertices = h.nodes, directed = F)
V(iNet)$degree = degree(iNet)
V(iNet)$eig = evcent(iNet)$vector
V(iNet)$betweenness = betweenness(iNet)
This appears to be working fine since I can do all the normal iGraph functions -- plot, calculate centralities, identify communities, etc. My problem comes when I try to convert this to a gexf object. I run the following code:
library(rgexf)
iNet.gexf igraph.to.gexf(iNet)
But get the below error message:
Error in `[.data.frame`(x, r, vars, drop = drop) :
undefined columns selected
Anyone know what's happening? Although I know the example here can all be done just by uploading the two CSVs straight to Gephi and running the calculations there, the end goal is to be able to attach iGraph's more robust calculations as attributes in ways that Gephi can't.
There is a function in the r mlr package that lists all the methods it supports for a given learner, which I have used once but cannot find again. I do recall that xgboost's xgb.create.feature was definitely on the included list, but I cannot find any docs on how to use it from within mlr. Does anyone know how to do this? (And if anyone can remember the name of the mlr search function for implemented learner methods that would also be much appreciated.)
xgb.create.features is a function from xgboost not mlr.
If you want to use the function, you can access the learner model directly and call the function.
library(mlr)
library(xgboost)
mod = train(makeLearner("classif.xgboost"), iris.task)
iris.dc = data.matrix(getTaskData(iris.task, target.extra = TRUE)$data)
xgboost::xgb.create.features(mod$learner.model, iris.dc)
Not all methods of learners are directly supported from mlr side.
I am new to theano, can anyone help me defining a theano function like this:
Basically, I have a network model looks like this:
y_hat, cost, mu, output_hiddens, cells = nn_f(x, y, in_size, out_size, hidden_size, layer_models, 'MDN', training=False)
here the input x is a tensor:
x = tensor.tensor3('features', dtype=theano.config.floatX)
I want to define two theano functions for later use:
f_x_hidden = theano.function([x], [output_hiddens])
f_hidden_mu = theano.function([output_hiddens], [mu], on_unused_input = 'warn')
the first one is fine. for the second one, the problem is both the input and the output are output of the original function. it gives me error:
theano.gof.fg.MissingInputError: An input of the graph, used to compute Elemwise{identity}(features), was not provided and not given a value.
my understanding is, both of [output_hiddens] and [mu] are related to the input [x], there should be an relation between them. I tried define another theano function from [x] to [mu] like:
f_x_mu = theano.function([x], [mu]),
then
f_hidden_mu = theano.function(f_x_hidden, f_x_mu),
but it still does not work. Does anyone can help me? Thanks.
The simple answer is NO WAY. In here
Because in Theano you first express everything symbolically and afterwards compile this expression to get functions, ...
You can't use the output of theano.function as input/output for another theano.function since they are already a compiled graph/function.
You should pass the symbolic variables, such as x in your example code for f_x_hidden, to build the model.
I have been implementing a calculator in Action Script 3 and I found Math classes for sin, cos, tan, asin, acos, atan but I do not find any way to implement sinh, cosh, tanh, asinh, acosh, atanh in Action Script 3.
Do I need to write the code on the basis of raw formulas or is there any AS libraries available which do the work. I am not very good in math so do not want to write it using formulas. Also using formula may result in imprecise result.
Please suggest a way to figure it out for both the cases.
What formulas did you intend to use? With the means at hand you can easily define
cosh(x) = 0.5*(exp(x)+exp(-x))
sinh(x) = 0.5*(exp(x)-exp(-x))
tanh(x) = 1-2/(1+exp(2*x)) = (exp(2*x)-1)/(exp(2*x)+1)
acosh(x) = log(x+sqrt(x*x-1))
asinh(x) = log(x+sqrt(x*x+1))
atanh(x) = 0.5*log(2/(1-x)-1) = 0.5*(log(1+x)-log(1-x))