Python Forum
Using Dictionary to Test Evenness of Distribution Generated by Randint Function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Dictionary to Test Evenness of Distribution Generated by Randint Function
#5
In addition to snippsat excellent answer - as always in programming Counter can be applied differently as well. It can be used in combination with with randint or choices for example:

+>>> import random
+>>> from collections import Counter
+>>> random.seed(42)              # for reproducibility
+>>> Counter(random.randint(1, 10) for i in range(1000))
Counter({4: 116, 5: 113, 2: 108, 8: 105, 9: 103, 7: 102, 10: 95, 1: 91, 3: 85, 6: 82})
+>>> Counter(random.choices(range(1, 11), k=1000))
Counter({6: 112, 8: 105, 10: 104, 1: 103, 5: 103, 4: 102, 2: 99, 3: 92, 7: 91, 9: 89})
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: Using Dictionary to Test Evenness of Distribution Generated by Randint Function - by perfringo - Feb-21-2021, 06:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  distribution fit Glaucio 1 289 Apr-07-2024, 12:30 AM
Last Post: Larz60+
  Weight Distribution 11drk9 11 877 Mar-13-2024, 06:08 AM
Last Post: Pedroski55
  random numbers, randint janeik 2 618 Nov-27-2023, 05:17 PM
Last Post: janeik
  Unexpected output while using random.randint with def terickson2367 1 569 Oct-24-2023, 05:56 AM
Last Post: buran
Information Best distribution method inovermyhead100 0 606 Jul-19-2023, 07:39 AM
Last Post: inovermyhead100
  HOW TO USE C# GENERATED DLL davide_vergnani 2 1,771 Jun-12-2023, 03:35 PM
Last Post: davide_vergnani
  passing dictionary to the function mark588 2 1,045 Dec-19-2022, 07:28 PM
Last Post: deanhystad
  How do I use a whl puython distribution? barryjo 6 1,881 Aug-15-2022, 03:00 AM
Last Post: barryjo
Sad Iterate randint() multiple times when calling a function Jake123 2 2,132 Feb-15-2022, 10:56 PM
Last Post: deanhystad
  How to test and import a model form computer to test accuracy using Sklearn library Anldra12 6 3,252 Jul-03-2021, 10:07 AM
Last Post: Anldra12

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020