Skip to content

Latest commit

 

History

History
41 lines (21 loc) · 2.62 KB

read-009.md

File metadata and controls

41 lines (21 loc) · 2.62 KB

Read 09: Game of Greed 4:

Dunder Methods:

  • Dunder methods are a set of predefined methods you can use to enrich your classes. They are easy to recognize because they start and end with double underscores, for example init or str.

  • They are used to create functionality that can’t be represented as a normal method.

  • Object Initialization init: To construct objects from class.

  • Object Representation str, repr:

    • str: The “informal” or nicely printable string representation of an object. This is for the enduser.

    • repr: The “official” string representation of an object. This is how you would make an object of the class. The goal of repr is to be unambiguous.

  • These “dunders” or “special methods” in Python are also sometimes called “magic methods.” But using this terminology can make them seem more complicated than they really are—at the end of the day there’s nothing “magical” about them. You should treat these methods like a normal language feature.

  • Dunder methods let you emulate the behavior of built-in types.


Statistics - Probability:

  • Probability is a measure of the likelihood of an event to occur.

  • The probability formula is defined as the possibility of an event to happen is equal to the ratio of the number of favourable outcomes and the total number of outcomes.

    • Probability of event to happen P(E) = Number of favourable outcomes/Total Number of outcomes
  • Statistics is the study of the collection, analysis, interpretation, presentation, and organization of data.

  • given enough data, statistics enables us to calculate probabilities using real-world observations. Probability provides the theory, while statistics provides the tools to test that theory using data.

  • the normal distribution is a probability distribution that is symmetric about the mean, showing that data near the mean are more frequent in occurrence than data far from the mean. In graph form, normal distribution will appear as a bell curve.

  • The normal distribution is significant to probability and statistics thanks to two factors: the Central Limit Theorem and the Three Sigma Rule.

  • The Z-score is a simple calculation that answers the question, “Given a data point, how many standard deviations is it away from the mean?” is positive if the value lies above the mean, and negative if it lies below the mean.

  • The formula for calculating a z-score is is z = (x-μ)/σ, where x is the raw score, μ is the population mean, and σ is the population standard deviation.