Search code examples
pythonweibull

How to make a right skewed Weibull distribution on Python


This is my left skewed weibull distribution for a battery state of charge distribution. Can you help me make it right skewed? Thanks!

def create_soc_distribution(self) -> np.array:
        
        multiplier = 25
        np.random.seed(4)

        socs = np.zeros((1000, 1))
        for i in range(socs.shape[0]):
            for j in range(socs.shape[1]):
                socs[i,j] = round(5 + np.random.weibull(1.5) * multiplier)
        return socs

Solution

  • Given the parameter you are passing to the Weibull distribution (1.5) and it's behavior, it is already right-skewed. A sample from 1000 draws of np.random.weibull(1.5,1000) plotted as histogram shows a right-skewed distribution. You can check the example on numpy's documentation:

    enter image description here

    Where as a using a parameter larger than 5, will prove left-skewedness:

    d