Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The calculated value under "Mean" is not correct #339

Open
edwin-bergstedt opened this issue Aug 24, 2023 · 1 comment
Open

The calculated value under "Mean" is not correct #339

edwin-bergstedt opened this issue Aug 24, 2023 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@edwin-bergstedt
Copy link

Version of the custom_component

0.0.14

Homeassistant version

2023.9.3

Configuration

  - platform: nordpool
    # Should the prices include vat? Default True
    VAT: True
    # What currency the api fetches the prices in
    # this is only need if you want a sensor in a non local currency
    currency: "EUR"
    # Option to show prices in cents (or the equivalent in local currency)
    price_in_cents: false
    # Helper so you can set your "low" price
    # low_price = hour_price < average * low_price_cutoff
    low_price_cutoff: 0.95
    # What power regions your are interested in
    # Possible values: "DK1", "DK2", "FI", "LT", "LV", "Oslo", "Kr.sand", "Bergen", "Molde", "Tr.heim", "Tromsø", "SE1", "SE2", "SE3","SE4", "SYS", "EE"
    region: "SE3"
    # How many decimals to use in the display of the price
    precision: 3
    # What the price should be displayed in default
    # Possible values: MWh, kWh and Wh
    # default: kWh
    price_type: kWh
    # This option allows the usage of a template to add a tariff.
    # now() always refers start of the hour of that price.
    # this way we can calculate the correct costs add that to graphs etc.
    # The price result of the additional_costs template expects this additional cost to be in kWh and not cents as a float
    # default {{0.0|float}}
    additional_costs: "{{0.0|float}}"

Describe the bug

The value calculated under "Mean" is not the mean value, mean and average are almost always the same. The value calculated is probably the Median, the center of all values.

If i run the values for today (24/8) in python:

state_class: total
average: 1.2279166666666668
off_peak_1: 0.30575
off_peak_2: 2.0285
peak: 1.5758333333333332
min: 0.276
max: 3.851
mean: 0.435
unit: kWh
currency: SEK
country: Sweden
region: SE3
low_price: true
price_percent_to_average: 0.3583305055989141
today:

  • 0.299
  • 0.288
  • 0.28
  • 0.276
  • 0.28
  • 0.299
  • 0.329
  • 0.395
  • 2.378
  • 1.918
  • 1.65
  • 1.583
  • 0.43
  • 0.416
  • 0.409
  • 0.446
  • 0.44
  • 2.311
  • 3.078
  • 3.851
  • 3.067
  • 2.309
  • 2.315
  • 0.423

Output from Pandas DataFrame:
count 24.000000
mean 1.227917
std 1.141570
min 0.276000
25% 0.321500
50% 0.435000
75% 2.309500
max 3.851000
median 0.435

The average is equal to the mean at 1.2279, but the mean is probably mislabelled and should be called median instead.

Debug log


This bug is not visible in logs.

@Hellowlol Hellowlol added bug Something isn't working good first issue Good for newcomers labels Oct 15, 2023
@Hellowlol
Copy link
Collaborator

That’s correct. We do use median to calculate the mean. I have no idea why I ended up calling that attribute mean…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants