Page 1 of 1

A question about calculating median

Posted: Tue Jan 14, 2020 6:20 pm
by RWTH_FCN
Hi,
My model simulates electricty market hourly from 2015-2050 for different countries. So it produces hourly price for each year. I was wondering how can I extract median electricity price per year? My regional price for every hour is as follows:

Regional Price this hour[EndUse Region]= INTEG (
price change this hour to next[EndUse Region],
Init Price[EndUse Region])
Units: eurocent/(KW*Hour)

Re: A question about calculating median

Posted: Wed Jan 15, 2020 3:21 pm
by tomfid
You can report the median with the Stats tool.

If you need it dynamically, you store values in an array and use the VECTOR SORT-type functions to find the midpoint.

Re: A question about calculating median

Posted: Sun Jan 19, 2020 6:44 pm
by RWTH_FCN
tomfid wrote: Wed Jan 15, 2020 3:21 pm You can report the median with the Stats tool.

If you need it dynamically, you store values in an array and use the VECTOR SORT-type functions to find the midpoint.
I want to use second method but I get error yet. My hourly price is a stock and its flow is price change this to next hour. Can you please update medain of VECTOR SORT example in a way that values should be stored in an array and ranked after one time period (e.g. one year).

Re: A question about calculating median

Posted: Tue Jan 21, 2020 5:01 pm
by tomfid
If you're running with a 1-hr time step, this will be VERY expensive computationally, because you'll be sorting an array of 8760 values every time step.

If the time step is larger, and the hour dimension is already in an array, it might work.

Re: A question about calculating median

Posted: Thu Jan 23, 2020 10:54 am
by RWTH_FCN
tomfid wrote: Tue Jan 21, 2020 5:01 pm If you're running with a 1-hr time step, this will be VERY expensive computationally, because you'll be sorting an array of 8760 values every time step.

If the time step is larger, and the hour dimension is already in an array, it might work.
Yes, I am running with a 1-hr time step for 35 years and it makes it challenging for storing median price.

Re: A question about calculating median

Posted: Thu Jan 23, 2020 3:04 pm
by tomfid
How often do you need to update it? There might be a way to create a function to access it occasionally (e.g., monthly updates), so that the load is lower.

Is there some other robust statistic that would work?

Re: A question about calculating median

Posted: Fri Jan 24, 2020 3:11 pm
by RWTH_FCN
tomfid wrote: Thu Jan 23, 2020 3:04 pm How often do you need to update it? There might be a way to create a function to access it occasionally (e.g., monthly updates), so that the load is lower.

Is there some other robust statistic that would work?
Yearly. I want to report yearly median price of electricity for 14 regions in Europe.