Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 2.44 KB

read401-09.md

File metadata and controls

41 lines (26 loc) · 2.44 KB

Game of Greed 4

Dunder Methods

Dunder or magic methods in Python are the methods having two prefix and suffix underscores in the method name. for example init or str.

dunder methods short cut for under-under-method-under-under

some example on dunder method:

  1. Object Representation: str, repr
  2. Iteration: len, getitem, reversed:
    • when we want to print len(class) python tell me there is an error(TypeError) but when use __len__ to return number of element it will be fine
    • if we want to know the position of an element in class we use __getitem__ to prevent error(TypeError)
    • to print all element in class in revers format we use __reversed__
  3. Operator Overloading for Comparing Accounts: eq, lt: we use it to comper betwen two object
  4. Operator Overloading for Merging Accounts: add: to marge two object
  5. Callable Python Objects: call: that is mean when calling the object or class do the following(the statments isnid call method/instance)
  6. Context Manager Support and the With Statement: enter, exit: to allow you to allocate and release resources precisely when you want to

Statistics - Probability

In the broad sense, a PROBABILITY is a measure of the degree to which an occurrence is certain [or uncertain]. A statistical definition of probability. People have thought about, and defined, probability in different ways.

The data and the distribution

The normal distribution refers to a particularly important phenomenon in the realm of probability and statistics.

A simple and commonly used plot to quickly check the distribution of a sample of data is the histogram. In the histogram, the data is divided into a pre-specified number of groups called bins. The data is then sorted into each bin and the count of the number of observations in each bin is retained.

Revisiting the normal

  1. Central Limit Theorem A simulation to explain Central Limit Theorem: even when a sample is not normally distributed, if you draw multiple samples and take each of their averages, these averages will represent a normal distribution.

  2. Three Sigma Rule The Three Sigma rule dictates that given a normal distribution, 68% of your observations will fall between one standard deviation of the mean. 95% will fall within two, and 99.7% will fall within three. ... Any value that is more than three standard deviations away from the mean should be treated with caution or care.