How to rotate a matrix in J? - j

Imagine a matrix with rank 2. I want to rotate this so that the rows become columns and vice versa. I've been able to do this with ,./,."1, but I'm not sure that's the most idiomatic way to do it.

Use the transpose function: |:
You can read all about it at http://www.jsoftware.com/docs/help802/dictionary/d232.htm

Related

Pearson correlation in python data.corr()

I have a matrix with the following shape (20, 17) with rows being the time and columns the number of variables.
When i compute the correlation matrix using data.corr() naturally i get a (17 , 17) matrix.
My questions:
Is there a way to normalise the variables directly within the .corr() function? (i know i can do that before hand and then apply the function)
My correlation matrix is large and I have trouble viewing everything in one go (i have to scroll down to do the necessary comparison). Is there a way to present the results in a concise way (like a heat map) where i can easily spot the highest from the lowest correlation?
Many Thanks
You could use matplotlib's imshow() to see a heatmap of any matrix.
Also, consider using pandas dataframes, this way you could sort by correlation strength and keep the labels of each row and col.

Filter and plot values that satisfy a certain condition

The data comes from several sensors that arranged in columns, and each row represents a measurement instance (say, a 10-minute average).
I perform some filtering and get a 'Global criteria' column of TRUE and FALSE depending on whether the data met the criteria.
Now, I want to create an x-y plot that only portrays the data that fullfils the criteria; perhaps I am missing something blatantly obvious but I have not been able to produce this graph.
I have tried to create a 'Filtered' vector in the Name manager:
X is
=PRODUCT(GlobalCriteria;Data!$A:$A)
Y is
=PRODUCT(GlobalCriteria;Data!$B:$B)
to no avail...
I have found a non-optimal solution, in that I multiply the boolean vector with the vector(s) I want to plot, and then plot that multiplication. I get of course a lot of values at (0,0) but I can live with that.
I am of course looking for a more elegant solution, perhaps with dynamic names.

VBA EXCEL Fitting Curve with freely chosen function

As start situation, I have an xy-chart with some values on it whose progression resemble an exponential function. I need to write a code that draws a fitting curve on the chart, but I have to use a particular function which is not exponential (because I need to get some coefficients from it).
One of the functions i need to use is K(C-x)²/(1+x) whereby k and C are the parameters I need.(They are two and it makes it a lot more complicated) Obviously you can't find this kind of structure on the fitting curve tool in Excel. Is there any possibility to have a fitting curve to a chart where you can write yourself the structure of the function?
Sorry if I don't add any written code, but i just need a hint to start writing.
Thank you
I did something to similar to this a while ago. The approach I took was to use the solver (as gary's student suggests). I think it was fired from VBA but that's unimportant.
Basically you'd have two input cells per row of data with your variables K and C. Then you need to find the difference (errors) between the values the function produces with the values in the input cells compared to the actual values (I think using errors^2 gives quicker conversion). You then sum the differences in another cell. When running the solver, you ask it to minimise the sum of differences by changing K and C.
Does that makes sense...?

Convert a rectangle to ranges of Hilbert numbers

When spatial data is represented using Hilbert numbers, a rectangular range is mapped to multiple ranges of Hilbert numbers. Is there any quick way to find this mapping without going through every cell the given rectangle, R, overlaps with? I can think of considering only the border cells of R and then sorting them... Is there any better way?
Thanks.

How to get points that intersect the trendline?

Basically I did the Cavendish experiment, and I have a damped sinusoidal wave plotted on Excel. With Position (mm) against Time (s).
My problem is that I have added a tread line through the wave function, and wish to calculate the points of which the wave function intersects the tread line. From this I will then be able to calculate the time period.
At the moment I'm just having difficulty getting the intersects..
Thanks
Excel is probably not the best tool to do what you want. In general, you want to fit your data to a damped Sin() function, e.g., F(x) = (A - B x) Sin(C x) or F(x) = A exp(-B x) Sin(C x), for linear or exponential dampening. Fitting the curve to the data will give you the values of the constants A, B, and C that fit the data best, and you can then proceed to simply solve F(x) == f_tread(x) to get the values x of intersection.
Programms like Mathematica, Matlab, or the free python based Sage are ideal for this and you can do it literally with two lines (well maybe three if you need to import the data first :-) ). I highly encourage you to give them a try if possible.
If you want/have to use Excel, then you can use it in a similar way for the data fitting part to get the constants A, B, C, etc. However, the part of finding intersections is trickier and unless you want to find the intersections by hand, you probably have to use an add-in like Solver and VBA script.
Finally a third way (since you seem to already have the formula for the damped sin wave) is to just plug the F==tread equation into WolframAlpha like so.

Resources