The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
[SOLVED] Median calculation
RapidEndUser
Member Posts: 10 Contributor II
Hello Support,
Is there an operator to calculate median value in a column?
Thanks,
RapidEndUser.
Is there an operator to calculate median value in a column?
Thanks,
RapidEndUser.
0
Answers
You could use the Aggregate operator although you have to add a constant value for all the examples so that the operator has something to group against in order to find the median for that grouping. If you wanted to find the median for different labels then you would change the group by parameter to be the label in the example above.
regards
Andrew
This process is even simpler regards
Andrew
After experimenting the different operators yes I found that median function in the aggregate operator.
Currently the median value is only returning when you use aggregate function obvious since we are using aggregate function so it is returning that value only.
Row No. median(a1) median(a2) median(a3) median(4)
1 5.8 3.0 4.4 1.3
Actually I would like to keep all the rows in the table and add one more column which is called "MedianValue".
For e.g. If you have 4 columns in a table and would like to add 5th column that will be "MedianValue" column.
Since I want to do some calculation using "MedianValue" column with other columns and then produce 6th column, 7th column, etc.,
The output I am expecting:-
label a1 a2 a3 a4 median(a1) a1_percentage
Iris-setosa 5.1 3.5 1.4 0.2 5.800 0.879
Iris-setosa 4.9 3.0 1.4 0.2 5.800 0.844
Iris-setosa 4.7 3.2 1.3 0.2 5.800 0.810
Iris-setosa 4.6 3.1 1.5 0.2 5.800 0.793
Iris-setosa 5.0 3.6 1.4 0.2 5.800 0.862
Iris-setosa 5.4 3.9 1.7 0.4 5.800 0.931
Iris-setosa 4.6 3.4 1.4 0.3 5.800 0.793
Is it possible to do this?
Thanks,
RapidEndUser.
It can be done using the Extract Macro operator on the aggregate result example set then using the macros with Generate Attributes to create a new attribute with the original example set and the appropriate macro.
With a bit of effort, it could be done using Loop operators but it's a bit more involved.
regards
Andrew
Can you provide me sample XML how to use Extract Macro with Generate Attributes operator?
Thanks,
RapidEndUser.
I had a bit of spare time - so it's a lucky day. Quite complex because it does the work reasonably automatically with Loops and macros - enjoy!
regards
Andrew
Perfect in my scenario. It is working great. I had a separate process to calculate median value and now I don't need that. Just I can do it in one process.
Thanks,
RapidEndUser.