How to do multiple boxplots with Octave? - octave

I have 3 matrices that I would like to be plotted on a boxplot (two of them are 22 rows by 83 columns, and the other is 7 rows by 83 columns) within Octave.
I've tried:
boxplot([red(:,1),blue(:,1),purple(:,1)])
error: horizontal dimensions mismatch
error: evaluating argument list element number 1
But, I keep getting the above error. I assume it's because I have one matrix with 7 rows instead of 22? If so, is there any possible way of getting them both plotted on the same boxplot?

When you pass [a,b,c] you are trying to build a matrix by concatenating horizontally the other three. Since they do not have the same number of rows that will never work.
If you want to do the boxplot use cells (as indicated in help boxplot) that is
boxplot ({red(:,1),blue(:,1),purple(:,1)})

Related

Non Scaled SSRS Line Chart with mulitple series

I am trying to present time series of multiple sensors on a single SSRS (v14) line chart
I need to plot N series, with each independently plotting the series data in the space provided by the chart (independent vertical axis)
More about the data
There can be anywhere from ~1-10 series
The challenge is that they are different orders of magnitude.
One might be degrees F (~0-212)
One might be Carbon ppm (~1-16)
One might be Ftlbs Thrust (~10k-100k)
the point is , they have no relation and can be very different
The exact value is not important. I can hide the vertical axis
More about what I am trying to do
The idea is to show the multiple time series, plotted together against time for the 4 hours before and after
'an event'. Its not the necessarily the exact value that is important. the subject matter expert would be looking for something odd (temperature falls, thrust spikes, etc).
Things I have tried
If there were just 2 series, i could easily use the 2nd axis available in the SSRS chart. Thats exactly the idea I am chasing. But in this case, I want N series to plot using its own axis.
I have tried stacking N transparent graphs on top of each other. This would be a really ugly solution, but SSRS even wont let you do it. It unstacks them for you.
I have experimented with the Allow Scale Breaks property on the Vert Axis. This would solve the problem but we don't like the 'double jagged line'
Turning on Logarithmic scale is a possibility. It does do a better job of displaying all the data. but its not really what we want. Its going to change the shape of data that ranges over a couple orders of magnitude.
I tried the sparkline component and am having the same problem.
This approach is essentially the same a Greg's answer above. I've had to do this same process in the past comparing trends of data even though the units were dissimilar.
I took a very simple approach of adding an additional column to the query that showed each value as a percentage of the maximum value in each series.
As an example (just 2 series here for clarity) I started with data like this in myTable
Series Month myValue
A Jan 4
A Feb 8
A Mar 16
B Jan 200
B Feb 300
B Mar 400
My Dataset query would be something like.
SELECT *, myValue / MAX(myValue) OVER(PARTITION BY Series) as myPlotValue FROM myTable
This gives us a final dataset which looks liek this.
Series Month myValue myPlotValue
A Jan 4 0.25
A Feb 8 0.5
A Mar 16 1
B Jan 200 0.5
B Feb 300 0.75
B Mar 400 1
As you can see all plot values are now between 0 and 1.
I created that charts using the myPlotValue field and had the option of using the original values from the myValue field as datapoint labels.
After talking to some math people, this is a standard problem and it is solved by a process called normalization of the data.
Essentially you are changing all the series to fit in a given range (usually 0-1)
You can scale and add an offset if that makes sense for your problem domain somehow.
https://www.statisticshowto.datasciencecentral.com/normalized/

Difference between quantile results and iqr

I'm trying to understand a little more about how Octave calculates quartiles and interquartile range. Consider the following:
A=[1 4 7 10 14];
quantile(A, [0.25 0.75])
ans = 3.2500 11.0000
This result seems consistent with Method 3 on the Wikipedia page about quartiles. Given that the interquartile range is Q3-Q1, I'd expect the result to be 7.75.
However, running iqr(A) gives a result of 6. Clearly this is calculated from 10 minus 4 from the original data, which is consistent with Method 2 from the same Wikipedia page.
What is the reason for using two different methods for calculating Q1 and Q3?

"Out of Bounds" Error while calculating the mean gene

This is my first time trying to complete work in Octave. I have attempted to complete "for loops" to get the mean of each and then subtract this to centre the results in the 25 samples of the 5 items. I get the right figures, however I also get an out of bounds error (indicated below). Can anyone help me please?
error: TrialPartB: A(I,J): row index out of bounds; value 6 out of bound 5
You have populated your G_all structure with only 5 data members, but then, when you calculate the mean, you loop i=1:25. There are only 5 members, so when it gets to member 6, it fails with the 'row index out of bounds' error.
You need to limit the for loop to be just the size of the data, perhaps using rows(G_all) instead of 25 as the limit of the loop.
As rolfl already explained you are trying to access row 1..25 but G_all only has 5 rows.
But apart that problem you shouldn't calculate mean in a for loop but use the function "mean" instead.
a=[4 1 6];
mean(a)
ans = 3.6667
If you want to remove the mean from an vector just use "detrend":
detrend(a, 0)
ans =
0.33333 -2.66667 2.33333

For-Loop for finding combinations of springs?

I need to use a for-loop in a function in order to find spring constants of all possible combinations of springs in series and parallel. I have 5 springs with data therefore I found the spring constant (K) of each in a new matrix by using polyfit to find the slope (using F=Kx).
I have created a function that does so, however it returns data not in a matrix, but as individual outputs. So instead of KP (Parallel)= [1 2 3 4 5] it says KP=1, KP=2, KP=3, etc. Because of this, only the final output is stored in my workspace. Here is the code I have for the function. Keep in mind that the reason I need to use the +2 in the for loop for b is because my original matrix K with all spring constants is ten columns, with every odd number being a 0. Ex: K=[1 0 2 0 3 0 4 0 5] --- This is because my original dataset to find K (slope) was ten columns wide.
function[KP,KS]=function_name1(K)
L=length(K);
c=1;
for a=1:2:L
for b=a+2:2:L
KP=K(a)+K(b)
KS=1/((1/K(a))+(1/K(b)))
end
end
c=c+1;
and then a program calling that function
[KP,KS]=function_name1(K);
What I tried: - Suppressing and unsuppressing lines of code (unsuccessful)
Any help would be greatly appreciated.
hmmm...
your code seems workable, but you aren't dealing with things in the most practical manner
I'd start be redimensioning K so that it makes sense, that is that it's 5 spaces wide instead of your current 10 - you'll see why in a minute.
Then I'd adjust KP and KS to the size that you want (I'm going to do a 5X5 as that will give all the permutations - right now it looks like you are doing some triangular thing, I wouldn't worry too much about space unless you were to do this for say 50,000 spring constants or so)
So my code would look like this
function[KP,KS]=function_name1(K)
L=length(K);
KP = zeros(L);
KS = zeros(l);
c=1;
for a=1:L
for b=1:L
KP(a,b)=K(a)+K(b)
KS(a,b)=1/((1/K(a))+(1/K(b)))
end
end
c=c+1;
then when you want the parallel combination of springs 1 and 4 KP(1,4) or KP(4,1) will do the trick

Accessing from 2nd row of the matrix in octave?

I am new to octave and learning it.
Suppose I have a matrix X =
1 2
3 4
5 6
I want to access this matrix from second row, omitting the first row.
What is the syntax for it!?
I could delete the row by X(1,:) = [] which will change the original matrix,
How to access from the second row in octave?
Use colon syntax. To return row 2 to the end use:
X(2:end, :)
See GNU Octave documentation for more indexing options.