Monday, 15 August 2022

how to have custom quartiles and median for boxplot plotlyjs

I have dynamic data. Based on length of data i.e even or odd. Based on that i need to calculate custom quartiles and median and pass in theplotly js boxplot.

here is what quartile generally does,

Excel QUARTILE.EXC() Function / Wikipedia method 1 Use the median to divide the ordered data set into two halves. o If there is an odd number of data points in the original ordered data set, do not include the median (the central value in the ordered list) in either half. o If there is an even number of data points in the original ordered data set, split this data set exactly in half. The lower quartile value is the median of the lower half of the data. The upper quartile value is the median of the upper half of the data.

Excel QUARTILE.INC() Function / Wikipedia method 2 Use the median to divide the ordered data set into two halves. o If there are an odd number of data points in the original ordered data set, include the median (the central value in the ordered list) in both halves. o If there are an even number of data points in the original ordered data set, split this data set exactly in half. The lower quartile value is the median of the lower half of the data. The upper quartile value is the median of the upper half of the data.

I am thinking this way,

Exclusive method:

def get_Q1_exclusive(data):
    N = data.length
    return 

Inclusive method:

def get_Q1_inclusive(data):
    N = data.length
    return 

After calculating manual quartiles, need to pass like this,

var data = [
  {
    q1: [3, 1],
    median: [4, 2],
    q3: [5, 3],
    mean: [4.5, 2.5],
    sd: [1, 1],
    lowerfence: [0.5, 0.5],
    upperfence: [9, 8],
    type: 'box'
  }
];

Plotly.newPlot('myDiv', data);

How to calculate inclusive/exclusive quartiles, median etc.?



from how to have custom quartiles and median for boxplot plotlyjs

No comments:

Post a Comment