A question about calculating median

Use this forum to post Vensim related questions.
Post Reply
RWTH_FCN
Senior Member
Posts: 139
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

A question about calculating median

Post 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)

tomfid
Administrator
Posts: 3049
Joined: Wed May 24, 2006 4:54 am

Re: A question about calculating median

Post 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.

RWTH_FCN
Senior Member
Posts: 139
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: A question about calculating median

Post 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).

tomfid
Administrator
Posts: 3049
Joined: Wed May 24, 2006 4:54 am

Re: A question about calculating median

Post 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.

RWTH_FCN
Senior Member
Posts: 139
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: A question about calculating median

Post 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.

tomfid
Administrator
Posts: 3049
Joined: Wed May 24, 2006 4:54 am

Re: A question about calculating median

Post 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?

RWTH_FCN
Senior Member
Posts: 139
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: A question about calculating median

Post 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.

Post Reply